aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--python/_asyncio.pydbin45720 -> 0 bytes
-rw-r--r--python/_brotli.cp36-win32.pydbin757760 -> 0 bytes
-rw-r--r--python/_bz2.pydbin78488 -> 0 bytes
-rw-r--r--python/_ctypes.pydbin102552 -> 0 bytes
-rw-r--r--python/_decimal.pydbin216728 -> 0 bytes
-rw-r--r--python/_distutils_findvs.pydbin22168 -> 0 bytes
-rw-r--r--python/_elementtree.pydbin163992 -> 0 bytes
-rw-r--r--python/_hashlib.pydbin1121432 -> 0 bytes
-rw-r--r--python/_lzma.pydbin183960 -> 0 bytes
-rw-r--r--python/_msi.pydbin33432 -> 0 bytes
-rw-r--r--python/_multiprocessing.pydbin25752 -> 0 bytes
-rw-r--r--python/_overlapped.pydbin34456 -> 0 bytes
-rw-r--r--python/_socket.pydbin63640 -> 0 bytes
-rw-r--r--python/_sqlite3.pydbin64664 -> 0 bytes
-rw-r--r--python/_ssl.pydbin1459352 -> 0 bytes
-rw-r--r--python/atoma/__init__.py12
-rw-r--r--python/atoma/atom.py284
-rw-r--r--python/atoma/const.py1
-rw-r--r--python/atoma/exceptions.py14
-rw-r--r--python/atoma/json_feed.py223
-rw-r--r--python/atoma/opml.py107
-rw-r--r--python/atoma/rss.py221
-rw-r--r--python/atoma/simple.py224
-rw-r--r--python/atoma/utils.py84
-rw-r--r--python/attr/__init__.py65
-rw-r--r--python/attr/__init__.pyi252
-rw-r--r--python/attr/_compat.py163
-rw-r--r--python/attr/_config.py23
-rw-r--r--python/attr/_funcs.py290
-rw-r--r--python/attr/_make.py2034
-rw-r--r--python/attr/converters.py78
-rw-r--r--python/attr/converters.pyi12
-rw-r--r--python/attr/exceptions.py57
-rw-r--r--python/attr/exceptions.pyi7
-rw-r--r--python/attr/filters.py52
-rw-r--r--python/attr/filters.pyi5
-rw-r--r--python/attr/py.typed0
-rw-r--r--python/attr/validators.py170
-rw-r--r--python/attr/validators.pyi14
-rw-r--r--python/brotli.py56
-rw-r--r--python/click/__init__.py97
-rw-r--r--python/click/_bashcomplete.py293
-rw-r--r--python/click/_compat.py703
-rw-r--r--python/click/_termui_impl.py621
-rw-r--r--python/click/_textwrap.py38
-rw-r--r--python/click/_unicodefun.py125
-rw-r--r--python/click/_winconsole.py307
-rw-r--r--python/click/core.py1856
-rw-r--r--python/click/decorators.py311
-rw-r--r--python/click/exceptions.py235
-rw-r--r--python/click/formatting.py256
-rw-r--r--python/click/globals.py48
-rw-r--r--python/click/parser.py427
-rw-r--r--python/click/termui.py606
-rw-r--r--python/click/testing.py374
-rw-r--r--python/click/types.py668
-rw-r--r--python/click/utils.py440
-rw-r--r--python/dateutil/__init__.py2
-rw-r--r--python/dateutil/_common.py34
-rw-r--r--python/dateutil/_version.py10
-rw-r--r--python/dateutil/easter.py89
-rw-r--r--python/dateutil/parser.py1374
-rw-r--r--python/dateutil/relativedelta.py549
-rw-r--r--python/dateutil/rrule.py1610
-rw-r--r--python/dateutil/tz/__init__.py5
-rw-r--r--python/dateutil/tz/_common.py394
-rw-r--r--python/dateutil/tz/tz.py1511
-rw-r--r--python/dateutil/tz/win.py332
-rw-r--r--python/dateutil/tzwin.py2
-rw-r--r--python/dateutil/zoneinfo/__init__.py183
-rw-r--r--python/dateutil/zoneinfo/dateutil-zoneinfo.tar.gzbin138881 -> 0 bytes
-rw-r--r--python/dateutil/zoneinfo/rebuild.py52
-rw-r--r--python/defusedxml/ElementTree.py112
-rw-r--r--python/defusedxml/__init__.py45
-rw-r--r--python/defusedxml/cElementTree.py30
-rw-r--r--python/defusedxml/common.py120
-rw-r--r--python/defusedxml/expatbuilder.py110
-rw-r--r--python/defusedxml/expatreader.py59
-rw-r--r--python/defusedxml/lxml.py153
-rw-r--r--python/defusedxml/minidom.py42
-rw-r--r--python/defusedxml/pulldom.py34
-rw-r--r--python/defusedxml/sax.py49
-rw-r--r--python/defusedxml/xmlrpc.py157
-rw-r--r--python/flask/__init__.py49
-rw-r--r--python/flask/__main__.py14
-rw-r--r--python/flask/_compat.py101
-rw-r--r--python/flask/app.py2334
-rw-r--r--python/flask/blueprints.py447
-rw-r--r--python/flask/cli.py910
-rw-r--r--python/flask/config.py269
-rw-r--r--python/flask/ctx.py457
-rw-r--r--python/flask/debughelpers.py168
-rw-r--r--python/flask/globals.py61
-rw-r--r--python/flask/helpers.py1051
-rw-r--r--python/flask/json/__init__.py357
-rw-r--r--python/flask/json/tag.py300
-rw-r--r--python/flask/logging.py78
-rw-r--r--python/flask/sessions.py385
-rw-r--r--python/flask/signals.py57
-rw-r--r--python/flask/templating.py150
-rw-r--r--python/flask/testing.py246
-rw-r--r--python/flask/views.py158
-rw-r--r--python/flask/wrappers.py216
-rw-r--r--python/gevent/__greenlet_primitives.cp36-win32.pydbin41984 -> 0 bytes
-rw-r--r--python/gevent/__greenlet_primitives.pxd44
-rw-r--r--python/gevent/__hub_local.cp36-win32.pydbin40960 -> 0 bytes
-rw-r--r--python/gevent/__hub_local.pxd17
-rw-r--r--python/gevent/__hub_primitives.cp36-win32.pydbin96256 -> 0 bytes
-rw-r--r--python/gevent/__hub_primitives.pxd69
-rw-r--r--python/gevent/__ident.cp36-win32.pydbin37888 -> 0 bytes
-rw-r--r--python/gevent/__ident.pxd26
-rw-r--r--python/gevent/__imap.cp36-win32.pydbin69120 -> 0 bytes
-rw-r--r--python/gevent/__imap.pxd45
-rw-r--r--python/gevent/__init__.py178
-rw-r--r--python/gevent/__semaphore.cp36-win32.pydbin76800 -> 0 bytes
-rw-r--r--python/gevent/__semaphore.pxd54
-rw-r--r--python/gevent/__tracer.cp36-win32.pydbin71680 -> 0 bytes
-rw-r--r--python/gevent/__tracer.pxd43
-rw-r--r--python/gevent/__waiter.cp36-win32.pydbin62976 -> 0 bytes
-rw-r--r--python/gevent/__waiter.pxd48
-rw-r--r--python/gevent/_compat.py160
-rw-r--r--python/gevent/_config.py709
-rw-r--r--python/gevent/_event.cp36-win32.pydbin105984 -> 0 bytes
-rw-r--r--python/gevent/_event.pxd77
-rw-r--r--python/gevent/_ffi/__init__.py27
-rw-r--r--python/gevent/_ffi/callback.py58
-rw-r--r--python/gevent/_ffi/loop.py709
-rw-r--r--python/gevent/_ffi/watcher.py641
-rw-r--r--python/gevent/_fileobjectcommon.py275
-rw-r--r--python/gevent/_fileobjectposix.py320
-rw-r--r--python/gevent/_greenlet.cp36-win32.pydbin194048 -> 0 bytes
-rw-r--r--python/gevent/_greenlet.pxd174
-rw-r--r--python/gevent/_greenlet_primitives.c6042
-rw-r--r--python/gevent/_greenlet_primitives.py74
-rw-r--r--python/gevent/_hub_local.c5720
-rw-r--r--python/gevent/_hub_local.py101
-rw-r--r--python/gevent/_hub_primitives.c11875
-rw-r--r--python/gevent/_hub_primitives.py371
-rw-r--r--python/gevent/_ident.c5407
-rw-r--r--python/gevent/_ident.py84
-rw-r--r--python/gevent/_imap.c10490
-rw-r--r--python/gevent/_imap.py227
-rw-r--r--python/gevent/_interfaces.py220
-rw-r--r--python/gevent/_local.cp36-win32.pydbin105984 -> 0 bytes
-rw-r--r--python/gevent/_local.pxd113
-rw-r--r--python/gevent/_monitor.py325
-rw-r--r--python/gevent/_patcher.py127
-rw-r--r--python/gevent/_queue.cp36-win32.pydbin171520 -> 0 bytes
-rw-r--r--python/gevent/_queue.pxd74
-rw-r--r--python/gevent/_semaphore.c10292
-rw-r--r--python/gevent/_semaphore.py303
-rw-r--r--python/gevent/_socket2.py473
-rw-r--r--python/gevent/_socket3.py756
-rw-r--r--python/gevent/_socketcommon.py382
-rw-r--r--python/gevent/_ssl2.py441
-rw-r--r--python/gevent/_ssl3.py712
-rw-r--r--python/gevent/_sslgte279.py714
-rw-r--r--python/gevent/_tblib.py432
-rw-r--r--python/gevent/_threading.py168
-rw-r--r--python/gevent/_tracer.c9571
-rw-r--r--python/gevent/_tracer.py179
-rw-r--r--python/gevent/_util.py178
-rw-r--r--python/gevent/_util_py2.py23
-rw-r--r--python/gevent/_waiter.c8782
-rw-r--r--python/gevent/_waiter.py204
-rw-r--r--python/gevent/ares.py10
-rw-r--r--python/gevent/backdoor.py210
-rw-r--r--python/gevent/baseserver.py404
-rw-r--r--python/gevent/builtins.py135
-rw-r--r--python/gevent/core.py20
-rw-r--r--python/gevent/event.c13439
-rw-r--r--python/gevent/event.py481
-rw-r--r--python/gevent/events.py480
-rw-r--r--python/gevent/exceptions.py79
-rw-r--r--python/gevent/fileobject.py61
-rw-r--r--python/gevent/greenlet.c24050
-rw-r--r--python/gevent/greenlet.py944
-rw-r--r--python/gevent/hub.py733
-rw-r--r--python/gevent/libev/__init__.py0
-rw-r--r--python/gevent/libev/_corecffi_build.py75
-rw-r--r--python/gevent/libev/_corecffi_cdef.c243
-rw-r--r--python/gevent/libev/_corecffi_source.c69
-rw-r--r--python/gevent/libev/callbacks.c216
-rw-r--r--python/gevent/libev/callbacks.h38
-rw-r--r--python/gevent/libev/corecext.c22963
-rw-r--r--python/gevent/libev/corecext.cp36-win32.pydbin209920 -> 0 bytes
-rw-r--r--python/gevent/libev/corecext.h147
-rw-r--r--python/gevent/libev/corecext.pyx1340
-rw-r--r--python/gevent/libev/corecffi.py418
-rw-r--r--python/gevent/libev/libev.h100
-rw-r--r--python/gevent/libev/libev.pxd235
-rw-r--r--python/gevent/libev/libev_vfd.h225
-rw-r--r--python/gevent/libev/stathelper.c187
-rw-r--r--python/gevent/libev/watcher.py282
-rw-r--r--python/gevent/libuv/__init__.py0
-rw-r--r--python/gevent/libuv/_corecffi.cp36-win32.pydbin125952 -> 0 bytes
-rw-r--r--python/gevent/libuv/_corecffi_build.py253
-rw-r--r--python/gevent/libuv/_corecffi_cdef.c393
-rw-r--r--python/gevent/libuv/_corecffi_source.c181
-rw-r--r--python/gevent/libuv/loop.py601
-rw-r--r--python/gevent/libuv/watcher.py732
-rw-r--r--python/gevent/local.c13741
-rw-r--r--python/gevent/local.py605
-rw-r--r--python/gevent/lock.py263
-rw-r--r--python/gevent/monkey.py1079
-rw-r--r--python/gevent/os.py510
-rw-r--r--python/gevent/pool.py667
-rw-r--r--python/gevent/pywsgi.py1545
-rw-r--r--python/gevent/queue.c22127
-rw-r--r--python/gevent/queue.py685
-rw-r--r--python/gevent/resolver/__init__.py103
-rw-r--r--python/gevent/resolver/ares.py357
-rw-r--r--python/gevent/resolver/blocking.py41
-rw-r--r--python/gevent/resolver/cares.c15233
-rw-r--r--python/gevent/resolver/cares.cp36-win32.pydbin154112 -> 0 bytes
-rw-r--r--python/gevent/resolver/cares.pyx464
-rw-r--r--python/gevent/resolver/cares_ntop.h7
-rw-r--r--python/gevent/resolver/cares_pton.h8
-rw-r--r--python/gevent/resolver/dnshelper.c159
-rw-r--r--python/gevent/resolver/dnspython.py662
-rw-r--r--python/gevent/resolver/libcares.pxd109
-rw-r--r--python/gevent/resolver/thread.py71
-rw-r--r--python/gevent/resolver_ares.py10
-rw-r--r--python/gevent/resolver_thread.py10
-rw-r--r--python/gevent/select.py286
-rw-r--r--python/gevent/server.py282
-rw-r--r--python/gevent/signal.py137
-rw-r--r--python/gevent/socket.py129
-rw-r--r--python/gevent/ssl.py26
-rw-r--r--python/gevent/subprocess.py1672
-rw-r--r--python/gevent/thread.py114
-rw-r--r--python/gevent/threading.py235
-rw-r--r--python/gevent/threadpool.py580
-rw-r--r--python/gevent/time.py27
-rw-r--r--python/gevent/timeout.py373
-rw-r--r--python/gevent/util.py592
-rw-r--r--python/gevent/win32util.py98
-rw-r--r--python/greenlet.cp36-win32.pydbin22528 -> 0 bytes
-rw-r--r--python/itsdangerous/__init__.py22
-rw-r--r--python/itsdangerous/_compat.py46
-rw-r--r--python/itsdangerous/_json.py18
-rw-r--r--python/itsdangerous/encoding.py49
-rw-r--r--python/itsdangerous/exc.py98
-rw-r--r--python/itsdangerous/jws.py218
-rw-r--r--python/itsdangerous/serializer.py233
-rw-r--r--python/itsdangerous/signer.py179
-rw-r--r--python/itsdangerous/timed.py147
-rw-r--r--python/itsdangerous/url_safe.py65
-rw-r--r--python/jinja2/__init__.py83
-rw-r--r--python/jinja2/_compat.py99
-rw-r--r--python/jinja2/_identifier.py2
-rw-r--r--python/jinja2/asyncfilters.py146
-rw-r--r--python/jinja2/asyncsupport.py256
-rw-r--r--python/jinja2/bccache.py362
-rw-r--r--python/jinja2/compiler.py1721
-rw-r--r--python/jinja2/constants.py32
-rw-r--r--python/jinja2/debug.py372
-rw-r--r--python/jinja2/defaults.py56
-rw-r--r--python/jinja2/environment.py1276
-rw-r--r--python/jinja2/exceptions.py146
-rw-r--r--python/jinja2/ext.py627
-rw-r--r--python/jinja2/filters.py1190
-rw-r--r--python/jinja2/idtracking.py286
-rw-r--r--python/jinja2/lexer.py739
-rw-r--r--python/jinja2/loaders.py481
-rw-r--r--python/jinja2/meta.py106
-rw-r--r--python/jinja2/nativetypes.py220
-rw-r--r--python/jinja2/nodes.py999
-rw-r--r--python/jinja2/optimizer.py49
-rw-r--r--python/jinja2/parser.py903
-rw-r--r--python/jinja2/runtime.py813
-rw-r--r--python/jinja2/sandbox.py486
-rw-r--r--python/jinja2/tests.py175
-rw-r--r--python/jinja2/utils.py647
-rw-r--r--python/jinja2/visitor.py87
-rw-r--r--python/markupsafe/__init__.py305
-rw-r--r--python/markupsafe/_compat.py26
-rw-r--r--python/markupsafe/_constants.py267
-rw-r--r--python/markupsafe/_native.py46
-rw-r--r--python/markupsafe/_speedups.c239
-rw-r--r--python/msvcp140.dllbin440120 -> 0 bytes
-rw-r--r--python/pyexpat.pydbin164504 -> 0 bytes
-rw-r--r--python/python.exebin97944 -> 0 bytes
-rw-r--r--python/python3.dllbin58520 -> 0 bytes
-rw-r--r--python/python36._pth6
-rw-r--r--python/python36.dllbin3302040 -> 0 bytes
-rw-r--r--python/python36.zipbin2215299 -> 0 bytes
-rw-r--r--python/pythonw.exebin96408 -> 0 bytes
-rw-r--r--python/select.pydbin23704 -> 0 bytes
-rw-r--r--python/six.py891
-rw-r--r--python/socks.py870
-rw-r--r--python/sockshandler.py79
-rw-r--r--python/sqlite3.dllbin880792 -> 0 bytes
-rw-r--r--python/unicodedata.pydbin896152 -> 0 bytes
-rw-r--r--python/urllib3/__init__.py92
-rw-r--r--python/urllib3/_collections.py329
-rw-r--r--python/urllib3/connection.py391
-rw-r--r--python/urllib3/connectionpool.py896
-rw-r--r--python/urllib3/contrib/__init__.py0
-rw-r--r--python/urllib3/contrib/_appengine_environ.py30
-rw-r--r--python/urllib3/contrib/_securetransport/__init__.py0
-rw-r--r--python/urllib3/contrib/_securetransport/bindings.py593
-rw-r--r--python/urllib3/contrib/_securetransport/low_level.py346
-rw-r--r--python/urllib3/contrib/appengine.py289
-rw-r--r--python/urllib3/contrib/ntlmpool.py111
-rw-r--r--python/urllib3/contrib/pyopenssl.py466
-rw-r--r--python/urllib3/contrib/securetransport.py804
-rw-r--r--python/urllib3/contrib/socks.py192
-rw-r--r--python/urllib3/exceptions.py246
-rw-r--r--python/urllib3/fields.py178
-rw-r--r--python/urllib3/filepost.py98
-rw-r--r--python/urllib3/packages/__init__.py5
-rw-r--r--python/urllib3/packages/backports/__init__.py0
-rw-r--r--python/urllib3/packages/backports/makefile.py53
-rw-r--r--python/urllib3/packages/six.py868
-rw-r--r--python/urllib3/packages/ssl_match_hostname/__init__.py19
-rw-r--r--python/urllib3/packages/ssl_match_hostname/_implementation.py156
-rw-r--r--python/urllib3/poolmanager.py450
-rw-r--r--python/urllib3/request.py150
-rw-r--r--python/urllib3/response.py705
-rw-r--r--python/urllib3/util/__init__.py54
-rw-r--r--python/urllib3/util/connection.py134
-rw-r--r--python/urllib3/util/queue.py21
-rw-r--r--python/urllib3/util/request.py118
-rw-r--r--python/urllib3/util/response.py87
-rw-r--r--python/urllib3/util/retry.py411
-rw-r--r--python/urllib3/util/ssl_.py381
-rw-r--r--python/urllib3/util/timeout.py242
-rw-r--r--python/urllib3/util/url.py230
-rw-r--r--python/urllib3/util/wait.py150
-rw-r--r--python/vcruntime140.dllbin86840 -> 0 bytes
-rw-r--r--python/werkzeug/__init__.py233
-rw-r--r--python/werkzeug/_compat.py219
-rw-r--r--python/werkzeug/_internal.py484
-rw-r--r--python/werkzeug/_reloader.py334
-rw-r--r--python/werkzeug/contrib/__init__.py16
-rw-r--r--python/werkzeug/contrib/atom.py362
-rw-r--r--python/werkzeug/contrib/cache.py933
-rw-r--r--python/werkzeug/contrib/fixers.py262
-rw-r--r--python/werkzeug/contrib/iterio.py358
-rw-r--r--python/werkzeug/contrib/lint.py11
-rw-r--r--python/werkzeug/contrib/profiler.py42
-rw-r--r--python/werkzeug/contrib/securecookie.py362
-rw-r--r--python/werkzeug/contrib/sessions.py389
-rw-r--r--python/werkzeug/contrib/wrappers.py385
-rw-r--r--python/werkzeug/datastructures.py2852
-rw-r--r--python/werkzeug/exceptions.py774
-rw-r--r--python/werkzeug/filesystem.py64
-rw-r--r--python/werkzeug/formparser.py586
-rw-r--r--python/werkzeug/http.py1303
-rw-r--r--python/werkzeug/local.py421
-rw-r--r--python/werkzeug/middleware/__init__.py25
-rw-r--r--python/werkzeug/middleware/dispatcher.py66
-rw-r--r--python/werkzeug/middleware/http_proxy.py219
-rw-r--r--python/werkzeug/middleware/lint.py408
-rw-r--r--python/werkzeug/middleware/profiler.py132
-rw-r--r--python/werkzeug/middleware/proxy_fix.py228
-rw-r--r--python/werkzeug/middleware/shared_data.py260
-rw-r--r--python/werkzeug/posixemulation.py117
-rw-r--r--python/werkzeug/routing.py2026
-rw-r--r--python/werkzeug/security.py241
-rw-r--r--python/werkzeug/serving.py1074
-rw-r--r--python/werkzeug/test.py1146
-rw-r--r--python/werkzeug/testapp.py241
-rw-r--r--python/werkzeug/urls.py1134
-rw-r--r--python/werkzeug/useragents.py220
-rw-r--r--python/werkzeug/utils.py836
-rw-r--r--python/werkzeug/wrappers/__init__.py36
-rw-r--r--python/werkzeug/wrappers/accept.py50
-rw-r--r--python/werkzeug/wrappers/auth.py33
-rw-r--r--python/werkzeug/wrappers/base_request.py693
-rw-r--r--python/werkzeug/wrappers/base_response.py702
-rw-r--r--python/werkzeug/wrappers/common_descriptors.py322
-rw-r--r--python/werkzeug/wrappers/etag.py304
-rw-r--r--python/werkzeug/wrappers/json.py145
-rw-r--r--python/werkzeug/wrappers/request.py44
-rw-r--r--python/werkzeug/wrappers/response.py78
-rw-r--r--python/werkzeug/wrappers/user_agent.py15
-rw-r--r--python/werkzeug/wsgi.py1067
-rw-r--r--python/winsound.pydbin24728 -> 0 bytes
-rw-r--r--requirements.txt6
382 files changed, 9 insertions, 285714 deletions
diff --git a/.gitignore b/.gitignore
index b923852..149afa3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,8 @@ __pycache__/
*$py.class
debug/
data/
+python/
banned_addresses.txt
settings.txt
+
+*venv*
diff --git a/python/_asyncio.pyd b/python/_asyncio.pyd
deleted file mode 100644
index 83a447c..0000000
--- a/python/_asyncio.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_brotli.cp36-win32.pyd b/python/_brotli.cp36-win32.pyd
deleted file mode 100644
index 54f1e0c..0000000
--- a/python/_brotli.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_bz2.pyd b/python/_bz2.pyd
deleted file mode 100644
index e590110..0000000
--- a/python/_bz2.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_ctypes.pyd b/python/_ctypes.pyd
deleted file mode 100644
index 059069c..0000000
--- a/python/_ctypes.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_decimal.pyd b/python/_decimal.pyd
deleted file mode 100644
index 275af6c..0000000
--- a/python/_decimal.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_distutils_findvs.pyd b/python/_distutils_findvs.pyd
deleted file mode 100644
index f02b778..0000000
--- a/python/_distutils_findvs.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_elementtree.pyd b/python/_elementtree.pyd
deleted file mode 100644
index d7cea66..0000000
--- a/python/_elementtree.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_hashlib.pyd b/python/_hashlib.pyd
deleted file mode 100644
index 74385bc..0000000
--- a/python/_hashlib.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_lzma.pyd b/python/_lzma.pyd
deleted file mode 100644
index 5bd7a87..0000000
--- a/python/_lzma.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_msi.pyd b/python/_msi.pyd
deleted file mode 100644
index 8687eda..0000000
--- a/python/_msi.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_multiprocessing.pyd b/python/_multiprocessing.pyd
deleted file mode 100644
index 1c79fb0..0000000
--- a/python/_multiprocessing.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_overlapped.pyd b/python/_overlapped.pyd
deleted file mode 100644
index d3f2f86..0000000
--- a/python/_overlapped.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_socket.pyd b/python/_socket.pyd
deleted file mode 100644
index b4c013c..0000000
--- a/python/_socket.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_sqlite3.pyd b/python/_sqlite3.pyd
deleted file mode 100644
index 620b03a..0000000
--- a/python/_sqlite3.pyd
+++ /dev/null
Binary files differ
diff --git a/python/_ssl.pyd b/python/_ssl.pyd
deleted file mode 100644
index 52c435c..0000000
--- a/python/_ssl.pyd
+++ /dev/null
Binary files differ
diff --git a/python/atoma/__init__.py b/python/atoma/__init__.py
deleted file mode 100644
index 0768081..0000000
--- a/python/atoma/__init__.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from .atom import parse_atom_file, parse_atom_bytes
-from .rss import parse_rss_file, parse_rss_bytes
-from .json_feed import (
- parse_json_feed, parse_json_feed_file, parse_json_feed_bytes
-)
-from .opml import parse_opml_file, parse_opml_bytes
-from .exceptions import (
- FeedParseError, FeedDocumentError, FeedXMLError, FeedJSONError
-)
-from .const import VERSION
-
-__version__ = VERSION
diff --git a/python/atoma/atom.py b/python/atoma/atom.py
deleted file mode 100644
index d4e676c..0000000
--- a/python/atoma/atom.py
+++ /dev/null
@@ -1,284 +0,0 @@
-from datetime import datetime
-import enum
-from io import BytesIO
-from typing import Optional, List
-from xml.etree.ElementTree import Element
-
-import attr
-
-from .utils import (
- parse_xml, get_child, get_text, get_datetime, FeedParseError, ns
-)
-
-
-class AtomTextType(enum.Enum):
- text = "text"
- html = "html"
- xhtml = "xhtml"
-
-
-@attr.s
-class AtomTextConstruct:
- text_type: str = attr.ib()
- lang: Optional[str] = attr.ib()
- value: str = attr.ib()
-
-
-@attr.s
-class AtomEntry:
- title: AtomTextConstruct = attr.ib()
- id_: str = attr.ib()
-
- # Should be mandatory but many feeds use published instead
- updated: Optional[datetime] = attr.ib()
-
- authors: List['AtomPerson'] = attr.ib()
- contributors: List['AtomPerson'] = attr.ib()
- links: List['AtomLink'] = attr.ib()
- categories: List['AtomCategory'] = attr.ib()
- published: Optional[datetime] = attr.ib()
- rights: Optional[AtomTextConstruct] = attr.ib()
- summary: Optional[AtomTextConstruct] = attr.ib()
- content: Optional[AtomTextConstruct] = attr.ib()
- source: Optional['AtomFeed'] = attr.ib()
-
-
-@attr.s
-class AtomFeed:
- title: Optional[AtomTextConstruct] = attr.ib()
- id_: str = attr.ib()
-
- # Should be mandatory but many feeds do not include it
- updated: Optional[datetime] = attr.ib()
-
- authors: List['AtomPerson'] = attr.ib()
- contributors: List['AtomPerson'] = attr.ib()
- links: List['AtomLink'] = attr.ib()
- categories: List['AtomCategory'] = attr.ib()
- generator: Optional['AtomGenerator'] = attr.ib()
- subtitle: Optional[AtomTextConstruct] = attr.ib()
- rights: Optional[AtomTextConstruct] = attr.ib()
- icon: Optional[str] = attr.ib()
- logo: Optional[str] = attr.ib()
-
- entries: List[AtomEntry] = attr.ib()
-
-
-@attr.s
-class AtomPerson:
- name: str = attr.ib()
- uri: Optional[str] = attr.ib()
- email: Optional[str] = attr.ib()
-
-
-@attr.s
-class AtomLink:
- href: str = attr.ib()
- rel: Optional[str] = attr.ib()
- type_: Optional[str] = attr.ib()
- hreflang: Optional[str] = attr.ib()
- title: Optional[str] = attr.ib()
- length: Optional[int] = attr.ib()
-
-
-@attr.s
-class AtomCategory:
- term: str = attr.ib()
- scheme: Optional[str] = attr.ib()
- label: Optional[str] = attr.ib()
-
-
-@attr.s
-class AtomGenerator:
- name: str = attr.ib()
- uri: Optional[str] = attr.ib()
- version: Optional[str] = attr.ib()
-
-
-def _get_generator(element: Element, name,
- optional: bool=True) -> Optional[AtomGenerator]:
- child = get_child(element, name, optional)
- if child is None:
- return None
-
- return AtomGenerator(
- child.text.strip(),
- child.attrib.get('uri'),
- child.attrib.get('version'),
- )
-
-
-def _get_text_construct(element: Element, name,
- optional: bool=True) -> Optional[AtomTextConstruct]:
- child = get_child(element, name, optional)
- if child is None:
- return None
-
- try:
- text_type = AtomTextType(child.attrib['type'])
- except KeyError:
- text_type = AtomTextType.text
-
- try:
- lang = child.lang
- except AttributeError:
- lang = None
-
- if child.text is None:
- if optional:
- return None
-
- raise FeedParseError(
- 'Could not parse atom feed: "{}" text is required but is empty'
- .format(name)
- )
-
- return AtomTextConstruct(
- text_type,
- lang,
- child.text.strip()
- )
-
-
-def _get_person(element: Element) -> Optional[AtomPerson]:
- try:
- return AtomPerson(
- get_text(element, 'feed:name', optional=False),
- get_text(element, 'feed:uri'),
- get_text(element, 'feed:email')
- )
- except FeedParseError:
- return None
-
-
-def _get_link(element: Element) -> AtomLink:
- length = element.attrib.get('length')
- length = int(length) if length else None
- return AtomLink(
- element.attrib['href'],
- element.attrib.get('rel'),
- element.attrib.get('type'),
- element.attrib.get('hreflang'),
- element.attrib.get('title'),
- length
- )
-
-
-def _get_category(element: Element) -> AtomCategory:
- return AtomCategory(
- element.attrib['term'],
- element.attrib.get('scheme'),
- element.attrib.get('label'),
- )
-
-
-def _get_entry(element: Element,
- default_authors: List[AtomPerson]) -> AtomEntry:
- root = element
-
- # Mandatory
- title = _get_text_construct(root, 'feed:title')
- id_ = get_text(root, 'feed:id')
-
- # Optional
- try:
- source = _parse_atom(get_child(root, 'feed:source', optional=False),
- parse_entries=False)
- except FeedParseError:
- source = None
- source_authors = []
- else:
- source_authors = source.authors
-
- authors = [_get_person(e)
- for e in root.findall('feed:author', ns)] or default_authors
- authors = [a for a in authors if a is not None]
- authors = authors or default_authors or source_authors
-
- contributors = [_get_person(e)
- for e in root.findall('feed:contributor', ns) if e]
- contributors = [c for c in contributors if c is not None]
-
- links = [_get_link(e) for e in root.findall('feed:link', ns)]
- categories = [_get_category(e) for e in root.findall('feed:category', ns)]
-
- updated = get_datetime(root, 'feed:updated')
- published = get_datetime(root, 'feed:published')
- rights = _get_text_construct(root, 'feed:rights')
- summary = _get_text_construct(root, 'feed:summary')
- content = _get_text_construct(root, 'feed:content')
-
- return AtomEntry(
- title,
- id_,
- updated,
- authors,
- contributors,
- links,
- categories,
- published,
- rights,
- summary,
- content,
- source
- )
-
-
-def _parse_atom(root: Element, parse_entries: bool=True) -> AtomFeed:
- # Mandatory
- id_ = get_text(root, 'feed:id', optional=False)
-
- # Optional
- title = _get_text_construct(root, 'feed:title')
- updated = get_datetime(root, 'feed:updated')
- authors = [_get_person(e)
- for e in root.findall('feed:author', ns) if e]
- authors = [a for a in authors if a is not None]
- contributors = [_get_person(e)
- for e in root.findall('feed:contributor', ns) if e]
- contributors = [c for c in contributors if c is not None]
- links = [_get_link(e)
- for e in root.findall('feed:link', ns)]
- categories = [_get_category(e)
- for e in root.findall('feed:category', ns)]
-
- generator = _get_generator(root, 'feed:generator')
- subtitle = _get_text_construct(root, 'feed:subtitle')
- rights = _get_text_construct(root, 'feed:rights')
- icon = get_text(root, 'feed:icon')
- logo = get_text(root, 'feed:logo')
-
- if parse_entries:
- entries = [_get_entry(e, authors)
- for e in root.findall('feed:entry', ns)]
- else:
- entries = []
-
- atom_feed = AtomFeed(
- title,
- id_,
- updated,
- authors,
- contributors,
- links,
- categories,
- generator,
- subtitle,
- rights,
- icon,
- logo,
- entries
- )
- return atom_feed
-
-
-def parse_atom_file(filename: str) -> AtomFeed:
- """Parse an Atom feed from a local XML file."""
- root = parse_xml(filename).getroot()
- return _parse_atom(root)
-
-
-def parse_atom_bytes(data: bytes) -> AtomFeed:
- """Parse an Atom feed from a byte-string containing XML data."""
- root = parse_xml(BytesIO(data)).getroot()
- return _parse_atom(root)
diff --git a/python/atoma/const.py b/python/atoma/const.py
deleted file mode 100644
index d52d0f6..0000000
--- a/python/atoma/const.py
+++ /dev/null
@@ -1 +0,0 @@
-VERSION = '0.0.13'
diff --git a/python/atoma/exceptions.py b/python/atoma/exceptions.py
deleted file mode 100644
index 88170c5..0000000
--- a/python/atoma/exceptions.py
+++ /dev/null
@@ -1,14 +0,0 @@
-class FeedParseError(Exception):
- """Document is an invalid feed."""
-
-
-class FeedDocumentError(Exception):
- """Document is not a supported file."""
-
-
-class FeedXMLError(FeedDocumentError):
- """Document is not valid XML."""
-
-
-class FeedJSONError(FeedDocumentError):
- """Document is not valid JSON."""
diff --git a/python/atoma/json_feed.py b/python/atoma/json_feed.py
deleted file mode 100644
index 410ff4a..0000000
--- a/python/atoma/json_feed.py
+++ /dev/null
@@ -1,223 +0,0 @@
-from datetime import datetime, timedelta
-import json
-from typing import Optional, List
-
-import attr
-
-from .exceptions import FeedParseError, FeedJSONError
-from .utils import try_parse_date
-
-
-@attr.s
-class JSONFeedAuthor:
-
- name: Optional[str] = attr.ib()
- url: Optional[str] = attr.ib()
- avatar: Optional[str] = attr.ib()
-
-
-@attr.s
-class JSONFeedAttachment:
-
- url: str = attr.ib()
- mime_type: str = attr.ib()
- title: Optional[str] = attr.ib()
- size_in_bytes: Optional[int] = attr.ib()
- duration: Optional[timedelta] = attr.ib()
-
-
-@attr.s
-class JSONFeedItem:
-
- id_: str = attr.ib()
- url: Optional[str] = attr.ib()
- external_url: Optional[str] = attr.ib()
- title: Optional[str] = attr.ib()
- content_html: Optional[str] = attr.ib()
- content_text: Optional[str] = attr.ib()
- summary: Optional[str] = attr.ib()
- image: Optional[str] = attr.ib()
- banner_image: Optional[str] = attr.ib()
- date_published: Optional[datetime] = attr.ib()
- date_modified: Optional[datetime] = attr.ib()
- author: Optional[JSONFeedAuthor] = attr.ib()
-
- tags: List[str] = attr.ib()
- attachments: List[JSONFeedAttachment] = attr.ib()
-
-
-@attr.s
-class JSONFeed:
-
- version: str = attr.ib()
- title: str = attr.ib()
- home_page_url: Optional[str] = attr.ib()
- feed_url: Optional[str] = attr.ib()
- description: Optional[str] = attr.ib()
- user_comment: Optional[str] = attr.ib()
- next_url: Optional[str] = attr.ib()
- icon: Optional[str] = attr.ib()
- favicon: Optional[str] = attr.ib()
- author: Optional[JSONFeedAuthor] = attr.ib()
- expired: bool = attr.ib()
-
- items: List[JSONFeedItem] = attr.ib()
-
-
-def _get_items(root: dict) -> List[JSONFeedItem]:
- rv = []
- items = root.get('items', [])
- if not items:
- return rv
-
- for item in items:
- rv.append(_get_item(item))
-
- return rv
-
-
-def _get_item(item_dict: dict) -> JSONFeedItem:
- return JSONFeedItem(
- id_=_get_text(item_dict, 'id', optional=False),
- url=_get_text(item_dict, 'url'),
- external_url=_get_text(item_dict, 'external_url'),
- title=_get_text(item_dict, 'title'),
- content_html=_get_text(item_dict, 'content_html'),
- content_text=_get_text(item_dict, 'content_text'),
- summary=_get_text(item_dict, 'summary'),
- image=_get_text(item_dict, 'image'),
- banner_image=_get_text(item_dict, 'banner_image'),
- date_published=_get_datetime(item_dict, 'date_published'),
- date_modified=_get_datetime(item_dict, 'date_modified'),
- author=_get_author(item_dict),
- tags=_get_tags(item_dict, 'tags'),
- attachments=_get_attachments(item_dict, 'attachments')
- )
-
-
-def _get_attachments(root, name) -> List[JSONFeedAttachment]:
- rv = list()
- for attachment_dict in root.get(name, []):
- rv.append(JSONFeedAttachment(
- _get_text(attachment_dict, 'url', optional=False),
- _get_text(attachment_dict, 'mime_type', optional=False),
- _get_text(attachment_dict, 'title'),
- _get_int(attachment_dict, 'size_in_bytes'),
- _get_duration(attachment_dict, 'duration_in_seconds')
- ))
- return rv
-
-
-def _get_tags(root, name) -> List[str]:
- tags = root.get(name, [])
- return [tag for tag in tags if isinstance(tag, str)]
-
-
-def _get_datetime(root: dict, name, optional: bool=True) -> Optional[datetime]:
- text = _get_text(root, name, optional)
- if text is None:
- return None
-
- return try_parse_date(text)
-
-
-def _get_expired(root: dict) -> bool:
- if root.get('expired') is True:
- return True
-
- return False
-
-
-def _get_author(root: dict) -> Optional[JSONFeedAuthor]:
- author_dict = root.get('author')
- if not author_dict:
- return None
-
- rv = JSONFeedAuthor(
- name=_get_text(author_dict, 'name'),
- url=_get_text(author_dict, 'url'),
- avatar=_get_text(author_dict, 'avatar'),
- )
- if rv.name is None and rv.url is None and rv.avatar is None:
- return None
-
- return rv
-
-
-def _get_int(root: dict, name: str, optional: bool=True) -> Optional[int]:
- rv = root.get(name)
- if not optional and rv is None:
- raise FeedParseError('Could not parse feed: "{}" int is required but '
- 'is empty'.format(name))
-
- if optional and rv is None:
- return None
-
- if not isinstance(rv, int):
- raise FeedParseError('Could not parse feed: "{}" is not an int'
- .format(name))
-
- return rv
-
-
-def _get_duration(root: dict, name: str,
- optional: bool=True) -> Optional[timedelta]:
- duration = _get_int(root, name, optional)
- if duration is None:
- return None
-
- return timedelta(seconds=duration)
-
-
-def _get_text(root: dict, name: str, optional: bool=True) -> Optional[str]:
- rv = root.get(name)
- if not optional and rv is None:
- raise FeedParseError('Could not parse feed: "{}" text is required but '
- 'is empty'.format(name))
-
- if optional and rv is None:
- return None
-
- if not isinstance(rv, str):
- raise FeedParseError('Could not parse feed: "{}" is not a string'
- .format(name))
-
- return rv
-
-
-def parse_json_feed(root: dict) -> JSONFeed:
- return JSONFeed(
- version=_get_text(root, 'version', optional=False),
- title=_get_text(root, 'title', optional=False),
- home_page_url=_get_text(root, 'home_page_url'),
- feed_url=_get_text(root, 'feed_url'),
- description=_get_text(root, 'description'),
- user_comment=_get_text(root, 'user_comment'),
- next_url=_get_text(root, 'next_url'),
- icon=_get_text(root, 'icon'),
- favicon=_get_text(root, 'favicon'),
- author=_get_author(root),
- expired=_get_expired(root),
- items=_get_items(root)
- )
-
-
-def parse_json_feed_file(filename: str) -> JSONFeed:
- """Parse a JSON feed from a local json file."""
- with open(filename) as f:
- try:
- root = json.load(f)
- except json.decoder.JSONDecodeError:
- raise FeedJSONError('Not a valid JSON document')
-
- return parse_json_feed(root)
-
-
-def parse_json_feed_bytes(data: bytes) -> JSONFeed:
- """Parse a JSON feed from a byte-string containing JSON data."""
- try:
- root = json.loads(data)
- except json.decoder.JSONDecodeError:
- raise FeedJSONError('Not a valid JSON document')
-
- return parse_json_feed(root)
diff --git a/python/atoma/opml.py b/python/atoma/opml.py
deleted file mode 100644
index a73105e..0000000
--- a/python/atoma/opml.py
+++ /dev/null
@@ -1,107 +0,0 @@
-from datetime import datetime
-from io import BytesIO
-from typing import Optional, List
-from xml.etree.ElementTree import Element
-
-import attr
-
-from .utils import parse_xml, get_text, get_int, get_datetime
-
-
-@attr.s
-class OPMLOutline:
- text: Optional[str] = attr.ib()
- type: Optional[str] = attr.ib()
- xml_url: Optional[str] = attr.ib()
- description: Optional[str] = attr.ib()
- html_url: Optional[str] = attr.ib()
- language: Optional[str] = attr.ib()
- title: Optional[str] = attr.ib()
- version: Optional[str] = attr.ib()
-
- outlines: List['OPMLOutline'] = attr.ib()
-
-
-@attr.s
-class OPML:
- title: Optional[str] = attr.ib()
- owner_name: Optional[str] = attr.ib()
- owner_email: Optional[str] = attr.ib()
- date_created: Optional[datetime] = attr.ib()
- date_modified: Optional[datetime] = attr.ib()
- expansion_state: Optional[str] = attr.ib()
-
- vertical_scroll_state: Optional[int] = attr.ib()
- window_top: Optional[int] = attr.ib()
- window_left: Optional[int] = attr.ib()
- window_bottom: Optional[int] = attr.ib()
- window_right: Optional[int] = attr.ib()
-
- outlines: List[OPMLOutline] = attr.ib()
-
-
-def _get_outlines(element: Element) -> List[OPMLOutline]:
- rv = list()
-
- for outline in element.findall('outline'):
- rv.append(OPMLOutline(
- outline.attrib.get('text'),
- outline.attrib.get('type'),
- outline.attrib.get('xmlUrl'),
- outline.attrib.get('description'),
- outline.attrib.get('htmlUrl'),
- outline.attrib.get('language'),
- outline.attrib.get('title'),
- outline.attrib.get('version'),
- _get_outlines(outline)
- ))
-
- return rv
-
-
-def _parse_opml(root: Element) -> OPML:
- head = root.find('head')
- body = root.find('body')
-
- return OPML(
- get_text(head, 'title'),
- get_text(head, 'ownerName'),
- get_text(head, 'ownerEmail'),
- get_datetime(head, 'dateCreated'),
- get_datetime(head, 'dateModified'),
- get_text(head, 'expansionState'),
- get_int(head, 'vertScrollState'),
- get_int(head, 'windowTop'),
- get_int(head, 'windowLeft'),
- get_int(head, 'windowBottom'),
- get_int(head, 'windowRight'),
- outlines=_get_outlines(body)
- )
-
-
-def parse_opml_file(filename: str) -> OPML:
- """Parse an OPML document from a local XML file."""
- root = parse_xml(filename).getroot()
- return _parse_opml(root)
-
-
-def parse_opml_bytes(data: bytes) -> OPML:
- """Parse an OPML document from a byte-string containing XML data."""
- root = parse_xml(BytesIO(data)).getroot()
- return _parse_opml(root)
-
-
-def get_feed_list(opml_obj: OPML) -> List[str]:
- """Walk an OPML document to extract the list of feed it contains."""
- rv = list()
-
- def collect(obj):
- for outline in obj.outlines:
- if outline.type == 'rss' and outline.xml_url:
- rv.append(outline.xml_url)
-
- if outline.outlines:
- collect(outline)
-
- collect(opml_obj)
- return rv
diff --git a/python/atoma/rss.py b/python/atoma/rss.py
deleted file mode 100644
index f447a2f..0000000
--- a/python/atoma/rss.py
+++ /dev/null
@@ -1,221 +0,0 @@
-from datetime import datetime
-from io import BytesIO
-from typing import Optional, List
-from xml.etree.ElementTree import Element
-
-import attr
-
-from .utils import (
- parse_xml, get_child, get_text, get_int, get_datetime, FeedParseError
-)
-
-
-@attr.s
-class RSSImage:
- url: str = attr.ib()
- title: Optional[str] = attr.ib()
- link: str = attr.ib()
- width: int = attr.ib()
- height: int = attr.ib()
- description: Optional[str] = attr.ib()
-
-
-@attr.s
-class RSSEnclosure:
- url: str = attr.ib()
- length: Optional[int] = attr.ib()
- type: Optional[str] = attr.ib()
-
-
-@attr.s
-class RSSSource:
- title: str = attr.ib()
- url: Optional[str] = attr.ib()
-
-
-@attr.s
-class RSSItem:
- title: Optional[str] = attr.ib()
- link: Optional[str] = attr.ib()
- description: Optional[str] = attr.ib()
- author: Optional[str] = attr.ib()
- categories: List[str] = attr.ib()
- comments: Optional[str] = attr.ib()
- enclosures: List[RSSEnclosure] = attr.ib()
- guid: Optional[str] = attr.ib()
- pub_date: Optional[datetime] = attr.ib()
- source: Optional[RSSSource] = attr.ib()
-
- # Extension
- content_encoded: Optional[str] = attr.ib()
-
-
-@attr.s
-class RSSChannel:
- title: Optional[str] = attr.ib()
- link: Optional[str] = attr.ib()
- description: Optional[str] = attr.ib()
- language: Optional[str] = attr.ib()
- copyright: Optional[str] = attr.ib()
- managing_editor: Optional[str] = attr.ib()
- web_master: Optional[str] = attr.ib()
- pub_date: Optional[datetime] = attr.ib()
- last_build_date: Optional[datetime] = attr.ib()
- categories: List[str] = attr.ib()
- generator: Optional[str] = attr.ib()
- docs: Optional[str] = attr.ib()
- ttl: Optional[int] = attr.ib()
- image: Optional[RSSImage] = attr.ib()
-
- items: List[RSSItem] = attr.ib()
-
- # Extension
- content_encoded: Optional[str] = attr.ib()
-
-
-def _get_image(element: Element, name,
- optional: bool=True) -> Optional[RSSImage]:
- child = get_child(element, name, optional)
- if child is None:
- return None
-
- return RSSImage(
- get_text(child, 'url', optional=False),
- get_text(child, 'title'),
- get_text(child, 'link', optional=False),
- get_int(child, 'width') or 88,
- get_int(child, 'height') or 31,
- get_text(child, 'description')
- )
-
-
-def _get_source(element: Element, name,
- optional: bool=True) -> Optional[RSSSource]:
- child = get_child(element, name, optional)
- if child is None:
- return None
-
- return RSSSource(
- child.text.strip(),
- child.attrib.get('url'),
- )
-
-
-def _get_enclosure(element: Element) -> RSSEnclosure:
- length = element.attrib.get('length')
- try:
- length = int(length)
- except (TypeError, ValueError):
- length = None
-
- return RSSEnclosure(
- element.attrib['url'],
- length,
- element.attrib.get('type'),
- )
-
-
-def _get_link(element: Element) -> Optional[str]:
- """Attempt to retrieve item link.
-
- Use the GUID as a fallback if it is a permalink.
- """
- link = get_text(element, 'link')
- if link is not None:
- return link
-
- guid = get_child(element, 'guid')
- if guid is not None and guid.attrib.get('isPermaLink') == 'true':
- return get_text(element, 'guid')
-
- return None
-
-
-def _get_item(element: Element) -> RSSItem:
- root = element
-
- title = get_text(root, 'title')
- link = _get_link(root)
- description = get_text(root, 'description')
- author = get_text(root, 'author')
- categories = [e.text for e in root.findall('category')]
- comments = get_text(root, 'comments')
- enclosure = [_get_enclosure(e) for e in root.findall('enclosure')]
- guid = get_text(root, 'guid')
- pub_date = get_datetime(root, 'pubDate')
- source = _get_source(root, 'source')
-
- content_encoded = get_text(root, 'content:encoded')
-
- return RSSItem(
- title,
- link,
- description,
- author,
- categories,
- comments,
- enclosure,
- guid,
- pub_date,
- source,
- content_encoded
- )
-
-
-def _parse_rss(root: Element) -> RSSChannel:
- rss_version = root.get('version')
- if rss_version != '2.0':
- raise FeedParseError('Cannot process RSS feed version "{}"'
- .format(rss_version))
-
- root = root.find('channel')
-
- title = get_text(root, 'title')
- link = get_text(root, 'link')
- description = get_text(root, 'description')
- language = get_text(root, 'language')
- copyright = get_text(root, 'copyright')
- managing_editor = get_text(root, 'managingEditor')
- web_master = get_text(root, 'webMaster')
- pub_date = get_datetime(root, 'pubDate')
- last_build_date = get_datetime(root, 'lastBuildDate')
- categories = [e.text for e in root.findall('category')]
- generator = get_text(root, 'generator')
- docs = get_text(root, 'docs')
- ttl = get_int(root, 'ttl')
-
- image = _get_image(root, 'image')
- items = [_get_item(e) for e in root.findall('item')]
-
- content_encoded = get_text(root, 'content:encoded')
-
- return RSSChannel(
- title,
- link,
- description,
- language,
- copyright,
- managing_editor,
- web_master,
- pub_date,
- last_build_date,
- categories,
- generator,
- docs,
- ttl,
- image,
- items,
- content_encoded
- )
-
-
-def parse_rss_file(filename: str) -> RSSChannel:
- """Parse an RSS feed from a local XML file."""
- root = parse_xml(filename).getroot()
- return _parse_rss(root)
-
-
-def parse_rss_bytes(data: bytes) -> RSSChannel:
- """Parse an RSS feed from a byte-string containing XML data."""
- root = parse_xml(BytesIO(data)).getroot()
- return _parse_rss(root)
diff --git a/python/atoma/simple.py b/python/atoma/simple.py
deleted file mode 100644
index 98bb3e1..0000000
--- a/python/atoma/simple.py
+++ /dev/null
@@ -1,224 +0,0 @@
-"""Simple API that abstracts away the differences between feed types."""
-
-from datetime import datetime, timedelta
-import html
-import os
-from typing import Optional, List, Tuple
-import urllib.parse
-
-import attr
-
-from . import atom, rss, json_feed
-from .exceptions import (
- FeedParseError, FeedDocumentError, FeedXMLError, FeedJSONError
-)
-
-
-@attr.s
-class Attachment:
- link: str = attr.ib()
- mime_type: Optional[str] = attr.ib()
- title: Optional[str] = attr.ib()
- size_in_bytes: Optional[int] = attr.ib()
- duration: Optional[timedelta] = attr.ib()
-
-
-@attr.s
-class Article:
- id: str = attr.ib()
- title: Optional[str] = attr.ib()
- link: Optional[str] = attr.ib()
- content: str = attr.ib()
- published_at: Optional[datetime] = attr.ib()
- updated_at: Optional[datetime] = attr.ib()
- attachments: List[Attachment] = attr.ib()
-
-
-@attr.s
-class Feed:
- title: str = attr.ib()
- subtitle: Optional[str] = attr.ib()
- link: Optional[str] = attr.ib()
- updated_at: Optional[datetime] = attr.ib()
- articles: List[Article] = attr.ib()
-
-
-def _adapt_atom_feed(atom_feed: atom.AtomFeed) -> Feed:
- articles = list()
- for entry in atom_feed.entries:
- if entry.content is not None:
- content = entry.content.value
- elif entry.summary is not None:
- content = entry.summary.value
- else:
- content = ''
- published_at, updated_at = _get_article_dates(entry.published,
- entry.updated)
- # Find article link and attachments
- article_link = None
- attachments = list()
- for candidate_link in entry.links:
- if candidate_link.rel in ('alternate', None):
- article_link = candidate_link.href
- elif candidate_link.rel == 'enclosure':
- attachments.append(Attachment(
- title=_get_attachment_title(candidate_link.title,
- candidate_link.href),
- link=candidate_link.href,
- mime_type=candidate_link.type_,
- size_in_bytes=candidate_link.length,
- duration=None
- ))
-
- if entry.title is None:
- entry_title = None
- elif entry.title.text_type in (atom.AtomTextType.html,
- atom.AtomTextType.xhtml):
- entry_title = html.unescape(entry.title.value).strip()
- else:
- entry_title = entry.title.value
-
- articles.append(Article(
- entry.id_,
- entry_title,
- article_link,
- content,
- published_at,
- updated_at,
- attachments
- ))
-
- # Find feed link
- link = None
- for candidate_link in atom_feed.links:
- if candidate_link.rel == 'self':
- link = candidate_link.href
- break
-
- return Feed(
- atom_feed.title.value if atom_feed.title else atom_feed.id_,
- atom_feed.subtitle.value if atom_feed.subtitle else None,
- link,
- atom_feed.updated,
- articles
- )
-
-
-def _adapt_rss_channel(rss_channel: rss.RSSChannel) -> Feed:
- articles = list()
- for item in rss_channel.items:
- attachments = [
- Attachment(link=e.url, mime_type=e.type, size_in_bytes=e.length,
- title=_get_attachment_title(None, e.url), duration=None)
- for e in item.enclosures
- ]
- articles.append(Article(
- item.guid or item.link,
- item.title,
- item.link,
- item.content_encoded or item.description or '',
- item.pub_date,
- None,
- attachments
- ))
-
- if rss_channel.title is None and rss_channel.link is None:
- raise FeedParseError('RSS feed does not have a title nor a link')
-
- return Feed(
- rss_channel.title if rss_channel.title else rss_channel.link,
- rss_channel.description,
- rss_channel.link,
- rss_channel.pub_date,
- articles
- )
-
-
-def _adapt_json_feed(json_feed: json_feed.JSONFeed) -> Feed:
- articles = list()
- for item in json_feed.items:
- attachments = [
- Attachment(a.url, a.mime_type,
- _get_attachment_title(a.title, a.url),
- a.size_in_bytes, a.duration)
- for a in item.attachments
- ]
- articles.append(Article(
- item.id_,
- item.title,
- item.url,
- item.content_html or item.content_text or '',
- item.date_published,
- item.date_modified,
- attachments
- ))
-
- return Feed(
- json_feed.title,
- json_feed.description,
- json_feed.feed_url,
- None,
- articles
- )
-
-
-def _get_article_dates(published_at: Optional[datetime],
- updated_at: Optional[datetime]
- ) -> Tuple[Optional[datetime], Optional[datetime]]:
- if published_at and updated_at:
- return published_at, updated_at
-
- if updated_at:
- return updated_at, None
-
- if published_at:
- return published_at, None
-
- raise FeedParseError('Article does not have proper dates')
-
-
-def _get_attachment_title(attachment_title: Optional[str], link: str) -> str:
- if attachment_title:
- return attachment_title
-
- parsed_link = urllib.parse.urlparse(link)
- return os.path.basename(parsed_link.path)
-
-
-def _simple_parse(pairs, content) -> Feed:
- is_xml = True
- is_json = True
- for parser, adapter in pairs:
- try:
- return adapter(parser(content))
- except FeedXMLError:
- is_xml = False
- except FeedJSONError:
- is_json = False
- except FeedParseError:
- continue
-
- if not is_xml and not is_json:
- raise FeedDocumentError('File is not a supported feed type')
-
- raise FeedParseError('File is not a valid supported feed')
-
-
-def simple_parse_file(filename: str) -> Feed:
- """Parse an Atom, RSS or JSON feed from a local file."""
- pairs = (
- (rss.parse_rss_file, _adapt_rss_channel),
- (atom.parse_atom_file, _adapt_atom_feed),
- (json_feed.parse_json_feed_file, _adapt_json_feed)
- )
- return _simple_parse(pairs, filename)
-
-
-def simple_parse_bytes(data: bytes) -> Feed:
- """Parse an Atom, RSS or JSON feed from a byte-string containing data."""
- pairs = (
- (rss.parse_rss_bytes, _adapt_rss_channel),
- (atom.parse_atom_bytes, _adapt_atom_feed),
- (json_feed.parse_json_feed_bytes, _adapt_json_feed)
- )
- return _simple_parse(pairs, data)
diff --git a/python/atoma/utils.py b/python/atoma/utils.py
deleted file mode 100644
index 4dc1ab5..0000000
--- a/python/atoma/utils.py
+++ /dev/null
@@ -1,84 +0,0 @@
-from datetime import datetime, timezone
-from xml.etree.ElementTree import Element
-from typing import Optional
-
-import dateutil.parser
-from defusedxml.ElementTree import parse as defused_xml_parse, ParseError
-
-from .exceptions import FeedXMLError, FeedParseError
-
-ns = {
- 'content': 'http://purl.org/rss/1.0/modules/content/',
- 'feed': 'http://www.w3.org/2005/Atom'
-}
-
-
-def parse_xml(xml_content):
- try:
- return defused_xml_parse(xml_content)
- except ParseError:
- raise FeedXMLError('Not a valid XML document')
-
-
-def get_child(element: Element, name,
- optional: bool=True) -> Optional[Element]:
- child = element.find(name, namespaces=ns)
-
- if child is None and not optional:
- raise FeedParseError(
- 'Could not parse feed: "{}" does not have a "{}"'
- .format(element.tag, name)
- )
-
- elif child is None:
- return None
-
- return child
-
-
-def get_text(element: Element, name, optional: bool=True) -> Optional[str]:
- child = get_child(element, name, optional)
- if child is None:
- return None
-
- if child.text is None:
- if optional:
- return None
-
- raise FeedParseError(
- 'Could not parse feed: "{}" text is required but is empty'
- .format(name)
- )
-
- return child.text.strip()
-
-
-def get_int(element: Element, name, optional: bool=True) -> Optional[int]:
- text = get_text(element, name, optional)
- if text is None:
- return None
-
- return int(text)
-
-
-def get_datetime(element: Element, name,
- optional: bool=True) -> Optional[datetime]:
- text = get_text(element, name, optional)
- if text is None:
- return None
-
- return try_parse_date(text)
-
-
-def try_parse_date(date_str: str) -> Optional[datetime]:
- try:
- date = dateutil.parser.parse(date_str, fuzzy=True)
- except (ValueError, OverflowError):
- return None
-
- if date.tzinfo is None:
- # TZ naive datetime, make it a TZ aware datetime by assuming it
- # contains UTC time
- date = date.replace(tzinfo=timezone.utc)
-
- return date
diff --git a/python/attr/__init__.py b/python/attr/__init__.py
deleted file mode 100644
index debfd57..0000000
--- a/python/attr/__init__.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-from functools import partial
-
-from . import converters, exceptions, filters, validators
-from ._config import get_run_validators, set_run_validators
-from ._funcs import asdict, assoc, astuple, evolve, has
-from ._make import (
- NOTHING,
- Attribute,
- Factory,
- attrib,
- attrs,
- fields,
- fields_dict,
- make_class,
- validate,
-)
-
-
-__version__ = "18.2.0"
-
-__title__ = "attrs"
-__description__ = "Classes Without Boilerplate"
-__url__ = "https://www.attrs.org/"
-__uri__ = __url__
-__doc__ = __description__ + " <" + __uri__ + ">"
-
-__author__ = "Hynek Schlawack"
-__email__ = "hs@ox.cx"
-
-__license__ = "MIT"
-__copyright__ = "Copyright (c) 2015 Hynek Schlawack"
-
-
-s = attributes = attrs
-ib = attr = attrib
-dataclass = partial(attrs, auto_attribs=True) # happy Easter ;)
-
-__all__ = [
- "Attribute",
- "Factory",
- "NOTHING",
- "asdict",
- "assoc",
- "astuple",
- "attr",
- "attrib",
- "attributes",
- "attrs",
- "converters",
- "evolve",
- "exceptions",
- "fields",
- "fields_dict",
- "filters",
- "get_run_validators",
- "has",
- "ib",
- "make_class",
- "s",
- "set_run_validators",
- "validate",
- "validators",
-]
diff --git a/python/attr/__init__.pyi b/python/attr/__init__.pyi
deleted file mode 100644
index 492fb85..0000000
--- a/python/attr/__init__.pyi
+++ /dev/null
@@ -1,252 +0,0 @@
-from typing import (
- Any,
- Callable,
- Dict,
- Generic,
- List,
- Optional,
- Sequence,
- Mapping,
- Tuple,
- Type,
- TypeVar,
- Union,
- overload,
-)
-
-# `import X as X` is required to make these public
-from . import exceptions as exceptions
-from . import filters as filters
-from . import converters as converters
-from . import validators as validators
-
-_T = TypeVar("_T")
-_C = TypeVar("_C", bound=type)
-
-_ValidatorType = Callable[[Any, Attribute, _T], Any]
-_ConverterType = Callable[[Any], _T]
-_FilterType = Callable[[Attribute, Any], bool]
-# FIXME: in reality, if multiple validators are passed they must be in a list or tuple,
-# but those are invariant and so would prevent subtypes of _ValidatorType from working
-# when passed in a list or tuple.
-_ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
-
-# _make --
-
-NOTHING: object
-
-# NOTE: Factory lies about its return type to make this possible: `x: List[int] = Factory(list)`
-# Work around mypy issue #4554 in the common case by using an overload.
-@overload
-def Factory(factory: Callable[[], _T]) -> _T: ...
-@overload
-def Factory(
- factory: Union[Callable[[Any], _T], Callable[[], _T]],
- takes_self: bool = ...,
-) -> _T: ...
-
-class Attribute(Generic[_T]):
- name: str
- default: Optional[_T]
- validator: Optional[_ValidatorType[_T]]
- repr: bool
- cmp: bool
- hash: Optional[bool]
- init: bool
- converter: Optional[_ConverterType[_T]]
- metadata: Dict[Any, Any]
- type: Optional[Type[_T]]
- kw_only: bool
- def __lt__(self, x: Attribute) -> bool: ...
- def __le__(self, x: Attribute) -> bool: ...
- def __gt__(self, x: Attribute) -> bool: ...
- def __ge__(self, x: Attribute) -> bool: ...
-
-# NOTE: We had several choices for the annotation to use for type arg:
-# 1) Type[_T]
-# - Pros: Handles simple cases correctly
-# - Cons: Might produce less informative errors in the case of conflicting TypeVars
-# e.g. `attr.ib(default='bad', type=int)`
-# 2) Callable[..., _T]
-# - Pros: Better error messages than #1 for conflicting TypeVars
-# - Cons: Terrible error messages for validator checks.
-# e.g. attr.ib(type=int, validator=validate_str)
-# -> error: Cannot infer function type argument
-# 3) type (and do all of the work in the mypy plugin)
-# - Pros: Simple here, and we could customize the plugin with our own errors.
-# - Cons: Would need to write mypy plugin code to handle all the cases.
-# We chose option #1.
-
-# `attr` lies about its return type to make the following possible:
-# attr() -> Any
-# attr(8) -> int
-# attr(validator=<some callable>) -> Whatever the callable expects.
-# This makes this type of assignments possible:
-# x: int = attr(8)
-#
-# This form catches explicit None or no default but with no other arguments returns Any.
-@overload
-def attrib(
- default: None = ...,
- validator: None = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- convert: None = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: None = ...,
- converter: None = ...,
- factory: None = ...,
- kw_only: bool = ...,
-) -> Any: ...
-
-# This form catches an explicit None or no default and infers the type from the other arguments.
-@overload
-def attrib(
- default: None = ...,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- convert: Optional[_ConverterType[_T]] = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: Optional[Type[_T]] = ...,
- converter: Optional[_ConverterType[_T]] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
-) -> _T: ...
-
-# This form catches an explicit default argument.
-@overload
-def attrib(
- default: _T,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- convert: Optional[_ConverterType[_T]] = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: Optional[Type[_T]] = ...,
- converter: Optional[_ConverterType[_T]] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
-) -> _T: ...
-
-# This form covers type=non-Type: e.g. forward references (str), Any
-@overload
-def attrib(
- default: Optional[_T] = ...,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- convert: Optional[_ConverterType[_T]] = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: object = ...,
- converter: Optional[_ConverterType[_T]] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
-) -> Any: ...
-@overload
-def attrs(
- maybe_cls: _C,
- these: Optional[Dict[str, Any]] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
-) -> _C: ...
-@overload
-def attrs(
- maybe_cls: None = ...,
- these: Optional[Dict[str, Any]] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
-) -> Callable[[_C], _C]: ...
-
-# TODO: add support for returning NamedTuple from the mypy plugin
-class _Fields(Tuple[Attribute, ...]):
- def __getattr__(self, name: str) -> Attribute: ...
-
-def fields(cls: type) -> _Fields: ...
-def fields_dict(cls: type) -> Dict[str, Attribute]: ...
-def validate(inst: Any) -> None: ...
-
-# TODO: add support for returning a proper attrs class from the mypy plugin
-# we use Any instead of _CountingAttr so that e.g. `make_class('Foo', [attr.ib()])` is valid
-def make_class(
- name: str,
- attrs: Union[List[str], Tuple[str, ...], Dict[str, Any]],
- bases: Tuple[type, ...] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
- cmp: bool = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
-) -> type: ...
-
-# _funcs --
-
-# TODO: add support for returning TypedDict from the mypy plugin
-# FIXME: asdict/astuple do not honor their factory args. waiting on one of these:
-# https://github.com/python/mypy/issues/4236
-# https://github.com/python/typing/issues/253
-def asdict(
- inst: Any,
- recurse: bool = ...,
- filter: Optional[_FilterType] = ...,
- dict_factory: Type[Mapping[Any, Any]] = ...,
- retain_collection_types: bool = ...,
-) -> Dict[str, Any]: ...
-
-# TODO: add support for returning NamedTuple from the mypy plugin
-def astuple(
- inst: Any,
- recurse: bool = ...,
- filter: Optional[_FilterType] = ...,
- tuple_factory: Type[Sequence] = ...,
- retain_collection_types: bool = ...,
-) -> Tuple[Any, ...]: ...
-def has(cls: type) -> bool: ...
-def assoc(inst: _T, **changes: Any) -> _T: ...
-def evolve(inst: _T, **changes: Any) -> _T: ...
-
-# _config --
-
-def set_run_validators(run: bool) -> None: ...
-def get_run_validators() -> bool: ...
-
-# aliases --
-
-s = attributes = attrs
-ib = attr = attrib
-dataclass = attrs # Technically, partial(attrs, auto_attribs=True) ;)
diff --git a/python/attr/_compat.py b/python/attr/_compat.py
deleted file mode 100644
index 5bb0659..0000000
--- a/python/attr/_compat.py
+++ /dev/null
@@ -1,163 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-import platform
-import sys
-import types
-import warnings
-
-
-PY2 = sys.version_info[0] == 2
-PYPY = platform.python_implementation() == "PyPy"
-
-
-if PYPY or sys.version_info[:2] >= (3, 6):
- ordered_dict = dict
-else:
- from collections import OrderedDict
-
- ordered_dict = OrderedDict
-
-
-if PY2:
- from UserDict import IterableUserDict
-
- # We 'bundle' isclass instead of using inspect as importing inspect is
- # fairly expensive (order of 10-15 ms for a modern machine in 2016)
- def isclass(klass):
- return isinstance(klass, (type, types.ClassType))
-
- # TYPE is used in exceptions, repr(int) is different on Python 2 and 3.
- TYPE = "type"
-
- def iteritems(d):
- return d.iteritems()
-
- # Python 2 is bereft of a read-only dict proxy, so we make one!
- class ReadOnlyDict(IterableUserDict):
- """
- Best-effort read-only dict wrapper.
- """
-
- def __setitem__(self, key, val):
- # We gently pretend we're a Python 3 mappingproxy.
- raise TypeError(
- "'mappingproxy' object does not support item assignment"
- )
-
- def update(self, _):
- # We gently pretend we're a Python 3 mappingproxy.
- raise AttributeError(
- "'mappingproxy' object has no attribute 'update'"
- )
-
- def __delitem__(self, _):
- # We gently pretend we're a Python 3 mappingproxy.
- raise TypeError(
- "'mappingproxy' object does not support item deletion"
- )
-
- def clear(self):
- # We gently pretend we're a Python 3 mappingproxy.
- raise AttributeError(
- "'mappingproxy' object has no attribute 'clear'"
- )
-
- def pop(self, key, default=None):
- # We gently pretend we're a Python 3 mappingproxy.
- raise AttributeError(
- "'mappingproxy' object has no attribute 'pop'"
- )
-
- def popitem(self):
- # We gently pretend we're a Python 3 mappingproxy.
- raise AttributeError(
- "'mappingproxy' object has no attribute 'popitem'"
- )
-
- def setdefault(self, key, default=None):
- # We gently pretend we're a Python 3 mappingproxy.
- raise AttributeError(
- "'mappingproxy' object has no attribute 'setdefault'"
- )
-
- def __repr__(self):
- # Override to be identical to the Python 3 version.
- return "mappingproxy(" + repr(self.data) + ")"
-
- def metadata_proxy(d):
- res = ReadOnlyDict()
- res.data.update(d) # We blocked update, so we have to do it like this.
- return res
-
-
-else:
-
- def isclass(klass):
- return isinstance(klass, type)
-
- TYPE = "class"
-
- def iteritems(d):
- return d.items()
-
- def metadata_proxy(d):
- return types.MappingProxyType(dict(d))
-
-
-def import_ctypes():
- """
- Moved into a function for testability.
- """
- import ctypes
-
- return ctypes
-
-
-if not PY2:
-
- def just_warn(*args, **kw):
- """
- We only warn on Python 3 because we are not aware of any concrete
- consequences of not setting the cell on Python 2.
- """
- warnings.warn(
- "Missing ctypes. Some features like bare super() or accessing "
- "__class__ will not work with slots classes.",
- RuntimeWarning,
- stacklevel=2,
- )
-
-
-else:
-
- def just_warn(*args, **kw): # pragma: nocover
- """
- We only warn on Python 3 because we are not aware of any concrete
- consequences of not setting the cell on Python 2.
- """
-
-
-def make_set_closure_cell():
- """
- Moved into a function for testability.
- """
- if PYPY: # pragma: no cover
-
- def set_closure_cell(cell, value):
- cell.__setstate__((value,))
-
- else:
- try:
- ctypes = import_ctypes()
-
- set_closure_cell = ctypes.pythonapi.PyCell_Set
- set_closure_cell.argtypes = (ctypes.py_object, ctypes.py_object)
- set_closure_cell.restype = ctypes.c_int
- except Exception:
- # We try best effort to set the cell, but sometimes it's not
- # possible. For example on Jython or on GAE.
- set_closure_cell = just_warn
- return set_closure_cell
-
-
-set_closure_cell = make_set_closure_cell()
diff --git a/python/attr/_config.py b/python/attr/_config.py
deleted file mode 100644
index 8ec9209..0000000
--- a/python/attr/_config.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-
-__all__ = ["set_run_validators", "get_run_validators"]
-
-_run_validators = True
-
-
-def set_run_validators(run):
- """
- Set whether or not validators are run. By default, they are run.
- """
- if not isinstance(run, bool):
- raise TypeError("'run' must be bool.")
- global _run_validators
- _run_validators = run
-
-
-def get_run_validators():
- """
- Return whether or not validators are run.
- """
- return _run_validators
diff --git a/python/attr/_funcs.py b/python/attr/_funcs.py
deleted file mode 100644
index b61d239..0000000
--- a/python/attr/_funcs.py
+++ /dev/null
@@ -1,290 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-import copy
-
-from ._compat import iteritems
-from ._make import NOTHING, _obj_setattr, fields
-from .exceptions import AttrsAttributeNotFoundError
-
-
-def asdict(
- inst,
- recurse=True,
- filter=None,
- dict_factory=dict,
- retain_collection_types=False,
-):
- """
- Return the ``attrs`` attribute values of *inst* as a dict.
-
- Optionally recurse into other ``attrs``-decorated classes.
-
- :param inst: Instance of an ``attrs``-decorated class.
- :param bool recurse: Recurse into classes that are also
- ``attrs``-decorated.
- :param callable filter: A callable whose return code determines whether an
- attribute or element is included (``True``) or dropped (``False``). Is
- called with the :class:`attr.Attribute` as the first argument and the
- value as the second argument.
- :param callable dict_factory: A callable to produce dictionaries from. For
- example, to produce ordered dictionaries instead of normal Python
- dictionaries, pass in ``collections.OrderedDict``.
- :param bool retain_collection_types: Do not convert to ``list`` when
- encountering an attribute whose type is ``tuple`` or ``set``. Only
- meaningful if ``recurse`` is ``True``.
-
- :rtype: return type of *dict_factory*
-
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- .. versionadded:: 16.0.0 *dict_factory*
- .. versionadded:: 16.1.0 *retain_collection_types*
- """
- attrs = fields(inst.__class__)
- rv = dict_factory()
- for a in attrs:
- v = getattr(inst, a.name)
- if filter is not None and not filter(a, v):
- continue
- if recurse is True:
- if has(v.__class__):
- rv[a.name] = asdict(
- v, True, filter, dict_factory, retain_collection_types
- )
- elif isinstance(v, (tuple, list, set)):
- cf = v.__class__ if retain_collection_types is True else list
- rv[a.name] = cf(
- [
- _asdict_anything(
- i, filter, dict_factory, retain_collection_types
- )
- for i in v
- ]
- )
- elif isinstance(v, dict):
- df = dict_factory
- rv[a.name] = df(
- (
- _asdict_anything(
- kk, filter, df, retain_collection_types
- ),
- _asdict_anything(
- vv, filter, df, retain_collection_types
- ),
- )
- for kk, vv in iteritems(v)
- )
- else:
- rv[a.name] = v
- else:
- rv[a.name] = v
- return rv
-
-
-def _asdict_anything(val, filter, dict_factory, retain_collection_types):
- """
- ``asdict`` only works on attrs instances, this works on anything.
- """
- if getattr(val.__class__, "__attrs_attrs__", None) is not None:
- # Attrs class.
- rv = asdict(val, True, filter, dict_factory, retain_collection_types)
- elif isinstance(val, (tuple, list, set)):
- cf = val.__class__ if retain_collection_types is True else list
- rv = cf(
- [
- _asdict_anything(
- i, filter, dict_factory, retain_collection_types
- )
- for i in val
- ]
- )
- elif isinstance(val, dict):
- df = dict_factory
- rv = df(
- (
- _asdict_anything(kk, filter, df, retain_collection_types),
- _asdict_anything(vv, filter, df, retain_collection_types),
- )
- for kk, vv in iteritems(val)
- )
- else:
- rv = val
- return rv
-
-
-def astuple(
- inst,
- recurse=True,
- filter=None,
- tuple_factory=tuple,
- retain_collection_types=False,
-):
- """
- Return the ``attrs`` attribute values of *inst* as a tuple.
-
- Optionally recurse into other ``attrs``-decorated classes.
-
- :param inst: Instance of an ``attrs``-decorated class.
- :param bool recurse: Recurse into classes that are also
- ``attrs``-decorated.
- :param callable filter: A callable whose return code determines whether an
- attribute or element is included (``True``) or dropped (``False``). Is
- called with the :class:`attr.Attribute` as the first argument and the
- value as the second argument.
- :param callable tuple_factory: A callable to produce tuples from. For
- example, to produce lists instead of tuples.
- :param bool retain_collection_types: Do not convert to ``list``
- or ``dict`` when encountering an attribute which type is
- ``tuple``, ``dict`` or ``set``. Only meaningful if ``recurse`` is
- ``True``.
-
- :rtype: return type of *tuple_factory*
-
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- .. versionadded:: 16.2.0
- """
- attrs = fields(inst.__class__)
- rv = []
- retain = retain_collection_types # Very long. :/
- for a in attrs:
- v = getattr(inst, a.name)
- if filter is not None and not filter(a, v):
- continue
- if recurse is True:
- if has(v.__class__):
- rv.append(
- astuple(
- v,
- recurse=True,
- filter=filter,
- tuple_factory=tuple_factory,
- retain_collection_types=retain,
- )
- )
- elif isinstance(v, (tuple, list, set)):
- cf = v.__class__ if retain is True else list
- rv.append(
- cf(
- [
- astuple(
- j,
- recurse=True,
- filter=filter,
- tuple_factory=tuple_factory,
- retain_collection_types=retain,
- )
- if has(j.__class__)
- else j
- for j in v
- ]
- )
- )
- elif isinstance(v, dict):
- df = v.__class__ if retain is True else dict
- rv.append(
- df(
- (
- astuple(
- kk,
- tuple_factory=tuple_factory,
- retain_collection_types=retain,
- )
- if has(kk.__class__)
- else kk,
- astuple(
- vv,
- tuple_factory=tuple_factory,
- retain_collection_types=retain,
- )
- if has(vv.__class__)
- else vv,
- )
- for kk, vv in iteritems(v)
- )
- )
- else:
- rv.append(v)
- else:
- rv.append(v)
- return rv if tuple_factory is list else tuple_factory(rv)
-
-
-def has(cls):
- """
- Check whether *cls* is a class with ``attrs`` attributes.
-
- :param type cls: Class to introspect.
- :raise TypeError: If *cls* is not a class.
-
- :rtype: :class:`bool`
- """
- return getattr(cls, "__attrs_attrs__", None) is not None
-
-
-def assoc(inst, **changes):
- """
- Copy *inst* and apply *changes*.
-
- :param inst: Instance of a class with ``attrs`` attributes.
- :param changes: Keyword changes in the new copy.
-
- :return: A copy of inst with *changes* incorporated.
-
- :raise attr.exceptions.AttrsAttributeNotFoundError: If *attr_name* couldn't
- be found on *cls*.
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- .. deprecated:: 17.1.0
- Use :func:`evolve` instead.
- """
- import warnings
-
- warnings.warn(
- "assoc is deprecated and will be removed after 2018/01.",
- DeprecationWarning,
- stacklevel=2,
- )
- new = copy.copy(inst)
- attrs = fields(inst.__class__)
- for k, v in iteritems(changes):
- a = getattr(attrs, k, NOTHING)
- if a is NOTHING:
- raise AttrsAttributeNotFoundError(
- "{k} is not an attrs attribute on {cl}.".format(
- k=k, cl=new.__class__
- )
- )
- _obj_setattr(new, k, v)
- return new
-
-
-def evolve(inst, **changes):
- """
- Create a new instance, based on *inst* with *changes* applied.
-
- :param inst: Instance of a class with ``attrs`` attributes.
- :param changes: Keyword changes in the new copy.
-
- :return: A copy of inst with *changes* incorporated.
-
- :raise TypeError: If *attr_name* couldn't be found in the class
- ``__init__``.
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- .. versionadded:: 17.1.0
- """
- cls = inst.__class__
- attrs = fields(cls)
- for a in attrs:
- if not a.init:
- continue
- attr_name = a.name # To deal with private attributes.
- init_name = attr_name if attr_name[0] != "_" else attr_name[1:]
- if init_name not in changes:
- changes[init_name] = getattr(inst, attr_name)
- return cls(**changes)
diff --git a/python/attr/_make.py b/python/attr/_make.py
deleted file mode 100644
index f7fd05e..0000000
--- a/python/attr/_make.py
+++ /dev/null
@@ -1,2034 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-import copy
-import hashlib
-import linecache
-import sys
-import threading
-import warnings
-
-from operator import itemgetter
-
-from . import _config
-from ._compat import (
- PY2,
- isclass,
- iteritems,
- metadata_proxy,
- ordered_dict,
- set_closure_cell,
-)
-from .exceptions import (
- DefaultAlreadySetError,
- FrozenInstanceError,
- NotAnAttrsClassError,
- PythonTooOldError,
- UnannotatedAttributeError,
-)
-
-
-# This is used at least twice, so cache it here.
-_obj_setattr = object.__setattr__
-_init_converter_pat = "__attr_converter_{}"
-_init_factory_pat = "__attr_factory_{}"
-_tuple_property_pat = (
- " {attr_name} = _attrs_property(_attrs_itemgetter({index}))"
-)
-_classvar_prefixes = ("typing.ClassVar", "t.ClassVar", "ClassVar")
-# we don't use a double-underscore prefix because that triggers
-# name mangling when trying to create a slot for the field
-# (when slots=True)
-_hash_cache_field = "_attrs_cached_hash"
-
-_empty_metadata_singleton = metadata_proxy({})
-
-
-class _Nothing(object):
- """
- Sentinel class to indicate the lack of a value when ``None`` is ambiguous.
-
- ``_Nothing`` is a singleton. There is only ever one of it.
- """
-
- _singleton = None
-
- def __new__(cls):
- if _Nothing._singleton is None:
- _Nothing._singleton = super(_Nothing, cls).__new__(cls)
- return _Nothing._singleton
-
- def __repr__(self):
- return "NOTHING"
-
-
-NOTHING = _Nothing()
-"""
-Sentinel to indicate the lack of a value when ``None`` is ambiguous.
-"""
-
-
-def attrib(
- default=NOTHING,
- validator=None,
- repr=True,
- cmp=True,
- hash=None,
- init=True,
- convert=None,
- metadata=None,
- type=None,
- converter=None,
- factory=None,
- kw_only=False,
-):
- """
- Create a new attribute on a class.
-
- .. warning::
-
- Does *not* do anything unless the class is also decorated with
- :func:`attr.s`!
-
- :param default: A value that is used if an ``attrs``-generated ``__init__``
- is used and no value is passed while instantiating or the attribute is
- excluded using ``init=False``.
-
- If the value is an instance of :class:`Factory`, its callable will be
- used to construct a new value (useful for mutable data types like lists
- or dicts).
-
- If a default is not set (or set manually to ``attr.NOTHING``), a value
- *must* be supplied when instantiating; otherwise a :exc:`TypeError`
- will be raised.
-
- The default can also be set using decorator notation as shown below.
-
- :type default: Any value.
-
- :param callable factory: Syntactic sugar for
- ``default=attr.Factory(callable)``.
-
- :param validator: :func:`callable` that is called by ``attrs``-generated
- ``__init__`` methods after the instance has been initialized. They
- receive the initialized instance, the :class:`Attribute`, and the
- passed value.
-
- The return value is *not* inspected so the validator has to throw an
- exception itself.
-
- If a ``list`` is passed, its items are treated as validators and must
- all pass.
-
- Validators can be globally disabled and re-enabled using
- :func:`get_run_validators`.
-
- The validator can also be set using decorator notation as shown below.
-
- :type validator: ``callable`` or a ``list`` of ``callable``\\ s.
-
- :param bool repr: Include this attribute in the generated ``__repr__``
- method.
- :param bool cmp: Include this attribute in the generated comparison methods
- (``__eq__`` et al).
- :param hash: Include this attribute in the generated ``__hash__``
- method. If ``None`` (default), mirror *cmp*'s value. This is the
- correct behavior according the Python spec. Setting this value to
- anything else than ``None`` is *discouraged*.
- :type hash: ``bool`` or ``None``
- :param bool init: Include this attribute in the generated ``__init__``
- method. It is possible to set this to ``False`` and set a default
- value. In that case this attributed is unconditionally initialized
- with the specified default value or factory.
- :param callable converter: :func:`callable` that is called by
- ``attrs``-generated ``__init__`` methods to converter attribute's value
- to the desired format. It is given the passed-in value, and the
- returned value will be used as the new value of the attribute. The
- value is converted before being passed to the validator, if any.
- :param metadata: An arbitrary mapping, to be used by third-party
- components. See :ref:`extending_metadata`.
- :param type: The type of the attribute. In Python 3.6 or greater, the
- preferred method to specify the type is using a variable annotation
- (see `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_).
- This argument is provided for backward compatibility.
- Regardless of the approach used, the type will be stored on
- ``Attribute.type``.
-
- Please note that ``attrs`` doesn't do anything with this metadata by
- itself. You can use it as part of your own code or for
- :doc:`static type checking <types>`.
- :param kw_only: Make this attribute keyword-only (Python 3+)
- in the generated ``__init__`` (if ``init`` is ``False``, this
- parameter is ignored).
-
- .. versionadded:: 15.2.0 *convert*
- .. versionadded:: 16.3.0 *metadata*
- .. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
- .. versionchanged:: 17.1.0
- *hash* is ``None`` and therefore mirrors *cmp* by default.
- .. versionadded:: 17.3.0 *type*
- .. deprecated:: 17.4.0 *convert*
- .. versionadded:: 17.4.0 *converter* as a replacement for the deprecated
- *convert* to achieve consistency with other noun-based arguments.
- .. versionadded:: 18.1.0
- ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
- .. versionadded:: 18.2.0 *kw_only*
- """
- if hash is not None and hash is not True and hash is not False:
- raise TypeError(
- "Invalid value for hash. Must be True, False, or None."
- )
-
- if convert is not None:
- if converter is not None:
- raise RuntimeError(
- "Can't pass both `convert` and `converter`. "
- "Please use `converter` only."
- )
- warnings.warn(
- "The `convert` argument is deprecated in favor of `converter`. "
- "It will be removed after 2019/01.",
- DeprecationWarning,
- stacklevel=2,
- )
- converter = convert
-
- if factory is not None:
- if default is not NOTHING:
- raise ValueError(
- "The `default` and `factory` arguments are mutually "
- "exclusive."
- )
- if not callable(factory):
- raise ValueError("The `factory` argument must be a callable.")
- default = Factory(factory)
-
- if metadata is None:
- metadata = {}
-
- return _CountingAttr(
- default=default,
- validator=validator,
- repr=repr,
- cmp=cmp,
- hash=hash,
- init=init,
- converter=converter,
- metadata=metadata,
- type=type,
- kw_only=kw_only,
- )
-
-
-def _make_attr_tuple_class(cls_name, attr_names):
- """
- Create a tuple subclass to hold `Attribute`s for an `attrs` class.
-
- The subclass is a bare tuple with properties for names.
-
- class MyClassAttributes(tuple):
- __slots__ = ()
- x = property(itemgetter(0))
- """
- attr_class_name = "{}Attributes".format(cls_name)
- attr_class_template = [
- "class {}(tuple):".format(attr_class_name),
- " __slots__ = ()",
- ]
- if attr_names:
- for i, attr_name in enumerate(attr_names):
- attr_class_template.append(
- _tuple_property_pat.format(index=i, attr_name=attr_name)
- )
- else:
- attr_class_template.append(" pass")
- globs = {"_attrs_itemgetter": itemgetter, "_attrs_property": property}
- eval(compile("\n".join(attr_class_template), "", "exec"), globs)
-
- return globs[attr_class_name]
-
-
-# Tuple class for extracted attributes from a class definition.
-# `base_attrs` is a subset of `attrs`.
-_Attributes = _make_attr_tuple_class(
- "_Attributes",
- [
- # all attributes to build dunder methods for
- "attrs",
- # attributes that have been inherited
- "base_attrs",
- # map inherited attributes to their originating classes
- "base_attrs_map",
- ],
-)
-
-
-def _is_class_var(annot):
- """
- Check whether *annot* is a typing.ClassVar.
-
- The string comparison hack is used to avoid evaluating all string
- annotations which would put attrs-based classes at a performance
- disadvantage compared to plain old classes.
- """
- return str(annot).startswith(_classvar_prefixes)
-
-
-def _get_annotations(cls):
- """
- Get annotations for *cls*.
- """
- anns = getattr(cls, "__annotations__", None)
- if anns is None:
- return {}
-
- # Verify that the annotations aren't merely inherited.
- for base_cls in cls.__mro__[1:]:
- if anns is getattr(base_cls, "__annotations__", None):
- return {}
-
- return anns
-
-
-def _counter_getter(e):
- """
- Key function for sorting to avoid re-creating a lambda for every class.
- """
- return e[1].counter
-
-
-def _transform_attrs(cls, these, auto_attribs, kw_only):
- """
- Transform all `_CountingAttr`s on a class into `Attribute`s.
-
- If *these* is passed, use that and don't look for them on the class.
-
- Return an `_Attributes`.
- """
- cd = cls.__dict__
- anns = _get_annotations(cls)
-
- if these is not None:
- ca_list = [(name, ca) for name, ca in iteritems(these)]
-
- if not isinstance(these, ordered_dict):
- ca_list.sort(key=_counter_getter)
- elif auto_attribs is True:
- ca_names = {
- name
- for name, attr in cd.items()
- if isinstance(attr, _CountingAttr)
- }
- ca_list = []
- annot_names = set()
- for attr_name, type in anns.items():
- if _is_class_var(type):
- continue
- annot_names.add(attr_name)
- a = cd.get(attr_name, NOTHING)
- if not isinstance(a, _CountingAttr):
- if a is NOTHING:
- a = attrib()
- else:
- a = attrib(default=a)
- ca_list.append((attr_name, a))
-
- unannotated = ca_names - annot_names
- if len(unannotated) > 0:
- raise UnannotatedAttributeError(
- "The following `attr.ib`s lack a type annotation: "
- + ", ".join(
- sorted(unannotated, key=lambda n: cd.get(n).counter)
- )
- + "."
- )
- else:
- ca_list = sorted(
- (
- (name, attr)
- for name, attr in cd.items()
- if isinstance(attr, _CountingAttr)
- ),
- key=lambda e: e[1].counter,
- )
-
- own_attrs = [
- Attribute.from_counting_attr(
- name=attr_name, ca=ca, type=anns.get(attr_name)
- )
- for attr_name, ca in ca_list
- ]
-
- base_attrs = []
- base_attr_map = {} # A dictionary of base attrs to their classes.
- taken_attr_names = {a.name: a for a in own_attrs}
-
- # Traverse the MRO and collect attributes.
- for base_cls in cls.__mro__[1:-1]:
- sub_attrs = getattr(base_cls, "__attrs_attrs__", None)
- if sub_attrs is not None:
- for a in sub_attrs:
- prev_a = taken_attr_names.get(a.name)
- # Only add an attribute if it hasn't been defined before. This
- # allows for overwriting attribute definitions by subclassing.
- if prev_a is None:
- base_attrs.append(a)
- taken_attr_names[a.name] = a
- base_attr_map[a.name] = base_cls
-
- attr_names = [a.name for a in base_attrs + own_attrs]
-
- AttrsClass = _make_attr_tuple_class(cls.__name__, attr_names)
-
- if kw_only:
- own_attrs = [a._assoc(kw_only=True) for a in own_attrs]
- base_attrs = [a._assoc(kw_only=True) for a in base_attrs]
-
- attrs = AttrsClass(base_attrs + own_attrs)
-
- had_default = False
- was_kw_only = False
- for a in attrs:
- if (
- was_kw_only is False
- and had_default is True
- and a.default is NOTHING
- and a.init is True
- and a.kw_only is False
- ):
- raise ValueError(
- "No mandatory attributes allowed after an attribute with a "
- "default value or factory. Attribute in question: %r" % (a,)
- )
- elif (
- had_default is False
- and a.default is not NOTHING
- and a.init is not False
- and
- # Keyword-only attributes without defaults can be specified
- # after keyword-only attributes with defaults.
- a.kw_only is False
- ):
- had_default = True
- if was_kw_only is True and a.kw_only is False:
- raise ValueError(
- "Non keyword-only attributes are not allowed after a "
- "keyword-only attribute. Attribute in question: {a!r}".format(
- a=a
- )
- )
- if was_kw_only is False and a.init is True and a.kw_only is True:
- was_kw_only = True
-
- return _Attributes((attrs, base_attrs, base_attr_map))
-
-
-def _frozen_setattrs(self, name, value):
- """
- Attached to frozen classes as __setattr__.
- """
- raise FrozenInstanceError()
-
-
-def _frozen_delattrs(self, name):
- """
- Attached to frozen classes as __delattr__.
- """
- raise FrozenInstanceError()
-
-
-class _ClassBuilder(object):
- """
- Iteratively build *one* class.
- """
-
- __slots__ = (
- "_cls",
- "_cls_dict",
- "_attrs",
- "_base_names",
- "_attr_names",
- "_slots",
- "_frozen",
- "_weakref_slot",
- "_cache_hash",
- "_has_post_init",
- "_delete_attribs",
- "_base_attr_map",
- )
-
- def __init__(
- self,
- cls,
- these,
- slots,
- frozen,
- weakref_slot,
- auto_attribs,
- kw_only,
- cache_hash,
- ):
- attrs, base_attrs, base_map = _transform_attrs(
- cls, these, auto_attribs, kw_only
- )
-
- self._cls = cls
- self._cls_dict = dict(cls.__dict__) if slots else {}
- self._attrs = attrs
- self._base_names = set(a.name for a in base_attrs)
- self._base_attr_map = base_map
- self._attr_names = tuple(a.name for a in attrs)
- self._slots = slots
- self._frozen = frozen or _has_frozen_base_class(cls)
- self._weakref_slot = weakref_slot
- self._cache_hash = cache_hash
- self._has_post_init = bool(getattr(cls, "__attrs_post_init__", False))
- self._delete_attribs = not bool(these)
-
- self._cls_dict["__attrs_attrs__"] = self._attrs
-
- if frozen:
- self._cls_dict["__setattr__"] = _frozen_setattrs
- self._cls_dict["__delattr__"] = _frozen_delattrs
-
- def __repr__(self):
- return "<_ClassBuilder(cls={cls})>".format(cls=self._cls.__name__)
-
- def build_class(self):
- """
- Finalize class based on the accumulated configuration.
-
- Builder cannot be used after calling this method.
- """
- if self._slots is True:
- return self._create_slots_class()
- else:
- return self._patch_original_class()
-
- def _patch_original_class(self):
- """
- Apply accumulated methods and return the class.
- """
- cls = self._cls
- base_names = self._base_names
-
- # Clean class of attribute definitions (`attr.ib()`s).
- if self._delete_attribs:
- for name in self._attr_names:
- if (
- name not in base_names
- and getattr(cls, name, None) is not None
- ):
- try:
- delattr(cls, name)
- except AttributeError:
- # This can happen if a base class defines a class
- # variable and we want to set an attribute with the
- # same name by using only a type annotation.
- pass
-
- # Attach our dunder methods.
- for name, value in self._cls_dict.items():
- setattr(cls, name, value)
-
- return cls
-
- def _create_slots_class(self):
- """
- Build and return a new class with a `__slots__` attribute.
- """
- base_names = self._base_names
- cd = {
- k: v
- for k, v in iteritems(self._cls_dict)
- if k not in tuple(self._attr_names) + ("__dict__", "__weakref__")
- }
-
- weakref_inherited = False
-
- # Traverse the MRO to check for an existing __weakref__.
- for base_cls in self._cls.__mro__[1:-1]:
- if "__weakref__" in getattr(base_cls, "__dict__", ()):
- weakref_inherited = True
- break
-
- names = self._attr_names
- if (
- self._weakref_slot
- and "__weakref__" not in getattr(self._cls, "__slots__", ())
- and "__weakref__" not in names
- and not weakref_inherited
- ):
- names += ("__weakref__",)
-
- # We only add the names of attributes that aren't inherited.
- # Settings __slots__ to inherited attributes wastes memory.
- slot_names = [name for name in names if name not in base_names]
- if self._cache_hash:
- slot_names.append(_hash_cache_field)
- cd["__slots__"] = tuple(slot_names)
-
- qualname = getattr(self._cls, "__qualname__", None)
- if qualname is not None:
- cd["__qualname__"] = qualname
-
- # __weakref__ is not writable.
- state_attr_names = tuple(
- an for an in self._attr_names if an != "__weakref__"
- )
-
- def slots_getstate(self):
- """
- Automatically created by attrs.
- """
- return tuple(getattr(self, name) for name in state_attr_names)
-
- def slots_setstate(self, state):
- """
- Automatically created by attrs.
- """
- __bound_setattr = _obj_setattr.__get__(self, Attribute)
- for name, value in zip(state_attr_names, state):
- __bound_setattr(name, value)
-
- # slots and frozen require __getstate__/__setstate__ to work
- cd["__getstate__"] = slots_getstate
- cd["__setstate__"] = slots_setstate
-
- # Create new class based on old class and our methods.
- cls = type(self._cls)(self._cls.__name__, self._cls.__bases__, cd)
-
- # The following is a fix for
- # https://github.com/python-attrs/attrs/issues/102. On Python 3,
- # if a method mentions `__class__` or uses the no-arg super(), the
- # compiler will bake a reference to the class in the method itself
- # as `method.__closure__`. Since we replace the class with a
- # clone, we rewrite these references so it keeps working.
- for item in cls.__dict__.values():
- if isinstance(item, (classmethod, staticmethod)):
- # Class- and staticmethods hide their functions inside.
- # These might need to be rewritten as well.
- closure_cells = getattr(item.__func__, "__closure__", None)
- else:
- closure_cells = getattr(item, "__closure__", None)
-
- if not closure_cells: # Catch None or the empty list.
- continue
- for cell in closure_cells:
- if cell.cell_contents is self._cls:
- set_closure_cell(cell, cls)
-
- return cls
-
- def add_repr(self, ns):
- self._cls_dict["__repr__"] = self._add_method_dunders(
- _make_repr(self._attrs, ns=ns)
- )
- return self
-
- def add_str(self):
- repr = self._cls_dict.get("__repr__")
- if repr is None:
- raise ValueError(
- "__str__ can only be generated if a __repr__ exists."
- )
-
- def __str__(self):
- return self.__repr__()
-
- self._cls_dict["__str__"] = self._add_method_dunders(__str__)
- return self
-
- def make_unhashable(self):
- self._cls_dict["__hash__"] = None
- return self
-
- def add_hash(self):
- self._cls_dict["__hash__"] = self._add_method_dunders(
- _make_hash(
- self._attrs, frozen=self._frozen, cache_hash=self._cache_hash
- )
- )
-
- return self
-
- def add_init(self):
- self._cls_dict["__init__"] = self._add_method_dunders(
- _make_init(
- self._attrs,
- self._has_post_init,
- self._frozen,
- self._slots,
- self._cache_hash,
- self._base_attr_map,
- )
- )
-
- return self
-
- def add_cmp(self):
- cd = self._cls_dict
-
- cd["__eq__"], cd["__ne__"], cd["__lt__"], cd["__le__"], cd[
- "__gt__"
- ], cd["__ge__"] = (
- self._add_method_dunders(meth) for meth in _make_cmp(self._attrs)
- )
-
- return self
-
- def _add_method_dunders(self, method):
- """
- Add __module__ and __qualname__ to a *method* if possible.
- """
- try:
- method.__module__ = self._cls.__module__
- except AttributeError:
- pass
-
- try:
- method.__qualname__ = ".".join(
- (self._cls.__qualname__, method.__name__)
- )
- except AttributeError:
- pass
-
- return method
-
-
-def attrs(
- maybe_cls=None,
- these=None,
- repr_ns=None,
- repr=True,
- cmp=True,
- hash=None,
- init=True,
- slots=False,
- frozen=False,
- weakref_slot=True,
- str=False,
- auto_attribs=False,
- kw_only=False,
- cache_hash=False,
-):
- r"""
- A class decorator that adds `dunder
- <https://wiki.python.org/moin/DunderAlias>`_\ -methods according to the
- specified attributes using :func:`attr.ib` or the *these* argument.
-
- :param these: A dictionary of name to :func:`attr.ib` mappings. This is
- useful to avoid the definition of your attributes within the class body
- because you can't (e.g. if you want to add ``__repr__`` methods to
- Django models) or don't want to.
-
- If *these* is not ``None``, ``attrs`` will *not* search the class body
- for attributes and will *not* remove any attributes from it.
-
- If *these* is an ordered dict (:class:`dict` on Python 3.6+,
- :class:`collections.OrderedDict` otherwise), the order is deduced from
- the order of the attributes inside *these*. Otherwise the order
- of the definition of the attributes is used.
-
- :type these: :class:`dict` of :class:`str` to :func:`attr.ib`
-
- :param str repr_ns: When using nested classes, there's no way in Python 2
- to automatically detect that. Therefore it's possible to set the
- namespace explicitly for a more meaningful ``repr`` output.
- :param bool repr: Create a ``__repr__`` method with a human readable
- representation of ``attrs`` attributes..
- :param bool str: Create a ``__str__`` method that is identical to
- ``__repr__``. This is usually not necessary except for
- :class:`Exception`\ s.
- :param bool cmp: Create ``__eq__``, ``__ne__``, ``__lt__``, ``__le__``,
- ``__gt__``, and ``__ge__`` methods that compare the class as if it were
- a tuple of its ``attrs`` attributes. But the attributes are *only*
- compared, if the types of both classes are *identical*!
- :param hash: If ``None`` (default), the ``__hash__`` method is generated
- according how *cmp* and *frozen* are set.
-
- 1. If *both* are True, ``attrs`` will generate a ``__hash__`` for you.
- 2. If *cmp* is True and *frozen* is False, ``__hash__`` will be set to
- None, marking it unhashable (which it is).
- 3. If *cmp* is False, ``__hash__`` will be left untouched meaning the
- ``__hash__`` method of the base class will be used (if base class is
- ``object``, this means it will fall back to id-based hashing.).
-
- Although not recommended, you can decide for yourself and force
- ``attrs`` to create one (e.g. if the class is immutable even though you
- didn't freeze it programmatically) by passing ``True`` or not. Both of
- these cases are rather special and should be used carefully.
-
- See the `Python documentation \
- <https://docs.python.org/3/reference/datamodel.html#object.__hash__>`_
- and the `GitHub issue that led to the default behavior \
- <https://github.com/python-attrs/attrs/issues/136>`_ for more details.
- :type hash: ``bool`` or ``None``
- :param bool init: Create a ``__init__`` method that initializes the
- ``attrs`` attributes. Leading underscores are stripped for the
- argument name. If a ``__attrs_post_init__`` method exists on the
- class, it will be called after the class is fully initialized.
- :param bool slots: Create a slots_-style class that's more
- memory-efficient. See :ref:`slots` for further ramifications.
- :param bool frozen: Make instances immutable after initialization. If
- someone attempts to modify a frozen instance,
- :exc:`attr.exceptions.FrozenInstanceError` is raised.
-
- Please note:
-
- 1. This is achieved by installing a custom ``__setattr__`` method
- on your class so you can't implement an own one.
-
- 2. True immutability is impossible in Python.
-
- 3. This *does* have a minor a runtime performance :ref:`impact
- <how-frozen>` when initializing new instances. In other words:
- ``__init__`` is slightly slower with ``frozen=True``.
-
- 4. If a class is frozen, you cannot modify ``self`` in
- ``__attrs_post_init__`` or a self-written ``__init__``. You can
- circumvent that limitation by using
- ``object.__setattr__(self, "attribute_name", value)``.
-
- .. _slots: https://docs.python.org/3/reference/datamodel.html#slots
- :param bool weakref_slot: Make instances weak-referenceable. This has no
- effect unless ``slots`` is also enabled.
- :param bool auto_attribs: If True, collect `PEP 526`_-annotated attributes
- (Python 3.6 and later only) from the class body.
-
- In this case, you **must** annotate every field. If ``attrs``
- encounters a field that is set to an :func:`attr.ib` but lacks a type
- annotation, an :exc:`attr.exceptions.UnannotatedAttributeError` is
- raised. Use ``field_name: typing.Any = attr.ib(...)`` if you don't
- want to set a type.
-
- If you assign a value to those attributes (e.g. ``x: int = 42``), that
- value becomes the default value like if it were passed using
- ``attr.ib(default=42)``. Passing an instance of :class:`Factory` also
- works as expected.
-
- Attributes annotated as :data:`typing.ClassVar` are **ignored**.
-
- .. _`PEP 526`: https://www.python.org/dev/peps/pep-0526/
- :param bool kw_only: Make all attributes keyword-only (Python 3+)
- in the generated ``__init__`` (if ``init`` is ``False``, this
- parameter is ignored).
- :param bool cache_hash: Ensure that the object's hash code is computed
- only once and stored on the object. If this is set to ``True``,
- hashing must be either explicitly or implicitly enabled for this
- class. If the hash code is cached, then no attributes of this
- class which participate in hash code computation may be mutated
- after object creation.
-
-
- .. versionadded:: 16.0.0 *slots*
- .. versionadded:: 16.1.0 *frozen*
- .. versionadded:: 16.3.0 *str*
- .. versionadded:: 16.3.0 Support for ``__attrs_post_init__``.
- .. versionchanged:: 17.1.0
- *hash* supports ``None`` as value which is also the default now.
- .. versionadded:: 17.3.0 *auto_attribs*
- .. versionchanged:: 18.1.0
- If *these* is passed, no attributes are deleted from the class body.
- .. versionchanged:: 18.1.0 If *these* is ordered, the order is retained.
- .. versionadded:: 18.2.0 *weakref_slot*
- .. deprecated:: 18.2.0
- ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now raise a
- :class:`DeprecationWarning` if the classes compared are subclasses of
- each other. ``__eq`` and ``__ne__`` never tried to compared subclasses
- to each other.
- .. versionadded:: 18.2.0 *kw_only*
- .. versionadded:: 18.2.0 *cache_hash*
- """
-
- def wrap(cls):
- if getattr(cls, "__class__", None) is None:
- raise TypeError("attrs only works with new-style classes.")
-
- builder = _ClassBuilder(
- cls,
- these,
- slots,
- frozen,
- weakref_slot,
- auto_attribs,
- kw_only,
- cache_hash,
- )
-
- if repr is True:
- builder.add_repr(repr_ns)
- if str is True:
- builder.add_str()
- if cmp is True:
- builder.add_cmp()
-
- if hash is not True and hash is not False and hash is not None:
- # Can't use `hash in` because 1 == True for example.
- raise TypeError(
- "Invalid value for hash. Must be True, False, or None."
- )
- elif hash is False or (hash is None and cmp is False):
- if cache_hash:
- raise TypeError(
- "Invalid value for cache_hash. To use hash caching,"
- " hashing must be either explicitly or implicitly "
- "enabled."
- )
- elif hash is True or (hash is None and cmp is True and frozen is True):
- builder.add_hash()
- else:
- if cache_hash:
- raise TypeError(
- "Invalid value for cache_hash. To use hash caching,"
- " hashing must be either explicitly or implicitly "
- "enabled."
- )
- builder.make_unhashable()
-
- if init is True:
- builder.add_init()
- else:
- if cache_hash:
- raise TypeError(
- "Invalid value for cache_hash. To use hash caching,"
- " init must be True."
- )
-
- return builder.build_class()
-
- # maybe_cls's type depends on the usage of the decorator. It's a class
- # if it's used as `@attrs` but ``None`` if used as `@attrs()`.
- if maybe_cls is None:
- return wrap
- else:
- return wrap(maybe_cls)
-
-
-_attrs = attrs
-"""
-Internal alias so we can use it in functions that take an argument called
-*attrs*.
-"""
-
-
-if PY2:
-
- def _has_frozen_base_class(cls):
- """
- Check whether *cls* has a frozen ancestor by looking at its
- __setattr__.
- """
- return (
- getattr(cls.__setattr__, "__module__", None)
- == _frozen_setattrs.__module__
- and cls.__setattr__.__name__ == _frozen_setattrs.__name__
- )
-
-
-else:
-
- def _has_frozen_base_class(cls):
- """
- Check whether *cls* has a frozen ancestor by looking at its
- __setattr__.
- """
- return cls.__setattr__ == _frozen_setattrs
-
-
-def _attrs_to_tuple(obj, attrs):
- """
- Create a tuple of all values of *obj*'s *attrs*.
- """
- return tuple(getattr(obj, a.name) for a in attrs)
-
-
-def _make_hash(attrs, frozen, cache_hash):
- attrs = tuple(
- a
- for a in attrs
- if a.hash is True or (a.hash is None and a.cmp is True)
- )
-
- tab = " "
-
- # We cache the generated hash methods for the same kinds of attributes.
- sha1 = hashlib.sha1()
- sha1.update(repr(attrs).encode("utf-8"))
- unique_filename = "<attrs generated hash %s>" % (sha1.hexdigest(),)
- type_hash = hash(unique_filename)
-
- method_lines = ["def __hash__(self):"]
-
- def append_hash_computation_lines(prefix, indent):
- """
- Generate the code for actually computing the hash code.
- Below this will either be returned directly or used to compute
- a value which is then cached, depending on the value of cache_hash
- """
- method_lines.extend(
- [indent + prefix + "hash((", indent + " %d," % (type_hash,)]
- )
-
- for a in attrs:
- method_lines.append(indent + " self.%s," % a.name)
-
- method_lines.append(indent + " ))")
-
- if cache_hash:
- method_lines.append(tab + "if self.%s is None:" % _hash_cache_field)
- if frozen:
- append_hash_computation_lines(
- "object.__setattr__(self, '%s', " % _hash_cache_field, tab * 2
- )
- method_lines.append(tab * 2 + ")") # close __setattr__
- else:
- append_hash_computation_lines(
- "self.%s = " % _hash_cache_field, tab * 2
- )
- method_lines.append(tab + "return self.%s" % _hash_cache_field)
- else:
- append_hash_computation_lines("return ", tab)
-
- script = "\n".join(method_lines)
- globs = {}
- locs = {}
- bytecode = compile(script, unique_filename, "exec")
- eval(bytecode, globs, locs)
-
- # In order of debuggers like PDB being able to step through the code,
- # we add a fake linecache entry.
- linecache.cache[unique_filename] = (
- len(script),
- None,
- script.splitlines(True),
- unique_filename,
- )
-
- return locs["__hash__"]
-
-
-def _add_hash(cls, attrs):
- """
- Add a hash method to *cls*.
- """
- cls.__hash__ = _make_hash(attrs, frozen=False, cache_hash=False)
- return cls
-
-
-def __ne__(self, other):
- """
- Check equality and either forward a NotImplemented or return the result
- negated.
- """
- result = self.__eq__(other)
- if result is NotImplemented:
- return NotImplemented
-
- return not result
-
-
-WARNING_CMP_ISINSTANCE = (
- "Comparision of subclasses using __%s__ is deprecated and will be removed "
- "in 2019."
-)
-
-
-def _make_cmp(attrs):
- attrs = [a for a in attrs if a.cmp]
-
- # We cache the generated eq methods for the same kinds of attributes.
- sha1 = hashlib.sha1()
- sha1.update(repr(attrs).encode("utf-8"))
- unique_filename = "<attrs generated eq %s>" % (sha1.hexdigest(),)
- lines = [
- "def __eq__(self, other):",
- " if other.__class__ is not self.__class__:",
- " return NotImplemented",
- ]
- # We can't just do a big self.x = other.x and... clause due to
- # irregularities like nan == nan is false but (nan,) == (nan,) is true.
- if attrs:
- lines.append(" return (")
- others = [" ) == ("]
- for a in attrs:
- lines.append(" self.%s," % (a.name,))
- others.append(" other.%s," % (a.name,))
-
- lines += others + [" )"]
- else:
- lines.append(" return True")
-
- script = "\n".join(lines)
- globs = {}
- locs = {}
- bytecode = compile(script, unique_filename, "exec")
- eval(bytecode, globs, locs)
-
- # In order of debuggers like PDB being able to step through the code,
- # we add a fake linecache entry.
- linecache.cache[unique_filename] = (
- len(script),
- None,
- script.splitlines(True),
- unique_filename,
- )
- eq = locs["__eq__"]
- ne = __ne__
-
- def attrs_to_tuple(obj):
- """
- Save us some typing.
- """
- return _attrs_to_tuple(obj, attrs)
-
- def __lt__(self, other):
- """
- Automatically created by attrs.
- """
- if isinstance(other, self.__class__):
- if other.__class__ is not self.__class__:
- warnings.warn(
- WARNING_CMP_ISINSTANCE % ("lt",), DeprecationWarning
- )
- return attrs_to_tuple(self) < attrs_to_tuple(other)
- else:
- return NotImplemented
-
- def __le__(self, other):
- """
- Automatically created by attrs.
- """
- if isinstance(other, self.__class__):
- if other.__class__ is not self.__class__:
- warnings.warn(
- WARNING_CMP_ISINSTANCE % ("le",), DeprecationWarning
- )
- return attrs_to_tuple(self) <= attrs_to_tuple(other)
- else:
- return NotImplemented
-
- def __gt__(self, other):
- """
- Automatically created by attrs.
- """
- if isinstance(other, self.__class__):
- if other.__class__ is not self.__class__:
- warnings.warn(
- WARNING_CMP_ISINSTANCE % ("gt",), DeprecationWarning
- )
- return attrs_to_tuple(self) > attrs_to_tuple(other)
- else:
- return NotImplemented
-
- def __ge__(self, other):
- """
- Automatically created by attrs.
- """
- if isinstance(other, self.__class__):
- if other.__class__ is not self.__class__:
- warnings.warn(
- WARNING_CMP_ISINSTANCE % ("ge",), DeprecationWarning
- )
- return attrs_to_tuple(self) >= attrs_to_tuple(other)
- else:
- return NotImplemented
-
- return eq, ne, __lt__, __le__, __gt__, __ge__
-
-
-def _add_cmp(cls, attrs=None):
- """
- Add comparison methods to *cls*.
- """
- if attrs is None:
- attrs = cls.__attrs_attrs__
-
- cls.__eq__, cls.__ne__, cls.__lt__, cls.__le__, cls.__gt__, cls.__ge__ = _make_cmp( # noqa
- attrs
- )
-
- return cls
-
-
-_already_repring = threading.local()
-
-
-def _make_repr(attrs, ns):
- """
- Make a repr method for *attr_names* adding *ns* to the full name.
- """
- attr_names = tuple(a.name for a in attrs if a.repr)
-
- def __repr__(self):
- """
- Automatically created by attrs.
- """
- try:
- working_set = _already_repring.working_set
- except AttributeError:
- working_set = set()
- _already_repring.working_set = working_set
-
- if id(self) in working_set:
- return "..."
- real_cls = self.__class__
- if ns is None:
- qualname = getattr(real_cls, "__qualname__", None)
- if qualname is not None:
- class_name = qualname.rsplit(">.", 1)[-1]
- else:
- class_name = real_cls.__name__
- else:
- class_name = ns + "." + real_cls.__name__
-
- # Since 'self' remains on the stack (i.e.: strongly referenced) for the
- # duration of this call, it's safe to depend on id(...) stability, and
- # not need to track the instance and therefore worry about properties
- # like weakref- or hash-ability.
- working_set.add(id(self))
- try:
- result = [class_name, "("]
- first = True
- for name in attr_names:
- if first:
- first = False
- else:
- result.append(", ")
- result.extend((name, "=", repr(getattr(self, name, NOTHING))))
- return "".join(result) + ")"
- finally:
- working_set.remove(id(self))
-
- return __repr__
-
-
-def _add_repr(cls, ns=None, attrs=None):
- """
- Add a repr method to *cls*.
- """
- if attrs is None:
- attrs = cls.__attrs_attrs__
-
- cls.__repr__ = _make_repr(attrs, ns)
- return cls
-
-
-def _make_init(attrs, post_init, frozen, slots, cache_hash, base_attr_map):
- attrs = [a for a in attrs if a.init or a.default is not NOTHING]
-
- # We cache the generated init methods for the same kinds of attributes.
- sha1 = hashlib.sha1()
- sha1.update(repr(attrs).encode("utf-8"))
- unique_filename = "<attrs generated init {0}>".format(sha1.hexdigest())
-
- script, globs, annotations = _attrs_to_init_script(
- attrs, frozen, slots, post_init, cache_hash, base_attr_map
- )
- locs = {}
- bytecode = compile(script, unique_filename, "exec")
- attr_dict = dict((a.name, a) for a in attrs)
- globs.update({"NOTHING": NOTHING, "attr_dict": attr_dict})
- if frozen is True:
- # Save the lookup overhead in __init__ if we need to circumvent
- # immutability.
- globs["_cached_setattr"] = _obj_setattr
- eval(bytecode, globs, locs)
-
- # In order of debuggers like PDB being able to step through the code,
- # we add a fake linecache entry.
- linecache.cache[unique_filename] = (
- len(script),
- None,
- script.splitlines(True),
- unique_filename,
- )
-
- __init__ = locs["__init__"]
- __init__.__annotations__ = annotations
- return __init__
-
-
-def _add_init(cls, frozen):
- """
- Add a __init__ method to *cls*. If *frozen* is True, make it immutable.
- """
- cls.__init__ = _make_init(
- cls.__attrs_attrs__,
- getattr(cls, "__attrs_post_init__", False),
- frozen,
- _is_slot_cls(cls),
- cache_hash=False,
- base_attr_map={},
- )
- return cls
-
-
-def fields(cls):
- """
- Return the tuple of ``attrs`` attributes for a class.
-
- The tuple also allows accessing the fields by their names (see below for
- examples).
-
- :param type cls: Class to introspect.
-
- :raise TypeError: If *cls* is not a class.
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- :rtype: tuple (with name accessors) of :class:`attr.Attribute`
-
- .. versionchanged:: 16.2.0 Returned tuple allows accessing the fields
- by name.
- """
- if not isclass(cls):
- raise TypeError("Passed object must be a class.")
- attrs = getattr(cls, "__attrs_attrs__", None)
- if attrs is None:
- raise NotAnAttrsClassError(
- "{cls!r} is not an attrs-decorated class.".format(cls=cls)
- )
- return attrs
-
-
-def fields_dict(cls):
- """
- Return an ordered dictionary of ``attrs`` attributes for a class, whose
- keys are the attribute names.
-
- :param type cls: Class to introspect.
-
- :raise TypeError: If *cls* is not a class.
- :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
- class.
-
- :rtype: an ordered dict where keys are attribute names and values are
- :class:`attr.Attribute`\\ s. This will be a :class:`dict` if it's
- naturally ordered like on Python 3.6+ or an
- :class:`~collections.OrderedDict` otherwise.
-
- .. versionadded:: 18.1.0
- """
- if not isclass(cls):
- raise TypeError("Passed object must be a class.")
- attrs = getattr(cls, "__attrs_attrs__", None)
- if attrs is None:
- raise NotAnAttrsClassError(
- "{cls!r} is not an attrs-decorated class.".format(cls=cls)
- )
- return ordered_dict(((a.name, a) for a in attrs))
-
-
-def validate(inst):
- """
- Validate all attributes on *inst* that have a validator.
-
- Leaves all exceptions through.
-
- :param inst: Instance of a class with ``attrs`` attributes.
- """
- if _config._run_validators is False:
- return
-
- for a in fields(inst.__class__):
- v = a.validator
- if v is not None:
- v(inst, a, getattr(inst, a.name))
-
-
-def _is_slot_cls(cls):
- return "__slots__" in cls.__dict__
-
-
-def _is_slot_attr(a_name, base_attr_map):
- """
- Check if the attribute name comes from a slot class.
- """
- return a_name in base_attr_map and _is_slot_cls(base_attr_map[a_name])
-
-
-def _attrs_to_init_script(
- attrs, frozen, slots, post_init, cache_hash, base_attr_map
-):
- """
- Return a script of an initializer for *attrs* and a dict of globals.
-
- The globals are expected by the generated script.
-
- If *frozen* is True, we cannot set the attributes directly so we use
- a cached ``object.__setattr__``.
- """
- lines = []
- any_slot_ancestors = any(
- _is_slot_attr(a.name, base_attr_map) for a in attrs
- )
- if frozen is True:
- if slots is True:
- lines.append(
- # Circumvent the __setattr__ descriptor to save one lookup per
- # assignment.
- # Note _setattr will be used again below if cache_hash is True
- "_setattr = _cached_setattr.__get__(self, self.__class__)"
- )
-
- def fmt_setter(attr_name, value_var):
- return "_setattr('%(attr_name)s', %(value_var)s)" % {
- "attr_name": attr_name,
- "value_var": value_var,
- }
-
- def fmt_setter_with_converter(attr_name, value_var):
- conv_name = _init_converter_pat.format(attr_name)
- return "_setattr('%(attr_name)s', %(conv)s(%(value_var)s))" % {
- "attr_name": attr_name,
- "value_var": value_var,
- "conv": conv_name,
- }
-
- else:
- # Dict frozen classes assign directly to __dict__.
- # But only if the attribute doesn't come from an ancestor slot
- # class.
- # Note _inst_dict will be used again below if cache_hash is True
- lines.append("_inst_dict = self.__dict__")
- if any_slot_ancestors:
- lines.append(
- # Circumvent the __setattr__ descriptor to save one lookup
- # per assignment.
- "_setattr = _cached_setattr.__get__(self, self.__class__)"
- )
-
- def fmt_setter(attr_name, value_var):
- if _is_slot_attr(attr_name, base_attr_map):
- res = "_setattr('%(attr_name)s', %(value_var)s)" % {
- "attr_name": attr_name,
- "value_var": value_var,
- }
- else:
- res = "_inst_dict['%(attr_name)s'] = %(value_var)s" % {
- "attr_name": attr_name,
- "value_var": value_var,
- }
- return res
-
- def fmt_setter_with_converter(attr_name, value_var):
- conv_name = _init_converter_pat.format(attr_name)
- if _is_slot_attr(attr_name, base_attr_map):
- tmpl = "_setattr('%(attr_name)s', %(c)s(%(value_var)s))"
- else:
- tmpl = "_inst_dict['%(attr_name)s'] = %(c)s(%(value_var)s)"
- return tmpl % {
- "attr_name": attr_name,
- "value_var": value_var,
- "c": conv_name,
- }
-
- else:
- # Not frozen.
- def fmt_setter(attr_name, value):
- return "self.%(attr_name)s = %(value)s" % {
- "attr_name": attr_name,
- "value": value,
- }
-
- def fmt_setter_with_converter(attr_name, value_var):
- conv_name = _init_converter_pat.format(attr_name)
- return "self.%(attr_name)s = %(conv)s(%(value_var)s)" % {
- "attr_name": attr_name,
- "value_var": value_var,
- "conv": conv_name,
- }
-
- args = []
- kw_only_args = []
- attrs_to_validate = []
-
- # This is a dictionary of names to validator and converter callables.
- # Injecting this into __init__ globals lets us avoid lookups.
- names_for_globals = {}
- annotations = {"return": None}
-
- for a in attrs:
- if a.validator:
- attrs_to_validate.append(a)
- attr_name = a.name
- arg_name = a.name.lstrip("_")
- has_factory = isinstance(a.default, Factory)
- if has_factory and a.default.takes_self:
- maybe_self = "self"
- else:
- maybe_self = ""
- if a.init is False:
- if has_factory:
- init_factory_name = _init_factory_pat.format(a.name)
- if a.converter is not None:
- lines.append(
- fmt_setter_with_converter(
- attr_name,
- init_factory_name + "({0})".format(maybe_self),
- )
- )
- conv_name = _init_converter_pat.format(a.name)
- names_for_globals[conv_name] = a.converter
- else:
- lines.append(
- fmt_setter(
- attr_name,
- init_factory_name + "({0})".format(maybe_self),
- )
- )
- names_for_globals[init_factory_name] = a.default.factory
- else:
- if a.converter is not None:
- lines.append(
- fmt_setter_with_converter(
- attr_name,
- "attr_dict['{attr_name}'].default".format(
- attr_name=attr_name
- ),
- )
- )
- conv_name = _init_converter_pat.format(a.name)
- names_for_globals[conv_name] = a.converter
- else:
- lines.append(
- fmt_setter(
- attr_name,
- "attr_dict['{attr_name}'].default".format(
- attr_name=attr_name
- ),
- )
- )
- elif a.default is not NOTHING and not has_factory:
- arg = "{arg_name}=attr_dict['{attr_name}'].default".format(
- arg_name=arg_name, attr_name=attr_name
- )
- if a.kw_only:
- kw_only_args.append(arg)
- else:
- args.append(arg)
- if a.converter is not None:
- lines.append(fmt_setter_with_converter(attr_name, arg_name))
- names_for_globals[
- _init_converter_pat.format(a.name)
- ] = a.converter
- else:
- lines.append(fmt_setter(attr_name, arg_name))
- elif has_factory:
- arg = "{arg_name}=NOTHING".format(arg_name=arg_name)
- if a.kw_only:
- kw_only_args.append(arg)
- else:
- args.append(arg)
- lines.append(
- "if {arg_name} is not NOTHING:".format(arg_name=arg_name)
- )
- init_factory_name = _init_factory_pat.format(a.name)
- if a.converter is not None:
- lines.append(
- " " + fmt_setter_with_converter(attr_name, arg_name)
- )
- lines.append("else:")
- lines.append(
- " "
- + fmt_setter_with_converter(
- attr_name,
- init_factory_name + "({0})".format(maybe_self),
- )
- )
- names_for_globals[
- _init_converter_pat.format(a.name)
- ] = a.converter
- else:
- lines.append(" " + fmt_setter(attr_name, arg_name))
- lines.append("else:")
- lines.append(
- " "
- + fmt_setter(
- attr_name,
- init_factory_name + "({0})".format(maybe_self),
- )
- )
- names_for_globals[init_factory_name] = a.default.factory
- else:
- if a.kw_only:
- kw_only_args.append(arg_name)
- else:
- args.append(arg_name)
- if a.converter is not None:
- lines.append(fmt_setter_with_converter(attr_name, arg_name))
- names_for_globals[
- _init_converter_pat.format(a.name)
- ] = a.converter
- else:
- lines.append(fmt_setter(attr_name, arg_name))
-
- if a.init is True and a.converter is None and a.type is not None:
- annotations[arg_name] = a.type
-
- if attrs_to_validate: # we can skip this if there are no validators.
- names_for_globals["_config"] = _config
- lines.append("if _config._run_validators is True:")
- for a in attrs_to_validate:
- val_name = "__attr_validator_{}".format(a.name)
- attr_name = "__attr_{}".format(a.name)
- lines.append(
- " {}(self, {}, self.{})".format(val_name, attr_name, a.name)
- )
- names_for_globals[val_name] = a.validator
- names_for_globals[attr_name] = a
- if post_init:
- lines.append("self.__attrs_post_init__()")
-
- # because this is set only after __attrs_post_init is called, a crash
- # will result if post-init tries to access the hash code. This seemed
- # preferable to setting this beforehand, in which case alteration to
- # field values during post-init combined with post-init accessing the
- # hash code would result in silent bugs.
- if cache_hash:
- if frozen:
- if slots:
- # if frozen and slots, then _setattr defined above
- init_hash_cache = "_setattr('%s', %s)"
- else:
- # if frozen and not slots, then _inst_dict defined above
- init_hash_cache = "_inst_dict['%s'] = %s"
- else:
- init_hash_cache = "self.%s = %s"
- lines.append(init_hash_cache % (_hash_cache_field, "None"))
-
- args = ", ".join(args)
- if kw_only_args:
- if PY2:
- raise PythonTooOldError(
- "Keyword-only arguments only work on Python 3 and later."
- )
-
- args += "{leading_comma}*, {kw_only_args}".format(
- leading_comma=", " if args else "",
- kw_only_args=", ".join(kw_only_args),
- )
- return (
- """\
-def __init__(self, {args}):
- {lines}
-""".format(
- args=args, lines="\n ".join(lines) if lines else "pass"
- ),
- names_for_globals,
- annotations,
- )
-
-
-class Attribute(object):
- """
- *Read-only* representation of an attribute.
-
- :attribute name: The name of the attribute.
-
- Plus *all* arguments of :func:`attr.ib`.
-
- For the version history of the fields, see :func:`attr.ib`.
- """
-
- __slots__ = (
- "name",
- "default",
- "validator",
- "repr",
- "cmp",
- "hash",
- "init",
- "metadata",
- "type",
- "converter",
- "kw_only",
- )
-
- def __init__(
- self,
- name,
- default,
- validator,
- repr,
- cmp,
- hash,
- init,
- convert=None,
- metadata=None,
- type=None,
- converter=None,
- kw_only=False,
- ):
- # Cache this descriptor here to speed things up later.
- bound_setattr = _obj_setattr.__get__(self, Attribute)
-
- # Despite the big red warning, people *do* instantiate `Attribute`
- # themselves.
- if convert is not None:
- if converter is not None:
- raise RuntimeError(
- "Can't pass both `convert` and `converter`. "
- "Please use `converter` only."
- )
- warnings.warn(
- "The `convert` argument is deprecated in favor of `converter`."
- " It will be removed after 2019/01.",
- DeprecationWarning,
- stacklevel=2,
- )
- converter = convert
-
- bound_setattr("name", name)
- bound_setattr("default", default)
- bound_setattr("validator", validator)
- bound_setattr("repr", repr)
- bound_setattr("cmp", cmp)
- bound_setattr("hash", hash)
- bound_setattr("init", init)
- bound_setattr("converter", converter)
- bound_setattr(
- "metadata",
- (
- metadata_proxy(metadata)
- if metadata
- else _empty_metadata_singleton
- ),
- )
- bound_setattr("type", type)
- bound_setattr("kw_only", kw_only)
-
- def __setattr__(self, name, value):
- raise FrozenInstanceError()
-
- @property
- def convert(self):
- warnings.warn(
- "The `convert` attribute is deprecated in favor of `converter`. "
- "It will be removed after 2019/01.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.converter
-
- @classmethod
- def from_counting_attr(cls, name, ca, type=None):
- # type holds the annotated value. deal with conflicts:
- if type is None:
- type = ca.type
- elif ca.type is not None:
- raise ValueError(
- "Type annotation and type argument cannot both be present"
- )
- inst_dict = {
- k: getattr(ca, k)
- for k in Attribute.__slots__
- if k
- not in (
- "name",
- "validator",
- "default",
- "type",
- "convert",
- ) # exclude methods and deprecated alias
- }
- return cls(
- name=name,
- validator=ca._validator,
- default=ca._default,
- type=type,
- **inst_dict
- )
-
- # Don't use attr.assoc since fields(Attribute) doesn't work
- def _assoc(self, **changes):
- """
- Copy *self* and apply *changes*.
- """
- new = copy.copy(self)
-
- new._setattrs(changes.items())
-
- return new
-
- # Don't use _add_pickle since fields(Attribute) doesn't work
- def __getstate__(self):
- """
- Play nice with pickle.
- """
- return tuple(
- getattr(self, name) if name != "metadata" else dict(self.metadata)
- for name in self.__slots__
- )
-
- def __setstate__(self, state):
- """
- Play nice with pickle.
- """
- self._setattrs(zip(self.__slots__, state))
-
- def _setattrs(self, name_values_pairs):
- bound_setattr = _obj_setattr.__get__(self, Attribute)
- for name, value in name_values_pairs:
- if name != "metadata":
- bound_setattr(name, value)
- else:
- bound_setattr(
- name,
- metadata_proxy(value)
- if value
- else _empty_metadata_singleton,
- )
-
-
-_a = [
- Attribute(
- name=name,
- default=NOTHING,
- validator=None,
- repr=True,
- cmp=True,
- hash=(name != "metadata"),
- init=True,
- )
- for name in Attribute.__slots__
- if name != "convert" # XXX: remove once `convert` is gone
-]
-
-Attribute = _add_hash(
- _add_cmp(_add_repr(Attribute, attrs=_a), attrs=_a),
- attrs=[a for a in _a if a.hash],
-)
-
-
-class _CountingAttr(object):
- """
- Intermediate representation of attributes that uses a counter to preserve
- the order in which the attributes have been defined.
-
- *Internal* data structure of the attrs library. Running into is most
- likely the result of a bug like a forgotten `@attr.s` decorator.
- """
-
- __slots__ = (
- "counter",
- "_default",
- "repr",
- "cmp",
- "hash",
- "init",
- "metadata",
- "_validator",
- "converter",
- "type",
- "kw_only",
- )
- __attrs_attrs__ = tuple(
- Attribute(
- name=name,
- default=NOTHING,
- validator=None,
- repr=True,
- cmp=True,
- hash=True,
- init=True,
- kw_only=False,
- )
- for name in ("counter", "_default", "repr", "cmp", "hash", "init")
- ) + (
- Attribute(
- name="metadata",
- default=None,
- validator=None,
- repr=True,
- cmp=True,
- hash=False,
- init=True,
- kw_only=False,
- ),
- )
- cls_counter = 0
-
- def __init__(
- self,
- default,
- validator,
- repr,
- cmp,
- hash,
- init,
- converter,
- metadata,
- type,
- kw_only,
- ):
- _CountingAttr.cls_counter += 1
- self.counter = _CountingAttr.cls_counter
- self._default = default
- # If validator is a list/tuple, wrap it using helper validator.
- if validator and isinstance(validator, (list, tuple)):
- self._validator = and_(*validator)
- else:
- self._validator = validator
- self.repr = repr
- self.cmp = cmp
- self.hash = hash
- self.init = init
- self.converter = converter
- self.metadata = metadata
- self.type = type
- self.kw_only = kw_only
-
- def validator(self, meth):
- """
- Decorator that adds *meth* to the list of validators.
-
- Returns *meth* unchanged.
-
- .. versionadded:: 17.1.0
- """
- if self._validator is None:
- self._validator = meth
- else:
- self._validator = and_(self._validator, meth)
- return meth
-
- def default(self, meth):
- """
- Decorator that allows to set the default for an attribute.
-
- Returns *meth* unchanged.
-
- :raises DefaultAlreadySetError: If default has been set before.
-
- .. versionadded:: 17.1.0
- """
- if self._default is not NOTHING:
- raise DefaultAlreadySetError()
-
- self._default = Factory(meth, takes_self=True)
-
- return meth
-
-
-_CountingAttr = _add_cmp(_add_repr(_CountingAttr))
-
-
-@attrs(slots=True, init=False, hash=True)
-class Factory(object):
- """
- Stores a factory callable.
-
- If passed as the default value to :func:`attr.ib`, the factory is used to
- generate a new value.
-
- :param callable factory: A callable that takes either none or exactly one
- mandatory positional argument depending on *takes_self*.
- :param bool takes_self: Pass the partially initialized instance that is
- being initialized as a positional argument.
-
- .. versionadded:: 17.1.0 *takes_self*
- """
-
- factory = attrib()
- takes_self = attrib()
-
- def __init__(self, factory, takes_self=False):
- """
- `Factory` is part of the default machinery so if we want a default
- value here, we have to implement it ourselves.
- """
- self.factory = factory
- self.takes_self = takes_self
-
-
-def make_class(name, attrs, bases=(object,), **attributes_arguments):
- """
- A quick way to create a new class called *name* with *attrs*.
-
- :param name: The name for the new class.
- :type name: str
-
- :param attrs: A list of names or a dictionary of mappings of names to
- attributes.
-
- If *attrs* is a list or an ordered dict (:class:`dict` on Python 3.6+,
- :class:`collections.OrderedDict` otherwise), the order is deduced from
- the order of the names or attributes inside *attrs*. Otherwise the
- order of the definition of the attributes is used.
- :type attrs: :class:`list` or :class:`dict`
-
- :param tuple bases: Classes that the new class will subclass.
-
- :param attributes_arguments: Passed unmodified to :func:`attr.s`.
-
- :return: A new class with *attrs*.
- :rtype: type
-
- .. versionadded:: 17.1.0 *bases*
- .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained.
- """
- if isinstance(attrs, dict):
- cls_dict = attrs
- elif isinstance(attrs, (list, tuple)):
- cls_dict = dict((a, attrib()) for a in attrs)
- else:
- raise TypeError("attrs argument must be a dict or a list.")
-
- post_init = cls_dict.pop("__attrs_post_init__", None)
- type_ = type(
- name,
- bases,
- {} if post_init is None else {"__attrs_post_init__": post_init},
- )
- # For pickling to work, the __module__ variable needs to be set to the
- # frame where the class is created. Bypass this step in environments where
- # sys._getframe is not defined (Jython for example) or sys._getframe is not
- # defined for arguments greater than 0 (IronPython).
- try:
- type_.__module__ = sys._getframe(1).f_globals.get(
- "__name__", "__main__"
- )
- except (AttributeError, ValueError):
- pass
-
- return _attrs(these=cls_dict, **attributes_arguments)(type_)
-
-
-# These are required by within this module so we define them here and merely
-# import into .validators.
-
-
-@attrs(slots=True, hash=True)
-class _AndValidator(object):
- """
- Compose many validators to a single one.
- """
-
- _validators = attrib()
-
- def __call__(self, inst, attr, value):
- for v in self._validators:
- v(inst, attr, value)
-
-
-def and_(*validators):
- """
- A validator that composes multiple validators into one.
-
- When called on a value, it runs all wrapped validators.
-
- :param validators: Arbitrary number of validators.
- :type validators: callables
-
- .. versionadded:: 17.1.0
- """
- vals = []
- for validator in validators:
- vals.extend(
- validator._validators
- if isinstance(validator, _AndValidator)
- else [validator]
- )
-
- return _AndValidator(tuple(vals))
diff --git a/python/attr/converters.py b/python/attr/converters.py
deleted file mode 100644
index 37c4a07..0000000
--- a/python/attr/converters.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""
-Commonly useful converters.
-"""
-
-from __future__ import absolute_import, division, print_function
-
-from ._make import NOTHING, Factory
-
-
-def optional(converter):
- """
- A converter that allows an attribute to be optional. An optional attribute
- is one which can be set to ``None``.
-
- :param callable converter: the converter that is used for non-``None``
- values.
-
- .. versionadded:: 17.1.0
- """
-
- def optional_converter(val):
- if val is None:
- return None
- return converter(val)
-
- return optional_converter
-
-
-def default_if_none(default=NOTHING, factory=None):
- """
- A converter that allows to replace ``None`` values by *default* or the
- result of *factory*.
-
- :param default: Value to be used if ``None`` is passed. Passing an instance
- of :class:`attr.Factory` is supported, however the ``takes_self`` option
- is *not*.
- :param callable factory: A callable that takes not parameters whose result
- is used if ``None`` is passed.
-
- :raises TypeError: If **neither** *default* or *factory* is passed.
- :raises TypeError: If **both** *default* and *factory* are passed.
- :raises ValueError: If an instance of :class:`attr.Factory` is passed with
- ``takes_self=True``.
-
- .. versionadded:: 18.2.0
- """
- if default is NOTHING and factory is None:
- raise TypeError("Must pass either `default` or `factory`.")
-
- if default is not NOTHING and factory is not None:
- raise TypeError(
- "Must pass either `default` or `factory` but not both."
- )
-
- if factory is not None:
- default = Factory(factory)
-
- if isinstance(default, Factory):
- if default.takes_self:
- raise ValueError(
- "`takes_self` is not supported by default_if_none."
- )
-
- def default_if_none_converter(val):
- if val is not None:
- return val
-
- return default.factory()
-
- else:
-
- def default_if_none_converter(val):
- if val is not None:
- return val
-
- return default
-
- return default_if_none_converter
diff --git a/python/attr/converters.pyi b/python/attr/converters.pyi
deleted file mode 100644
index 63b2a38..0000000
--- a/python/attr/converters.pyi
+++ /dev/null
@@ -1,12 +0,0 @@
-from typing import TypeVar, Optional, Callable, overload
-from . import _ConverterType
-
-_T = TypeVar("_T")
-
-def optional(
- converter: _ConverterType[_T]
-) -> _ConverterType[Optional[_T]]: ...
-@overload
-def default_if_none(default: _T) -> _ConverterType[_T]: ...
-@overload
-def default_if_none(*, factory: Callable[[], _T]) -> _ConverterType[_T]: ...
diff --git a/python/attr/exceptions.py b/python/attr/exceptions.py
deleted file mode 100644
index b12e41e..0000000
--- a/python/attr/exceptions.py
+++ /dev/null
@@ -1,57 +0,0 @@
-from __future__ import absolute_import, division, print_function
-
-
-class FrozenInstanceError(AttributeError):
- """
- A frozen/immutable instance has been attempted to be modified.
-
- It mirrors the behavior of ``namedtuples`` by using the same error message
- and subclassing :exc:`AttributeError`.
-
- .. versionadded:: 16.1.0
- """
-
- msg = "can't set attribute"
- args = [msg]
-
-
-class AttrsAttributeNotFoundError(ValueError):
- """
- An ``attrs`` function couldn't find an attribute that the user asked for.
-
- .. versionadded:: 16.2.0
- """
-
-
-class NotAnAttrsClassError(ValueError):
- """
- A non-``attrs`` class has been passed into an ``attrs`` function.
-
- .. versionadded:: 16.2.0
- """
-
-
-class DefaultAlreadySetError(RuntimeError):
- """
- A default has been set using ``attr.ib()`` and is attempted to be reset
- using the decorator.
-
- .. versionadded:: 17.1.0
- """
-
-
-class UnannotatedAttributeError(RuntimeError):
- """
- A class with ``auto_attribs=True`` has an ``attr.ib()`` without a type
- annotation.
-
- .. versionadded:: 17.3.0
- """
-
-
-class PythonTooOldError(RuntimeError):
- """
- An ``attrs`` feature requiring a more recent python version has been used.
-
- .. versionadded:: 18.2.0
- """
diff --git a/python/attr/exceptions.pyi b/python/attr/exceptions.pyi
deleted file mode 100644
index 48fffcc..0000000
--- a/python/attr/exceptions.pyi
+++ /dev/null
@@ -1,7 +0,0 @@
-class FrozenInstanceError(AttributeError):
- msg: str = ...
-
-class AttrsAttributeNotFoundError(ValueError): ...
-class NotAnAttrsClassError(ValueError): ...
-class DefaultAlreadySetError(RuntimeError): ...
-class UnannotatedAttributeError(RuntimeError): ...
diff --git a/python/attr/filters.py b/python/attr/filters.py
deleted file mode 100644
index f1c69b8..0000000
--- a/python/attr/filters.py
+++ /dev/null
@@ -1,52 +0,0 @@
-"""
-Commonly useful filters for :func:`attr.asdict`.
-"""
-
-from __future__ import absolute_import, division, print_function
-
-from ._compat import isclass
-from ._make import Attribute
-
-
-def _split_what(what):
- """
- Returns a tuple of `frozenset`s of classes and attributes.
- """
- return (
- frozenset(cls for cls in what if isclass(cls)),
- frozenset(cls for cls in what if isinstance(cls, Attribute)),
- )
-
-
-def include(*what):
- """
- Whitelist *what*.
-
- :param what: What to whitelist.
- :type what: :class:`list` of :class:`type` or :class:`attr.Attribute`\\ s
-
- :rtype: :class:`callable`
- """
- cls, attrs = _split_what(what)
-
- def include_(attribute, value):
- return value.__class__ in cls or attribute in attrs
-
- return include_
-
-
-def exclude(*what):
- """
- Blacklist *what*.
-
- :param what: What to blacklist.
- :type what: :class:`list` of classes or :class:`attr.Attribute`\\ s.
-
- :rtype: :class:`callable`
- """
- cls, attrs = _split_what(what)
-
- def exclude_(attribute, value):
- return value.__class__ not in cls and attribute not in attrs
-
- return exclude_
diff --git a/python/attr/filters.pyi b/python/attr/filters.pyi
deleted file mode 100644
index a618140..0000000
--- a/python/attr/filters.pyi
+++ /dev/null
@@ -1,5 +0,0 @@
-from typing import Union
-from . import Attribute, _FilterType
-
-def include(*what: Union[type, Attribute]) -> _FilterType: ...
-def exclude(*what: Union[type, Attribute]) -> _FilterType: ...
diff --git a/python/attr/py.typed b/python/attr/py.typed
deleted file mode 100644
index e69de29..0000000
--- a/python/attr/py.typed
+++ /dev/null
diff --git a/python/attr/validators.py b/python/attr/validators.py
deleted file mode 100644
index f12d0aa..0000000
--- a/python/attr/validators.py
+++ /dev/null
@@ -1,170 +0,0 @@
-"""
-Commonly useful validators.
-"""
-
-from __future__ import absolute_import, division, print_function
-
-from ._make import _AndValidator, and_, attrib, attrs
-
-
-__all__ = ["and_", "in_", "instance_of", "optional", "provides"]
-
-
-@attrs(repr=False, slots=True, hash=True)
-class _InstanceOfValidator(object):
- type = attrib()
-
- def __call__(self, inst, attr, value):
- """
- We use a callable class to be able to change the ``__repr__``.
- """
- if not isinstance(value, self.type):
- raise TypeError(
- "'{name}' must be {type!r} (got {value!r} that is a "
- "{actual!r}).".format(
- name=attr.name,
- type=self.type,
- actual=value.__class__,
- value=value,
- ),
- attr,
- self.type,
- value,
- )
-
- def __repr__(self):
- return "<instance_of validator for type {type!r}>".format(
- type=self.type
- )
-
-
-def instance_of(type):
- """
- A validator that raises a :exc:`TypeError` if the initializer is called
- with a wrong type for this particular attribute (checks are performed using
- :func:`isinstance` therefore it's also valid to pass a tuple of types).
-
- :param type: The type to check for.
- :type type: type or tuple of types
-
- :raises TypeError: With a human readable error message, the attribute
- (of type :class:`attr.Attribute`), the expected type, and the value it
- got.
- """
- return _InstanceOfValidator(type)
-
-
-@attrs(repr=False, slots=True, hash=True)
-class _ProvidesValidator(object):
- interface = attrib()
-
- def __call__(self, inst, attr, value):
- """
- We use a callable class to be able to change the ``__repr__``.
- """
- if not self.interface.providedBy(value):
- raise TypeError(
- "'{name}' must provide {interface!r} which {value!r} "
- "doesn't.".format(
- name=attr.name, interface=self.interface, value=value
- ),
- attr,
- self.interface,
- value,
- )
-
- def __repr__(self):
- return "<provides validator for interface {interface!r}>".format(
- interface=self.interface
- )
-
-
-def provides(interface):
- """
- A validator that raises a :exc:`TypeError` if the initializer is called
- with an object that does not provide the requested *interface* (checks are
- performed using ``interface.providedBy(value)`` (see `zope.interface
- <https://zopeinterface.readthedocs.io/en/latest/>`_).
-
- :param zope.interface.Interface interface: The interface to check for.
-
- :raises TypeError: With a human readable error message, the attribute
- (of type :class:`attr.Attribute`), the expected interface, and the
- value it got.
- """
- return _ProvidesValidator(interface)
-
-
-@attrs(repr=False, slots=True, hash=True)
-class _OptionalValidator(object):
- validator = attrib()
-
- def __call__(self, inst, attr, value):
- if value is None:
- return
-
- self.validator(inst, attr, value)
-
- def __repr__(self):
- return "<optional validator for {what} or None>".format(
- what=repr(self.validator)
- )
-
-
-def optional(validator):
- """
- A validator that makes an attribute optional. An optional attribute is one
- which can be set to ``None`` in addition to satisfying the requirements of
- the sub-validator.
-
- :param validator: A validator (or a list of validators) that is used for
- non-``None`` values.
- :type validator: callable or :class:`list` of callables.
-
- .. versionadded:: 15.1.0
- .. versionchanged:: 17.1.0 *validator* can be a list of validators.
- """
- if isinstance(validator, list):
- return _OptionalValidator(_AndValidator(validator))
- return _OptionalValidator(validator)
-
-
-@attrs(repr=False, slots=True, hash=True)
-class _InValidator(object):
- options = attrib()
-
- def __call__(self, inst, attr, value):
- try:
- in_options = value in self.options
- except TypeError as e: # e.g. `1 in "abc"`
- in_options = False
-
- if not in_options:
- raise ValueError(
- "'{name}' must be in {options!r} (got {value!r})".format(
- name=attr.name, options=self.options, value=value
- )
- )
-
- def __repr__(self):
- return "<in_ validator with options {options!r}>".format(
- options=self.options
- )
-
-
-def in_(options):
- """
- A validator that raises a :exc:`ValueError` if the initializer is called
- with a value that does not belong in the options provided. The check is
- performed using ``value in options``.
-
- :param options: Allowed options.
- :type options: list, tuple, :class:`enum.Enum`, ...
-
- :raises ValueError: With a human readable error message, the attribute (of
- type :class:`attr.Attribute`), the expected options, and the value it
- got.
-
- .. versionadded:: 17.1.0
- """
- return _InValidator(options)
diff --git a/python/attr/validators.pyi b/python/attr/validators.pyi
deleted file mode 100644
index abbaedf..0000000
--- a/python/attr/validators.pyi
+++ /dev/null
@@ -1,14 +0,0 @@
-from typing import Container, List, Union, TypeVar, Type, Any, Optional, Tuple
-from . import _ValidatorType
-
-_T = TypeVar("_T")
-
-def instance_of(
- type: Union[Tuple[Type[_T], ...], Type[_T]]
-) -> _ValidatorType[_T]: ...
-def provides(interface: Any) -> _ValidatorType[Any]: ...
-def optional(
- validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]]
-) -> _ValidatorType[Optional[_T]]: ...
-def in_(options: Container[_T]) -> _ValidatorType[_T]: ...
-def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ...
diff --git a/python/brotli.py b/python/brotli.py
deleted file mode 100644
index d66966b..0000000
--- a/python/brotli.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2016 The Brotli Authors. All rights reserved.
-#
-# Distributed under MIT license.
-# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
-
-"""Functions to compress and decompress data using the Brotli library."""
-
-import _brotli
-
-
-# The library version.
-__version__ = _brotli.__version__
-
-# The compression mode.
-MODE_GENERIC = _brotli.MODE_GENERIC
-MODE_TEXT = _brotli.MODE_TEXT
-MODE_FONT = _brotli.MODE_FONT
-
-# The Compressor object.
-Compressor = _brotli.Compressor
-
-# The Decompressor object.
-Decompressor = _brotli.Decompressor
-
-# Compress a byte string.
-def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0):
- """Compress a byte string.
-
- Args:
- string (bytes): The input data.
- mode (int, optional): The compression mode can be MODE_GENERIC (default),
- MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0).
- quality (int, optional): Controls the compression-speed vs compression-
- density tradeoff. The higher the quality, the slower the compression.
- Range is 0 to 11. Defaults to 11.
- lgwin (int, optional): Base 2 logarithm of the sliding window size. Range
- is 10 to 24. Defaults to 22.
- lgblock (int, optional): Base 2 logarithm of the maximum input block size.
- Range is 16 to 24. If set to 0, the value will be set based on the
- quality. Defaults to 0.
-
- Returns:
- The compressed byte string.
-
- Raises:
- brotli.error: If arguments are invalid, or compressor fails.
- """
- compressor = Compressor(mode=mode, quality=quality, lgwin=lgwin,
- lgblock=lgblock)
- return compressor.process(string) + compressor.finish()
-
-# Decompress a compressed byte string.
-decompress = _brotli.decompress
-
-# Raised if compression or decompression fails.
-error = _brotli.error
diff --git a/python/click/__init__.py b/python/click/__init__.py
deleted file mode 100644
index d3c3366..0000000
--- a/python/click/__init__.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-click
-~~~~~
-
-Click is a simple Python module inspired by the stdlib optparse to make
-writing command line scripts fun. Unlike other modules, it's based
-around a simple API that does not come with too much magic and is
-composable.
-
-:copyright: © 2014 by the Pallets team.
-:license: BSD, see LICENSE.rst for more details.
-"""
-
-# Core classes
-from .core import Context, BaseCommand, Command, MultiCommand, Group, \
- CommandCollection, Parameter, Option, Argument
-
-# Globals
-from .globals import get_current_context
-
-# Decorators
-from .decorators import pass_context, pass_obj, make_pass_decorator, \
- command, group, argument, option, confirmation_option, \
- password_option, version_option, help_option
-
-# Types
-from .types import ParamType, File, Path, Choice, IntRange, Tuple, \
- DateTime, STRING, INT, FLOAT, BOOL, UUID, UNPROCESSED, FloatRange
-
-# Utilities
-from .utils import echo, get_binary_stream, get_text_stream, open_file, \
- format_filename, get_app_dir, get_os_args
-
-# Terminal functions
-from .termui import prompt, confirm, get_terminal_size, echo_via_pager, \
- progressbar, clear, style, unstyle, secho, edit, launch, getchar, \
- pause
-
-# Exceptions
-from .exceptions import ClickException, UsageError, BadParameter, \
- FileError, Abort, NoSuchOption, BadOptionUsage, BadArgumentUsage, \
- MissingParameter
-
-# Formatting
-from .formatting import HelpFormatter, wrap_text
-
-# Parsing
-from .parser import OptionParser
-
-
-__all__ = [
- # Core classes
- 'Context', 'BaseCommand', 'Command', 'MultiCommand', 'Group',
- 'CommandCollection', 'Parameter', 'Option', 'Argument',
-
- # Globals
- 'get_current_context',
-
- # Decorators
- 'pass_context', 'pass_obj', 'make_pass_decorator', 'command', 'group',
- 'argument', 'option', 'confirmation_option', 'password_option',
- 'version_option', 'help_option',
-
- # Types
- 'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'Tuple',
- 'DateTime', 'STRING', 'INT', 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED',
- 'FloatRange',
-
- # Utilities
- 'echo', 'get_binary_stream', 'get_text_stream', 'open_file',
- 'format_filename', 'get_app_dir', 'get_os_args',
-
- # Terminal functions
- 'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager',
- 'progressbar', 'clear', 'style', 'unstyle', 'secho', 'edit', 'launch',
- 'getchar', 'pause',
-
- # Exceptions
- 'ClickException', 'UsageError', 'BadParameter', 'FileError',
- 'Abort', 'NoSuchOption', 'BadOptionUsage', 'BadArgumentUsage',
- 'MissingParameter',
-
- # Formatting
- 'HelpFormatter', 'wrap_text',
-
- # Parsing
- 'OptionParser',
-]
-
-
-# Controls if click should emit the warning about the use of unicode
-# literals.
-disable_unicode_literals_warning = False
-
-
-__version__ = '7.0'
diff --git a/python/click/_bashcomplete.py b/python/click/_bashcomplete.py
deleted file mode 100644
index a5f1084..0000000
--- a/python/click/_bashcomplete.py
+++ /dev/null
@@ -1,293 +0,0 @@
-import copy
-import os
-import re
-
-from .utils import echo
-from .parser import split_arg_string
-from .core import MultiCommand, Option, Argument
-from .types import Choice
-
-try:
- from collections import abc
-except ImportError:
- import collections as abc
-
-WORDBREAK = '='
-
-# Note, only BASH version 4.4 and later have the nosort option.
-COMPLETION_SCRIPT_BASH = '''
-%(complete_func)s() {
- local IFS=$'\n'
- COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \\
- COMP_CWORD=$COMP_CWORD \\
- %(autocomplete_var)s=complete $1 ) )
- return 0
-}
-
-%(complete_func)setup() {
- local COMPLETION_OPTIONS=""
- local BASH_VERSION_ARR=(${BASH_VERSION//./ })
- # Only BASH version 4.4 and later have the nosort option.
- if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
- COMPLETION_OPTIONS="-o nosort"
- fi
-
- complete $COMPLETION_OPTIONS -F %(complete_func)s %(script_names)s
-}
-
-%(complete_func)setup
-'''
-
-COMPLETION_SCRIPT_ZSH = '''
-%(complete_func)s() {
- local -a completions
- local -a completions_with_descriptions
- local -a response
- response=("${(@f)$( env COMP_WORDS=\"${words[*]}\" \\
- COMP_CWORD=$((CURRENT-1)) \\
- %(autocomplete_var)s=\"complete_zsh\" \\
- %(script_names)s )}")
-
- for key descr in ${(kv)response}; do
- if [[ "$descr" == "_" ]]; then
- completions+=("$key")
- else
- completions_with_descriptions+=("$key":"$descr")
- fi
- done
-
- if [ -n "$completions_with_descriptions" ]; then
- _describe -V unsorted completions_with_descriptions -U -Q
- fi
-
- if [ -n "$completions" ]; then
- compadd -U -V unsorted -Q -a completions
- fi
- compstate[insert]="automenu"
-}
-
-compdef %(complete_func)s %(script_names)s
-'''
-
-_invalid_ident_char_re = re.compile(r'[^a-zA-Z0-9_]')
-
-
-def get_completion_script(prog_name, complete_var, shell):
- cf_name = _invalid_ident_char_re.sub('', prog_name.replace('-', '_'))
- script = COMPLETION_SCRIPT_ZSH if shell == 'zsh' else COMPLETION_SCRIPT_BASH
- return (script % {
- 'complete_func': '_%s_completion' % cf_name,
- 'script_names': prog_name,
- 'autocomplete_var': complete_var,
- }).strip() + ';'
-
-
-def resolve_ctx(cli, prog_name, args):
- """
- Parse into a hierarchy of contexts. Contexts are connected through the parent variable.
- :param cli: command definition
- :param prog_name: the program that is running
- :param args: full list of args
- :return: the final context/command parsed
- """
- ctx = cli.make_context(prog_name, args, resilient_parsing=True)
- args = ctx.protected_args + ctx.args
- while args:
- if isinstance(ctx.command, MultiCommand):
- if not ctx.command.chain:
- cmd_name, cmd, args = ctx.command.resolve_command(ctx, args)
- if cmd is None:
- return ctx
- ctx = cmd.make_context(cmd_name, args, parent=ctx,
- resilient_parsing=True)
- args = ctx.protected_args + ctx.args
- else:
- # Walk chained subcommand contexts saving the last one.
- while args:
- cmd_name, cmd, args = ctx.command.resolve_command(ctx, args)
- if cmd is None:
- return ctx
- sub_ctx = cmd.make_context(cmd_name, args, parent=ctx,
- allow_extra_args=True,
- allow_interspersed_args=False,
- resilient_parsing=True)
- args = sub_ctx.args
- ctx = sub_ctx
- args = sub_ctx.protected_args + sub_ctx.args
- else:
- break
- return ctx
-
-
-def start_of_option(param_str):
- """
- :param param_str: param_str to check
- :return: whether or not this is the start of an option declaration (i.e. starts "-" or "--")
- """
- return param_str and param_str[:1] == '-'
-
-
-def is_incomplete_option(all_args, cmd_param):
- """
- :param all_args: the full original list of args supplied
- :param cmd_param: the current command paramter
- :return: whether or not the last option declaration (i.e. starts "-" or "--") is incomplete and
- corresponds to this cmd_param. In other words whether this cmd_param option can still accept
- values
- """
- if not isinstance(cmd_param, Option):
- return False
- if cmd_param.is_flag:
- return False
- last_option = None
- for index, arg_str in enumerate(reversed([arg for arg in all_args if arg != WORDBREAK])):
- if index + 1 > cmd_param.nargs:
- break
- if start_of_option(arg_str):
- last_option = arg_str
-
- return True if last_option and last_option in cmd_param.opts else False
-
-
-def is_incomplete_argument(current_params, cmd_param):
- """
- :param current_params: the current params and values for this argument as already entered
- :param cmd_param: the current command parameter
- :return: whether or not the last argument is incomplete and corresponds to this cmd_param. In
- other words whether or not the this cmd_param argument can still accept values
- """
- if not isinstance(cmd_param, Argument):
- return False
- current_param_values = current_params[cmd_param.name]
- if current_param_values is None:
- return True
- if cmd_param.nargs == -1:
- return True
- if isinstance(current_param_values, abc.Iterable) \
- and cmd_param.nargs > 1 and len(current_param_values) < cmd_param.nargs:
- return True
- return False
-
-
-def get_user_autocompletions(ctx, args, incomplete, cmd_param):
- """
- :param ctx: context associated with the parsed command
- :param args: full list of args
- :param incomplete: the incomplete text to autocomplete
- :param cmd_param: command definition
- :return: all the possible user-specified completions for the param
- """
- results = []
- if isinstance(cmd_param.type, Choice):
- # Choices don't support descriptions.
- results = [(c, None)
- for c in cmd_param.type.choices if str(c).startswith(incomplete)]
- elif cmd_param.autocompletion is not None:
- dynamic_completions = cmd_param.autocompletion(ctx=ctx,
- args=args,
- incomplete=incomplete)
- results = [c if isinstance(c, tuple) else (c, None)
- for c in dynamic_completions]
- return results
-
-
-def get_visible_commands_starting_with(ctx, starts_with):
- """
- :param ctx: context associated with the parsed command
- :starts_with: string that visible commands must start with.
- :return: all visible (not hidden) commands that start with starts_with.
- """
- for c in ctx.command.list_commands(ctx):
- if c.startswith(starts_with):
- command = ctx.command.get_command(ctx, c)
- if not command.hidden:
- yield command
-
-
-def add_subcommand_completions(ctx, incomplete, completions_out):
- # Add subcommand completions.
- if isinstance(ctx.command, MultiCommand):
- completions_out.extend(
- [(c.name, c.get_short_help_str()) for c in get_visible_commands_starting_with(ctx, incomplete)])
-
- # Walk up the context list and add any other completion possibilities from chained commands
- while ctx.parent is not None:
- ctx = ctx.parent
- if isinstance(ctx.command, MultiCommand) and ctx.command.chain:
- remaining_commands = [c for c in get_visible_commands_starting_with(ctx, incomplete)
- if c.name not in ctx.protected_args]
- completions_out.extend([(c.name, c.get_short_help_str()) for c in remaining_commands])
-
-
-def get_choices(cli, prog_name, args, incomplete):
- """
- :param cli: command definition
- :param prog_name: the program that is running
- :param args: full list of args
- :param incomplete: the incomplete text to autocomplete
- :return: all the possible completions for the incomplete
- """
- all_args = copy.deepcopy(args)
-
- ctx = resolve_ctx(cli, prog_name, args)
- if ctx is None:
- return []
-
- # In newer versions of bash long opts with '='s are partitioned, but it's easier to parse
- # without the '='
- if start_of_option(incomplete) and WORDBREAK in incomplete:
- partition_incomplete = incomplete.partition(WORDBREAK)
- all_args.append(partition_incomplete[0])
- incomplete = partition_incomplete[2]
- elif incomplete == WORDBREAK:
- incomplete = ''
-
- completions = []
- if start_of_option(incomplete):
- # completions for partial options
- for param in ctx.command.params:
- if isinstance(param, Option) and not param.hidden:
- param_opts = [param_opt for param_opt in param.opts +
- param.secondary_opts if param_opt not in all_args or param.multiple]
- completions.extend([(o, param.help) for o in param_opts if o.startswith(incomplete)])
- return completions
- # completion for option values from user supplied values
- for param in ctx.command.params:
- if is_incomplete_option(all_args, param):
- return get_user_autocompletions(ctx, all_args, incomplete, param)
- # completion for argument values from user supplied values
- for param in ctx.command.params:
- if is_incomplete_argument(ctx.params, param):
- return get_user_autocompletions(ctx, all_args, incomplete, param)
-
- add_subcommand_completions(ctx, incomplete, completions)
- # Sort before returning so that proper ordering can be enforced in custom types.
- return sorted(completions)
-
-
-def do_complete(cli, prog_name, include_descriptions):
- cwords = split_arg_string(os.environ['COMP_WORDS'])
- cword = int(os.environ['COMP_CWORD'])
- args = cwords[1:cword]
- try:
- incomplete = cwords[cword]
- except IndexError:
- incomplete = ''
-
- for item in get_choices(cli, prog_name, args, incomplete):
- echo(item[0])
- if include_descriptions:
- # ZSH has trouble dealing with empty array parameters when returned from commands, so use a well defined character '_' to indicate no description is present.
- echo(item[1] if item[1] else '_')
-
- return True
-
-
-def bashcomplete(cli, prog_name, complete_var, complete_instr):
- if complete_instr.startswith('source'):
- shell = 'zsh' if complete_instr == 'source_zsh' else 'bash'
- echo(get_completion_script(prog_name, complete_var, shell))
- return True
- elif complete_instr == 'complete' or complete_instr == 'complete_zsh':
- return do_complete(cli, prog_name, complete_instr == 'complete_zsh')
- return False
diff --git a/python/click/_compat.py b/python/click/_compat.py
deleted file mode 100644
index 937e230..0000000
--- a/python/click/_compat.py
+++ /dev/null
@@ -1,703 +0,0 @@
-import re
-import io
-import os
-import sys
-import codecs
-from weakref import WeakKeyDictionary
-
-
-PY2 = sys.version_info[0] == 2
-CYGWIN = sys.platform.startswith('cygwin')
-# Determine local App Engine environment, per Google's own suggestion
-APP_ENGINE = ('APPENGINE_RUNTIME' in os.environ and
- 'Development/' in os.environ['SERVER_SOFTWARE'])
-WIN = sys.platform.startswith('win') and not APP_ENGINE
-DEFAULT_COLUMNS = 80
-
-
-_ansi_re = re.compile(r'\033\[((?:\d|;)*)([a-zA-Z])')
-
-
-def get_filesystem_encoding():
- return sys.getfilesystemencoding() or sys.getdefaultencoding()
-
-
-def _make_text_stream(stream, encoding, errors,
- force_readable=False, force_writable=False):
- if encoding is None:
- encoding = get_best_encoding(stream)
- if errors is None:
- errors = 'replace'
- return _NonClosingTextIOWrapper(stream, encoding, errors,
- line_buffering=True,
- force_readable=force_readable,
- force_writable=force_writable)
-
-
-def is_ascii_encoding(encoding):
- """Checks if a given encoding is ascii."""
- try:
- return codecs.lookup(encoding).name == 'ascii'
- except LookupError:
- return False
-
-
-def get_best_encoding(stream):
- """Returns the default stream encoding if not found."""
- rv = getattr(stream, 'encoding', None) or sys.getdefaultencoding()
- if is_ascii_encoding(rv):
- return 'utf-8'
- return rv
-
-
-class _NonClosingTextIOWrapper(io.TextIOWrapper):
-
- def __init__(self, stream, encoding, errors,
- force_readable=False, force_writable=False, **extra):
- self._stream = stream = _FixupStream(stream, force_readable,
- force_writable)
- io.TextIOWrapper.__init__(self, stream, encoding, errors, **extra)
-
- # The io module is a place where the Python 3 text behavior
- # was forced upon Python 2, so we need to unbreak
- # it to look like Python 2.
- if PY2:
- def write(self, x):
- if isinstance(x, str) or is_bytes(x):
- try:
- self.flush()
- except Exception:
- pass
- return self.buffer.write(str(x))
- return io.TextIOWrapper.write(self, x)
-
- def writelines(self, lines):
- for line in lines:
- self.write(line)
-
- def __del__(self):
- try:
- self.detach()
- except Exception:
- pass
-
- def isatty(self):
- # https://bitbucket.org/pypy/pypy/issue/1803
- return self._stream.isatty()
-
-
-class _FixupStream(object):
- """The new io interface needs more from streams than streams
- traditionally implement. As such, this fix-up code is necessary in
- some circumstances.
-
- The forcing of readable and writable flags are there because some tools
- put badly patched objects on sys (one such offender are certain version
- of jupyter notebook).
- """
-
- def __init__(self, stream, force_readable=False, force_writable=False):
- self._stream = stream
- self._force_readable = force_readable
- self._force_writable = force_writable
-
- def __getattr__(self, name):
- return getattr(self._stream, name)
-
- def read1(self, size):
- f = getattr(self._stream, 'read1', None)
- if f is not None:
- return f(size)
- # We only dispatch to readline instead of read in Python 2 as we
- # do not want cause problems with the different implementation
- # of line buffering.
- if PY2:
- return self._stream.readline(size)
- return self._stream.read(size)
-
- def readable(self):
- if self._force_readable:
- return True
- x = getattr(self._stream, 'readable', None)
- if x is not None:
- return x()
- try:
- self._stream.read(0)
- except Exception:
- return False
- return True
-
- def writable(self):
- if self._force_writable:
- return True
- x = getattr(self._stream, 'writable', None)
- if x is not None:
- return x()
- try:
- self._stream.write('')
- except Exception:
- try:
- self._stream.write(b'')
- except Exception:
- return False
- return True
-
- def seekable(self):
- x = getattr(self._stream, 'seekable', None)
- if x is not None:
- return x()
- try:
- self._stream.seek(self._stream.tell())
- except Exception:
- return False
- return True
-
-
-if PY2:
- text_type = unicode
- bytes = str
- raw_input = raw_input
- string_types = (str, unicode)
- int_types = (int, long)
- iteritems = lambda x: x.iteritems()
- range_type = xrange
-
- def is_bytes(x):
- return isinstance(x, (buffer, bytearray))
-
- _identifier_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
-
- # For Windows, we need to force stdout/stdin/stderr to binary if it's
- # fetched for that. This obviously is not the most correct way to do
- # it as it changes global state. Unfortunately, there does not seem to
- # be a clear better way to do it as just reopening the file in binary
- # mode does not change anything.
- #
- # An option would be to do what Python 3 does and to open the file as
- # binary only, patch it back to the system, and then use a wrapper
- # stream that converts newlines. It's not quite clear what's the
- # correct option here.
- #
- # This code also lives in _winconsole for the fallback to the console
- # emulation stream.
- #
- # There are also Windows environments where the `msvcrt` module is not
- # available (which is why we use try-catch instead of the WIN variable
- # here), such as the Google App Engine development server on Windows. In
- # those cases there is just nothing we can do.
- def set_binary_mode(f):
- return f
-
- try:
- import msvcrt
- except ImportError:
- pass
- else:
- def set_binary_mode(f):
- try:
- fileno = f.fileno()
- except Exception:
- pass
- else:
- msvcrt.setmode(fileno, os.O_BINARY)
- return f
-
- try:
- import fcntl
- except ImportError:
- pass
- else:
- def set_binary_mode(f):
- try:
- fileno = f.fileno()
- except Exception:
- pass
- else:
- flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
- fcntl.fcntl(fileno, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
- return f
-
- def isidentifier(x):
- return _identifier_re.search(x) is not None
-
- def get_binary_stdin():
- return set_binary_mode(sys.stdin)
-
- def get_binary_stdout():
- _wrap_std_stream('stdout')
- return set_binary_mode(sys.stdout)
-
- def get_binary_stderr():
- _wrap_std_stream('stderr')
- return set_binary_mode(sys.stderr)
-
- def get_text_stdin(encoding=None, errors=None):
- rv = _get_windows_console_stream(sys.stdin, encoding, errors)
- if rv is not None:
- return rv
- return _make_text_stream(sys.stdin, encoding, errors,
- force_readable=True)
-
- def get_text_stdout(encoding=None, errors=None):
- _wrap_std_stream('stdout')
- rv = _get_windows_console_stream(sys.stdout, encoding, errors)
- if rv is not None:
- return rv
- return _make_text_stream(sys.stdout, encoding, errors,
- force_writable=True)
-
- def get_text_stderr(encoding=None, errors=None):
- _wrap_std_stream('stderr')
- rv = _get_windows_console_stream(sys.stderr, encoding, errors)
- if rv is not None:
- return rv
- return _make_text_stream(sys.stderr, encoding, errors,
- force_writable=True)
-
- def filename_to_ui(value):
- if isinstance(value, bytes):
- value = value.decode(get_filesystem_encoding(), 'replace')
- return value
-else:
- import io
- text_type = str
- raw_input = input
- string_types = (str,)
- int_types = (int,)
- range_type = range
- isidentifier = lambda x: x.isidentifier()
- iteritems = lambda x: iter(x.items())
-
- def is_bytes(x):
- return isinstance(x, (bytes, memoryview, bytearray))
-
- def _is_binary_reader(stream, default=False):
- try:
- return isinstance(stream.read(0), bytes)
- except Exception:
- return default
- # This happens in some cases where the stream was already
- # closed. In this case, we assume the default.
-
- def _is_binary_writer(stream, default=False):
- try:
- stream.write(b'')
- except Exception:
- try:
- stream.write('')
- return False
- except Exception:
- pass
- return default
- return True
-
- def _find_binary_reader(stream):
- # We need to figure out if the given stream is already binary.
- # This can happen because the official docs recommend detaching
- # the streams to get binary streams. Some code might do this, so
- # we need to deal with this case explicitly.
- if _is_binary_reader(stream, False):
- return stream
-
- buf = getattr(stream, 'buffer', None)
-
- # Same situation here; this time we assume that the buffer is
- # actually binary in case it's closed.
- if buf is not None and _is_binary_reader(buf, True):
- return buf
-
- def _find_binary_writer(stream):
- # We need to figure out if the given stream is already binary.
- # This can happen because the official docs recommend detatching
- # the streams to get binary streams. Some code might do this, so
- # we need to deal with this case explicitly.
- if _is_binary_writer(stream, False):
- return stream
-
- buf = getattr(stream, 'buffer', None)
-
- # Same situation here; this time we assume that the buffer is
- # actually binary in case it's closed.
- if buf is not None and _is_binary_writer(buf, True):
- return buf
-
- def _stream_is_misconfigured(stream):
- """A stream is misconfigured if its encoding is ASCII."""
- # If the stream does not have an encoding set, we assume it's set
- # to ASCII. This appears to happen in certain unittest
- # environments. It's not quite clear what the correct behavior is
- # but this at least will force Click to recover somehow.
- return is_ascii_encoding(getattr(stream, 'encoding', None) or 'ascii')
-
- def _is_compatible_text_stream(stream, encoding, errors):
- stream_encoding = getattr(stream, 'encoding', None)
- stream_errors = getattr(stream, 'errors', None)
-
- # Perfect match.
- if stream_encoding == encoding and stream_errors == errors:
- return True
-
- # Otherwise, it's only a compatible stream if we did not ask for
- # an encoding.
- if encoding is None:
- return stream_encoding is not None
-
- return False
-
- def _force_correct_text_reader(text_reader, encoding, errors,
- force_readable=False):
- if _is_binary_reader(text_reader, False):
- binary_reader = text_reader
- else:
- # If there is no target encoding set, we need to verify that the
- # reader is not actually misconfigured.
- if encoding is None and not _stream_is_misconfigured(text_reader):
- return text_reader
-
- if _is_compatible_text_stream(text_reader, encoding, errors):
- return text_reader
-
- # If the reader has no encoding, we try to find the underlying
- # binary reader for it. If that fails because the environment is
- # misconfigured, we silently go with the same reader because this
- # is too common to happen. In that case, mojibake is better than
- # exceptions.
- binary_reader = _find_binary_reader(text_reader)
- if binary_reader is None:
- return text_reader
-
- # At this point, we default the errors to replace instead of strict
- # because nobody handles those errors anyways and at this point
- # we're so fundamentally fucked that nothing can repair it.
- if errors is None:
- errors = 'replace'
- return _make_text_stream(binary_reader, encoding, errors,
- force_readable=force_readable)
-
- def _force_correct_text_writer(text_writer, encoding, errors,
- force_writable=False):
- if _is_binary_writer(text_writer, False):
- binary_writer = text_writer
- else:
- # If there is no target encoding set, we need to verify that the
- # writer is not actually misconfigured.
- if encoding is None and not _stream_is_misconfigured(text_writer):
- return text_writer
-
- if _is_compatible_text_stream(text_writer, encoding, errors):
- return text_writer
-
- # If the writer has no encoding, we try to find the underlying
- # binary writer for it. If that fails because the environment is
- # misconfigured, we silently go with the same writer because this
- # is too common to happen. In that case, mojibake is better than
- # exceptions.
- binary_writer = _find_binary_writer(text_writer)
- if binary_writer is None:
- return text_writer
-
- # At this point, we default the errors to replace instead of strict
- # because nobody handles those errors anyways and at this point
- # we're so fundamentally fucked that nothing can repair it.
- if errors is None:
- errors = 'replace'
- return _make_text_stream(binary_writer, encoding, errors,
- force_writable=force_writable)
-
- def get_binary_stdin():
- reader = _find_binary_reader(sys.stdin)
- if reader is None:
- raise RuntimeError('Was not able to determine binary '
- 'stream for sys.stdin.')
- return reader
-
- def get_binary_stdout():
- writer = _find_binary_writer(sys.stdout)
- if writer is None:
- raise RuntimeError('Was not able to determine binary '
- 'stream for sys.stdout.')
- return writer
-
- def get_binary_stderr():
- writer = _find_binary_writer(sys.stderr)
- if writer is None:
- raise RuntimeError('Was not able to determine binary '
- 'stream for sys.stderr.')
- return writer
-
- def get_text_stdin(encoding=None, errors=None):
- rv = _get_windows_console_stream(sys.stdin, encoding, errors)
- if rv is not None:
- return rv
- return _force_correct_text_reader(sys.stdin, encoding, errors,
- force_readable=True)
-
- def get_text_stdout(encoding=None, errors=None):
- rv = _get_windows_console_stream(sys.stdout, encoding, errors)
- if rv is not None:
- return rv
- return _force_correct_text_writer(sys.stdout, encoding, errors,
- force_writable=True)
-
- def get_text_stderr(encoding=None, errors=None):
- rv = _get_windows_console_stream(sys.stderr, encoding, errors)
- if rv is not None:
- return rv
- return _force_correct_text_writer(sys.stderr, encoding, errors,
- force_writable=True)
-
- def filename_to_ui(value):
- if isinstance(value, bytes):
- value = value.decode(get_filesystem_encoding(), 'replace')
- else:
- value = value.encode('utf-8', 'surrogateescape') \
- .decode('utf-8', 'replace')
- return value
-
-
-def get_streerror(e, default=None):
- if hasattr(e, 'strerror'):
- msg = e.strerror
- else:
- if default is not None:
- msg = default
- else:
- msg = str(e)
- if isinstance(msg, bytes):
- msg = msg.decode('utf-8', 'replace')
- return msg
-
-
-def open_stream(filename, mode='r', encoding=None, errors='strict',
- atomic=False):
- # Standard streams first. These are simple because they don't need
- # special handling for the atomic flag. It's entirely ignored.
- if filename == '-':
- if any(m in mode for m in ['w', 'a', 'x']):
- if 'b' in mode:
- return get_binary_stdout(), False
- return get_text_stdout(encoding=encoding, errors=errors), False
- if 'b' in mode:
- return get_binary_stdin(), False
- return get_text_stdin(encoding=encoding, errors=errors), False
-
- # Non-atomic writes directly go out through the regular open functions.
- if not atomic:
- if encoding is None:
- return open(filename, mode), True
- return io.open(filename, mode, encoding=encoding, errors=errors), True
-
- # Some usability stuff for atomic writes
- if 'a' in mode:
- raise ValueError(
- 'Appending to an existing file is not supported, because that '
- 'would involve an expensive `copy`-operation to a temporary '
- 'file. Open the file in normal `w`-mode and copy explicitly '
- 'if that\'s what you\'re after.'
- )
- if 'x' in mode:
- raise ValueError('Use the `overwrite`-parameter instead.')
- if 'w' not in mode:
- raise ValueError('Atomic writes only make sense with `w`-mode.')
-
- # Atomic writes are more complicated. They work by opening a file
- # as a proxy in the same folder and then using the fdopen
- # functionality to wrap it in a Python file. Then we wrap it in an
- # atomic file that moves the file over on close.
- import tempfile
- fd, tmp_filename = tempfile.mkstemp(dir=os.path.dirname(filename),
- prefix='.__atomic-write')
-
- if encoding is not None:
- f = io.open(fd, mode, encoding=encoding, errors=errors)
- else:
- f = os.fdopen(fd, mode)
-
- return _AtomicFile(f, tmp_filename, os.path.realpath(filename)), True
-
-
-# Used in a destructor call, needs extra protection from interpreter cleanup.
-if hasattr(os, 'replace'):
- _replace = os.replace
- _can_replace = True
-else:
- _replace = os.rename
- _can_replace = not WIN
-
-
-class _AtomicFile(object):
-
- def __init__(self, f, tmp_filename, real_filename):
- self._f = f
- self._tmp_filename = tmp_filename
- self._real_filename = real_filename
- self.closed = False
-
- @property
- def name(self):
- return self._real_filename
-
- def close(self, delete=False):
- if self.closed:
- return
- self._f.close()
- if not _can_replace:
- try:
- os.remove(self._real_filename)
- except OSError:
- pass
- _replace(self._tmp_filename, self._real_filename)
- self.closed = True
-
- def __getattr__(self, name):
- return getattr(self._f, name)
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.close(delete=exc_type is not None)
-
- def __repr__(self):
- return repr(self._f)
-
-
-auto_wrap_for_ansi = None
-colorama = None
-get_winterm_size = None
-
-
-def strip_ansi(value):
- return _ansi_re.sub('', value)
-
-
-def should_strip_ansi(stream=None, color=None):
- if color is None:
- if stream is None:
- stream = sys.stdin
- return not isatty(stream)
- return not color
-
-
-# If we're on Windows, we provide transparent integration through
-# colorama. This will make ANSI colors through the echo function
-# work automatically.
-if WIN:
- # Windows has a smaller terminal
- DEFAULT_COLUMNS = 79
-
- from ._winconsole import _get_windows_console_stream, _wrap_std_stream
-
- def _get_argv_encoding():
- import locale
- return locale.getpreferredencoding()
-
- if PY2:
- def raw_input(prompt=''):
- sys.stderr.flush()
- if prompt:
- stdout = _default_text_stdout()
- stdout.write(prompt)
- stdin = _default_text_stdin()
- return stdin.readline().rstrip('\r\n')
-
- try:
- import colorama
- except ImportError:
- pass
- else:
- _ansi_stream_wrappers = WeakKeyDictionary()
-
- def auto_wrap_for_ansi(stream, color=None):
- """This function wraps a stream so that calls through colorama
- are issued to the win32 console API to recolor on demand. It
- also ensures to reset the colors if a write call is interrupted
- to not destroy the console afterwards.
- """
- try:
- cached = _ansi_stream_wrappers.get(stream)
- except Exception:
- cached = None
- if cached is not None:
- return cached
- strip = should_strip_ansi(stream, color)
- ansi_wrapper = colorama.AnsiToWin32(stream, strip=strip)
- rv = ansi_wrapper.stream
- _write = rv.write
-
- def _safe_write(s):
- try:
- return _write(s)
- except:
- ansi_wrapper.reset_all()
- raise
-
- rv.write = _safe_write
- try:
- _ansi_stream_wrappers[stream] = rv
- except Exception:
- pass
- return rv
-
- def get_winterm_size():
- win = colorama.win32.GetConsoleScreenBufferInfo(
- colorama.win32.STDOUT).srWindow
- return win.Right - win.Left, win.Bottom - win.Top
-else:
- def _get_argv_encoding():
- return getattr(sys.stdin, 'encoding', None) or get_filesystem_encoding()
-
- _get_windows_console_stream = lambda *x: None
- _wrap_std_stream = lambda *x: None
-
-
-def term_len(x):
- return len(strip_ansi(x))
-
-
-def isatty(stream):
- try:
- return stream.isatty()
- except Exception:
- return False
-
-
-def _make_cached_stream_func(src_func, wrapper_func):
- cache = WeakKeyDictionary()
- def func():
- stream = src_func()
- try:
- rv = cache.get(stream)
- except Exception:
- rv = None
- if rv is not None:
- return rv
- rv = wrapper_func()
- try:
- stream = src_func() # In case wrapper_func() modified the stream
- cache[stream] = rv
- except Exception:
- pass
- return rv
- return func
-
-
-_default_text_stdin = _make_cached_stream_func(
- lambda: sys.stdin, get_text_stdin)
-_default_text_stdout = _make_cached_stream_func(
- lambda: sys.stdout, get_text_stdout)
-_default_text_stderr = _make_cached_stream_func(
- lambda: sys.stderr, get_text_stderr)
-
-
-binary_streams = {
- 'stdin': get_binary_stdin,
- 'stdout': get_binary_stdout,
- 'stderr': get_binary_stderr,
-}
-
-text_streams = {
- 'stdin': get_text_stdin,
- 'stdout': get_text_stdout,
- 'stderr': get_text_stderr,
-}
diff --git a/python/click/_termui_impl.py b/python/click/_termui_impl.py
deleted file mode 100644
index 00a8e5e..0000000
--- a/python/click/_termui_impl.py
+++ /dev/null
@@ -1,621 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-click._termui_impl
-~~~~~~~~~~~~~~~~~~
-
-This module contains implementations for the termui module. To keep the
-import time of Click down, some infrequently used functionality is
-placed in this module and only imported as needed.
-
-:copyright: © 2014 by the Pallets team.
-:license: BSD, see LICENSE.rst for more details.
-"""
-
-import os
-import sys
-import time
-import math
-import contextlib
-from ._compat import _default_text_stdout, range_type, PY2, isatty, \
- open_stream, strip_ansi, term_len, get_best_encoding, WIN, int_types, \
- CYGWIN
-from .utils import echo
-from .exceptions import ClickException
-
-
-if os.name == 'nt':
- BEFORE_BAR = '\r'
- AFTER_BAR = '\n'
-else:
- BEFORE_BAR = '\r\033[?25l'
- AFTER_BAR = '\033[?25h\n'
-
-
-def _length_hint(obj):
- """Returns the length hint of an object."""
- try:
- return len(obj)
- except (AttributeError, TypeError):
- try:
- get_hint = type(obj).__length_hint__
- except AttributeError:
- return None
- try:
- hint = get_hint(obj)
- except TypeError:
- return None
- if hint is NotImplemented or \
- not isinstance(hint, int_types) or \
- hint < 0:
- return None
- return hint
-
-
-class ProgressBar(object):
-
- def __init__(self, iterable, length=None, fill_char='#', empty_char=' ',
- bar_template='%(bar)s', info_sep=' ', show_eta=True,
- show_percent=None, show_pos=False, item_show_func=None,
- label=None, file=None, color=None, width=30):
- self.fill_char = fill_char
- self.empty_char = empty_char
- self.bar_template = bar_template
- self.info_sep = info_sep
- self.show_eta = show_eta
- self.show_percent = show_percent
- self.show_pos = show_pos
- self.item_show_func = item_show_func
- self.label = label or ''
- if file is None:
- file = _default_text_stdout()
- self.file = file
- self.color = color
- self.width = width
- self.autowidth = width == 0
-
- if length is None:
- length = _length_hint(iterable)
- if iterable is None:
- if length is None:
- raise TypeError('iterable or length is required')
- iterable = range_type(length)
- self.iter = iter(iterable)
- self.length = length
- self.length_known = length is not None
- self.pos = 0
- self.avg = []
- self.start = self.last_eta = time.time()
- self.eta_known = False
- self.finished = False
- self.max_width = None
- self.entered = False
- self.current_item = None
- self.is_hidden = not isatty(self.file)
- self._last_line = None
- self.short_limit = 0.5
-
- def __enter__(self):
- self.entered = True
- self.render_progress()
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.render_finish()
-
- def __iter__(self):
- if not self.entered:
- raise RuntimeError('You need to use progress bars in a with block.')
- self.render_progress()
- return self.generator()
-
- def is_fast(self):
- return time.time() - self.start <= self.short_limit
-
- def render_finish(self):
- if self.is_hidden or self.is_fast():
- return
- self.file.write(AFTER_BAR)
- self.file.flush()
-
- @property
- def pct(self):
- if self.finished:
- return 1.0
- return min(self.pos / (float(self.length) or 1), 1.0)
-
- @property
- def time_per_iteration(self):
- if not self.avg:
- return 0.0
- return sum(self.avg) / float(len(self.avg))
-
- @property
- def eta(self):
- if self.length_known and not self.finished:
- return self.time_per_iteration * (self.length - self.pos)
- return 0.0
-
- def format_eta(self):
- if self.eta_known:
- t = int(self.eta)
- seconds = t % 60
- t //= 60
- minutes = t % 60
- t //= 60
- hours = t % 24
- t //= 24
- if t > 0:
- days = t
- return '%dd %02d:%02d:%02d' % (days, hours, minutes, seconds)
- else:
- return '%02d:%02d:%02d' % (hours, minutes, seconds)
- return ''
-
- def format_pos(self):
- pos = str(self.pos)
- if self.length_known:
- pos += '/%s' % self.length
- return pos
-
- def format_pct(self):
- return ('% 4d%%' % int(self.pct * 100))[1:]
-
- def format_bar(self):
- if self.length_known:
- bar_length = int(self.pct * self.width)
- bar = self.fill_char * bar_length
- bar += self.empty_char * (self.width - bar_length)
- elif self.finished:
- bar = self.fill_char * self.width
- else:
- bar = list(self.empty_char * (self.width or 1))
- if self.time_per_iteration != 0:
- bar[int((math.cos(self.pos * self.time_per_iteration)
- / 2.0 + 0.5) * self.width)] = self.fill_char
- bar = ''.join(bar)
- return bar
-
- def format_progress_line(self):
- show_percent = self.show_percent
-
- info_bits = []
- if self.length_known and show_percent is None:
- show_percent = not self.show_pos
-
- if self.show_pos:
- info_bits.append(self.format_pos())
- if show_percent:
- info_bits.append(self.format_pct())
- if self.show_eta and self.eta_known and not self.finished:
- info_bits.append(self.format_eta())
- if self.item_show_func is not None:
- item_info = self.item_show_func(self.current_item)
- if item_info is not None:
- info_bits.append(item_info)
-
- return (self.bar_template % {
- 'label': self.label,
- 'bar': self.format_bar(),
- 'info': self.info_sep.join(info_bits)
- }).rstrip()
-
- def render_progress(self):
- from .termui import get_terminal_size
-
- if self.is_hidden:
- return
-
- buf = []
- # Update width in case the terminal has been resized
- if self.autowidth:
- old_width = self.width
- self.width = 0
- clutter_length = term_len(self.format_progress_line())
- new_width = max(0, get_terminal_size()[0] - clutter_length)
- if new_width < old_width:
- buf.append(BEFORE_BAR)
- buf.append(' ' * self.max_width)
- self.max_width = new_width
- self.width = new_width
-
- clear_width = self.width
- if self.max_width is not None:
- clear_width = self.max_width
-
- buf.append(BEFORE_BAR)
- line = self.format_progress_line()
- line_len = term_len(line)
- if self.max_width is None or self.max_width < line_len:
- self.max_width = line_len
-
- buf.append(line)
- buf.append(' ' * (clear_width - line_len))
- line = ''.join(buf)
- # Render the line only if it changed.
-
- if line != self._last_line and not self.is_fast():
- self._last_line = line
- echo(line, file=self.file, color=self.color, nl=False)
- self.file.flush()
-
- def make_step(self, n_steps):
- self.pos += n_steps
- if self.length_known and self.pos >= self.length:
- self.finished = True
-
- if (time.time() - self.last_eta) < 1.0:
- return
-
- self.last_eta = time.time()
-
- # self.avg is a rolling list of length <= 7 of steps where steps are
- # defined as time elapsed divided by the total progress through
- # self.length.
- if self.pos:
- step = (time.time() - self.start) / self.pos
- else:
- step = time.time() - self.start
-
- self.avg = self.avg[-6:] + [step]
-
- self.eta_known = self.length_known
-
- def update(self, n_steps):
- self.make_step(n_steps)
- self.render_progress()
-
- def finish(self):
- self.eta_known = 0
- self.current_item = None
- self.finished = True
-
- def generator(self):
- """
- Returns a generator which yields the items added to the bar during
- construction, and updates the progress bar *after* the yielded block
- returns.
- """
- if not self.entered:
- raise RuntimeError('You need to use progress bars in a with block.')
-
- if self.is_hidden:
- for rv in self.iter:
- yield rv
- else:
- for rv in self.iter:
- self.current_item = rv
- yield rv
- self.update(1)
- self.finish()
- self.render_progress()
-
-
-def pager(generator, color=None):
- """Decide what method to use for paging through text."""
- stdout = _default_text_stdout()
- if not isatty(sys.stdin) or not isatty(stdout):
- return _nullpager(stdout, generator, color)
- pager_cmd = (os.environ.get('PAGER', None) or '').strip()
- if pager_cmd:
- if WIN:
- return _tempfilepager(generator, pager_cmd, color)
- return _pipepager(generator, pager_cmd, color)
- if os.environ.get('TERM') in ('dumb', 'emacs'):
- return _nullpager(stdout, generator, color)
- if WIN or sys.platform.startswith('os2'):
- return _tempfilepager(generator, 'more <', color)
- if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
- return _pipepager(generator, 'less', color)
-
- import tempfile
- fd, filename = tempfile.mkstemp()
- os.close(fd)
- try:
- if hasattr(os, 'system') and os.system('more "%s"' % filename) == 0:
- return _pipepager(generator, 'more', color)
- return _nullpager(stdout, generator, color)
- finally:
- os.unlink(filename)
-
-
-def _pipepager(generator, cmd, color):
- """Page through text by feeding it to another program. Invoking a
- pager through this might support colors.
- """
- import subprocess
- env = dict(os.environ)
-
- # If we're piping to less we might support colors under the
- # condition that
- cmd_detail = cmd.rsplit('/', 1)[-1].split()
- if color is None and cmd_detail[0] == 'less':
- less_flags = os.environ.get('LESS', '') + ' '.join(cmd_detail[1:])
- if not less_flags:
- env['LESS'] = '-R'
- color = True
- elif 'r' in less_flags or 'R' in less_flags:
- color = True
-
- c = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
- env=env)
- encoding = get_best_encoding(c.stdin)
- try:
- for text in generator:
- if not color:
- text = strip_ansi(text)
-
- c.stdin.write(text.encode(encoding, 'replace'))
- except (IOError, KeyboardInterrupt):
- pass
- else:
- c.stdin.close()
-
- # Less doesn't respect ^C, but catches it for its own UI purposes (aborting
- # search or other commands inside less).
- #
- # That means when the user hits ^C, the parent process (click) terminates,
- # but less is still alive, paging the output and messing up the terminal.
- #
- # If the user wants to make the pager exit on ^C, they should set
- # `LESS='-K'`. It's not our decision to make.
- while True:
- try:
- c.wait()
- except KeyboardInterrupt:
- pass
- else:
- break
-
-
-def _tempfilepager(generator, cmd, color):
- """Page through text by invoking a program on a temporary file."""
- import tempfile
- filename = tempfile.mktemp()
- # TODO: This never terminates if the passed generator never terminates.
- text = "".join(generator)
- if not color:
- text = strip_ansi(text)
- encoding = get_best_encoding(sys.stdout)
- with open_stream(filename, 'wb')[0] as f:
- f.write(text.encode(encoding))
- try:
- os.system(cmd + ' "' + filename + '"')
- finally:
- os.unlink(filename)
-
-
-def _nullpager(stream, generator, color):
- """Simply print unformatted text. This is the ultimate fallback."""
- for text in generator:
- if not color:
- text = strip_ansi(text)
- stream.write(text)
-
-
-class Editor(object):
-
- def __init__(self, editor=None, env=None, require_save=True,
- extension='.txt'):
- self.editor = editor
- self.env = env
- self.require_save = require_save
- self.extension = extension
-
- def get_editor(self):
- if self.editor is not None:
- return self.editor
- for key in 'VISUAL', 'EDITOR':
- rv = os.environ.get(key)
- if rv:
- return rv
- if WIN:
- return 'notepad'
- for editor in 'vim', 'nano':
- if os.system('which %s >/dev/null 2>&1' % editor) == 0:
- return editor
- return 'vi'
-
- def edit_file(self, filename):
- import subprocess
- editor = self.get_editor()
- if self.env:
- environ = os.environ.copy()
- environ.update(self.env)
- else:
- environ = None
- try:
- c = subprocess.Popen('%s "%s"' % (editor, filename),
- env=environ, shell=True)
- exit_code = c.wait()
- if exit_code != 0:
- raise ClickException('%s: Editing failed!' % editor)
- except OSError as e:
- raise ClickException('%s: Editing failed: %s' % (editor, e))
-
- def edit(self, text):
- import tempfile
-
- text = text or ''
- if text and not text.endswith('\n'):
- text += '\n'
-
- fd, name = tempfile.mkstemp(prefix='editor-', suffix=self.extension)
- try:
- if WIN:
- encoding = 'utf-8-sig'
- text = text.replace('\n', '\r\n')
- else:
- encoding = 'utf-8'
- text = text.encode(encoding)
-
- f = os.fdopen(fd, 'wb')
- f.write(text)
- f.close()
- timestamp = os.path.getmtime(name)
-
- self.edit_file(name)
-
- if self.require_save \
- and os.path.getmtime(name) == timestamp:
- return None
-
- f = open(name, 'rb')
- try:
- rv = f.read()
- finally:
- f.close()
- return rv.decode('utf-8-sig').replace('\r\n', '\n')
- finally:
- os.unlink(name)
-
-
-def open_url(url, wait=False, locate=False):
- import subprocess
-
- def _unquote_file(url):
- try:
- import urllib
- except ImportError:
- import urllib
- if url.startswith('file://'):
- url = urllib.unquote(url[7:])
- return url
-
- if sys.platform == 'darwin':
- args = ['open']
- if wait:
- args.append('-W')
- if locate:
- args.append('-R')
- args.append(_unquote_file(url))
- null = open('/dev/null', 'w')
- try:
- return subprocess.Popen(args, stderr=null).wait()
- finally:
- null.close()
- elif WIN:
- if locate:
- url = _unquote_file(url)
- args = 'explorer /select,"%s"' % _unquote_file(
- url.replace('"', ''))
- else:
- args = 'start %s "" "%s"' % (
- wait and '/WAIT' or '', url.replace('"', ''))
- return os.system(args)
- elif CYGWIN:
- if locate:
- url = _unquote_file(url)
- args = 'cygstart "%s"' % (os.path.dirname(url).replace('"', ''))
- else:
- args = 'cygstart %s "%s"' % (
- wait and '-w' or '', url.replace('"', ''))
- return os.system(args)
-
- try:
- if locate:
- url = os.path.dirname(_unquote_file(url)) or '.'
- else:
- url = _unquote_file(url)
- c = subprocess.Popen(['xdg-open', url])
- if wait:
- return c.wait()
- return 0
- except OSError:
- if url.startswith(('http://', 'https://')) and not locate and not wait:
- import webbrowser
- webbrowser.open(url)
- return 0
- return 1
-
-
-def _translate_ch_to_exc(ch):
- if ch == u'\x03':
- raise KeyboardInterrupt()
- if ch == u'\x04' and not WIN: # Unix-like, Ctrl+D
- raise EOFError()
- if ch == u'\x1a' and WIN: # Windows, Ctrl+Z
- raise EOFError()
-
-
-if WIN:
- import msvcrt
-
- @contextlib.contextmanager
- def raw_terminal():
- yield
-
- def getchar(echo):
- # The function `getch` will return a bytes object corresponding to
- # the pressed character. Since Windows 10 build 1803, it will also
- # return \x00 when called a second time after pressing a regular key.
- #
- # `getwch` does not share this probably-bugged behavior. Moreover, it
- # returns a Unicode object by default, which is what we want.
- #
- # Either of these functions will return \x00 or \xe0 to indicate
- # a special key, and you need to call the same function again to get
- # the "rest" of the code. The fun part is that \u00e0 is
- # "latin small letter a with grave", so if you type that on a French
- # keyboard, you _also_ get a \xe0.
- # E.g., consider the Up arrow. This returns \xe0 and then \x48. The
- # resulting Unicode string reads as "a with grave" + "capital H".
- # This is indistinguishable from when the user actually types
- # "a with grave" and then "capital H".
- #
- # When \xe0 is returned, we assume it's part of a special-key sequence
- # and call `getwch` again, but that means that when the user types
- # the \u00e0 character, `getchar` doesn't return until a second
- # character is typed.
- # The alternative is returning immediately, but that would mess up
- # cross-platform handling of arrow keys and others that start with
- # \xe0. Another option is using `getch`, but then we can't reliably
- # read non-ASCII characters, because return values of `getch` are
- # limited to the current 8-bit codepage.
- #
- # Anyway, Click doesn't claim to do this Right(tm), and using `getwch`
- # is doing the right thing in more situations than with `getch`.
- if echo:
- func = msvcrt.getwche
- else:
- func = msvcrt.getwch
-
- rv = func()
- if rv in (u'\x00', u'\xe0'):
- # \x00 and \xe0 are control characters that indicate special key,
- # see above.
- rv += func()
- _translate_ch_to_exc(rv)
- return rv
-else:
- import tty
- import termios
-
- @contextlib.contextmanager
- def raw_terminal():
- if not isatty(sys.stdin):
- f = open('/dev/tty')
- fd = f.fileno()
- else:
- fd = sys.stdin.fileno()
- f = None
- try:
- old_settings = termios.tcgetattr(fd)
- try:
- tty.setraw(fd)
- yield fd
- finally:
- termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
- sys.stdout.flush()
- if f is not None:
- f.close()
- except termios.error:
- pass
-
- def getchar(echo):
- with raw_terminal() as fd:
- ch = os.read(fd, 32)
- ch = ch.decode(get_best_encoding(sys.stdin), 'replace')
- if echo and isatty(sys.stdout):
- sys.stdout.write(ch)
- _translate_ch_to_exc(ch)
- return ch
diff --git a/python/click/_textwrap.py b/python/click/_textwrap.py
deleted file mode 100644
index 7e77603..0000000
--- a/python/click/_textwrap.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import textwrap
-from contextlib import contextmanager
-
-
-class TextWrapper(textwrap.TextWrapper):
-
- def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
- space_left = max(width - cur_len, 1)
-
- if self.break_long_words:
- last = reversed_chunks[-1]
- cut = last[:space_left]
- res = last[space_left:]
- cur_line.append(cut)
- reversed_chunks[-1] = res
- elif not cur_line:
- cur_line.append(reversed_chunks.pop())
-
- @contextmanager
- def extra_indent(self, indent):
- old_initial_indent = self.initial_indent
- old_subsequent_indent = self.subsequent_indent
- self.initial_indent += indent
- self.subsequent_indent += indent
- try:
- yield
- finally:
- self.initial_indent = old_initial_indent
- self.subsequent_indent = old_subsequent_indent
-
- def indent_only(self, text):
- rv = []
- for idx, line in enumerate(text.splitlines()):
- indent = self.initial_indent
- if idx > 0:
- indent = self.subsequent_indent
- rv.append(indent + line)
- return '\n'.join(rv)
diff --git a/python/click/_unicodefun.py b/python/click/_unicodefun.py
deleted file mode 100644
index 620edff..0000000
--- a/python/click/_unicodefun.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import os
-import sys
-import codecs
-
-from ._compat import PY2
-
-
-# If someone wants to vendor click, we want to ensure the
-# correct package is discovered. Ideally we could use a
-# relative import here but unfortunately Python does not
-# support that.
-click = sys.modules[__name__.rsplit('.', 1)[0]]
-
-
-def _find_unicode_literals_frame():
- import __future__
- if not hasattr(sys, '_getframe'): # not all Python implementations have it
- return 0
- frm = sys._getframe(1)
- idx = 1
- while frm is not None:
- if frm.f_globals.get('__name__', '').startswith('click.'):
- frm = frm.f_back
- idx += 1
- elif frm.f_code.co_flags & __future__.unicode_literals.compiler_flag:
- return idx
- else:
- break
- return 0
-
-
-def _check_for_unicode_literals():
- if not __debug__:
- return
- if not PY2 or click.disable_unicode_literals_warning:
- return
- bad_frame = _find_unicode_literals_frame()
- if bad_frame <= 0:
- return
- from warnings import warn
- warn(Warning('Click detected the use of the unicode_literals '
- '__future__ import. This is heavily discouraged '
- 'because it can introduce subtle bugs in your '
- 'code. You should instead use explicit u"" literals '
- 'for your unicode strings. For more information see '
- 'https://click.palletsprojects.com/python3/'),
- stacklevel=bad_frame)
-
-
-def _verify_python3_env():
- """Ensures that the environment is good for unicode on Python 3."""
- if PY2:
- return
- try:
- import locale
- fs_enc = codecs.lookup(locale.getpreferredencoding()).name
- except Exception:
- fs_enc = 'ascii'
- if fs_enc != 'ascii':
- return
-
- extra = ''
- if os.name == 'posix':
- import subprocess
- try:
- rv = subprocess.Popen(['locale', '-a'], stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()[0]
- except OSError:
- rv = b''
- good_locales = set()
- has_c_utf8 = False
-
- # Make sure we're operating on text here.
- if isinstance(rv, bytes):
- rv = rv.decode('ascii', 'replace')
-
- for line in rv.splitlines():
- locale = line.strip()
- if locale.lower().endswith(('.utf-8', '.utf8')):
- good_locales.add(locale)
- if locale.lower() in ('c.utf8', 'c.utf-8'):
- has_c_utf8 = True
-
- extra += '\n\n'
- if not good_locales:
- extra += (
- 'Additional information: on this system no suitable UTF-8\n'
- 'locales were discovered. This most likely requires resolving\n'
- 'by reconfiguring the locale system.'
- )
- elif has_c_utf8:
- extra += (
- 'This system supports the C.UTF-8 locale which is recommended.\n'
- 'You might be able to resolve your issue by exporting the\n'
- 'following environment variables:\n\n'
- ' export LC_ALL=C.UTF-8\n'
- ' export LANG=C.UTF-8'
- )
- else:
- extra += (
- 'This system lists a couple of UTF-8 supporting locales that\n'
- 'you can pick from. The following suitable locales were\n'
- 'discovered: %s'
- ) % ', '.join(sorted(good_locales))
-
- bad_locale = None
- for locale in os.environ.get('LC_ALL'), os.environ.get('LANG'):
- if locale and locale.lower().endswith(('.utf-8', '.utf8')):
- bad_locale = locale
- if locale is not None:
- break
- if bad_locale is not None:
- extra += (
- '\n\nClick discovered that you exported a UTF-8 locale\n'
- 'but the locale system could not pick up from it because\n'
- 'it does not exist. The exported locale is "%s" but it\n'
- 'is not supported'
- ) % bad_locale
-
- raise RuntimeError(
- 'Click will abort further execution because Python 3 was'
- ' configured to use ASCII as encoding for the environment.'
- ' Consult https://click.palletsprojects.com/en/7.x/python3/ for'
- ' mitigation steps.' + extra
- )
diff --git a/python/click/_winconsole.py b/python/click/_winconsole.py
deleted file mode 100644
index bbb080d..0000000
--- a/python/click/_winconsole.py
+++ /dev/null
@@ -1,307 +0,0 @@
-# -*- coding: utf-8 -*-
-# This module is based on the excellent work by Adam Bartoš who
-# provided a lot of what went into the implementation here in
-# the discussion to issue1602 in the Python bug tracker.
-#
-# There are some general differences in regards to how this works
-# compared to the original patches as we do not need to patch
-# the entire interpreter but just work in our little world of
-# echo and prmopt.
-
-import io
-import os
-import sys
-import zlib
-import time
-import ctypes
-import msvcrt
-from ._compat import _NonClosingTextIOWrapper, text_type, PY2
-from ctypes import byref, POINTER, c_int, c_char, c_char_p, \
- c_void_p, py_object, c_ssize_t, c_ulong, windll, WINFUNCTYPE
-try:
- from ctypes import pythonapi
- PyObject_GetBuffer = pythonapi.PyObject_GetBuffer
- PyBuffer_Release = pythonapi.PyBuffer_Release
-except ImportError:
- pythonapi = None
-from ctypes.wintypes import LPWSTR, LPCWSTR
-
-
-c_ssize_p = POINTER(c_ssize_t)
-
-kernel32 = windll.kernel32
-GetStdHandle = kernel32.GetStdHandle
-ReadConsoleW = kernel32.ReadConsoleW
-WriteConsoleW = kernel32.WriteConsoleW
-GetLastError = kernel32.GetLastError
-GetCommandLineW = WINFUNCTYPE(LPWSTR)(
- ('GetCommandLineW', windll.kernel32))
-CommandLineToArgvW = WINFUNCTYPE(
- POINTER(LPWSTR), LPCWSTR, POINTER(c_int))(
- ('CommandLineToArgvW', windll.shell32))
-
-
-STDIN_HANDLE = GetStdHandle(-10)
-STDOUT_HANDLE = GetStdHandle(-11)
-STDERR_HANDLE = GetStdHandle(-12)
-
-
-PyBUF_SIMPLE = 0
-PyBUF_WRITABLE = 1
-
-ERROR_SUCCESS = 0
-ERROR_NOT_ENOUGH_MEMORY = 8
-ERROR_OPERATION_ABORTED = 995
-
-STDIN_FILENO = 0
-STDOUT_FILENO = 1
-STDERR_FILENO = 2
-
-EOF = b'\x1a'
-MAX_BYTES_WRITTEN = 32767
-
-
-class Py_buffer(ctypes.Structure):
- _fields_ = [
- ('buf', c_void_p),
- ('obj', py_object),
- ('len', c_ssize_t),
- ('itemsize', c_ssize_t),
- ('readonly', c_int),
- ('ndim', c_int),
- ('format', c_char_p),
- ('shape', c_ssize_p),
- ('strides', c_ssize_p),
- ('suboffsets', c_ssize_p),
- ('internal', c_void_p)
- ]
-
- if PY2:
- _fields_.insert(-1, ('smalltable', c_ssize_t * 2))
-
-
-# On PyPy we cannot get buffers so our ability to operate here is
-# serverly limited.
-if pythonapi is None:
- get_buffer = None
-else:
- def get_buffer(obj, writable=False):
- buf = Py_buffer()
- flags = PyBUF_WRITABLE if writable else PyBUF_SIMPLE
- PyObject_GetBuffer(py_object(obj), byref(buf), flags)
- try:
- buffer_type = c_char * buf.len
- return buffer_type.from_address(buf.buf)
- finally:
- PyBuffer_Release(byref(buf))
-
-
-class _WindowsConsoleRawIOBase(io.RawIOBase):
-
- def __init__(self, handle):
- self.handle = handle
-
- def isatty(self):
- io.RawIOBase.isatty(self)
- return True
-
-
-class _WindowsConsoleReader(_WindowsConsoleRawIOBase):
-
- def readable(self):
- return True
-
- def readinto(self, b):
- bytes_to_be_read = len(b)
- if not bytes_to_be_read:
- return 0
- elif bytes_to_be_read % 2:
- raise ValueError('cannot read odd number of bytes from '
- 'UTF-16-LE encoded console')
-
- buffer = get_buffer(b, writable=True)
- code_units_to_be_read = bytes_to_be_read // 2
- code_units_read = c_ulong()
-
- rv = ReadConsoleW(self.handle, buffer, code_units_to_be_read,
- byref(code_units_read), None)
- if GetLastError() == ERROR_OPERATION_ABORTED:
- # wait for KeyboardInterrupt
- time.sleep(0.1)
- if not rv:
- raise OSError('Windows error: %s' % GetLastError())
-
- if buffer[0] == EOF:
- return 0
- return 2 * code_units_read.value
-
-
-class _WindowsConsoleWriter(_WindowsConsoleRawIOBase):
-
- def writable(self):
- return True
-
- @staticmethod
- def _get_error_message(errno):
- if errno == ERROR_SUCCESS:
- return 'ERROR_SUCCESS'
- elif errno == ERROR_NOT_ENOUGH_MEMORY:
- return 'ERROR_NOT_ENOUGH_MEMORY'
- return 'Windows error %s' % errno
-
- def write(self, b):
- bytes_to_be_written = len(b)
- buf = get_buffer(b)
- code_units_to_be_written = min(bytes_to_be_written,
- MAX_BYTES_WRITTEN) // 2
- code_units_written = c_ulong()
-
- WriteConsoleW(self.handle, buf, code_units_to_be_written,
- byref(code_units_written), None)
- bytes_written = 2 * code_units_written.value
-
- if bytes_written == 0 and bytes_to_be_written > 0:
- raise OSError(self._get_error_message(GetLastError()))
- return bytes_written
-
-
-class ConsoleStream(object):
-
- def __init__(self, text_stream, byte_stream):
- self._text_stream = text_stream
- self.buffer = byte_stream
-
- @property
- def name(self):
- return self.buffer.name
-
- def write(self, x):
- if isinstance(x, text_type):
- return self._text_stream.write(x)
- try:
- self.flush()
- except Exception:
- pass
- return self.buffer.write(x)
-
- def writelines(self, lines):
- for line in lines:
- self.write(line)
-
- def __getattr__(self, name):
- return getattr(self._text_stream, name)
-
- def isatty(self):
- return self.buffer.isatty()
-
- def __repr__(self):
- return '<ConsoleStream name=%r encoding=%r>' % (
- self.name,
- self.encoding,
- )
-
-
-class WindowsChunkedWriter(object):
- """
- Wraps a stream (such as stdout), acting as a transparent proxy for all
- attribute access apart from method 'write()' which we wrap to write in
- limited chunks due to a Windows limitation on binary console streams.
- """
- def __init__(self, wrapped):
- # double-underscore everything to prevent clashes with names of
- # attributes on the wrapped stream object.
- self.__wrapped = wrapped
-
- def __getattr__(self, name):
- return getattr(self.__wrapped, name)
-
- def write(self, text):
- total_to_write = len(text)
- written = 0
-
- while written < total_to_write:
- to_write = min(total_to_write - written, MAX_BYTES_WRITTEN)
- self.__wrapped.write(text[written:written+to_write])
- written += to_write
-
-
-_wrapped_std_streams = set()
-
-
-def _wrap_std_stream(name):
- # Python 2 & Windows 7 and below
- if PY2 and sys.getwindowsversion()[:2] <= (6, 1) and name not in _wrapped_std_streams:
- setattr(sys, name, WindowsChunkedWriter(getattr(sys, name)))
- _wrapped_std_streams.add(name)
-
-
-def _get_text_stdin(buffer_stream):
- text_stream = _NonClosingTextIOWrapper(
- io.BufferedReader(_WindowsConsoleReader(STDIN_HANDLE)),
- 'utf-16-le', 'strict', line_buffering=True)
- return ConsoleStream(text_stream, buffer_stream)
-
-
-def _get_text_stdout(buffer_stream):
- text_stream = _NonClosingTextIOWrapper(
- io.BufferedWriter(_WindowsConsoleWriter(STDOUT_HANDLE)),
- 'utf-16-le', 'strict', line_buffering=True)
- return ConsoleStream(text_stream, buffer_stream)
-
-
-def _get_text_stderr(buffer_stream):
- text_stream = _NonClosingTextIOWrapper(
- io.BufferedWriter(_WindowsConsoleWriter(STDERR_HANDLE)),
- 'utf-16-le', 'strict', line_buffering=True)
- return ConsoleStream(text_stream, buffer_stream)
-
-
-if PY2:
- def _hash_py_argv():
- return zlib.crc32('\x00'.join(sys.argv[1:]))
-
- _initial_argv_hash = _hash_py_argv()
-
- def _get_windows_argv():
- argc = c_int(0)
- argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))
- argv = [argv_unicode[i] for i in range(0, argc.value)]
-
- if not hasattr(sys, 'frozen'):
- argv = argv[1:]
- while len(argv) > 0:
- arg = argv[0]
- if not arg.startswith('-') or arg == '-':
- break
- argv = argv[1:]
- if arg.startswith(('-c', '-m')):
- break
-
- return argv[1:]
-
-
-_stream_factories = {
- 0: _get_text_stdin,
- 1: _get_text_stdout,
- 2: _get_text_stderr,
-}
-
-
-def _get_windows_console_stream(f, encoding, errors):
- if get_buffer is not None and \
- encoding in ('utf-16-le', None) \
- and errors in ('strict', None) and \
- hasattr(f, 'isatty') and f.isatty():
- func = _stream_factories.get(f.fileno())
- if func is not None:
- if not PY2:
- f = getattr(f, 'buffer', None)
- if f is None:
- return None
- else:
- # If we are on Python 2 we need to set the stream that we
- # deal with to binary mode as otherwise the exercise if a
- # bit moot. The same problems apply as for
- # get_binary_stdin and friends from _compat.
- msvcrt.setmode(f.fileno(), os.O_BINARY)
- return func(f)
diff --git a/python/click/core.py b/python/click/core.py
deleted file mode 100644
index 7a1e342..0000000
--- a/python/click/core.py
+++ /dev/null
@@ -1,1856 +0,0 @@
-import errno
-import inspect
-import os
-import sys
-from contextlib import contextmanager
-from itertools import repeat
-from functools import update_wrapper
-
-from .types import convert_type, IntRange, BOOL
-from .utils import PacifyFlushWrapper, make_str, make_default_short_help, \
- echo, get_os_args
-from .exceptions import ClickException, UsageError, BadParameter, Abort, \
- MissingParameter, Exit
-from .termui import prompt, confirm, style
-from .formatting import HelpFormatter, join_options
-from .parser import OptionParser, split_opt
-from .globals import push_context, pop_context
-
-from ._compat import PY2, isidentifier, iteritems, string_types
-from ._unicodefun import _check_for_unicode_literals, _verify_python3_env
-
-
-_missing = object()
-
-
-SUBCOMMAND_METAVAR = 'COMMAND [ARGS]...'
-SUBCOMMANDS_METAVAR = 'COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...'
-
-DEPRECATED_HELP_NOTICE = ' (DEPRECATED)'
-DEPRECATED_INVOKE_NOTICE = 'DeprecationWarning: ' + \
- 'The command %(name)s is deprecated.'
-
-
-def _maybe_show_deprecated_notice(cmd):
- if cmd.deprecated:
- echo(style(DEPRECATED_INVOKE_NOTICE % {'name': cmd.name}, fg='red'), err=True)
-
-
-def fast_exit(code):
- """Exit without garbage collection, this speeds up exit by about 10ms for
- things like bash completion.
- """
- sys.stdout.flush()
- sys.stderr.flush()
- os._exit(code)
-
-
-def _bashcomplete(cmd, prog_name, complete_var=None):
- """Internal handler for the bash completion support."""
- if complete_var is None:
- complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper()
- complete_instr = os.environ.get(complete_var)
- if not complete_instr:
- return
-
- from ._bashcomplete import bashcomplete
- if bashcomplete(cmd, prog_name, complete_var, complete_instr):
- fast_exit(1)
-
-
-def _check_multicommand(base_command, cmd_name, cmd, register=False):
- if not base_command.chain or not isinstance(cmd, MultiCommand):
- return
- if register:
- hint = 'It is not possible to add multi commands as children to ' \
- 'another multi command that is in chain mode'
- else:
- hint = 'Found a multi command as subcommand to a multi command ' \
- 'that is in chain mode. This is not supported'
- raise RuntimeError('%s. Command "%s" is set to chain and "%s" was '
- 'added as subcommand but it in itself is a '
- 'multi command. ("%s" is a %s within a chained '
- '%s named "%s").' % (
- hint, base_command.name, cmd_name,
- cmd_name, cmd.__class__.__name__,
- base_command.__class__.__name__,
- base_command.name))
-
-
-def batch(iterable, batch_size):
- return list(zip(*repeat(iter(iterable), batch_size)))
-
-
-def invoke_param_callback(callback, ctx, param, value):
- code = getattr(callback, '__code__', None)
- args = getattr(code, 'co_argcount', 3)
-
- if args < 3:
- # This will become a warning in Click 3.0:
- from warnings import warn
- warn(Warning('Invoked legacy parameter callback "%s". The new '
- 'signature for such callbacks starting with '
- 'click 2.0 is (ctx, param, value).'
- % callback), stacklevel=3)
- return callback(ctx, value)
- return callback(ctx, param, value)
-
-
-@contextmanager
-def augment_usage_errors(ctx, param=None):
- """Context manager that attaches extra information to exceptions that
- fly.
- """
- try:
- yield
- except BadParameter as e:
- if e.ctx is None:
- e.ctx = ctx
- if param is not None and e.param is None:
- e.param = param
- raise
- except UsageError as e:
- if e.ctx is None:
- e.ctx = ctx
- raise
-
-
-def iter_params_for_processing(invocation_order, declaration_order):
- """Given a sequence of parameters in the order as should be considered
- for processing and an iterable of parameters that exist, this returns
- a list in the correct order as they should be processed.
- """
- def sort_key(item):
- try:
- idx = invocation_order.index(item)
- except ValueError:
- idx = float('inf')
- return (not item.is_eager, idx)
-
- return sorted(declaration_order, key=sort_key)
-
-
-class Context(object):
- """The context is a special internal object that holds state relevant
- for the script execution at every single level. It's normally invisible
- to commands unless they opt-in to getting access to it.
-
- The context is useful as it can pass internal objects around and can
- control special execution features such as reading data from
- environment variables.
-
- A context can be used as context manager in which case it will call
- :meth:`close` on teardown.
-
- .. versionadded:: 2.0
- Added the `resilient_parsing`, `help_option_names`,
- `token_normalize_func` parameters.
-
- .. versionadded:: 3.0
- Added the `allow_extra_args` and `allow_interspersed_args`
- parameters.
-
- .. versionadded:: 4.0
- Added the `color`, `ignore_unknown_options`, and
- `max_content_width` parameters.
-
- :param command: the command class for this context.
- :param parent: the parent context.
- :param info_name: the info name for this invocation. Generally this
- is the most descriptive name for the script or
- command. For the toplevel script it is usually
- the name of the script, for commands below it it's
- the name of the script.
- :param obj: an arbitrary object of user data.
- :param auto_envvar_prefix: the prefix to use for automatic environment
- variables. If this is `None` then reading
- from environment variables is disabled. This
- does not affect manually set environment
- variables which are always read.
- :param default_map: a dictionary (like object) with default values
- for parameters.
- :param terminal_width: the width of the terminal. The default is
- inherit from parent context. If no context
- defines the terminal width then auto
- detection will be applied.
- :param max_content_width: the maximum width for content rendered by
- Click (this currently only affects help
- pages). This defaults to 80 characters if
- not overridden. In other words: even if the
- terminal is larger than that, Click will not
- format things wider than 80 characters by
- default. In addition to that, formatters might
- add some safety mapping on the right.
- :param resilient_parsing: if this flag is enabled then Click will
- parse without any interactivity or callback
- invocation. Default values will also be
- ignored. This is useful for implementing
- things such as completion support.
- :param allow_extra_args: if this is set to `True` then extra arguments
- at the end will not raise an error and will be
- kept on the context. The default is to inherit
- from the command.
- :param allow_interspersed_args: if this is set to `False` then options
- and arguments cannot be mixed. The
- default is to inherit from the command.
- :param ignore_unknown_options: instructs click to ignore options it does
- not know and keeps them for later
- processing.
- :param help_option_names: optionally a list of strings that define how
- the default help parameter is named. The
- default is ``['--help']``.
- :param token_normalize_func: an optional function that is used to
- normalize tokens (options, choices,
- etc.). This for instance can be used to
- implement case insensitive behavior.
- :param color: controls if the terminal supports ANSI colors or not. The
- default is autodetection. This is only needed if ANSI
- codes are used in texts that Click prints which is by
- default not the case. This for instance would affect
- help output.
- """
-
- def __init__(self, command, parent=None, info_name=None, obj=None,
- auto_envvar_prefix=None, default_map=None,
- terminal_width=None, max_content_width=None,
- resilient_parsing=False, allow_extra_args=None,
- allow_interspersed_args=None,
- ignore_unknown_options=None, help_option_names=None,
- token_normalize_func=None, color=None):
- #: the parent context or `None` if none exists.
- self.parent = parent
- #: the :class:`Command` for this context.
- self.command = command
- #: the descriptive information name
- self.info_name = info_name
- #: the parsed parameters except if the value is hidden in which
- #: case it's not remembered.
- self.params = {}
- #: the leftover arguments.
- self.args = []
- #: protected arguments. These are arguments that are prepended
- #: to `args` when certain parsing scenarios are encountered but
- #: must be never propagated to another arguments. This is used
- #: to implement nested parsing.
- self.protected_args = []
- if obj is None and parent is not None:
- obj = parent.obj
- #: the user object stored.
- self.obj = obj
- self._meta = getattr(parent, 'meta', {})
-
- #: A dictionary (-like object) with defaults for parameters.
- if default_map is None \
- and parent is not None \
- and parent.default_map is not None:
- default_map = parent.default_map.get(info_name)
- self.default_map = default_map
-
- #: This flag indicates if a subcommand is going to be executed. A
- #: group callback can use this information to figure out if it's
- #: being executed directly or because the execution flow passes
- #: onwards to a subcommand. By default it's None, but it can be
- #: the name of the subcommand to execute.
- #:
- #: If chaining is enabled this will be set to ``'*'`` in case
- #: any commands are executed. It is however not possible to
- #: figure out which ones. If you require this knowledge you
- #: should use a :func:`resultcallback`.
- self.invoked_subcommand = None
-
- if terminal_width is None and parent is not None:
- terminal_width = parent.terminal_width
- #: The width of the terminal (None is autodetection).
- self.terminal_width = terminal_width
-
- if max_content_width is None and parent is not None:
- max_content_width = parent.max_content_width
- #: The maximum width of formatted content (None implies a sensible
- #: default which is 80 for most things).
- self.max_content_width = max_content_width
-
- if allow_extra_args is None:
- allow_extra_args = command.allow_extra_args
- #: Indicates if the context allows extra args or if it should
- #: fail on parsing.
- #:
- #: .. versionadded:: 3.0
- self.allow_extra_args = allow_extra_args
-
- if allow_interspersed_args is None:
- allow_interspersed_args = command.allow_interspersed_args
- #: Indicates if the context allows mixing of arguments and
- #: options or not.
- #:
- #: .. versionadded:: 3.0
- self.allow_interspersed_args = allow_interspersed_args
-
- if ignore_unknown_options is None:
- ignore_unknown_options = command.ignore_unknown_options
- #: Instructs click to ignore options that a command does not
- #: understand and will store it on the context for later
- #: processing. This is primarily useful for situations where you
- #: want to call into external programs. Generally this pattern is
- #: strongly discouraged because it's not possibly to losslessly
- #: forward all arguments.
- #:
- #: .. versionadded:: 4.0
- self.ignore_unknown_options = ignore_unknown_options
-
- if help_option_names is None:
- if parent is not None:
- help_option_names = parent.help_option_names
- else:
- help_option_names = ['--help']
-
- #: The names for the help options.
- self.help_option_names = help_option_names
-
- if token_normalize_func is None and parent is not None:
- token_normalize_func = parent.token_normalize_func
-
- #: An optional normalization function for tokens. This is
- #: options, choices, commands etc.
- self.token_normalize_func = token_normalize_func
-
- #: Indicates if resilient parsing is enabled. In that case Click
- #: will do its best to not cause any failures and default values
- #: will be ignored. Useful for completion.
- self.resilient_parsing = resilient_parsing
-
- # If there is no envvar prefix yet, but the parent has one and
- # the command on this level has a name, we can expand the envvar
- # prefix automatically.
- if auto_envvar_prefix is None:
- if parent is not None \
- and parent.auto_envvar_prefix is not None and \
- self.info_name is not None:
- auto_envvar_prefix = '%s_%s' % (parent.auto_envvar_prefix,
- self.info_name.upper())
- else:
- auto_envvar_prefix = auto_envvar_prefix.upper()
- self.auto_envvar_prefix = auto_envvar_prefix
-
- if color is None and parent is not None:
- color = parent.color
-
- #: Controls if styling output is wanted or not.
- self.color = color
-
- self._close_callbacks = []
- self._depth = 0
-
- def __enter__(self):
- self._depth += 1
- push_context(self)
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self._depth -= 1
- if self._depth == 0:
- self.close()
- pop_context()
-
- @contextmanager
- def scope(self, cleanup=True):
- """This helper method can be used with the context object to promote
- it to the current thread local (see :func:`get_current_context`).
- The default behavior of this is to invoke the cleanup functions which
- can be disabled by setting `cleanup` to `False`. The cleanup
- functions are typically used for things such as closing file handles.
-
- If the cleanup is intended the context object can also be directly
- used as a context manager.
-
- Example usage::
-
- with ctx.scope():
- assert get_current_context() is ctx
-
- This is equivalent::
-
- with ctx:
- assert get_current_context() is ctx
-
- .. versionadded:: 5.0
-
- :param cleanup: controls if the cleanup functions should be run or
- not. The default is to run these functions. In
- some situations the context only wants to be
- temporarily pushed in which case this can be disabled.
- Nested pushes automatically defer the cleanup.
- """
- if not cleanup:
- self._depth += 1
- try:
- with self as rv:
- yield rv
- finally:
- if not cleanup:
- self._depth -= 1
-
- @property
- def meta(self):
- """This is a dictionary which is shared with all the contexts
- that are nested. It exists so that click utilities can store some
- state here if they need to. It is however the responsibility of
- that code to manage this dictionary well.
-
- The keys are supposed to be unique dotted strings. For instance
- module paths are a good choice for it. What is stored in there is
- irrelevant for the operation of click. However what is important is
- that code that places data here adheres to the general semantics of
- the system.
-
- Example usage::
-
- LANG_KEY = __name__ + '.lang'
-
- def set_language(value):
- ctx = get_current_context()
- ctx.meta[LANG_KEY] = value
-
- def get_language():
- return get_current_context().meta.get(LANG_KEY, 'en_US')
-
- .. versionadded:: 5.0
- """
- return self._meta
-
- def make_formatter(self):
- """Creates the formatter for the help and usage output."""
- return HelpFormatter(width=self.terminal_width,
- max_width=self.max_content_width)
-
- def call_on_close(self, f):
- """This decorator remembers a function as callback that should be
- executed when the context tears down. This is most useful to bind
- resource handling to the script execution. For instance, file objects
- opened by the :class:`File` type will register their close callbacks
- here.
-
- :param f: the function to execute on teardown.
- """
- self._close_callbacks.append(f)
- return f
-
- def close(self):
- """Invokes all close callbacks."""
- for cb in self._close_callbacks:
- cb()
- self._close_callbacks = []
-
- @property
- def command_path(self):
- """The computed command path. This is used for the ``usage``
- information on the help page. It's automatically created by
- combining the info names of the chain of contexts to the root.
- """
- rv = ''
- if self.info_name is not None:
- rv = self.info_name
- if self.parent is not None:
- rv = self.parent.command_path + ' ' + rv
- return rv.lstrip()
-
- def find_root(self):
- """Finds the outermost context."""
- node = self
- while node.parent is not None:
- node = node.parent
- return node
-
- def find_object(self, object_type):
- """Finds the closest object of a given type."""
- node = self
- while node is not None:
- if isinstance(node.obj, object_type):
- return node.obj
- node = node.parent
-
- def ensure_object(self, object_type):
- """Like :meth:`find_object` but sets the innermost object to a
- new instance of `object_type` if it does not exist.
- """
- rv = self.find_object(object_type)
- if rv is None:
- self.obj = rv = object_type()
- return rv
-
- def lookup_default(self, name):
- """Looks up the default for a parameter name. This by default
- looks into the :attr:`default_map` if available.
- """
- if self.default_map is not None:
- rv = self.default_map.get(name)
- if callable(rv):
- rv = rv()
- return rv
-
- def fail(self, message):
- """Aborts the execution of the program with a specific error
- message.
-
- :param message: the error message to fail with.
- """
- raise UsageError(message, self)
-
- def abort(self):
- """Aborts the script."""
- raise Abort()
-
- def exit(self, code=0):
- """Exits the application with a given exit code."""
- raise Exit(code)
-
- def get_usage(self):
- """Helper method to get formatted usage string for the current
- context and command.
- """
- return self.command.get_usage(self)
-
- def get_help(self):
- """Helper method to get formatted help page for the current
- context and command.
- """
- return self.command.get_help(self)
-
- def invoke(*args, **kwargs):
- """Invokes a command callback in exactly the way it expects. There
- are two ways to invoke this method:
-
- 1. the first argument can be a callback and all other arguments and
- keyword arguments are forwarded directly to the function.
- 2. the first argument is a click command object. In that case all
- arguments are forwarded as well but proper click parameters
- (options and click arguments) must be keyword arguments and Click
- will fill in defaults.
-
- Note that before Click 3.2 keyword arguments were not properly filled
- in against the intention of this code and no context was created. For
- more information about this change and why it was done in a bugfix
- release see :ref:`upgrade-to-3.2`.
- """
- self, callback = args[:2]
- ctx = self
-
- # It's also possible to invoke another command which might or
- # might not have a callback. In that case we also fill
- # in defaults and make a new context for this command.
- if isinstance(callback, Command):
- other_cmd = callback
- callback = other_cmd.callback
- ctx = Context(other_cmd, info_name=other_cmd.name, parent=self)
- if callback is None:
- raise TypeError('The given command does not have a '
- 'callback that can be invoked.')
-
- for param in other_cmd.params:
- if param.name not in kwargs and param.expose_value:
- kwargs[param.name] = param.get_default(ctx)
-
- args = args[2:]
- with augment_usage_errors(self):
- with ctx:
- return callback(*args, **kwargs)
-
- def forward(*args, **kwargs):
- """Similar to :meth:`invoke` but fills in default keyword
- arguments from the current context if the other command expects
- it. This cannot invoke callbacks directly, only other commands.
- """
- self, cmd = args[:2]
-
- # It's also possible to invoke another command which might or
- # might not have a callback.
- if not isinstance(cmd, Command):
- raise TypeError('Callback is not a command.')
-
- for param in self.params:
- if param not in kwargs:
- kwargs[param] = self.params[param]
-
- return self.invoke(cmd, **kwargs)
-
-
-class BaseCommand(object):
- """The base command implements the minimal API contract of commands.
- Most code will never use this as it does not implement a lot of useful
- functionality but it can act as the direct subclass of alternative
- parsing methods that do not depend on the Click parser.
-
- For instance, this can be used to bridge Click and other systems like
- argparse or docopt.
-
- Because base commands do not implement a lot of the API that other
- parts of Click take for granted, they are not supported for all
- operations. For instance, they cannot be used with the decorators
- usually and they have no built-in callback system.
-
- .. versionchanged:: 2.0
- Added the `context_settings` parameter.
-
- :param name: the name of the command to use unless a group overrides it.
- :param context_settings: an optional dictionary with defaults that are
- passed to the context object.
- """
- #: the default for the :attr:`Context.allow_extra_args` flag.
- allow_extra_args = False
- #: the default for the :attr:`Context.allow_interspersed_args` flag.
- allow_interspersed_args = True
- #: the default for the :attr:`Context.ignore_unknown_options` flag.
- ignore_unknown_options = False
-
- def __init__(self, name, context_settings=None):
- #: the name the command thinks it has. Upon registering a command
- #: on a :class:`Group` the group will default the command name
- #: with this information. You should instead use the
- #: :class:`Context`\'s :attr:`~Context.info_name` attribute.
- self.name = name
- if context_settings is None:
- context_settings = {}
- #: an optional dictionary with defaults passed to the context.
- self.context_settings = context_settings
-
- def get_usage(self, ctx):
- raise NotImplementedError('Base commands cannot get usage')
-
- def get_help(self, ctx):
- raise NotImplementedError('Base commands cannot get help')
-
- def make_context(self, info_name, args, parent=None, **extra):
- """This function when given an info name and arguments will kick
- off the parsing and create a new :class:`Context`. It does not
- invoke the actual command callback though.
-
- :param info_name: the info name for this invokation. Generally this
- is the most descriptive name for the script or
- command. For the toplevel script it's usually
- the name of the script, for commands below it it's
- the name of the script.
- :param args: the arguments to parse as list of strings.
- :param parent: the parent context if available.
- :param extra: extra keyword arguments forwarded to the context
- constructor.
- """
- for key, value in iteritems(self.context_settings):
- if key not in extra:
- extra[key] = value
- ctx = Context(self, info_name=info_name, parent=parent, **extra)
- with ctx.scope(cleanup=False):
- self.parse_args(ctx, args)
- return ctx
-
- def parse_args(self, ctx, args):
- """Given a context and a list of arguments this creates the parser
- and parses the arguments, then modifies the context as necessary.
- This is automatically invoked by :meth:`make_context`.
- """
- raise NotImplementedError('Base commands do not know how to parse '
- 'arguments.')
-
- def invoke(self, ctx):
- """Given a context, this invokes the command. The default
- implementation is raising a not implemented error.
- """
- raise NotImplementedError('Base commands are not invokable by default')
-
- def main(self, args=None, prog_name=None, complete_var=None,
- standalone_mode=True, **extra):
- """This is the way to invoke a script with all the bells and
- whistles as a command line application. This will always terminate
- the application after a call. If this is not wanted, ``SystemExit``
- needs to be caught.
-
- This method is also available by directly calling the instance of
- a :class:`Command`.
-
- .. versionadded:: 3.0
- Added the `standalone_mode` flag to control the standalone mode.
-
- :param args: the arguments that should be used for parsing. If not
- provided, ``sys.argv[1:]`` is used.
- :param prog_name: the program name that should be used. By default
- the program name is constructed by taking the file
- name from ``sys.argv[0]``.
- :param complete_var: the environment variable that controls the
- bash completion support. The default is
- ``"_<prog_name>_COMPLETE"`` with prog_name in
- uppercase.
- :param standalone_mode: the default behavior is to invoke the script
- in standalone mode. Click will then
- handle exceptions and convert them into
- error messages and the function will never
- return but shut down the interpreter. If
- this is set to `False` they will be
- propagated to the caller and the return
- value of this function is the return value
- of :meth:`invoke`.
- :param extra: extra keyword arguments are forwarded to the context
- constructor. See :class:`Context` for more information.
- """
- # If we are in Python 3, we will verify that the environment is
- # sane at this point or reject further execution to avoid a
- # broken script.
- if not PY2:
- _verify_python3_env()
- else:
- _check_for_unicode_literals()
-
- if args is None:
- args = get_os_args()
- else:
- args = list(args)
-
- if prog_name is None:
- prog_name = make_str(os.path.basename(
- sys.argv and sys.argv[0] or __file__))
-
- # Hook for the Bash completion. This only activates if the Bash
- # completion is actually enabled, otherwise this is quite a fast
- # noop.
- _bashcomplete(self, prog_name, complete_var)
-
- try:
- try:
- with self.make_context(prog_name, args, **extra) as ctx:
- rv = self.invoke(ctx)
- if not standalone_mode:
- return rv
- # it's not safe to `ctx.exit(rv)` here!
- # note that `rv` may actually contain data like "1" which
- # has obvious effects
- # more subtle case: `rv=[None, None]` can come out of
- # chained commands which all returned `None` -- so it's not
- # even always obvious that `rv` indicates success/failure
- # by its truthiness/falsiness
- ctx.exit()
- except (EOFError, KeyboardInterrupt):
- echo(file=sys.stderr)
- raise Abort()
- except ClickException as e:
- if not standalone_mode:
- raise
- e.show()
- sys.exit(e.exit_code)
- except IOError as e:
- if e.errno == errno.EPIPE:
- sys.stdout = PacifyFlushWrapper(sys.stdout)
- sys.stderr = PacifyFlushWrapper(sys.stderr)
- sys.exit(1)
- else:
- raise
- except Exit as e:
- if standalone_mode:
- sys.exit(e.exit_code)
- else:
- # in non-standalone mode, return the exit code
- # note that this is only reached if `self.invoke` above raises
- # an Exit explicitly -- thus bypassing the check there which
- # would return its result
- # the results of non-standalone execution may therefore be
- # somewhat ambiguous: if there are codepaths which lead to
- # `ctx.exit(1)` and to `return 1`, the caller won't be able to
- # tell the difference between the two
- return e.exit_code
- except Abort:
- if not standalone_mode:
- raise
- echo('Aborted!', file=sys.stderr)
- sys.exit(1)
-
- def __call__(self, *args, **kwargs):
- """Alias for :meth:`main`."""
- return self.main(*args, **kwargs)
-
-
-class Command(BaseCommand):
- """Commands are the basic building block of command line interfaces in
- Click. A basic command handles command line parsing and might dispatch
- more parsing to commands nested below it.
-
- .. versionchanged:: 2.0
- Added the `context_settings` parameter.
-
- :param name: the name of the command to use unless a group overrides it.
- :param context_settings: an optional dictionary with defaults that are
- passed to the context object.
- :param callback: the callback to invoke. This is optional.
- :param params: the parameters to register with this command. This can
- be either :class:`Option` or :class:`Argument` objects.
- :param help: the help string to use for this command.
- :param epilog: like the help string but it's printed at the end of the
- help page after everything else.
- :param short_help: the short help to use for this command. This is
- shown on the command listing of the parent command.
- :param add_help_option: by default each command registers a ``--help``
- option. This can be disabled by this parameter.
- :param hidden: hide this command from help outputs.
-
- :param deprecated: issues a message indicating that
- the command is deprecated.
- """
-
- def __init__(self, name, context_settings=None, callback=None,
- params=None, help=None, epilog=None, short_help=None,
- options_metavar='[OPTIONS]', add_help_option=True,
- hidden=False, deprecated=False):
- BaseCommand.__init__(self, name, context_settings)
- #: the callback to execute when the command fires. This might be
- #: `None` in which case nothing happens.
- self.callback = callback
- #: the list of parameters for this command in the order they
- #: should show up in the help page and execute. Eager parameters
- #: will automatically be handled before non eager ones.
- self.params = params or []
- # if a form feed (page break) is found in the help text, truncate help
- # text to the content preceding the first form feed
- if help and '\f' in help:
- help = help.split('\f', 1)[0]
- self.help = help
- self.epilog = epilog
- self.options_metavar = options_metavar
- self.short_help = short_help
- self.add_help_option = add_help_option
- self.hidden = hidden
- self.deprecated = deprecated
-
- def get_usage(self, ctx):
- formatter = ctx.make_formatter()
- self.format_usage(ctx, formatter)
- return formatter.getvalue().rstrip('\n')
-
- def get_params(self, ctx):
- rv = self.params
- help_option = self.get_help_option(ctx)
- if help_option is not None:
- rv = rv + [help_option]
- return rv
-
- def format_usage(self, ctx, formatter):
- """Writes the usage line into the formatter."""
- pieces = self.collect_usage_pieces(ctx)
- formatter.write_usage(ctx.command_path, ' '.join(pieces))
-
- def collect_usage_pieces(self, ctx):
- """Returns all the pieces that go into the usage line and returns
- it as a list of strings.
- """
- rv = [self.options_metavar]
- for param in self.get_params(ctx):
- rv.extend(param.get_usage_pieces(ctx))
- return rv
-
- def get_help_option_names(self, ctx):
- """Returns the names for the help option."""
- all_names = set(ctx.help_option_names)
- for param in self.params:
- all_names.difference_update(param.opts)
- all_names.difference_update(param.secondary_opts)
- return all_names
-
- def get_help_option(self, ctx):
- """Returns the help option object."""
- help_options = self.get_help_option_names(ctx)
- if not help_options or not self.add_help_option:
- return
-
- def show_help(ctx, param, value):
- if value and not ctx.resilient_parsing:
- echo(ctx.get_help(), color=ctx.color)
- ctx.exit()
- return Option(help_options, is_flag=True,
- is_eager=True, expose_value=False,
- callback=show_help,
- help='Show this message and exit.')
-
- def make_parser(self, ctx):
- """Creates the underlying option parser for this command."""
- parser = OptionParser(ctx)
- for param in self.get_params(ctx):
- param.add_to_parser(parser, ctx)
- return parser
-
- def get_help(self, ctx):
- """Formats the help into a string and returns it. This creates a
- formatter and will call into the following formatting methods:
- """
- formatter = ctx.make_formatter()
- self.format_help(ctx, formatter)
- return formatter.getvalue().rstrip('\n')
-
- def get_short_help_str(self, limit=45):
- """Gets short help for the command or makes it by shortening the long help string."""
- return self.short_help or self.help and make_default_short_help(self.help, limit) or ''
-
- def format_help(self, ctx, formatter):
- """Writes the help into the formatter if it exists.
-
- This calls into the following methods:
-
- - :meth:`format_usage`
- - :meth:`format_help_text`
- - :meth:`format_options`
- - :meth:`format_epilog`
- """
- self.format_usage(ctx, formatter)
- self.format_help_text(ctx, formatter)
- self.format_options(ctx, formatter)
- self.format_epilog(ctx, formatter)
-
- def format_help_text(self, ctx, formatter):
- """Writes the help text to the formatter if it exists."""
- if self.help:
- formatter.write_paragraph()
- with formatter.indentation():
- help_text = self.help
- if self.deprecated:
- help_text += DEPRECATED_HELP_NOTICE
- formatter.write_text(help_text)
- elif self.deprecated:
- formatter.write_paragraph()
- with formatter.indentation():
- formatter.write_text(DEPRECATED_HELP_NOTICE)
-
- def format_options(self, ctx, formatter):
- """Writes all the options into the formatter if they exist."""
- opts = []
- for param in self.get_params(ctx):
- rv = param.get_help_record(ctx)
- if rv is not None:
- opts.append(rv)
-
- if opts:
- with formatter.section('Options'):
- formatter.write_dl(opts)
-
- def format_epilog(self, ctx, formatter):
- """Writes the epilog into the formatter if it exists."""
- if self.epilog:
- formatter.write_paragraph()
- with formatter.indentation():
- formatter.write_text(self.epilog)
-
- def parse_args(self, ctx, args):
- parser = self.make_parser(ctx)
- opts, args, param_order = parser.parse_args(args=args)
-
- for param in iter_params_for_processing(
- param_order, self.get_params(ctx)):
- value, args = param.handle_parse_result(ctx, opts, args)
-
- if args and not ctx.allow_extra_args and not ctx.resilient_parsing:
- ctx.fail('Got unexpected extra argument%s (%s)'
- % (len(args) != 1 and 's' or '',
- ' '.join(map(make_str, args))))
-
- ctx.args = args
- return args
-
- def invoke(self, ctx):
- """Given a context, this invokes the attached callback (if it exists)
- in the right way.
- """
- _maybe_show_deprecated_notice(self)
- if self.callback is not None:
- return ctx.invoke(self.callback, **ctx.params)
-
-
-class MultiCommand(Command):
- """A multi command is the basic implementation of a command that
- dispatches to subcommands. The most common version is the
- :class:`Group`.
-
- :param invoke_without_command: this controls how the multi command itself
- is invoked. By default it's only invoked
- if a subcommand is provided.
- :param no_args_is_help: this controls what happens if no arguments are
- provided. This option is enabled by default if
- `invoke_without_command` is disabled or disabled
- if it's enabled. If enabled this will add
- ``--help`` as argument if no arguments are
- passed.
- :param subcommand_metavar: the string that is used in the documentation
- to indicate the subcommand place.
- :param chain: if this is set to `True` chaining of multiple subcommands
- is enabled. This restricts the form of commands in that
- they cannot have optional arguments but it allows
- multiple commands to be chained together.
- :param result_callback: the result callback to attach to this multi
- command.
- """
- allow_extra_args = True
- allow_interspersed_args = False
-
- def __init__(self, name=None, invoke_without_command=False,
- no_args_is_help=None, subcommand_metavar=None,
- chain=False, result_callback=None, **attrs):
- Command.__init__(self, name, **attrs)
- if no_args_is_help is None:
- no_args_is_help = not invoke_without_command
- self.no_args_is_help = no_args_is_help
- self.invoke_without_command = invoke_without_command
- if subcommand_metavar is None:
- if chain:
- subcommand_metavar = SUBCOMMANDS_METAVAR
- else:
- subcommand_metavar = SUBCOMMAND_METAVAR
- self.subcommand_metavar = subcommand_metavar
- self.chain = chain
- #: The result callback that is stored. This can be set or
- #: overridden with the :func:`resultcallback` decorator.
- self.result_callback = result_callback
-
- if self.chain:
- for param in self.params:
- if isinstance(param, Argument) and not param.required:
- raise RuntimeError('Multi commands in chain mode cannot '
- 'have optional arguments.')
-
- def collect_usage_pieces(self, ctx):
- rv = Command.collect_usage_pieces(self, ctx)
- rv.append(self.subcommand_metavar)
- return rv
-
- def format_options(self, ctx, formatter):
- Command.format_options(self, ctx, formatter)
- self.format_commands(ctx, formatter)
-
- def resultcallback(self, replace=False):
- """Adds a result callback to the chain command. By default if a
- result callback is already registered this will chain them but
- this can be disabled with the `replace` parameter. The result
- callback is invoked with the return value of the subcommand
- (or the list of return values from all subcommands if chaining
- is enabled) as well as the parameters as they would be passed
- to the main callback.
-
- Example::
-
- @click.group()
- @click.option('-i', '--input', default=23)
- def cli(input):
- return 42
-
- @cli.resultcallback()
- def process_result(result, input):
- return result + input
-
- .. versionadded:: 3.0
-
- :param replace: if set to `True` an already existing result
- callback will be removed.
- """
- def decorator(f):
- old_callback = self.result_callback
- if old_callback is None or replace:
- self.result_callback = f
- return f
- def function(__value, *args, **kwargs):
- return f(old_callback(__value, *args, **kwargs),
- *args, **kwargs)
- self.result_callback = rv = update_wrapper(function, f)
- return rv
- return decorator
-
- def format_commands(self, ctx, formatter):
- """Extra format methods for multi methods that adds all the commands
- after the options.
- """
- commands = []
- for subcommand in self.list_commands(ctx):
- cmd = self.get_command(ctx, subcommand)
- # What is this, the tool lied about a command. Ignore it
- if cmd is None:
- continue
- if cmd.hidden:
- continue
-
- commands.append((subcommand, cmd))
-
- # allow for 3 times the default spacing
- if len(commands):
- limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)
-
- rows = []
- for subcommand, cmd in commands:
- help = cmd.get_short_help_str(limit)
- rows.append((subcommand, help))
-
- if rows:
- with formatter.section('Commands'):
- formatter.write_dl(rows)
-
- def parse_args(self, ctx, args):
- if not args and self.no_args_is_help and not ctx.resilient_parsing:
- echo(ctx.get_help(), color=ctx.color)
- ctx.exit()
-
- rest = Command.parse_args(self, ctx, args)
- if self.chain:
- ctx.protected_args = rest
- ctx.args = []
- elif rest:
- ctx.protected_args, ctx.args = rest[:1], rest[1:]
-
- return ctx.args
-
- def invoke(self, ctx):
- def _process_result(value):
- if self.result_callback is not None:
- value = ctx.invoke(self.result_callback, value,
- **ctx.params)
- return value
-
- if not ctx.protected_args:
- # If we are invoked without command the chain flag controls
- # how this happens. If we are not in chain mode, the return
- # value here is the return value of the command.
- # If however we are in chain mode, the return value is the
- # return value of the result processor invoked with an empty
- # list (which means that no subcommand actually was executed).
- if self.invoke_without_command:
- if not self.chain:
- return Command.invoke(self, ctx)
- with ctx:
- Command.invoke(self, ctx)
- return _process_result([])
- ctx.fail('Missing command.')
-
- # Fetch args back out
- args = ctx.protected_args + ctx.args
- ctx.args = []
- ctx.protected_args = []
-
- # If we're not in chain mode, we only allow the invocation of a
- # single command but we also inform the current context about the
- # name of the command to invoke.
- if not self.chain:
- # Make sure the context is entered so we do not clean up
- # resources until the result processor has worked.
- with ctx:
- cmd_name, cmd, args = self.resolve_command(ctx, args)
- ctx.invoked_subcommand = cmd_name
- Command.invoke(self, ctx)
- sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
- with sub_ctx:
- return _process_result(sub_ctx.command.invoke(sub_ctx))
-
- # In chain mode we create the contexts step by step, but after the
- # base command has been invoked. Because at that point we do not
- # know the subcommands yet, the invoked subcommand attribute is
- # set to ``*`` to inform the command that subcommands are executed
- # but nothing else.
- with ctx:
- ctx.invoked_subcommand = args and '*' or None
- Command.invoke(self, ctx)
-
- # Otherwise we make every single context and invoke them in a
- # chain. In that case the return value to the result processor
- # is the list of all invoked subcommand's results.
- contexts = []
- while args:
- cmd_name, cmd, args = self.resolve_command(ctx, args)
- sub_ctx = cmd.make_context(cmd_name, args, parent=ctx,
- allow_extra_args=True,
- allow_interspersed_args=False)
- contexts.append(sub_ctx)
- args, sub_ctx.args = sub_ctx.args, []
-
- rv = []
- for sub_ctx in contexts:
- with sub_ctx:
- rv.append(sub_ctx.command.invoke(sub_ctx))
- return _process_result(rv)
-
- def resolve_command(self, ctx, args):
- cmd_name = make_str(args[0])
- original_cmd_name = cmd_name
-
- # Get the command
- cmd = self.get_command(ctx, cmd_name)
-
- # If we can't find the command but there is a normalization
- # function available, we try with that one.
- if cmd is None and ctx.token_normalize_func is not None:
- cmd_name = ctx.token_normalize_func(cmd_name)
- cmd = self.get_command(ctx, cmd_name)
-
- # If we don't find the command we want to show an error message
- # to the user that it was not provided. However, there is
- # something else we should do: if the first argument looks like
- # an option we want to kick off parsing again for arguments to
- # resolve things like --help which now should go to the main
- # place.
- if cmd is None and not ctx.resilient_parsing:
- if split_opt(cmd_name)[0]:
- self.parse_args(ctx, ctx.args)
- ctx.fail('No such command "%s".' % original_cmd_name)
-
- return cmd_name, cmd, args[1:]
-
- def get_command(self, ctx, cmd_name):
- """Given a context and a command name, this returns a
- :class:`Command` object if it exists or returns `None`.
- """
- raise NotImplementedError()
-
- def list_commands(self, ctx):
- """Returns a list of subcommand names in the order they should
- appear.
- """
- return []
-
-
-class Group(MultiCommand):
- """A group allows a command to have subcommands attached. This is the
- most common way to implement nesting in Click.
-
- :param commands: a dictionary of commands.
- """
-
- def __init__(self, name=None, commands=None, **attrs):
- MultiCommand.__init__(self, name, **attrs)
- #: the registered subcommands by their exported names.
- self.commands = commands or {}
-
- def add_command(self, cmd, name=None):
- """Registers another :class:`Command` with this group. If the name
- is not provided, the name of the command is used.
- """
- name = name or cmd.name
- if name is None:
- raise TypeError('Command has no name.')
- _check_multicommand(self, name, cmd, register=True)
- self.commands[name] = cmd
-
- def command(self, *args, **kwargs):
- """A shortcut decorator for declaring and attaching a command to
- the group. This takes the same arguments as :func:`command` but
- immediately registers the created command with this instance by
- calling into :meth:`add_command`.
- """
- def decorator(f):
- cmd = command(*args, **kwargs)(f)
- self.add_command(cmd)
- return cmd
- return decorator
-
- def group(self, *args, **kwargs):
- """A shortcut decorator for declaring and attaching a group to
- the group. This takes the same arguments as :func:`group` but
- immediately registers the created command with this instance by
- calling into :meth:`add_command`.
- """
- def decorator(f):
- cmd = group(*args, **kwargs)(f)
- self.add_command(cmd)
- return cmd
- return decorator
-
- def get_command(self, ctx, cmd_name):
- return self.commands.get(cmd_name)
-
- def list_commands(self, ctx):
- return sorted(self.commands)
-
-
-class CommandCollection(MultiCommand):
- """A command collection is a multi command that merges multiple multi
- commands together into one. This is a straightforward implementation
- that accepts a list of different multi commands as sources and
- provides all the commands for each of them.
- """
-
- def __init__(self, name=None, sources=None, **attrs):
- MultiCommand.__init__(self, name, **attrs)
- #: The list of registered multi commands.
- self.sources = sources or []
-
- def add_source(self, multi_cmd):
- """Adds a new multi command to the chain dispatcher."""
- self.sources.append(multi_cmd)
-
- def get_command(self, ctx, cmd_name):
- for source in self.sources:
- rv = source.get_command(ctx, cmd_name)
- if rv is not None:
- if self.chain:
- _check_multicommand(self, cmd_name, rv)
- return rv
-
- def list_commands(self, ctx):
- rv = set()
- for source in self.sources:
- rv.update(source.list_commands(ctx))
- return sorted(rv)
-
-
-class Parameter(object):
- r"""A parameter to a command comes in two versions: they are either
- :class:`Option`\s or :class:`Argument`\s. Other subclasses are currently
- not supported by design as some of the internals for parsing are
- intentionally not finalized.
-
- Some settings are supported by both options and arguments.
-
- .. versionchanged:: 2.0
- Changed signature for parameter callback to also be passed the
- parameter. In Click 2.0, the old callback format will still work,
- but it will raise a warning to give you change to migrate the
- code easier.
-
- :param param_decls: the parameter declarations for this option or
- argument. This is a list of flags or argument
- names.
- :param type: the type that should be used. Either a :class:`ParamType`
- or a Python type. The later is converted into the former
- automatically if supported.
- :param required: controls if this is optional or not.
- :param default: the default value if omitted. This can also be a callable,
- in which case it's invoked when the default is needed
- without any arguments.
- :param callback: a callback that should be executed after the parameter
- was matched. This is called as ``fn(ctx, param,
- value)`` and needs to return the value. Before Click
- 2.0, the signature was ``(ctx, value)``.
- :param nargs: the number of arguments to match. If not ``1`` the return
- value is a tuple instead of single value. The default for
- nargs is ``1`` (except if the type is a tuple, then it's
- the arity of the tuple).
- :param metavar: how the value is represented in the help page.
- :param expose_value: if this is `True` then the value is passed onwards
- to the command callback and stored on the context,
- otherwise it's skipped.
- :param is_eager: eager values are processed before non eager ones. This
- should not be set for arguments or it will inverse the
- order of processing.
- :param envvar: a string or list of strings that are environment variables
- that should be checked.
- """
- param_type_name = 'parameter'
-
- def __init__(self, param_decls=None, type=None, required=False,
- default=None, callback=None, nargs=None, metavar=None,
- expose_value=True, is_eager=False, envvar=None,
- autocompletion=None):
- self.name, self.opts, self.secondary_opts = \
- self._parse_decls(param_decls or (), expose_value)
-
- self.type = convert_type(type, default)
-
- # Default nargs to what the type tells us if we have that
- # information available.
- if nargs is None:
- if self.type.is_composite:
- nargs = self.type.arity
- else:
- nargs = 1
-
- self.required = required
- self.callback = callback
- self.nargs = nargs
- self.multiple = False
- self.expose_value = expose_value
- self.default = default
- self.is_eager = is_eager
- self.metavar = metavar
- self.envvar = envvar
- self.autocompletion = autocompletion
-
- @property
- def human_readable_name(self):
- """Returns the human readable name of this parameter. This is the
- same as the name for options, but the metavar for arguments.
- """
- return self.name
-
- def make_metavar(self):
- if self.metavar is not None:
- return self.metavar
- metavar = self.type.get_metavar(self)
- if metavar is None:
- metavar = self.type.name.upper()
- if self.nargs != 1:
- metavar += '...'
- return metavar
-
- def get_default(self, ctx):
- """Given a context variable this calculates the default value."""
- # Otherwise go with the regular default.
- if callable(self.default):
- rv = self.default()
- else:
- rv = self.default
- return self.type_cast_value(ctx, rv)
-
- def add_to_parser(self, parser, ctx):
- pass
-
- def consume_value(self, ctx, opts):
- value = opts.get(self.name)
- if value is None:
- value = self.value_from_envvar(ctx)
- if value is None:
- value = ctx.lookup_default(self.name)
- return value
-
- def type_cast_value(self, ctx, value):
- """Given a value this runs it properly through the type system.
- This automatically handles things like `nargs` and `multiple` as
- well as composite types.
- """
- if self.type.is_composite:
- if self.nargs <= 1:
- raise TypeError('Attempted to invoke composite type '
- 'but nargs has been set to %s. This is '
- 'not supported; nargs needs to be set to '
- 'a fixed value > 1.' % self.nargs)
- if self.multiple:
- return tuple(self.type(x or (), self, ctx) for x in value or ())
- return self.type(value or (), self, ctx)
-
- def _convert(value, level):
- if level == 0:
- return self.type(value, self, ctx)
- return tuple(_convert(x, level - 1) for x in value or ())
- return _convert(value, (self.nargs != 1) + bool(self.multiple))
-
- def process_value(self, ctx, value):
- """Given a value and context this runs the logic to convert the
- value as necessary.
- """
- # If the value we were given is None we do nothing. This way
- # code that calls this can easily figure out if something was
- # not provided. Otherwise it would be converted into an empty
- # tuple for multiple invocations which is inconvenient.
- if value is not None:
- return self.type_cast_value(ctx, value)
-
- def value_is_missing(self, value):
- if value is None:
- return True
- if (self.nargs != 1 or self.multiple) and value == ():
- return True
- return False
-
- def full_process_value(self, ctx, value):
- value = self.process_value(ctx, value)
-
- if value is None and not ctx.resilient_parsing:
- value = self.get_default(ctx)
-
- if self.required and self.value_is_missing(value):
- raise MissingParameter(ctx=ctx, param=self)
-
- return value
-
- def resolve_envvar_value(self, ctx):
- if self.envvar is None:
- return
- if isinstance(self.envvar, (tuple, list)):
- for envvar in self.envvar:
- rv = os.environ.get(envvar)
- if rv is not None:
- return rv
- else:
- return os.environ.get(self.envvar)
-
- def value_from_envvar(self, ctx):
- rv = self.resolve_envvar_value(ctx)
- if rv is not None and self.nargs != 1:
- rv = self.type.split_envvar_value(rv)
- return rv
-
- def handle_parse_result(self, ctx, opts, args):
- with augment_usage_errors(ctx, param=self):
- value = self.consume_value(ctx, opts)
- try:
- value = self.full_process_value(ctx, value)
- except Exception:
- if not ctx.resilient_parsing:
- raise
- value = None
- if self.callback is not None:
- try:
- value = invoke_param_callback(
- self.callback, ctx, self, value)
- except Exception:
- if not ctx.resilient_parsing:
- raise
-
- if self.expose_value:
- ctx.params[self.name] = value
- return value, args
-
- def get_help_record(self, ctx):
- pass
-
- def get_usage_pieces(self, ctx):
- return []
-
- def get_error_hint(self, ctx):
- """Get a stringified version of the param for use in error messages to
- indicate which param caused the error.
- """
- hint_list = self.opts or [self.human_readable_name]
- return ' / '.join('"%s"' % x for x in hint_list)
-
-
-class Option(Parameter):
- """Options are usually optional values on the command line and
- have some extra features that arguments don't have.
-
- All other parameters are passed onwards to the parameter constructor.
-
- :param show_default: controls if the default value should be shown on the
- help page. Normally, defaults are not shown. If this
- value is a string, it shows the string instead of the
- value. This is particularly useful for dynamic options.
- :param show_envvar: controls if an environment variable should be shown on
- the help page. Normally, environment variables
- are not shown.
- :param prompt: if set to `True` or a non empty string then the user will be
- prompted for input. If set to `True` the prompt will be the
- option name capitalized.
- :param confirmation_prompt: if set then the value will need to be confirmed
- if it was prompted for.
- :param hide_input: if this is `True` then the input on the prompt will be
- hidden from the user. This is useful for password
- input.
- :param is_flag: forces this option to act as a flag. The default is
- auto detection.
- :param flag_value: which value should be used for this flag if it's
- enabled. This is set to a boolean automatically if
- the option string contains a slash to mark two options.
- :param multiple: if this is set to `True` then the argument is accepted
- multiple times and recorded. This is similar to ``nargs``
- in how it works but supports arbitrary number of
- arguments.
- :param count: this flag makes an option increment an integer.
- :param allow_from_autoenv: if this is enabled then the value of this
- parameter will be pulled from an environment
- variable in case a prefix is defined on the
- context.
- :param help: the help string.
- :param hidden: hide this option from help outputs.
- """
- param_type_name = 'option'
-
- def __init__(self, param_decls=None, show_default=False,
- prompt=False, confirmation_prompt=False,
- hide_input=False, is_flag=None, flag_value=None,
- multiple=False, count=False, allow_from_autoenv=True,
- type=None, help=None, hidden=False, show_choices=True,
- show_envvar=False, **attrs):
- default_is_missing = attrs.get('default', _missing) is _missing
- Parameter.__init__(self, param_decls, type=type, **attrs)
-
- if prompt is True:
- prompt_text = self.name.replace('_', ' ').capitalize()
- elif prompt is False:
- prompt_text = None
- else:
- prompt_text = prompt
- self.prompt = prompt_text
- self.confirmation_prompt = confirmation_prompt
- self.hide_input = hide_input
- self.hidden = hidden
-
- # Flags
- if is_flag is None:
- if flag_value is not None:
- is_flag = True
- else:
- is_flag = bool(self.secondary_opts)
- if is_flag and default_is_missing:
- self.default = False
- if flag_value is None:
- flag_value = not self.default
- self.is_flag = is_flag
- self.flag_value = flag_value
- if self.is_flag and isinstance(self.flag_value, bool) \
- and type is None:
- self.type = BOOL
- self.is_bool_flag = True
- else:
- self.is_bool_flag = False
-
- # Counting
- self.count = count
- if count:
- if type is None:
- self.type = IntRange(min=0)
- if default_is_missing:
- self.default = 0
-
- self.multiple = multiple
- self.allow_from_autoenv = allow_from_autoenv
- self.help = help
- self.show_default = show_default
- self.show_choices = show_choices
- self.show_envvar = show_envvar
-
- # Sanity check for stuff we don't support
- if __debug__:
- if self.nargs < 0:
- raise TypeError('Options cannot have nargs < 0')
- if self.prompt and self.is_flag and not self.is_bool_flag:
- raise TypeError('Cannot prompt for flags that are not bools.')
- if not self.is_bool_flag and self.secondary_opts:
- raise TypeError('Got secondary option for non boolean flag.')
- if self.is_bool_flag and self.hide_input \
- and self.prompt is not None:
- raise TypeError('Hidden input does not work with boolean '
- 'flag prompts.')
- if self.count:
- if self.multiple:
- raise TypeError('Options cannot be multiple and count '
- 'at the same time.')
- elif self.is_flag:
- raise TypeError('Options cannot be count and flags at '
- 'the same time.')
-
- def _parse_decls(self, decls, expose_value):
- opts = []
- secondary_opts = []
- name = None
- possible_names = []
-
- for decl in decls:
- if isidentifier(decl):
- if name is not None:
- raise TypeError('Name defined twice')
- name = decl
- else:
- split_char = decl[:1] == '/' and ';' or '/'
- if split_char in decl:
- first, second = decl.split(split_char, 1)
- first = first.rstrip()
- if first:
- possible_names.append(split_opt(first))
- opts.append(first)
- second = second.lstrip()
- if second:
- secondary_opts.append(second.lstrip())
- else:
- possible_names.append(split_opt(decl))
- opts.append(decl)
-
- if name is None and possible_names:
- possible_names.sort(key=lambda x: -len(x[0])) # group long options first
- name = possible_names[0][1].replace('-', '_').lower()
- if not isidentifier(name):
- name = None
-
- if name is None:
- if not expose_value:
- return None, opts, secondary_opts
- raise TypeError('Could not determine name for option')
-
- if not opts and not secondary_opts:
- raise TypeError('No options defined but a name was passed (%s). '
- 'Did you mean to declare an argument instead '
- 'of an option?' % name)
-
- return name, opts, secondary_opts
-
- def add_to_parser(self, parser, ctx):
- kwargs = {
- 'dest': self.name,
- 'nargs': self.nargs,
- 'obj': self,
- }
-
- if self.multiple:
- action = 'append'
- elif self.count:
- action = 'count'
- else:
- action = 'store'
-
- if self.is_flag:
- kwargs.pop('nargs', None)
- if self.is_bool_flag and self.secondary_opts:
- parser.add_option(self.opts, action=action + '_const',
- const=True, **kwargs)
- parser.add_option(self.secondary_opts, action=action +
- '_const', const=False, **kwargs)
- else:
- parser.add_option(self.opts, action=action + '_const',
- const=self.flag_value,
- **kwargs)
- else:
- kwargs['action'] = action
- parser.add_option(self.opts, **kwargs)
-
- def get_help_record(self, ctx):
- if self.hidden:
- return
- any_prefix_is_slash = []
-
- def _write_opts(opts):
- rv, any_slashes = join_options(opts)
- if any_slashes:
- any_prefix_is_slash[:] = [True]
- if not self.is_flag and not self.count:
- rv += ' ' + self.make_metavar()
- return rv
-
- rv = [_write_opts(self.opts)]
- if self.secondary_opts:
- rv.append(_write_opts(self.secondary_opts))
-
- help = self.help or ''
- extra = []
- if self.show_envvar:
- envvar = self.envvar
- if envvar is None:
- if self.allow_from_autoenv and \
- ctx.auto_envvar_prefix is not None:
- envvar = '%s_%s' % (ctx.auto_envvar_prefix, self.name.upper())
- if envvar is not None:
- extra.append('env var: %s' % (
- ', '.join('%s' % d for d in envvar)
- if isinstance(envvar, (list, tuple))
- else envvar, ))
- if self.default is not None and self.show_default:
- if isinstance(self.show_default, string_types):
- default_string = '({})'.format(self.show_default)
- elif isinstance(self.default, (list, tuple)):
- default_string = ', '.join('%s' % d for d in self.default)
- elif inspect.isfunction(self.default):
- default_string = "(dynamic)"
- else:
- default_string = self.default
- extra.append('default: {}'.format(default_string))
-
- if self.required:
- extra.append('required')
- if extra:
- help = '%s[%s]' % (help and help + ' ' or '', '; '.join(extra))
-
- return ((any_prefix_is_slash and '; ' or ' / ').join(rv), help)
-
- def get_default(self, ctx):
- # If we're a non boolean flag out default is more complex because
- # we need to look at all flags in the same group to figure out
- # if we're the the default one in which case we return the flag
- # value as default.
- if self.is_flag and not self.is_bool_flag:
- for param in ctx.command.params:
- if param.name == self.name and param.default:
- return param.flag_value
- return None
- return Parameter.get_default(self, ctx)
-
- def prompt_for_value(self, ctx):
- """This is an alternative flow that can be activated in the full
- value processing if a value does not exist. It will prompt the
- user until a valid value exists and then returns the processed
- value as result.
- """
- # Calculate the default before prompting anything to be stable.
- default = self.get_default(ctx)
-
- # If this is a prompt for a flag we need to handle this
- # differently.
- if self.is_bool_flag:
- return confirm(self.prompt, default)
-
- return prompt(self.prompt, default=default, type=self.type,
- hide_input=self.hide_input, show_choices=self.show_choices,
- confirmation_prompt=self.confirmation_prompt,
- value_proc=lambda x: self.process_value(ctx, x))
-
- def resolve_envvar_value(self, ctx):
- rv = Parameter.resolve_envvar_value(self, ctx)
- if rv is not None:
- return rv
- if self.allow_from_autoenv and \
- ctx.auto_envvar_prefix is not None:
- envvar = '%s_%s' % (ctx.auto_envvar_prefix, self.name.upper())
- return os.environ.get(envvar)
-
- def value_from_envvar(self, ctx):
- rv = self.resolve_envvar_value(ctx)
- if rv is None:
- return None
- value_depth = (self.nargs != 1) + bool(self.multiple)
- if value_depth > 0 and rv is not None:
- rv = self.type.split_envvar_value(rv)
- if self.multiple and self.nargs != 1:
- rv = batch(rv, self.nargs)
- return rv
-
- def full_process_value(self, ctx, value):
- if value is None and self.prompt is not None \
- and not ctx.resilient_parsing:
- return self.prompt_for_value(ctx)
- return Parameter.full_process_value(self, ctx, value)
-
-
-class Argument(Parameter):
- """Arguments are positional parameters to a command. They generally
- provide fewer features than options but can have infinite ``nargs``
- and are required by default.
-
- All parameters are passed onwards to the parameter constructor.
- """
- param_type_name = 'argument'
-
- def __init__(self, param_decls, required=None, **attrs):
- if required is None:
- if attrs.get('default') is not None:
- required = False
- else:
- required = attrs.get('nargs', 1) > 0
- Parameter.__init__(self, param_decls, required=required, **attrs)
- if self.default is not None and self.nargs < 0:
- raise TypeError('nargs=-1 in combination with a default value '
- 'is not supported.')
-
- @property
- def human_readable_name(self):
- if self.metavar is not None:
- return self.metavar
- return self.name.upper()
-
- def make_metavar(self):
- if self.metavar is not None:
- return self.metavar
- var = self.type.get_metavar(self)
- if not var:
- var = self.name.upper()
- if not self.required:
- var = '[%s]' % var
- if self.nargs != 1:
- var += '...'
- return var
-
- def _parse_decls(self, decls, expose_value):
- if not decls:
- if not expose_value:
- return None, [], []
- raise TypeError('Could not determine name for argument')
- if len(decls) == 1:
- name = arg = decls[0]
- name = name.replace('-', '_').lower()
- else:
- raise TypeError('Arguments take exactly one '
- 'parameter declaration, got %d' % len(decls))
- return name, [arg], []
-
- def get_usage_pieces(self, ctx):
- return [self.make_metavar()]
-
- def get_error_hint(self, ctx):
- return '"%s"' % self.make_metavar()
-
- def add_to_parser(self, parser, ctx):
- parser.add_argument(dest=self.name, nargs=self.nargs,
- obj=self)
-
-
-# Circular dependency between decorators and core
-from .decorators import command, group
diff --git a/python/click/decorators.py b/python/click/decorators.py
deleted file mode 100644
index c57c530..0000000
--- a/python/click/decorators.py
+++ /dev/null
@@ -1,311 +0,0 @@
-import sys
-import inspect
-
-from functools import update_wrapper
-
-from ._compat import iteritems
-from ._unicodefun import _check_for_unicode_literals
-from .utils import echo
-from .globals import get_current_context
-
-
-def pass_context(f):
- """Marks a callback as wanting to receive the current context
- object as first argument.
- """
- def new_func(*args, **kwargs):
- return f(get_current_context(), *args, **kwargs)
- return update_wrapper(new_func, f)
-
-
-def pass_obj(f):
- """Similar to :func:`pass_context`, but only pass the object on the
- context onwards (:attr:`Context.obj`). This is useful if that object
- represents the state of a nested system.
- """
- def new_func(*args, **kwargs):
- return f(get_current_context().obj, *args, **kwargs)
- return update_wrapper(new_func, f)
-
-
-def make_pass_decorator(object_type, ensure=False):
- """Given an object type this creates a decorator that will work
- similar to :func:`pass_obj` but instead of passing the object of the
- current context, it will find the innermost context of type
- :func:`object_type`.
-
- This generates a decorator that works roughly like this::
-
- from functools import update_wrapper
-
- def decorator(f):
- @pass_context
- def new_func(ctx, *args, **kwargs):
- obj = ctx.find_object(object_type)
- return ctx.invoke(f, obj, *args, **kwargs)
- return update_wrapper(new_func, f)
- return decorator
-
- :param object_type: the type of the object to pass.
- :param ensure: if set to `True`, a new object will be created and
- remembered on the context if it's not there yet.
- """
- def decorator(f):
- def new_func(*args, **kwargs):
- ctx = get_current_context()
- if ensure:
- obj = ctx.ensure_object(object_type)
- else:
- obj = ctx.find_object(object_type)
- if obj is None:
- raise RuntimeError('Managed to invoke callback without a '
- 'context object of type %r existing'
- % object_type.__name__)
- return ctx.invoke(f, obj, *args, **kwargs)
- return update_wrapper(new_func, f)
- return decorator
-
-
-def _make_command(f, name, attrs, cls):
- if isinstance(f, Command):
- raise TypeError('Attempted to convert a callback into a '
- 'command twice.')
- try:
- params = f.__click_params__
- params.reverse()
- del f.__click_params__
- except AttributeError:
- params = []
- help = attrs.get('help')
- if help is None:
- help = inspect.getdoc(f)
- if isinstance(help, bytes):
- help = help.decode('utf-8')
- else:
- help = inspect.cleandoc(help)
- attrs['help'] = help
- _check_for_unicode_literals()
- return cls(name=name or f.__name__.lower().replace('_', '-'),
- callback=f, params=params, **attrs)
-
-
-def command(name=None, cls=None, **attrs):
- r"""Creates a new :class:`Command` and uses the decorated function as
- callback. This will also automatically attach all decorated
- :func:`option`\s and :func:`argument`\s as parameters to the command.
-
- The name of the command defaults to the name of the function. If you
- want to change that, you can pass the intended name as the first
- argument.
-
- All keyword arguments are forwarded to the underlying command class.
-
- Once decorated the function turns into a :class:`Command` instance
- that can be invoked as a command line utility or be attached to a
- command :class:`Group`.
-
- :param name: the name of the command. This defaults to the function
- name with underscores replaced by dashes.
- :param cls: the command class to instantiate. This defaults to
- :class:`Command`.
- """
- if cls is None:
- cls = Command
- def decorator(f):
- cmd = _make_command(f, name, attrs, cls)
- cmd.__doc__ = f.__doc__
- return cmd
- return decorator
-
-
-def group(name=None, **attrs):
- """Creates a new :class:`Group` with a function as callback. This
- works otherwise the same as :func:`command` just that the `cls`
- parameter is set to :class:`Group`.
- """
- attrs.setdefault('cls', Group)
- return command(name, **attrs)
-
-
-def _param_memo(f, param):
- if isinstance(f, Command):
- f.params.append(param)
- else:
- if not hasattr(f, '__click_params__'):
- f.__click_params__ = []
- f.__click_params__.append(param)
-
-
-def argument(*param_decls, **attrs):
- """Attaches an argument to the command. All positional arguments are
- passed as parameter declarations to :class:`Argument`; all keyword
- arguments are forwarded unchanged (except ``cls``).
- This is equivalent to creating an :class:`Argument` instance manually
- and attaching it to the :attr:`Command.params` list.
-
- :param cls: the argument class to instantiate. This defaults to
- :class:`Argument`.
- """
- def decorator(f):
- ArgumentClass = attrs.pop('cls', Argument)
- _param_memo(f, ArgumentClass(param_decls, **attrs))
- return f
- return decorator
-
-
-def option(*param_decls, **attrs):
- """Attaches an option to the command. All positional arguments are
- passed as parameter declarations to :class:`Option`; all keyword
- arguments are forwarded unchanged (except ``cls``).
- This is equivalent to creating an :class:`Option` instance manually
- and attaching it to the :attr:`Command.params` list.
-
- :param cls: the option class to instantiate. This defaults to
- :class:`Option`.
- """
- def decorator(f):
- # Issue 926, copy attrs, so pre-defined options can re-use the same cls=
- option_attrs = attrs.copy()
-
- if 'help' in option_attrs:
- option_attrs['help'] = inspect.cleandoc(option_attrs['help'])
- OptionClass = option_attrs.pop('cls', Option)
- _param_memo(f, OptionClass(param_decls, **option_attrs))
- return f
- return decorator
-
-
-def confirmation_option(*param_decls, **attrs):
- """Shortcut for confirmation prompts that can be ignored by passing
- ``--yes`` as parameter.
-
- This is equivalent to decorating a function with :func:`option` with
- the following parameters::
-
- def callback(ctx, param, value):
- if not value:
- ctx.abort()
-
- @click.command()
- @click.option('--yes', is_flag=True, callback=callback,
- expose_value=False, prompt='Do you want to continue?')
- def dropdb():
- pass
- """
- def decorator(f):
- def callback(ctx, param, value):
- if not value:
- ctx.abort()
- attrs.setdefault('is_flag', True)
- attrs.setdefault('callback', callback)
- attrs.setdefault('expose_value', False)
- attrs.setdefault('prompt', 'Do you want to continue?')
- attrs.setdefault('help', 'Confirm the action without prompting.')
- return option(*(param_decls or ('--yes',)), **attrs)(f)
- return decorator
-
-
-def password_option(*param_decls, **attrs):
- """Shortcut for password prompts.
-
- This is equivalent to decorating a function with :func:`option` with
- the following parameters::
-
- @click.command()
- @click.option('--password', prompt=True, confirmation_prompt=True,
- hide_input=True)
- def changeadmin(password):
- pass
- """
- def decorator(f):
- attrs.setdefault('prompt', True)
- attrs.setdefault('confirmation_prompt', True)
- attrs.setdefault('hide_input', True)
- return option(*(param_decls or ('--password',)), **attrs)(f)
- return decorator
-
-
-def version_option(version=None, *param_decls, **attrs):
- """Adds a ``--version`` option which immediately ends the program
- printing out the version number. This is implemented as an eager
- option that prints the version and exits the program in the callback.
-
- :param version: the version number to show. If not provided Click
- attempts an auto discovery via setuptools.
- :param prog_name: the name of the program (defaults to autodetection)
- :param message: custom message to show instead of the default
- (``'%(prog)s, version %(version)s'``)
- :param others: everything else is forwarded to :func:`option`.
- """
- if version is None:
- if hasattr(sys, '_getframe'):
- module = sys._getframe(1).f_globals.get('__name__')
- else:
- module = ''
-
- def decorator(f):
- prog_name = attrs.pop('prog_name', None)
- message = attrs.pop('message', '%(prog)s, version %(version)s')
-
- def callback(ctx, param, value):
- if not value or ctx.resilient_parsing:
- return
- prog = prog_name
- if prog is None:
- prog = ctx.find_root().info_name
- ver = version
- if ver is None:
- try:
- import pkg_resources
- except ImportError:
- pass
- else:
- for dist in pkg_resources.working_set:
- scripts = dist.get_entry_map().get('console_scripts') or {}
- for script_name, entry_point in iteritems(scripts):
- if entry_point.module_name == module:
- ver = dist.version
- break
- if ver is None:
- raise RuntimeError('Could not determine version')
- echo(message % {
- 'prog': prog,
- 'version': ver,
- }, color=ctx.color)
- ctx.exit()
-
- attrs.setdefault('is_flag', True)
- attrs.setdefault('expose_value', False)
- attrs.setdefault('is_eager', True)
- attrs.setdefault('help', 'Show the version and exit.')
- attrs['callback'] = callback
- return option(*(param_decls or ('--version',)), **attrs)(f)
- return decorator
-
-
-def help_option(*param_decls, **attrs):
- """Adds a ``--help`` option which immediately ends the program
- printing out the help page. This is usually unnecessary to add as
- this is added by default to all commands unless suppressed.
-
- Like :func:`version_option`, this is implemented as eager option that
- prints in the callback and exits.
-
- All arguments are forwarded to :func:`option`.
- """
- def decorator(f):
- def callback(ctx, param, value):
- if value and not ctx.resilient_parsing:
- echo(ctx.get_help(), color=ctx.color)
- ctx.exit()
- attrs.setdefault('is_flag', True)
- attrs.setdefault('expose_value', False)
- attrs.setdefault('help', 'Show this message and exit.')
- attrs.setdefault('is_eager', True)
- attrs['callback'] = callback
- return option(*(param_decls or ('--help',)), **attrs)(f)
- return decorator
-
-
-# Circular dependencies between core and decorators
-from .core import Command, Group, Argument, Option
diff --git a/python/click/exceptions.py b/python/click/exceptions.py
deleted file mode 100644
index 6fa1765..0000000
--- a/python/click/exceptions.py
+++ /dev/null
@@ -1,235 +0,0 @@
-from ._compat import PY2, filename_to_ui, get_text_stderr
-from .utils import echo
-
-
-def _join_param_hints(param_hint):
- if isinstance(param_hint, (tuple, list)):
- return ' / '.join('"%s"' % x for x in param_hint)
- return param_hint
-
-
-class ClickException(Exception):
- """An exception that Click can handle and show to the user."""
-
- #: The exit code for this exception
- exit_code = 1
-
- def __init__(self, message):
- ctor_msg = message
- if PY2:
- if ctor_msg is not None:
- ctor_msg = ctor_msg.encode('utf-8')
- Exception.__init__(self, ctor_msg)
- self.message = message
-
- def format_message(self):
- return self.message
-
- def __str__(self):
- return self.message
-
- if PY2:
- __unicode__ = __str__
-
- def __str__(self):
- return self.message.encode('utf-8')
-
- def show(self, file=None):
- if file is None:
- file = get_text_stderr()
- echo('Error: %s' % self.format_message(), file=file)
-
-
-class UsageError(ClickException):
- """An internal exception that signals a usage error. This typically
- aborts any further handling.
-
- :param message: the error message to display.
- :param ctx: optionally the context that caused this error. Click will
- fill in the context automatically in some situations.
- """
- exit_code = 2
-
- def __init__(self, message, ctx=None):
- ClickException.__init__(self, message)
- self.ctx = ctx
- self.cmd = self.ctx and self.ctx.command or None
-
- def show(self, file=None):
- if file is None:
- file = get_text_stderr()
- color = None
- hint = ''
- if (self.cmd is not None and
- self.cmd.get_help_option(self.ctx) is not None):
- hint = ('Try "%s %s" for help.\n'
- % (self.ctx.command_path, self.ctx.help_option_names[0]))
- if self.ctx is not None:
- color = self.ctx.color
- echo(self.ctx.get_usage() + '\n%s' % hint, file=file, color=color)
- echo('Error: %s' % self.format_message(), file=file, color=color)
-
-
-class BadParameter(UsageError):
- """An exception that formats out a standardized error message for a
- bad parameter. This is useful when thrown from a callback or type as
- Click will attach contextual information to it (for instance, which
- parameter it is).
-
- .. versionadded:: 2.0
-
- :param param: the parameter object that caused this error. This can
- be left out, and Click will attach this info itself
- if possible.
- :param param_hint: a string that shows up as parameter name. This
- can be used as alternative to `param` in cases
- where custom validation should happen. If it is
- a string it's used as such, if it's a list then
- each item is quoted and separated.
- """
-
- def __init__(self, message, ctx=None, param=None,
- param_hint=None):
- UsageError.__init__(self, message, ctx)
- self.param = param
- self.param_hint = param_hint
-
- def format_message(self):
- if self.param_hint is not None:
- param_hint = self.param_hint
- elif self.param is not None:
- param_hint = self.param.get_error_hint(self.ctx)
- else:
- return 'Invalid value: %s' % self.message
- param_hint = _join_param_hints(param_hint)
-
- return 'Invalid value for %s: %s' % (param_hint, self.message)
-
-
-class MissingParameter(BadParameter):
- """Raised if click required an option or argument but it was not
- provided when invoking the script.
-
- .. versionadded:: 4.0
-
- :param param_type: a string that indicates the type of the parameter.
- The default is to inherit the parameter type from
- the given `param`. Valid values are ``'parameter'``,
- ``'option'`` or ``'argument'``.
- """
-
- def __init__(self, message=None, ctx=None, param=None,
- param_hint=None, param_type=None):
- BadParameter.__init__(self, message, ctx, param, param_hint)
- self.param_type = param_type
-
- def format_message(self):
- if self.param_hint is not None:
- param_hint = self.param_hint
- elif self.param is not None:
- param_hint = self.param.get_error_hint(self.ctx)
- else:
- param_hint = None
- param_hint = _join_param_hints(param_hint)
-
- param_type = self.param_type
- if param_type is None and self.param is not None:
- param_type = self.param.param_type_name
-
- msg = self.message
- if self.param is not None:
- msg_extra = self.param.type.get_missing_message(self.param)
- if msg_extra:
- if msg:
- msg += '. ' + msg_extra
- else:
- msg = msg_extra
-
- return 'Missing %s%s%s%s' % (
- param_type,
- param_hint and ' %s' % param_hint or '',
- msg and '. ' or '.',
- msg or '',
- )
-
-
-class NoSuchOption(UsageError):
- """Raised if click attempted to handle an option that does not
- exist.
-
- .. versionadded:: 4.0
- """
-
- def __init__(self, option_name, message=None, possibilities=None,
- ctx=None):
- if message is None:
- message = 'no such option: %s' % option_name
- UsageError.__init__(self, message, ctx)
- self.option_name = option_name
- self.possibilities = possibilities
-
- def format_message(self):
- bits = [self.message]
- if self.possibilities:
- if len(self.possibilities) == 1:
- bits.append('Did you mean %s?' % self.possibilities[0])
- else:
- possibilities = sorted(self.possibilities)
- bits.append('(Possible options: %s)' % ', '.join(possibilities))
- return ' '.join(bits)
-
-
-class BadOptionUsage(UsageError):
- """Raised if an option is generally supplied but the use of the option
- was incorrect. This is for instance raised if the number of arguments
- for an option is not correct.
-
- .. versionadded:: 4.0
-
- :param option_name: the name of the option being used incorrectly.
- """
-
- def __init__(self, option_name, message, ctx=None):
- UsageError.__init__(self, message, ctx)
- self.option_name = option_name
-
-
-class BadArgumentUsage(UsageError):
- """Raised if an argument is generally supplied but the use of the argument
- was incorrect. This is for instance raised if the number of values
- for an argument is not correct.
-
- .. versionadded:: 6.0
- """
-
- def __init__(self, message, ctx=None):
- UsageError.__init__(self, message, ctx)
-
-
-class FileError(ClickException):
- """Raised if a file cannot be opened."""
-
- def __init__(self, filename, hint=None):
- ui_filename = filename_to_ui(filename)
- if hint is None:
- hint = 'unknown error'
- ClickException.__init__(self, hint)
- self.ui_filename = ui_filename
- self.filename = filename
-
- def format_message(self):
- return 'Could not open file %s: %s' % (self.ui_filename, self.message)
-
-
-class Abort(RuntimeError):
- """An internal signalling exception that signals Click to abort."""
-
-
-class Exit(RuntimeError):
- """An exception that indicates that the application should exit with some
- status code.
-
- :param code: the status code to exit with.
- """
- def __init__(self, code=0):
- self.exit_code = code
diff --git a/python/click/formatting.py b/python/click/formatting.py
deleted file mode 100644
index a3d6a4d..0000000
--- a/python/click/formatting.py
+++ /dev/null
@@ -1,256 +0,0 @@
-from contextlib import contextmanager
-from .termui import get_terminal_size
-from .parser import split_opt
-from ._compat import term_len
-
-
-# Can force a width. This is used by the test system
-FORCED_WIDTH = None
-
-
-def measure_table(rows):
- widths = {}
- for row in rows:
- for idx, col in enumerate(row):
- widths[idx] = max(widths.get(idx, 0), term_len(col))
- return tuple(y for x, y in sorted(widths.items()))
-
-
-def iter_rows(rows, col_count):
- for row in rows:
- row = tuple(row)
- yield row + ('',) * (col_count - len(row))
-
-
-def wrap_text(text, width=78, initial_indent='', subsequent_indent='',
- preserve_paragraphs=False):
- """A helper function that intelligently wraps text. By default, it
- assumes that it operates on a single paragraph of text but if the
- `preserve_paragraphs` parameter is provided it will intelligently
- handle paragraphs (defined by two empty lines).
-
- If paragraphs are handled, a paragraph can be prefixed with an empty
- line containing the ``\\b`` character (``\\x08``) to indicate that
- no rewrapping should happen in that block.
-
- :param text: the text that should be rewrapped.
- :param width: the maximum width for the text.
- :param initial_indent: the initial indent that should be placed on the
- first line as a string.
- :param subsequent_indent: the indent string that should be placed on
- each consecutive line.
- :param preserve_paragraphs: if this flag is set then the wrapping will
- intelligently handle paragraphs.
- """
- from ._textwrap import TextWrapper
- text = text.expandtabs()
- wrapper = TextWrapper(width, initial_indent=initial_indent,
- subsequent_indent=subsequent_indent,
- replace_whitespace=False)
- if not preserve_paragraphs:
- return wrapper.fill(text)
-
- p = []
- buf = []
- indent = None
-
- def _flush_par():
- if not buf:
- return
- if buf[0].strip() == '\b':
- p.append((indent or 0, True, '\n'.join(buf[1:])))
- else:
- p.append((indent or 0, False, ' '.join(buf)))
- del buf[:]
-
- for line in text.splitlines():
- if not line:
- _flush_par()
- indent = None
- else:
- if indent is None:
- orig_len = term_len(line)
- line = line.lstrip()
- indent = orig_len - term_len(line)
- buf.append(line)
- _flush_par()
-
- rv = []
- for indent, raw, text in p:
- with wrapper.extra_indent(' ' * indent):
- if raw:
- rv.append(wrapper.indent_only(text))
- else:
- rv.append(wrapper.fill(text))
-
- return '\n\n'.join(rv)
-
-
-class HelpFormatter(object):
- """This class helps with formatting text-based help pages. It's
- usually just needed for very special internal cases, but it's also
- exposed so that developers can write their own fancy outputs.
-
- At present, it always writes into memory.
-
- :param indent_increment: the additional increment for each level.
- :param width: the width for the text. This defaults to the terminal
- width clamped to a maximum of 78.
- """
-
- def __init__(self, indent_increment=2, width=None, max_width=None):
- self.indent_increment = indent_increment
- if max_width is None:
- max_width = 80
- if width is None:
- width = FORCED_WIDTH
- if width is None:
- width = max(min(get_terminal_size()[0], max_width) - 2, 50)
- self.width = width
- self.current_indent = 0
- self.buffer = []
-
- def write(self, string):
- """Writes a unicode string into the internal buffer."""
- self.buffer.append(string)
-
- def indent(self):
- """Increases the indentation."""
- self.current_indent += self.indent_increment
-
- def dedent(self):
- """Decreases the indentation."""
- self.current_indent -= self.indent_increment
-
- def write_usage(self, prog, args='', prefix='Usage: '):
- """Writes a usage line into the buffer.
-
- :param prog: the program name.
- :param args: whitespace separated list of arguments.
- :param prefix: the prefix for the first line.
- """
- usage_prefix = '%*s%s ' % (self.current_indent, prefix, prog)
- text_width = self.width - self.current_indent
-
- if text_width >= (term_len(usage_prefix) + 20):
- # The arguments will fit to the right of the prefix.
- indent = ' ' * term_len(usage_prefix)
- self.write(wrap_text(args, text_width,
- initial_indent=usage_prefix,
- subsequent_indent=indent))
- else:
- # The prefix is too long, put the arguments on the next line.
- self.write(usage_prefix)
- self.write('\n')
- indent = ' ' * (max(self.current_indent, term_len(prefix)) + 4)
- self.write(wrap_text(args, text_width,
- initial_indent=indent,
- subsequent_indent=indent))
-
- self.write('\n')
-
- def write_heading(self, heading):
- """Writes a heading into the buffer."""
- self.write('%*s%s:\n' % (self.current_indent, '', heading))
-
- def write_paragraph(self):
- """Writes a paragraph into the buffer."""
- if self.buffer:
- self.write('\n')
-
- def write_text(self, text):
- """Writes re-indented text into the buffer. This rewraps and
- preserves paragraphs.
- """
- text_width = max(self.width - self.current_indent, 11)
- indent = ' ' * self.current_indent
- self.write(wrap_text(text, text_width,
- initial_indent=indent,
- subsequent_indent=indent,
- preserve_paragraphs=True))
- self.write('\n')
-
- def write_dl(self, rows, col_max=30, col_spacing=2):
- """Writes a definition list into the buffer. This is how options
- and commands are usually formatted.
-
- :param rows: a list of two item tuples for the terms and values.
- :param col_max: the maximum width of the first column.
- :param col_spacing: the number of spaces between the first and
- second column.
- """
- rows = list(rows)
- widths = measure_table(rows)
- if len(widths) != 2:
- raise TypeError('Expected two columns for definition list')
-
- first_col = min(widths[0], col_max) + col_spacing
-
- for first, second in iter_rows(rows, len(widths)):
- self.write('%*s%s' % (self.current_indent, '', first))
- if not second:
- self.write('\n')
- continue
- if term_len(first) <= first_col - col_spacing:
- self.write(' ' * (first_col - term_len(first)))
- else:
- self.write('\n')
- self.write(' ' * (first_col + self.current_indent))
-
- text_width = max(self.width - first_col - 2, 10)
- lines = iter(wrap_text(second, text_width).splitlines())
- if lines:
- self.write(next(lines) + '\n')
- for line in lines:
- self.write('%*s%s\n' % (
- first_col + self.current_indent, '', line))
- else:
- self.write('\n')
-
- @contextmanager
- def section(self, name):
- """Helpful context manager that writes a paragraph, a heading,
- and the indents.
-
- :param name: the section name that is written as heading.
- """
- self.write_paragraph()
- self.write_heading(name)
- self.indent()
- try:
- yield
- finally:
- self.dedent()
-
- @contextmanager
- def indentation(self):
- """A context manager that increases the indentation."""
- self.indent()
- try:
- yield
- finally:
- self.dedent()
-
- def getvalue(self):
- """Returns the buffer contents."""
- return ''.join(self.buffer)
-
-
-def join_options(options):
- """Given a list of option strings this joins them in the most appropriate
- way and returns them in the form ``(formatted_string,
- any_prefix_is_slash)`` where the second item in the tuple is a flag that
- indicates if any of the option prefixes was a slash.
- """
- rv = []
- any_prefix_is_slash = False
- for opt in options:
- prefix = split_opt(opt)[0]
- if prefix == '/':
- any_prefix_is_slash = True
- rv.append((len(prefix), opt))
-
- rv.sort(key=lambda x: x[0])
-
- rv = ', '.join(x[1] for x in rv)
- return rv, any_prefix_is_slash
diff --git a/python/click/globals.py b/python/click/globals.py
deleted file mode 100644
index 843b594..0000000
--- a/python/click/globals.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from threading import local
-
-
-_local = local()
-
-
-def get_current_context(silent=False):
- """Returns the current click context. This can be used as a way to
- access the current context object from anywhere. This is a more implicit
- alternative to the :func:`pass_context` decorator. This function is
- primarily useful for helpers such as :func:`echo` which might be
- interested in changing its behavior based on the current context.
-
- To push the current context, :meth:`Context.scope` can be used.
-
- .. versionadded:: 5.0
-
- :param silent: is set to `True` the return value is `None` if no context
- is available. The default behavior is to raise a
- :exc:`RuntimeError`.
- """
- try:
- return getattr(_local, 'stack')[-1]
- except (AttributeError, IndexError):
- if not silent:
- raise RuntimeError('There is no active click context.')
-
-
-def push_context(ctx):
- """Pushes a new context to the current stack."""
- _local.__dict__.setdefault('stack', []).append(ctx)
-
-
-def pop_context():
- """Removes the top level from the stack."""
- _local.stack.pop()
-
-
-def resolve_color_default(color=None):
- """"Internal helper to get the default value of the color flag. If a
- value is passed it's returned unchanged, otherwise it's looked up from
- the current context.
- """
- if color is not None:
- return color
- ctx = get_current_context(silent=True)
- if ctx is not None:
- return ctx.color
diff --git a/python/click/parser.py b/python/click/parser.py
deleted file mode 100644
index 1c3ae9c..0000000
--- a/python/click/parser.py
+++ /dev/null
@@ -1,427 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-click.parser
-~~~~~~~~~~~~
-
-This module started out as largely a copy paste from the stdlib's
-optparse module with the features removed that we do not need from
-optparse because we implement them in Click on a higher level (for
-instance type handling, help formatting and a lot more).
-
-The plan is to remove more and more from here over time.
-
-The reason this is a different module and not optparse from the stdlib
-is that there are differences in 2.x and 3.x about the error messages
-generated and optparse in the stdlib uses gettext for no good reason
-and might cause us issues.
-"""
-
-import re
-from collections import deque
-from .exceptions import UsageError, NoSuchOption, BadOptionUsage, \
- BadArgumentUsage
-
-
-def _unpack_args(args, nargs_spec):
- """Given an iterable of arguments and an iterable of nargs specifications,
- it returns a tuple with all the unpacked arguments at the first index
- and all remaining arguments as the second.
-
- The nargs specification is the number of arguments that should be consumed
- or `-1` to indicate that this position should eat up all the remainders.
-
- Missing items are filled with `None`.
- """
- args = deque(args)
- nargs_spec = deque(nargs_spec)
- rv = []
- spos = None
-
- def _fetch(c):
- try:
- if spos is None:
- return c.popleft()
- else:
- return c.pop()
- except IndexError:
- return None
-
- while nargs_spec:
- nargs = _fetch(nargs_spec)
- if nargs == 1:
- rv.append(_fetch(args))
- elif nargs > 1:
- x = [_fetch(args) for _ in range(nargs)]
- # If we're reversed, we're pulling in the arguments in reverse,
- # so we need to turn them around.
- if spos is not None:
- x.reverse()
- rv.append(tuple(x))
- elif nargs < 0:
- if spos is not None:
- raise TypeError('Cannot have two nargs < 0')
- spos = len(rv)
- rv.append(None)
-
- # spos is the position of the wildcard (star). If it's not `None`,
- # we fill it with the remainder.
- if spos is not None:
- rv[spos] = tuple(args)
- args = []
- rv[spos + 1:] = reversed(rv[spos + 1:])
-
- return tuple(rv), list(args)
-
-
-def _error_opt_args(nargs, opt):
- if nargs == 1:
- raise BadOptionUsage(opt, '%s option requires an argument' % opt)
- raise BadOptionUsage(opt, '%s option requires %d arguments' % (opt, nargs))
-
-
-def split_opt(opt):
- first = opt[:1]
- if first.isalnum():
- return '', opt
- if opt[1:2] == first:
- return opt[:2], opt[2:]
- return first, opt[1:]
-
-
-def normalize_opt(opt, ctx):
- if ctx is None or ctx.token_normalize_func is None:
- return opt
- prefix, opt = split_opt(opt)
- return prefix + ctx.token_normalize_func(opt)
-
-
-def split_arg_string(string):
- """Given an argument string this attempts to split it into small parts."""
- rv = []
- for match in re.finditer(r"('([^'\\]*(?:\\.[^'\\]*)*)'"
- r'|"([^"\\]*(?:\\.[^"\\]*)*)"'
- r'|\S+)\s*', string, re.S):
- arg = match.group().strip()
- if arg[:1] == arg[-1:] and arg[:1] in '"\'':
- arg = arg[1:-1].encode('ascii', 'backslashreplace') \
- .decode('unicode-escape')
- try:
- arg = type(string)(arg)
- except UnicodeError:
- pass
- rv.append(arg)
- return rv
-
-
-class Option(object):
-
- def __init__(self, opts, dest, action=None, nargs=1, const=None, obj=None):
- self._short_opts = []
- self._long_opts = []
- self.prefixes = set()
-
- for opt in opts:
- prefix, value = split_opt(opt)
- if not prefix:
- raise ValueError('Invalid start character for option (%s)'
- % opt)
- self.prefixes.add(prefix[0])
- if len(prefix) == 1 and len(value) == 1:
- self._short_opts.append(opt)
- else:
- self._long_opts.append(opt)
- self.prefixes.add(prefix)
-
- if action is None:
- action = 'store'
-
- self.dest = dest
- self.action = action
- self.nargs = nargs
- self.const = const
- self.obj = obj
-
- @property
- def takes_value(self):
- return self.action in ('store', 'append')
-
- def process(self, value, state):
- if self.action == 'store':
- state.opts[self.dest] = value
- elif self.action == 'store_const':
- state.opts[self.dest] = self.const
- elif self.action == 'append':
- state.opts.setdefault(self.dest, []).append(value)
- elif self.action == 'append_const':
- state.opts.setdefault(self.dest, []).append(self.const)
- elif self.action == 'count':
- state.opts[self.dest] = state.opts.get(self.dest, 0) + 1
- else:
- raise ValueError('unknown action %r' % self.action)
- state.order.append(self.obj)
-
-
-class Argument(object):
-
- def __init__(self, dest, nargs=1, obj=None):
- self.dest = dest
- self.nargs = nargs
- self.obj = obj
-
- def process(self, value, state):
- if self.nargs > 1:
- holes = sum(1 for x in value if x is None)
- if holes == len(value):
- value = None
- elif holes != 0:
- raise BadArgumentUsage('argument %s takes %d values'
- % (self.dest, self.nargs))
- state.opts[self.dest] = value
- state.order.append(self.obj)
-
-
-class ParsingState(object):
-
- def __init__(self, rargs):
- self.opts = {}
- self.largs = []
- self.rargs = rargs
- self.order = []
-
-
-class OptionParser(object):
- """The option parser is an internal class that is ultimately used to
- parse options and arguments. It's modelled after optparse and brings
- a similar but vastly simplified API. It should generally not be used
- directly as the high level Click classes wrap it for you.
-
- It's not nearly as extensible as optparse or argparse as it does not
- implement features that are implemented on a higher level (such as
- types or defaults).
-
- :param ctx: optionally the :class:`~click.Context` where this parser
- should go with.
- """
-
- def __init__(self, ctx=None):
- #: The :class:`~click.Context` for this parser. This might be
- #: `None` for some advanced use cases.
- self.ctx = ctx
- #: This controls how the parser deals with interspersed arguments.
- #: If this is set to `False`, the parser will stop on the first
- #: non-option. Click uses this to implement nested subcommands
- #: safely.
- self.allow_interspersed_args = True
- #: This tells the parser how to deal with unknown options. By
- #: default it will error out (which is sensible), but there is a
- #: second mode where it will ignore it and continue processing
- #: after shifting all the unknown options into the resulting args.
- self.ignore_unknown_options = False
- if ctx is not None:
- self.allow_interspersed_args = ctx.allow_interspersed_args
- self.ignore_unknown_options = ctx.ignore_unknown_options
- self._short_opt = {}
- self._long_opt = {}
- self._opt_prefixes = set(['-', '--'])
- self._args = []
-
- def add_option(self, opts, dest, action=None, nargs=1, const=None,
- obj=None):
- """Adds a new option named `dest` to the parser. The destination
- is not inferred (unlike with optparse) and needs to be explicitly
- provided. Action can be any of ``store``, ``store_const``,
- ``append``, ``appnd_const`` or ``count``.
-
- The `obj` can be used to identify the option in the order list
- that is returned from the parser.
- """
- if obj is None:
- obj = dest
- opts = [normalize_opt(opt, self.ctx) for opt in opts]
- option = Option(opts, dest, action=action, nargs=nargs,
- const=const, obj=obj)
- self._opt_prefixes.update(option.prefixes)
- for opt in option._short_opts:
- self._short_opt[opt] = option
- for opt in option._long_opts:
- self._long_opt[opt] = option
-
- def add_argument(self, dest, nargs=1, obj=None):
- """Adds a positional argument named `dest` to the parser.
-
- The `obj` can be used to identify the option in the order list
- that is returned from the parser.
- """
- if obj is None:
- obj = dest
- self._args.append(Argument(dest=dest, nargs=nargs, obj=obj))
-
- def parse_args(self, args):
- """Parses positional arguments and returns ``(values, args, order)``
- for the parsed options and arguments as well as the leftover
- arguments if there are any. The order is a list of objects as they
- appear on the command line. If arguments appear multiple times they
- will be memorized multiple times as well.
- """
- state = ParsingState(args)
- try:
- self._process_args_for_options(state)
- self._process_args_for_args(state)
- except UsageError:
- if self.ctx is None or not self.ctx.resilient_parsing:
- raise
- return state.opts, state.largs, state.order
-
- def _process_args_for_args(self, state):
- pargs, args = _unpack_args(state.largs + state.rargs,
- [x.nargs for x in self._args])
-
- for idx, arg in enumerate(self._args):
- arg.process(pargs[idx], state)
-
- state.largs = args
- state.rargs = []
-
- def _process_args_for_options(self, state):
- while state.rargs:
- arg = state.rargs.pop(0)
- arglen = len(arg)
- # Double dashes always handled explicitly regardless of what
- # prefixes are valid.
- if arg == '--':
- return
- elif arg[:1] in self._opt_prefixes and arglen > 1:
- self._process_opts(arg, state)
- elif self.allow_interspersed_args:
- state.largs.append(arg)
- else:
- state.rargs.insert(0, arg)
- return
-
- # Say this is the original argument list:
- # [arg0, arg1, ..., arg(i-1), arg(i), arg(i+1), ..., arg(N-1)]
- # ^
- # (we are about to process arg(i)).
- #
- # Then rargs is [arg(i), ..., arg(N-1)] and largs is a *subset* of
- # [arg0, ..., arg(i-1)] (any options and their arguments will have
- # been removed from largs).
- #
- # The while loop will usually consume 1 or more arguments per pass.
- # If it consumes 1 (eg. arg is an option that takes no arguments),
- # then after _process_arg() is done the situation is:
- #
- # largs = subset of [arg0, ..., arg(i)]
- # rargs = [arg(i+1), ..., arg(N-1)]
- #
- # If allow_interspersed_args is false, largs will always be
- # *empty* -- still a subset of [arg0, ..., arg(i-1)], but
- # not a very interesting subset!
-
- def _match_long_opt(self, opt, explicit_value, state):
- if opt not in self._long_opt:
- possibilities = [word for word in self._long_opt
- if word.startswith(opt)]
- raise NoSuchOption(opt, possibilities=possibilities, ctx=self.ctx)
-
- option = self._long_opt[opt]
- if option.takes_value:
- # At this point it's safe to modify rargs by injecting the
- # explicit value, because no exception is raised in this
- # branch. This means that the inserted value will be fully
- # consumed.
- if explicit_value is not None:
- state.rargs.insert(0, explicit_value)
-
- nargs = option.nargs
- if len(state.rargs) < nargs:
- _error_opt_args(nargs, opt)
- elif nargs == 1:
- value = state.rargs.pop(0)
- else:
- value = tuple(state.rargs[:nargs])
- del state.rargs[:nargs]
-
- elif explicit_value is not None:
- raise BadOptionUsage(opt, '%s option does not take a value' % opt)
-
- else:
- value = None
-
- option.process(value, state)
-
- def _match_short_opt(self, arg, state):
- stop = False
- i = 1
- prefix = arg[0]
- unknown_options = []
-
- for ch in arg[1:]:
- opt = normalize_opt(prefix + ch, self.ctx)
- option = self._short_opt.get(opt)
- i += 1
-
- if not option:
- if self.ignore_unknown_options:
- unknown_options.append(ch)
- continue
- raise NoSuchOption(opt, ctx=self.ctx)
- if option.takes_value:
- # Any characters left in arg? Pretend they're the
- # next arg, and stop consuming characters of arg.
- if i < len(arg):
- state.rargs.insert(0, arg[i:])
- stop = True
-
- nargs = option.nargs
- if len(state.rargs) < nargs:
- _error_opt_args(nargs, opt)
- elif nargs == 1:
- value = state.rargs.pop(0)
- else:
- value = tuple(state.rargs[:nargs])
- del state.rargs[:nargs]
-
- else:
- value = None
-
- option.process(value, state)
-
- if stop:
- break
-
- # If we got any unknown options we re-combinate the string of the
- # remaining options and re-attach the prefix, then report that
- # to the state as new larg. This way there is basic combinatorics
- # that can be achieved while still ignoring unknown arguments.
- if self.ignore_unknown_options and unknown_options:
- state.largs.append(prefix + ''.join(unknown_options))
-
- def _process_opts(self, arg, state):
- explicit_value = None
- # Long option handling happens in two parts. The first part is
- # supporting explicitly attached values. In any case, we will try
- # to long match the option first.
- if '=' in arg:
- long_opt, explicit_value = arg.split('=', 1)
- else:
- long_opt = arg
- norm_long_opt = normalize_opt(long_opt, self.ctx)
-
- # At this point we will match the (assumed) long option through
- # the long option matching code. Note that this allows options
- # like "-foo" to be matched as long options.
- try:
- self._match_long_opt(norm_long_opt, explicit_value, state)
- except NoSuchOption:
- # At this point the long option matching failed, and we need
- # to try with short options. However there is a special rule
- # which says, that if we have a two character options prefix
- # (applies to "--foo" for instance), we do not dispatch to the
- # short option code and will instead raise the no option
- # error.
- if arg[:2] not in self._opt_prefixes:
- return self._match_short_opt(arg, state)
- if not self.ignore_unknown_options:
- raise
- state.largs.append(arg)
diff --git a/python/click/termui.py b/python/click/termui.py
deleted file mode 100644
index bf9a3aa..0000000
--- a/python/click/termui.py
+++ /dev/null
@@ -1,606 +0,0 @@
-import os
-import sys
-import struct
-import inspect
-import itertools
-
-from ._compat import raw_input, text_type, string_types, \
- isatty, strip_ansi, get_winterm_size, DEFAULT_COLUMNS, WIN
-from .utils import echo
-from .exceptions import Abort, UsageError
-from .types import convert_type, Choice, Path
-from .globals import resolve_color_default
-
-
-# The prompt functions to use. The doc tools currently override these
-# functions to customize how they work.
-visible_prompt_func = raw_input
-
-_ansi_colors = {
- 'black': 30,
- 'red': 31,
- 'green': 32,
- 'yellow': 33,
- 'blue': 34,
- 'magenta': 35,
- 'cyan': 36,
- 'white': 37,
- 'reset': 39,
- 'bright_black': 90,
- 'bright_red': 91,
- 'bright_green': 92,
- 'bright_yellow': 93,
- 'bright_blue': 94,
- 'bright_magenta': 95,
- 'bright_cyan': 96,
- 'bright_white': 97,
-}
-_ansi_reset_all = '\033[0m'
-
-
-def hidden_prompt_func(prompt):
- import getpass
- return getpass.getpass(prompt)
-
-
-def _build_prompt(text, suffix, show_default=False, default=None, show_choices=True, type=None):
- prompt = text
- if type is not None and show_choices and isinstance(type, Choice):
- prompt += ' (' + ", ".join(map(str, type.choices)) + ')'
- if default is not None and show_default:
- prompt = '%s [%s]' % (prompt, default)
- return prompt + suffix
-
-
-def prompt(text, default=None, hide_input=False, confirmation_prompt=False,
- type=None, value_proc=None, prompt_suffix=': ', show_default=True,
- err=False, show_choices=True):
- """Prompts a user for input. This is a convenience function that can
- be used to prompt a user for input later.
-
- If the user aborts the input by sending a interrupt signal, this
- function will catch it and raise a :exc:`Abort` exception.
-
- .. versionadded:: 7.0
- Added the show_choices parameter.
-
- .. versionadded:: 6.0
- Added unicode support for cmd.exe on Windows.
-
- .. versionadded:: 4.0
- Added the `err` parameter.
-
- :param text: the text to show for the prompt.
- :param default: the default value to use if no input happens. If this
- is not given it will prompt until it's aborted.
- :param hide_input: if this is set to true then the input value will
- be hidden.
- :param confirmation_prompt: asks for confirmation for the value.
- :param type: the type to use to check the value against.
- :param value_proc: if this parameter is provided it's a function that
- is invoked instead of the type conversion to
- convert a value.
- :param prompt_suffix: a suffix that should be added to the prompt.
- :param show_default: shows or hides the default value in the prompt.
- :param err: if set to true the file defaults to ``stderr`` instead of
- ``stdout``, the same as with echo.
- :param show_choices: Show or hide choices if the passed type is a Choice.
- For example if type is a Choice of either day or week,
- show_choices is true and text is "Group by" then the
- prompt will be "Group by (day, week): ".
- """
- result = None
-
- def prompt_func(text):
- f = hide_input and hidden_prompt_func or visible_prompt_func
- try:
- # Write the prompt separately so that we get nice
- # coloring through colorama on Windows
- echo(text, nl=False, err=err)
- return f('')
- except (KeyboardInterrupt, EOFError):
- # getpass doesn't print a newline if the user aborts input with ^C.
- # Allegedly this behavior is inherited from getpass(3).
- # A doc bug has been filed at https://bugs.python.org/issue24711
- if hide_input:
- echo(None, err=err)
- raise Abort()
-
- if value_proc is None:
- value_proc = convert_type(type, default)
-
- prompt = _build_prompt(text, prompt_suffix, show_default, default, show_choices, type)
-
- while 1:
- while 1:
- value = prompt_func(prompt)
- if value:
- break
- elif default is not None:
- if isinstance(value_proc, Path):
- # validate Path default value(exists, dir_okay etc.)
- value = default
- break
- return default
- try:
- result = value_proc(value)
- except UsageError as e:
- echo('Error: %s' % e.message, err=err)
- continue
- if not confirmation_prompt:
- return result
- while 1:
- value2 = prompt_func('Repeat for confirmation: ')
- if value2:
- break
- if value == value2:
- return result
- echo('Error: the two entered values do not match', err=err)
-
-
-def confirm(text, default=False, abort=False, prompt_suffix=': ',
- show_default=True, err=False):
- """Prompts for confirmation (yes/no question).
-
- If the user aborts the input by sending a interrupt signal this
- function will catch it and raise a :exc:`Abort` exception.
-
- .. versionadded:: 4.0
- Added the `err` parameter.
-
- :param text: the question to ask.
- :param default: the default for the prompt.
- :param abort: if this is set to `True` a negative answer aborts the
- exception by raising :exc:`Abort`.
- :param prompt_suffix: a suffix that should be added to the prompt.
- :param show_default: shows or hides the default value in the prompt.
- :param err: if set to true the file defaults to ``stderr`` instead of
- ``stdout``, the same as with echo.
- """
- prompt = _build_prompt(text, prompt_suffix, show_default,
- default and 'Y/n' or 'y/N')
- while 1:
- try:
- # Write the prompt separately so that we get nice
- # coloring through colorama on Windows
- echo(prompt, nl=False, err=err)
- value = visible_prompt_func('').lower().strip()
- except (KeyboardInterrupt, EOFError):
- raise Abort()
- if value in ('y', 'yes'):
- rv = True
- elif value in ('n', 'no'):
- rv = False
- elif value == '':
- rv = default
- else:
- echo('Error: invalid input', err=err)
- continue
- break
- if abort and not rv:
- raise Abort()
- return rv
-
-
-def get_terminal_size():
- """Returns the current size of the terminal as tuple in the form
- ``(width, height)`` in columns and rows.
- """
- # If shutil has get_terminal_size() (Python 3.3 and later) use that
- if sys.version_info >= (3, 3):
- import shutil
- shutil_get_terminal_size = getattr(shutil, 'get_terminal_size', None)
- if shutil_get_terminal_size:
- sz = shutil_get_terminal_size()
- return sz.columns, sz.lines
-
- # We provide a sensible default for get_winterm_size() when being invoked
- # inside a subprocess. Without this, it would not provide a useful input.
- if get_winterm_size is not None:
- size = get_winterm_size()
- if size == (0, 0):
- return (79, 24)
- else:
- return size
-
- def ioctl_gwinsz(fd):
- try:
- import fcntl
- import termios
- cr = struct.unpack(
- 'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
- except Exception:
- return
- return cr
-
- cr = ioctl_gwinsz(0) or ioctl_gwinsz(1) or ioctl_gwinsz(2)
- if not cr:
- try:
- fd = os.open(os.ctermid(), os.O_RDONLY)
- try:
- cr = ioctl_gwinsz(fd)
- finally:
- os.close(fd)
- except Exception:
- pass
- if not cr or not cr[0] or not cr[1]:
- cr = (os.environ.get('LINES', 25),
- os.environ.get('COLUMNS', DEFAULT_COLUMNS))
- return int(cr[1]), int(cr[0])
-
-
-def echo_via_pager(text_or_generator, color=None):
- """This function takes a text and shows it via an environment specific
- pager on stdout.
-
- .. versionchanged:: 3.0
- Added the `color` flag.
-
- :param text_or_generator: the text to page, or alternatively, a
- generator emitting the text to page.
- :param color: controls if the pager supports ANSI colors or not. The
- default is autodetection.
- """
- color = resolve_color_default(color)
-
- if inspect.isgeneratorfunction(text_or_generator):
- i = text_or_generator()
- elif isinstance(text_or_generator, string_types):
- i = [text_or_generator]
- else:
- i = iter(text_or_generator)
-
- # convert every element of i to a text type if necessary
- text_generator = (el if isinstance(el, string_types) else text_type(el)
- for el in i)
-
- from ._termui_impl import pager
- return pager(itertools.chain(text_generator, "\n"), color)
-
-
-def progressbar(iterable=None, length=None, label=None, show_eta=True,
- show_percent=None, show_pos=False,
- item_show_func=None, fill_char='#', empty_char='-',
- bar_template='%(label)s [%(bar)s] %(info)s',
- info_sep=' ', width=36, file=None, color=None):
- """This function creates an iterable context manager that can be used
- to iterate over something while showing a progress bar. It will
- either iterate over the `iterable` or `length` items (that are counted
- up). While iteration happens, this function will print a rendered
- progress bar to the given `file` (defaults to stdout) and will attempt
- to calculate remaining time and more. By default, this progress bar
- will not be rendered if the file is not a terminal.
-
- The context manager creates the progress bar. When the context
- manager is entered the progress bar is already displayed. With every
- iteration over the progress bar, the iterable passed to the bar is
- advanced and the bar is updated. When the context manager exits,
- a newline is printed and the progress bar is finalized on screen.
-
- No printing must happen or the progress bar will be unintentionally
- destroyed.
-
- Example usage::
-
- with progressbar(items) as bar:
- for item in bar:
- do_something_with(item)
-
- Alternatively, if no iterable is specified, one can manually update the
- progress bar through the `update()` method instead of directly
- iterating over the progress bar. The update method accepts the number
- of steps to increment the bar with::
-
- with progressbar(length=chunks.total_bytes) as bar:
- for chunk in chunks:
- process_chunk(chunk)
- bar.update(chunks.bytes)
-
- .. versionadded:: 2.0
-
- .. versionadded:: 4.0
- Added the `color` parameter. Added a `update` method to the
- progressbar object.
-
- :param iterable: an iterable to iterate over. If not provided the length
- is required.
- :param length: the number of items to iterate over. By default the
- progressbar will attempt to ask the iterator about its
- length, which might or might not work. If an iterable is
- also provided this parameter can be used to override the
- length. If an iterable is not provided the progress bar
- will iterate over a range of that length.
- :param label: the label to show next to the progress bar.
- :param show_eta: enables or disables the estimated time display. This is
- automatically disabled if the length cannot be
- determined.
- :param show_percent: enables or disables the percentage display. The
- default is `True` if the iterable has a length or
- `False` if not.
- :param show_pos: enables or disables the absolute position display. The
- default is `False`.
- :param item_show_func: a function called with the current item which
- can return a string to show the current item
- next to the progress bar. Note that the current
- item can be `None`!
- :param fill_char: the character to use to show the filled part of the
- progress bar.
- :param empty_char: the character to use to show the non-filled part of
- the progress bar.
- :param bar_template: the format string to use as template for the bar.
- The parameters in it are ``label`` for the label,
- ``bar`` for the progress bar and ``info`` for the
- info section.
- :param info_sep: the separator between multiple info items (eta etc.)
- :param width: the width of the progress bar in characters, 0 means full
- terminal width
- :param file: the file to write to. If this is not a terminal then
- only the label is printed.
- :param color: controls if the terminal supports ANSI colors or not. The
- default is autodetection. This is only needed if ANSI
- codes are included anywhere in the progress bar output
- which is not the case by default.
- """
- from ._termui_impl import ProgressBar
- color = resolve_color_default(color)
- return ProgressBar(iterable=iterable, length=length, show_eta=show_eta,
- show_percent=show_percent, show_pos=show_pos,
- item_show_func=item_show_func, fill_char=fill_char,
- empty_char=empty_char, bar_template=bar_template,
- info_sep=info_sep, file=file, label=label,
- width=width, color=color)
-
-
-def clear():
- """Clears the terminal screen. This will have the effect of clearing
- the whole visible space of the terminal and moving the cursor to the
- top left. This does not do anything if not connected to a terminal.
-
- .. versionadded:: 2.0
- """
- if not isatty(sys.stdout):
- return
- # If we're on Windows and we don't have colorama available, then we
- # clear the screen by shelling out. Otherwise we can use an escape
- # sequence.
- if WIN:
- os.system('cls')
- else:
- sys.stdout.write('\033[2J\033[1;1H')
-
-
-def style(text, fg=None, bg=None, bold=None, dim=None, underline=None,
- blink=None, reverse=None, reset=True):
- """Styles a text with ANSI styles and returns the new string. By
- default the styling is self contained which means that at the end
- of the string a reset code is issued. This can be prevented by
- passing ``reset=False``.
-
- Examples::
-
- click.echo(click.style('Hello World!', fg='green'))
- click.echo(click.style('ATTENTION!', blink=True))
- click.echo(click.style('Some things', reverse=True, fg='cyan'))
-
- Supported color names:
-
- * ``black`` (might be a gray)
- * ``red``
- * ``green``
- * ``yellow`` (might be an orange)
- * ``blue``
- * ``magenta``
- * ``cyan``
- * ``white`` (might be light gray)
- * ``bright_black``
- * ``bright_red``
- * ``bright_green``
- * ``bright_yellow``
- * ``bright_blue``
- * ``bright_magenta``
- * ``bright_cyan``
- * ``bright_white``
- * ``reset`` (reset the color code only)
-
- .. versionadded:: 2.0
-
- .. versionadded:: 7.0
- Added support for bright colors.
-
- :param text: the string to style with ansi codes.
- :param fg: if provided this will become the foreground color.
- :param bg: if provided this will become the background color.
- :param bold: if provided this will enable or disable bold mode.
- :param dim: if provided this will enable or disable dim mode. This is
- badly supported.
- :param underline: if provided this will enable or disable underline.
- :param blink: if provided this will enable or disable blinking.
- :param reverse: if provided this will enable or disable inverse
- rendering (foreground becomes background and the
- other way round).
- :param reset: by default a reset-all code is added at the end of the
- string which means that styles do not carry over. This
- can be disabled to compose styles.
- """
- bits = []
- if fg:
- try:
- bits.append('\033[%dm' % (_ansi_colors[fg]))
- except KeyError:
- raise TypeError('Unknown color %r' % fg)
- if bg:
- try:
- bits.append('\033[%dm' % (_ansi_colors[bg] + 10))
- except KeyError:
- raise TypeError('Unknown color %r' % bg)
- if bold is not None:
- bits.append('\033[%dm' % (1 if bold else 22))
- if dim is not None:
- bits.append('\033[%dm' % (2 if dim else 22))
- if underline is not None:
- bits.append('\033[%dm' % (4 if underline else 24))
- if blink is not None:
- bits.append('\033[%dm' % (5 if blink else 25))
- if reverse is not None:
- bits.append('\033[%dm' % (7 if reverse else 27))
- bits.append(text)
- if reset:
- bits.append(_ansi_reset_all)
- return ''.join(bits)
-
-
-def unstyle(text):
- """Removes ANSI styling information from a string. Usually it's not
- necessary to use this function as Click's echo function will
- automatically remove styling if necessary.
-
- .. versionadded:: 2.0
-
- :param text: the text to remove style information from.
- """
- return strip_ansi(text)
-
-
-def secho(message=None, file=None, nl=True, err=False, color=None, **styles):
- """This function combines :func:`echo` and :func:`style` into one
- call. As such the following two calls are the same::
-
- click.secho('Hello World!', fg='green')
- click.echo(click.style('Hello World!', fg='green'))
-
- All keyword arguments are forwarded to the underlying functions
- depending on which one they go with.
-
- .. versionadded:: 2.0
- """
- if message is not None:
- message = style(message, **styles)
- return echo(message, file=file, nl=nl, err=err, color=color)
-
-
-def edit(text=None, editor=None, env=None, require_save=True,
- extension='.txt', filename=None):
- r"""Edits the given text in the defined editor. If an editor is given
- (should be the full path to the executable but the regular operating
- system search path is used for finding the executable) it overrides
- the detected editor. Optionally, some environment variables can be
- used. If the editor is closed without changes, `None` is returned. In
- case a file is edited directly the return value is always `None` and
- `require_save` and `extension` are ignored.
-
- If the editor cannot be opened a :exc:`UsageError` is raised.
-
- Note for Windows: to simplify cross-platform usage, the newlines are
- automatically converted from POSIX to Windows and vice versa. As such,
- the message here will have ``\n`` as newline markers.
-
- :param text: the text to edit.
- :param editor: optionally the editor to use. Defaults to automatic
- detection.
- :param env: environment variables to forward to the editor.
- :param require_save: if this is true, then not saving in the editor
- will make the return value become `None`.
- :param extension: the extension to tell the editor about. This defaults
- to `.txt` but changing this might change syntax
- highlighting.
- :param filename: if provided it will edit this file instead of the
- provided text contents. It will not use a temporary
- file as an indirection in that case.
- """
- from ._termui_impl import Editor
- editor = Editor(editor=editor, env=env, require_save=require_save,
- extension=extension)
- if filename is None:
- return editor.edit(text)
- editor.edit_file(filename)
-
-
-def launch(url, wait=False, locate=False):
- """This function launches the given URL (or filename) in the default
- viewer application for this file type. If this is an executable, it
- might launch the executable in a new session. The return value is
- the exit code of the launched application. Usually, ``0`` indicates
- success.
-
- Examples::
-
- click.launch('https://click.palletsprojects.com/')
- click.launch('/my/downloaded/file', locate=True)
-
- .. versionadded:: 2.0
-
- :param url: URL or filename of the thing to launch.
- :param wait: waits for the program to stop.
- :param locate: if this is set to `True` then instead of launching the
- application associated with the URL it will attempt to
- launch a file manager with the file located. This
- might have weird effects if the URL does not point to
- the filesystem.
- """
- from ._termui_impl import open_url
- return open_url(url, wait=wait, locate=locate)
-
-
-# If this is provided, getchar() calls into this instead. This is used
-# for unittesting purposes.
-_getchar = None
-
-
-def getchar(echo=False):
- """Fetches a single character from the terminal and returns it. This
- will always return a unicode character and under certain rare
- circumstances this might return more than one character. The
- situations which more than one character is returned is when for
- whatever reason multiple characters end up in the terminal buffer or
- standard input was not actually a terminal.
-
- Note that this will always read from the terminal, even if something
- is piped into the standard input.
-
- Note for Windows: in rare cases when typing non-ASCII characters, this
- function might wait for a second character and then return both at once.
- This is because certain Unicode characters look like special-key markers.
-
- .. versionadded:: 2.0
-
- :param echo: if set to `True`, the character read will also show up on
- the terminal. The default is to not show it.
- """
- f = _getchar
- if f is None:
- from ._termui_impl import getchar as f
- return f(echo)
-
-
-def raw_terminal():
- from ._termui_impl import raw_terminal as f
- return f()
-
-
-def pause(info='Press any key to continue ...', err=False):
- """This command stops execution and waits for the user to press any
- key to continue. This is similar to the Windows batch "pause"
- command. If the program is not run through a terminal, this command
- will instead do nothing.
-
- .. versionadded:: 2.0
-
- .. versionadded:: 4.0
- Added the `err` parameter.
-
- :param info: the info string to print before pausing.
- :param err: if set to message goes to ``stderr`` instead of
- ``stdout``, the same as with echo.
- """
- if not isatty(sys.stdin) or not isatty(sys.stdout):
- return
- try:
- if info:
- echo(info, nl=False, err=err)
- try:
- getchar()
- except (KeyboardInterrupt, EOFError):
- pass
- finally:
- if info:
- echo(err=err)
diff --git a/python/click/testing.py b/python/click/testing.py
deleted file mode 100644
index 1b2924e..0000000
--- a/python/click/testing.py
+++ /dev/null
@@ -1,374 +0,0 @@
-import os
-import sys
-import shutil
-import tempfile
-import contextlib
-import shlex
-
-from ._compat import iteritems, PY2, string_types
-
-
-# If someone wants to vendor click, we want to ensure the
-# correct package is discovered. Ideally we could use a
-# relative import here but unfortunately Python does not
-# support that.
-clickpkg = sys.modules[__name__.rsplit('.', 1)[0]]
-
-
-if PY2:
- from cStringIO import StringIO
-else:
- import io
- from ._compat import _find_binary_reader
-
-
-class EchoingStdin(object):
-
- def __init__(self, input, output):
- self._input = input
- self._output = output
-
- def __getattr__(self, x):
- return getattr(self._input, x)
-
- def _echo(self, rv):
- self._output.write(rv)
- return rv
-
- def read(self, n=-1):
- return self._echo(self._input.read(n))
-
- def readline(self, n=-1):
- return self._echo(self._input.readline(n))
-
- def readlines(self):
- return [self._echo(x) for x in self._input.readlines()]
-
- def __iter__(self):
- return iter(self._echo(x) for x in self._input)
-
- def __repr__(self):
- return repr(self._input)
-
-
-def make_input_stream(input, charset):
- # Is already an input stream.
- if hasattr(input, 'read'):
- if PY2:
- return input
- rv = _find_binary_reader(input)
- if rv is not None:
- return rv
- raise TypeError('Could not find binary reader for input stream.')
-
- if input is None:
- input = b''
- elif not isinstance(input, bytes):
- input = input.encode(charset)
- if PY2:
- return StringIO(input)
- return io.BytesIO(input)
-
-
-class Result(object):
- """Holds the captured result of an invoked CLI script."""
-
- def __init__(self, runner, stdout_bytes, stderr_bytes, exit_code,
- exception, exc_info=None):
- #: The runner that created the result
- self.runner = runner
- #: The standard output as bytes.
- self.stdout_bytes = stdout_bytes
- #: The standard error as bytes, or False(y) if not available
- self.stderr_bytes = stderr_bytes
- #: The exit code as integer.
- self.exit_code = exit_code
- #: The exception that happened if one did.
- self.exception = exception
- #: The traceback
- self.exc_info = exc_info
-
- @property
- def output(self):
- """The (standard) output as unicode string."""
- return self.stdout
-
- @property
- def stdout(self):
- """The standard output as unicode string."""
- return self.stdout_bytes.decode(self.runner.charset, 'replace') \
- .replace('\r\n', '\n')
-
- @property
- def stderr(self):
- """The standard error as unicode string."""
- if not self.stderr_bytes:
- raise ValueError("stderr not separately captured")
- return self.stderr_bytes.decode(self.runner.charset, 'replace') \
- .replace('\r\n', '\n')
-
-
- def __repr__(self):
- return '<%s %s>' % (
- type(self).__name__,
- self.exception and repr(self.exception) or 'okay',
- )
-
-
-class CliRunner(object):
- """The CLI runner provides functionality to invoke a Click command line
- script for unittesting purposes in a isolated environment. This only
- works in single-threaded systems without any concurrency as it changes the
- global interpreter state.
-
- :param charset: the character set for the input and output data. This is
- UTF-8 by default and should not be changed currently as
- the reporting to Click only works in Python 2 properly.
- :param env: a dictionary with environment variables for overriding.
- :param echo_stdin: if this is set to `True`, then reading from stdin writes
- to stdout. This is useful for showing examples in
- some circumstances. Note that regular prompts
- will automatically echo the input.
- :param mix_stderr: if this is set to `False`, then stdout and stderr are
- preserved as independent streams. This is useful for
- Unix-philosophy apps that have predictable stdout and
- noisy stderr, such that each may be measured
- independently
- """
-
- def __init__(self, charset=None, env=None, echo_stdin=False,
- mix_stderr=True):
- if charset is None:
- charset = 'utf-8'
- self.charset = charset
- self.env = env or {}
- self.echo_stdin = echo_stdin
- self.mix_stderr = mix_stderr
-
- def get_default_prog_name(self, cli):
- """Given a command object it will return the default program name
- for it. The default is the `name` attribute or ``"root"`` if not
- set.
- """
- return cli.name or 'root'
-
- def make_env(self, overrides=None):
- """Returns the environment overrides for invoking a script."""
- rv = dict(self.env)
- if overrides:
- rv.update(overrides)
- return rv
-
- @contextlib.contextmanager
- def isolation(self, input=None, env=None, color=False):
- """A context manager that sets up the isolation for invoking of a
- command line tool. This sets up stdin with the given input data
- and `os.environ` with the overrides from the given dictionary.
- This also rebinds some internals in Click to be mocked (like the
- prompt functionality).
-
- This is automatically done in the :meth:`invoke` method.
-
- .. versionadded:: 4.0
- The ``color`` parameter was added.
-
- :param input: the input stream to put into sys.stdin.
- :param env: the environment overrides as dictionary.
- :param color: whether the output should contain color codes. The
- application can still override this explicitly.
- """
- input = make_input_stream(input, self.charset)
-
- old_stdin = sys.stdin
- old_stdout = sys.stdout
- old_stderr = sys.stderr
- old_forced_width = clickpkg.formatting.FORCED_WIDTH
- clickpkg.formatting.FORCED_WIDTH = 80
-
- env = self.make_env(env)
-
- if PY2:
- bytes_output = StringIO()
- if self.echo_stdin:
- input = EchoingStdin(input, bytes_output)
- sys.stdout = bytes_output
- if not self.mix_stderr:
- bytes_error = StringIO()
- sys.stderr = bytes_error
- else:
- bytes_output = io.BytesIO()
- if self.echo_stdin:
- input = EchoingStdin(input, bytes_output)
- input = io.TextIOWrapper(input, encoding=self.charset)
- sys.stdout = io.TextIOWrapper(
- bytes_output, encoding=self.charset)
- if not self.mix_stderr:
- bytes_error = io.BytesIO()
- sys.stderr = io.TextIOWrapper(
- bytes_error, encoding=self.charset)
-
- if self.mix_stderr:
- sys.stderr = sys.stdout
-
- sys.stdin = input
-
- def visible_input(prompt=None):
- sys.stdout.write(prompt or '')
- val = input.readline().rstrip('\r\n')
- sys.stdout.write(val + '\n')
- sys.stdout.flush()
- return val
-
- def hidden_input(prompt=None):
- sys.stdout.write((prompt or '') + '\n')
- sys.stdout.flush()
- return input.readline().rstrip('\r\n')
-
- def _getchar(echo):
- char = sys.stdin.read(1)
- if echo:
- sys.stdout.write(char)
- sys.stdout.flush()
- return char
-
- default_color = color
-
- def should_strip_ansi(stream=None, color=None):
- if color is None:
- return not default_color
- return not color
-
- old_visible_prompt_func = clickpkg.termui.visible_prompt_func
- old_hidden_prompt_func = clickpkg.termui.hidden_prompt_func
- old__getchar_func = clickpkg.termui._getchar
- old_should_strip_ansi = clickpkg.utils.should_strip_ansi
- clickpkg.termui.visible_prompt_func = visible_input
- clickpkg.termui.hidden_prompt_func = hidden_input
- clickpkg.termui._getchar = _getchar
- clickpkg.utils.should_strip_ansi = should_strip_ansi
-
- old_env = {}
- try:
- for key, value in iteritems(env):
- old_env[key] = os.environ.get(key)
- if value is None:
- try:
- del os.environ[key]
- except Exception:
- pass
- else:
- os.environ[key] = value
- yield (bytes_output, not self.mix_stderr and bytes_error)
- finally:
- for key, value in iteritems(old_env):
- if value is None:
- try:
- del os.environ[key]
- except Exception:
- pass
- else:
- os.environ[key] = value
- sys.stdout = old_stdout
- sys.stderr = old_stderr
- sys.stdin = old_stdin
- clickpkg.termui.visible_prompt_func = old_visible_prompt_func
- clickpkg.termui.hidden_prompt_func = old_hidden_prompt_func
- clickpkg.termui._getchar = old__getchar_func
- clickpkg.utils.should_strip_ansi = old_should_strip_ansi
- clickpkg.formatting.FORCED_WIDTH = old_forced_width
-
- def invoke(self, cli, args=None, input=None, env=None,
- catch_exceptions=True, color=False, mix_stderr=False, **extra):
- """Invokes a command in an isolated environment. The arguments are
- forwarded directly to the command line script, the `extra` keyword
- arguments are passed to the :meth:`~clickpkg.Command.main` function of
- the command.
-
- This returns a :class:`Result` object.
-
- .. versionadded:: 3.0
- The ``catch_exceptions`` parameter was added.
-
- .. versionchanged:: 3.0
- The result object now has an `exc_info` attribute with the
- traceback if available.
-
- .. versionadded:: 4.0
- The ``color`` parameter was added.
-
- :param cli: the command to invoke
- :param args: the arguments to invoke. It may be given as an iterable
- or a string. When given as string it will be interpreted
- as a Unix shell command. More details at
- :func:`shlex.split`.
- :param input: the input data for `sys.stdin`.
- :param env: the environment overrides.
- :param catch_exceptions: Whether to catch any other exceptions than
- ``SystemExit``.
- :param extra: the keyword arguments to pass to :meth:`main`.
- :param color: whether the output should contain color codes. The
- application can still override this explicitly.
- """
- exc_info = None
- with self.isolation(input=input, env=env, color=color) as outstreams:
- exception = None
- exit_code = 0
-
- if isinstance(args, string_types):
- args = shlex.split(args)
-
- try:
- prog_name = extra.pop("prog_name")
- except KeyError:
- prog_name = self.get_default_prog_name(cli)
-
- try:
- cli.main(args=args or (), prog_name=prog_name, **extra)
- except SystemExit as e:
- exc_info = sys.exc_info()
- exit_code = e.code
- if exit_code is None:
- exit_code = 0
-
- if exit_code != 0:
- exception = e
-
- if not isinstance(exit_code, int):
- sys.stdout.write(str(exit_code))
- sys.stdout.write('\n')
- exit_code = 1
-
- except Exception as e:
- if not catch_exceptions:
- raise
- exception = e
- exit_code = 1
- exc_info = sys.exc_info()
- finally:
- sys.stdout.flush()
- stdout = outstreams[0].getvalue()
- stderr = outstreams[1] and outstreams[1].getvalue()
-
- return Result(runner=self,
- stdout_bytes=stdout,
- stderr_bytes=stderr,
- exit_code=exit_code,
- exception=exception,
- exc_info=exc_info)
-
- @contextlib.contextmanager
- def isolated_filesystem(self):
- """A context manager that creates a temporary folder and changes
- the current working directory to it for isolated filesystem tests.
- """
- cwd = os.getcwd()
- t = tempfile.mkdtemp()
- os.chdir(t)
- try:
- yield t
- finally:
- os.chdir(cwd)
- try:
- shutil.rmtree(t)
- except (OSError, IOError):
- pass
diff --git a/python/click/types.py b/python/click/types.py
deleted file mode 100644
index 1f88032..0000000
--- a/python/click/types.py
+++ /dev/null
@@ -1,668 +0,0 @@
-import os
-import stat
-from datetime import datetime
-
-from ._compat import open_stream, text_type, filename_to_ui, \
- get_filesystem_encoding, get_streerror, _get_argv_encoding, PY2
-from .exceptions import BadParameter
-from .utils import safecall, LazyFile
-
-
-class ParamType(object):
- """Helper for converting values through types. The following is
- necessary for a valid type:
-
- * it needs a name
- * it needs to pass through None unchanged
- * it needs to convert from a string
- * it needs to convert its result type through unchanged
- (eg: needs to be idempotent)
- * it needs to be able to deal with param and context being `None`.
- This can be the case when the object is used with prompt
- inputs.
- """
- is_composite = False
-
- #: the descriptive name of this type
- name = None
-
- #: if a list of this type is expected and the value is pulled from a
- #: string environment variable, this is what splits it up. `None`
- #: means any whitespace. For all parameters the general rule is that
- #: whitespace splits them up. The exception are paths and files which
- #: are split by ``os.path.pathsep`` by default (":" on Unix and ";" on
- #: Windows).
- envvar_list_splitter = None
-
- def __call__(self, value, param=None, ctx=None):
- if value is not None:
- return self.convert(value, param, ctx)
-
- def get_metavar(self, param):
- """Returns the metavar default for this param if it provides one."""
-
- def get_missing_message(self, param):
- """Optionally might return extra information about a missing
- parameter.
-
- .. versionadded:: 2.0
- """
-
- def convert(self, value, param, ctx):
- """Converts the value. This is not invoked for values that are
- `None` (the missing value).
- """
- return value
-
- def split_envvar_value(self, rv):
- """Given a value from an environment variable this splits it up
- into small chunks depending on the defined envvar list splitter.
-
- If the splitter is set to `None`, which means that whitespace splits,
- then leading and trailing whitespace is ignored. Otherwise, leading
- and trailing splitters usually lead to empty items being included.
- """
- return (rv or '').split(self.envvar_list_splitter)
-
- def fail(self, message, param=None, ctx=None):
- """Helper method to fail with an invalid value message."""
- raise BadParameter(message, ctx=ctx, param=param)
-
-
-class CompositeParamType(ParamType):
- is_composite = True
-
- @property
- def arity(self):
- raise NotImplementedError()
-
-
-class FuncParamType(ParamType):
-
- def __init__(self, func):
- self.name = func.__name__
- self.func = func
-
- def convert(self, value, param, ctx):
- try:
- return self.func(value)
- except ValueError:
- try:
- value = text_type(value)
- except UnicodeError:
- value = str(value).decode('utf-8', 'replace')
- self.fail(value, param, ctx)
-
-
-class UnprocessedParamType(ParamType):
- name = 'text'
-
- def convert(self, value, param, ctx):
- return value
-
- def __repr__(self):
- return 'UNPROCESSED'
-
-
-class StringParamType(ParamType):
- name = 'text'
-
- def convert(self, value, param, ctx):
- if isinstance(value, bytes):
- enc = _get_argv_encoding()
- try:
- value = value.decode(enc)
- except UnicodeError:
- fs_enc = get_filesystem_encoding()
- if fs_enc != enc:
- try:
- value = value.decode(fs_enc)
- except UnicodeError:
- value = value.decode('utf-8', 'replace')
- return value
- return value
-
- def __repr__(self):
- return 'STRING'
-
-
-class Choice(ParamType):
- """The choice type allows a value to be checked against a fixed set
- of supported values. All of these values have to be strings.
-
- You should only pass a list or tuple of choices. Other iterables
- (like generators) may lead to surprising results.
-
- See :ref:`choice-opts` for an example.
-
- :param case_sensitive: Set to false to make choices case
- insensitive. Defaults to true.
- """
-
- name = 'choice'
-
- def __init__(self, choices, case_sensitive=True):
- self.choices = choices
- self.case_sensitive = case_sensitive
-
- def get_metavar(self, param):
- return '[%s]' % '|'.join(self.choices)
-
- def get_missing_message(self, param):
- return 'Choose from:\n\t%s.' % ',\n\t'.join(self.choices)
-
- def convert(self, value, param, ctx):
- # Exact match
- if value in self.choices:
- return value
-
- # Match through normalization and case sensitivity
- # first do token_normalize_func, then lowercase
- # preserve original `value` to produce an accurate message in
- # `self.fail`
- normed_value = value
- normed_choices = self.choices
-
- if ctx is not None and \
- ctx.token_normalize_func is not None:
- normed_value = ctx.token_normalize_func(value)
- normed_choices = [ctx.token_normalize_func(choice) for choice in
- self.choices]
-
- if not self.case_sensitive:
- normed_value = normed_value.lower()
- normed_choices = [choice.lower() for choice in normed_choices]
-
- if normed_value in normed_choices:
- return normed_value
-
- self.fail('invalid choice: %s. (choose from %s)' %
- (value, ', '.join(self.choices)), param, ctx)
-
- def __repr__(self):
- return 'Choice(%r)' % list(self.choices)
-
-
-class DateTime(ParamType):
- """The DateTime type converts date strings into `datetime` objects.
-
- The format strings which are checked are configurable, but default to some
- common (non-timezone aware) ISO 8601 formats.
-
- When specifying *DateTime* formats, you should only pass a list or a tuple.
- Other iterables, like generators, may lead to surprising results.
-
- The format strings are processed using ``datetime.strptime``, and this
- consequently defines the format strings which are allowed.
-
- Parsing is tried using each format, in order, and the first format which
- parses successfully is used.
-
- :param formats: A list or tuple of date format strings, in the order in
- which they should be tried. Defaults to
- ``'%Y-%m-%d'``, ``'%Y-%m-%dT%H:%M:%S'``,
- ``'%Y-%m-%d %H:%M:%S'``.
- """
- name = 'datetime'
-
- def __init__(self, formats=None):
- self.formats = formats or [
- '%Y-%m-%d',
- '%Y-%m-%dT%H:%M:%S',
- '%Y-%m-%d %H:%M:%S'
- ]
-
- def get_metavar(self, param):
- return '[{}]'.format('|'.join(self.formats))
-
- def _try_to_convert_date(self, value, format):
- try:
- return datetime.strptime(value, format)
- except ValueError:
- return None
-
- def convert(self, value, param, ctx):
- # Exact match
- for format in self.formats:
- dtime = self._try_to_convert_date(value, format)
- if dtime:
- return dtime
-
- self.fail(
- 'invalid datetime format: {}. (choose from {})'.format(
- value, ', '.join(self.formats)))
-
- def __repr__(self):
- return 'DateTime'
-
-
-class IntParamType(ParamType):
- name = 'integer'
-
- def convert(self, value, param, ctx):
- try:
- return int(value)
- except (ValueError, UnicodeError):
- self.fail('%s is not a valid integer' % value, param, ctx)
-
- def __repr__(self):
- return 'INT'
-
-
-class IntRange(IntParamType):
- """A parameter that works similar to :data:`click.INT` but restricts
- the value to fit into a range. The default behavior is to fail if the
- value falls outside the range, but it can also be silently clamped
- between the two edges.
-
- See :ref:`ranges` for an example.
- """
- name = 'integer range'
-
- def __init__(self, min=None, max=None, clamp=False):
- self.min = min
- self.max = max
- self.clamp = clamp
-
- def convert(self, value, param, ctx):
- rv = IntParamType.convert(self, value, param, ctx)
- if self.clamp:
- if self.min is not None and rv < self.min:
- return self.min
- if self.max is not None and rv > self.max:
- return self.max
- if self.min is not None and rv < self.min or \
- self.max is not None and rv > self.max:
- if self.min is None:
- self.fail('%s is bigger than the maximum valid value '
- '%s.' % (rv, self.max), param, ctx)
- elif self.max is None:
- self.fail('%s is smaller than the minimum valid value '
- '%s.' % (rv, self.min), param, ctx)
- else:
- self.fail('%s is not in the valid range of %s to %s.'
- % (rv, self.min, self.max), param, ctx)
- return rv
-
- def __repr__(self):
- return 'IntRange(%r, %r)' % (self.min, self.max)
-
-
-class FloatParamType(ParamType):
- name = 'float'
-
- def convert(self, value, param, ctx):
- try:
- return float(value)
- except (UnicodeError, ValueError):
- self.fail('%s is not a valid floating point value' %
- value, param, ctx)
-
- def __repr__(self):
- return 'FLOAT'
-
-
-class FloatRange(FloatParamType):
- """A parameter that works similar to :data:`click.FLOAT` but restricts
- the value to fit into a range. The default behavior is to fail if the
- value falls outside the range, but it can also be silently clamped
- between the two edges.
-
- See :ref:`ranges` for an example.
- """
- name = 'float range'
-
- def __init__(self, min=None, max=None, clamp=False):
- self.min = min
- self.max = max
- self.clamp = clamp
-
- def convert(self, value, param, ctx):
- rv = FloatParamType.convert(self, value, param, ctx)
- if self.clamp:
- if self.min is not None and rv < self.min:
- return self.min
- if self.max is not None and rv > self.max:
- return self.max
- if self.min is not None and rv < self.min or \
- self.max is not None and rv > self.max:
- if self.min is None:
- self.fail('%s is bigger than the maximum valid value '
- '%s.' % (rv, self.max), param, ctx)
- elif self.max is None:
- self.fail('%s is smaller than the minimum valid value '
- '%s.' % (rv, self.min), param, ctx)
- else:
- self.fail('%s is not in the valid range of %s to %s.'
- % (rv, self.min, self.max), param, ctx)
- return rv
-
- def __repr__(self):
- return 'FloatRange(%r, %r)' % (self.min, self.max)
-
-
-class BoolParamType(ParamType):
- name = 'boolean'
-
- def convert(self, value, param, ctx):
- if isinstance(value, bool):
- return bool(value)
- value = value.lower()
- if value in ('true', 't', '1', 'yes', 'y'):
- return True
- elif value in ('false', 'f', '0', 'no', 'n'):
- return False
- self.fail('%s is not a valid boolean' % value, param, ctx)
-
- def __repr__(self):
- return 'BOOL'
-
-
-class UUIDParameterType(ParamType):
- name = 'uuid'
-
- def convert(self, value, param, ctx):
- import uuid
- try:
- if PY2 and isinstance(value, text_type):
- value = value.encode('ascii')
- return uuid.UUID(value)
- except (UnicodeError, ValueError):
- self.fail('%s is not a valid UUID value' % value, param, ctx)
-
- def __repr__(self):
- return 'UUID'
-
-
-class File(ParamType):
- """Declares a parameter to be a file for reading or writing. The file
- is automatically closed once the context tears down (after the command
- finished working).
-
- Files can be opened for reading or writing. The special value ``-``
- indicates stdin or stdout depending on the mode.
-
- By default, the file is opened for reading text data, but it can also be
- opened in binary mode or for writing. The encoding parameter can be used
- to force a specific encoding.
-
- The `lazy` flag controls if the file should be opened immediately or upon
- first IO. The default is to be non-lazy for standard input and output
- streams as well as files opened for reading, `lazy` otherwise. When opening a
- file lazily for reading, it is still opened temporarily for validation, but
- will not be held open until first IO. lazy is mainly useful when opening
- for writing to avoid creating the file until it is needed.
-
- Starting with Click 2.0, files can also be opened atomically in which
- case all writes go into a separate file in the same folder and upon
- completion the file will be moved over to the original location. This
- is useful if a file regularly read by other users is modified.
-
- See :ref:`file-args` for more information.
- """
- name = 'filename'
- envvar_list_splitter = os.path.pathsep
-
- def __init__(self, mode='r', encoding=None, errors='strict', lazy=None,
- atomic=False):
- self.mode = mode
- self.encoding = encoding
- self.errors = errors
- self.lazy = lazy
- self.atomic = atomic
-
- def resolve_lazy_flag(self, value):
- if self.lazy is not None:
- return self.lazy
- if value == '-':
- return False
- elif 'w' in self.mode:
- return True
- return False
-
- def convert(self, value, param, ctx):
- try:
- if hasattr(value, 'read') or hasattr(value, 'write'):
- return value
-
- lazy = self.resolve_lazy_flag(value)
-
- if lazy:
- f = LazyFile(value, self.mode, self.encoding, self.errors,
- atomic=self.atomic)
- if ctx is not None:
- ctx.call_on_close(f.close_intelligently)
- return f
-
- f, should_close = open_stream(value, self.mode,
- self.encoding, self.errors,
- atomic=self.atomic)
- # If a context is provided, we automatically close the file
- # at the end of the context execution (or flush out). If a
- # context does not exist, it's the caller's responsibility to
- # properly close the file. This for instance happens when the
- # type is used with prompts.
- if ctx is not None:
- if should_close:
- ctx.call_on_close(safecall(f.close))
- else:
- ctx.call_on_close(safecall(f.flush))
- return f
- except (IOError, OSError) as e:
- self.fail('Could not open file: %s: %s' % (
- filename_to_ui(value),
- get_streerror(e),
- ), param, ctx)
-
-
-class Path(ParamType):
- """The path type is similar to the :class:`File` type but it performs
- different checks. First of all, instead of returning an open file
- handle it returns just the filename. Secondly, it can perform various
- basic checks about what the file or directory should be.
-
- .. versionchanged:: 6.0
- `allow_dash` was added.
-
- :param exists: if set to true, the file or directory needs to exist for
- this value to be valid. If this is not required and a
- file does indeed not exist, then all further checks are
- silently skipped.
- :param file_okay: controls if a file is a possible value.
- :param dir_okay: controls if a directory is a possible value.
- :param writable: if true, a writable check is performed.
- :param readable: if true, a readable check is performed.
- :param resolve_path: if this is true, then the path is fully resolved
- before the value is passed onwards. This means
- that it's absolute and symlinks are resolved. It
- will not expand a tilde-prefix, as this is
- supposed to be done by the shell only.
- :param allow_dash: If this is set to `True`, a single dash to indicate
- standard streams is permitted.
- :param path_type: optionally a string type that should be used to
- represent the path. The default is `None` which
- means the return value will be either bytes or
- unicode depending on what makes most sense given the
- input data Click deals with.
- """
- envvar_list_splitter = os.path.pathsep
-
- def __init__(self, exists=False, file_okay=True, dir_okay=True,
- writable=False, readable=True, resolve_path=False,
- allow_dash=False, path_type=None):
- self.exists = exists
- self.file_okay = file_okay
- self.dir_okay = dir_okay
- self.writable = writable
- self.readable = readable
- self.resolve_path = resolve_path
- self.allow_dash = allow_dash
- self.type = path_type
-
- if self.file_okay and not self.dir_okay:
- self.name = 'file'
- self.path_type = 'File'
- elif self.dir_okay and not self.file_okay:
- self.name = 'directory'
- self.path_type = 'Directory'
- else:
- self.name = 'path'
- self.path_type = 'Path'
-
- def coerce_path_result(self, rv):
- if self.type is not None and not isinstance(rv, self.type):
- if self.type is text_type:
- rv = rv.decode(get_filesystem_encoding())
- else:
- rv = rv.encode(get_filesystem_encoding())
- return rv
-
- def convert(self, value, param, ctx):
- rv = value
-
- is_dash = self.file_okay and self.allow_dash and rv in (b'-', '-')
-
- if not is_dash:
- if self.resolve_path:
- rv = os.path.realpath(rv)
-
- try:
- st = os.stat(rv)
- except OSError:
- if not self.exists:
- return self.coerce_path_result(rv)
- self.fail('%s "%s" does not exist.' % (
- self.path_type,
- filename_to_ui(value)
- ), param, ctx)
-
- if not self.file_okay and stat.S_ISREG(st.st_mode):
- self.fail('%s "%s" is a file.' % (
- self.path_type,
- filename_to_ui(value)
- ), param, ctx)
- if not self.dir_okay and stat.S_ISDIR(st.st_mode):
- self.fail('%s "%s" is a directory.' % (
- self.path_type,
- filename_to_ui(value)
- ), param, ctx)
- if self.writable and not os.access(value, os.W_OK):
- self.fail('%s "%s" is not writable.' % (
- self.path_type,
- filename_to_ui(value)
- ), param, ctx)
- if self.readable and not os.access(value, os.R_OK):
- self.fail('%s "%s" is not readable.' % (
- self.path_type,
- filename_to_ui(value)
- ), param, ctx)
-
- return self.coerce_path_result(rv)
-
-
-class Tuple(CompositeParamType):
- """The default behavior of Click is to apply a type on a value directly.
- This works well in most cases, except for when `nargs` is set to a fixed
- count and different types should be used for different items. In this
- case the :class:`Tuple` type can be used. This type can only be used
- if `nargs` is set to a fixed number.
-
- For more information see :ref:`tuple-type`.
-
- This can be selected by using a Python tuple literal as a type.
-
- :param types: a list of types that should be used for the tuple items.
- """
-
- def __init__(self, types):
- self.types = [convert_type(ty) for ty in types]
-
- @property
- def name(self):
- return "<" + " ".join(ty.name for ty in self.types) + ">"
-
- @property
- def arity(self):
- return len(self.types)
-
- def convert(self, value, param, ctx):
- if len(value) != len(self.types):
- raise TypeError('It would appear that nargs is set to conflict '
- 'with the composite type arity.')
- return tuple(ty(x, param, ctx) for ty, x in zip(self.types, value))
-
-
-def convert_type(ty, default=None):
- """Converts a callable or python ty into the most appropriate param
- ty.
- """
- guessed_type = False
- if ty is None and default is not None:
- if isinstance(default, tuple):
- ty = tuple(map(type, default))
- else:
- ty = type(default)
- guessed_type = True
-
- if isinstance(ty, tuple):
- return Tuple(ty)
- if isinstance(ty, ParamType):
- return ty
- if ty is text_type or ty is str or ty is None:
- return STRING
- if ty is int:
- return INT
- # Booleans are only okay if not guessed. This is done because for
- # flags the default value is actually a bit of a lie in that it
- # indicates which of the flags is the one we want. See get_default()
- # for more information.
- if ty is bool and not guessed_type:
- return BOOL
- if ty is float:
- return FLOAT
- if guessed_type:
- return STRING
-
- # Catch a common mistake
- if __debug__:
- try:
- if issubclass(ty, ParamType):
- raise AssertionError('Attempted to use an uninstantiated '
- 'parameter type (%s).' % ty)
- except TypeError:
- pass
- return FuncParamType(ty)
-
-
-#: A dummy parameter type that just does nothing. From a user's
-#: perspective this appears to just be the same as `STRING` but internally
-#: no string conversion takes place. This is necessary to achieve the
-#: same bytes/unicode behavior on Python 2/3 in situations where you want
-#: to not convert argument types. This is usually useful when working
-#: with file paths as they can appear in bytes and unicode.
-#:
-#: For path related uses the :class:`Path` type is a better choice but
-#: there are situations where an unprocessed type is useful which is why
-#: it is is provided.
-#:
-#: .. versionadded:: 4.0
-UNPROCESSED = UnprocessedParamType()
-
-#: A unicode string parameter type which is the implicit default. This
-#: can also be selected by using ``str`` as type.
-STRING = StringParamType()
-
-#: An integer parameter. This can also be selected by using ``int`` as
-#: type.
-INT = IntParamType()
-
-#: A floating point value parameter. This can also be selected by using
-#: ``float`` as type.
-FLOAT = FloatParamType()
-
-#: A boolean parameter. This is the default for boolean flags. This can
-#: also be selected by using ``bool`` as a type.
-BOOL = BoolParamType()
-
-#: A UUID parameter.
-UUID = UUIDParameterType()
diff --git a/python/click/utils.py b/python/click/utils.py
deleted file mode 100644
index fc84369..0000000
--- a/python/click/utils.py
+++ /dev/null
@@ -1,440 +0,0 @@
-import os
-import sys
-
-from .globals import resolve_color_default
-
-from ._compat import text_type, open_stream, get_filesystem_encoding, \
- get_streerror, string_types, PY2, binary_streams, text_streams, \
- filename_to_ui, auto_wrap_for_ansi, strip_ansi, should_strip_ansi, \
- _default_text_stdout, _default_text_stderr, is_bytes, WIN
-
-if not PY2:
- from ._compat import _find_binary_writer
-elif WIN:
- from ._winconsole import _get_windows_argv, \
- _hash_py_argv, _initial_argv_hash
-
-
-echo_native_types = string_types + (bytes, bytearray)
-
-
-def _posixify(name):
- return '-'.join(name.split()).lower()
-
-
-def safecall(func):
- """Wraps a function so that it swallows exceptions."""
- def wrapper(*args, **kwargs):
- try:
- return func(*args, **kwargs)
- except Exception:
- pass
- return wrapper
-
-
-def make_str(value):
- """Converts a value into a valid string."""
- if isinstance(value, bytes):
- try:
- return value.decode(get_filesystem_encoding())
- except UnicodeError:
- return value.decode('utf-8', 'replace')
- return text_type(value)
-
-
-def make_default_short_help(help, max_length=45):
- """Return a condensed version of help string."""
- words = help.split()
- total_length = 0
- result = []
- done = False
-
- for word in words:
- if word[-1:] == '.':
- done = True
- new_length = result and 1 + len(word) or len(word)
- if total_length + new_length > max_length:
- result.append('...')
- done = True
- else:
- if result:
- result.append(' ')
- result.append(word)
- if done:
- break
- total_length += new_length
-
- return ''.join(result)
-
-
-class LazyFile(object):
- """A lazy file works like a regular file but it does not fully open
- the file but it does perform some basic checks early to see if the
- filename parameter does make sense. This is useful for safely opening
- files for writing.
- """
-
- def __init__(self, filename, mode='r', encoding=None, errors='strict',
- atomic=False):
- self.name = filename
- self.mode = mode
- self.encoding = encoding
- self.errors = errors
- self.atomic = atomic
-
- if filename == '-':
- self._f, self.should_close = open_stream(filename, mode,
- encoding, errors)
- else:
- if 'r' in mode:
- # Open and close the file in case we're opening it for
- # reading so that we can catch at least some errors in
- # some cases early.
- open(filename, mode).close()
- self._f = None
- self.should_close = True
-
- def __getattr__(self, name):
- return getattr(self.open(), name)
-
- def __repr__(self):
- if self._f is not None:
- return repr(self._f)
- return '<unopened file %r %s>' % (self.name, self.mode)
-
- def open(self):
- """Opens the file if it's not yet open. This call might fail with
- a :exc:`FileError`. Not handling this error will produce an error
- that Click shows.
- """
- if self._f is not None:
- return self._f
- try:
- rv, self.should_close = open_stream(self.name, self.mode,
- self.encoding,
- self.errors,
- atomic=self.atomic)
- except (IOError, OSError) as e:
- from .exceptions import FileError
- raise FileError(self.name, hint=get_streerror(e))
- self._f = rv
- return rv
-
- def close(self):
- """Closes the underlying file, no matter what."""
- if self._f is not None:
- self._f.close()
-
- def close_intelligently(self):
- """This function only closes the file if it was opened by the lazy
- file wrapper. For instance this will never close stdin.
- """
- if self.should_close:
- self.close()
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.close_intelligently()
-
- def __iter__(self):
- self.open()
- return iter(self._f)
-
-
-class KeepOpenFile(object):
-
- def __init__(self, file):
- self._file = file
-
- def __getattr__(self, name):
- return getattr(self._file, name)
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- pass
-
- def __repr__(self):
- return repr(self._file)
-
- def __iter__(self):
- return iter(self._file)
-
-
-def echo(message=None, file=None, nl=True, err=False, color=None):
- """Prints a message plus a newline to the given file or stdout. On
- first sight, this looks like the print function, but it has improved
- support for handling Unicode and binary data that does not fail no
- matter how badly configured the system is.
-
- Primarily it means that you can print binary data as well as Unicode
- data on both 2.x and 3.x to the given file in the most appropriate way
- possible. This is a very carefree function in that it will try its
- best to not fail. As of Click 6.0 this includes support for unicode
- output on the Windows console.
-
- In addition to that, if `colorama`_ is installed, the echo function will
- also support clever handling of ANSI codes. Essentially it will then
- do the following:
-
- - add transparent handling of ANSI color codes on Windows.
- - hide ANSI codes automatically if the destination file is not a
- terminal.
-
- .. _colorama: https://pypi.org/project/colorama/
-
- .. versionchanged:: 6.0
- As of Click 6.0 the echo function will properly support unicode
- output on the windows console. Not that click does not modify
- the interpreter in any way which means that `sys.stdout` or the
- print statement or function will still not provide unicode support.
-
- .. versionchanged:: 2.0
- Starting with version 2.0 of Click, the echo function will work
- with colorama if it's installed.
-
- .. versionadded:: 3.0
- The `err` parameter was added.
-
- .. versionchanged:: 4.0
- Added the `color` flag.
-
- :param message: the message to print
- :param file: the file to write to (defaults to ``stdout``)
- :param err: if set to true the file defaults to ``stderr`` instead of
- ``stdout``. This is faster and easier than calling
- :func:`get_text_stderr` yourself.
- :param nl: if set to `True` (the default) a newline is printed afterwards.
- :param color: controls if the terminal supports ANSI colors or not. The
- default is autodetection.
- """
- if file is None:
- if err:
- file = _default_text_stderr()
- else:
- file = _default_text_stdout()
-
- # Convert non bytes/text into the native string type.
- if message is not None and not isinstance(message, echo_native_types):
- message = text_type(message)
-
- if nl:
- message = message or u''
- if isinstance(message, text_type):
- message += u'\n'
- else:
- message += b'\n'
-
- # If there is a message, and we're in Python 3, and the value looks
- # like bytes, we manually need to find the binary stream and write the
- # message in there. This is done separately so that most stream
- # types will work as you would expect. Eg: you can write to StringIO
- # for other cases.
- if message and not PY2 and is_bytes(message):
- binary_file = _find_binary_writer(file)
- if binary_file is not None:
- file.flush()
- binary_file.write(message)
- binary_file.flush()
- return
-
- # ANSI-style support. If there is no message or we are dealing with
- # bytes nothing is happening. If we are connected to a file we want
- # to strip colors. If we are on windows we either wrap the stream
- # to strip the color or we use the colorama support to translate the
- # ansi codes to API calls.
- if message and not is_bytes(message):
- color = resolve_color_default(color)
- if should_strip_ansi(file, color):
- message = strip_ansi(message)
- elif WIN:
- if auto_wrap_for_ansi is not None:
- file = auto_wrap_for_ansi(file)
- elif not color:
- message = strip_ansi(message)
-
- if message:
- file.write(message)
- file.flush()
-
-
-def get_binary_stream(name):
- """Returns a system stream for byte processing. This essentially
- returns the stream from the sys module with the given name but it
- solves some compatibility issues between different Python versions.
- Primarily this function is necessary for getting binary streams on
- Python 3.
-
- :param name: the name of the stream to open. Valid names are ``'stdin'``,
- ``'stdout'`` and ``'stderr'``
- """
- opener = binary_streams.get(name)
- if opener is None:
- raise TypeError('Unknown standard stream %r' % name)
- return opener()
-
-
-def get_text_stream(name, encoding=None, errors='strict'):
- """Returns a system stream for text processing. This usually returns
- a wrapped stream around a binary stream returned from
- :func:`get_binary_stream` but it also can take shortcuts on Python 3
- for already correctly configured streams.
-
- :param name: the name of the stream to open. Valid names are ``'stdin'``,
- ``'stdout'`` and ``'stderr'``
- :param encoding: overrides the detected default encoding.
- :param errors: overrides the default error mode.
- """
- opener = text_streams.get(name)
- if opener is None:
- raise TypeError('Unknown standard stream %r' % name)
- return opener(encoding, errors)
-
-
-def open_file(filename, mode='r', encoding=None, errors='strict',
- lazy=False, atomic=False):
- """This is similar to how the :class:`File` works but for manual
- usage. Files are opened non lazy by default. This can open regular
- files as well as stdin/stdout if ``'-'`` is passed.
-
- If stdin/stdout is returned the stream is wrapped so that the context
- manager will not close the stream accidentally. This makes it possible
- to always use the function like this without having to worry to
- accidentally close a standard stream::
-
- with open_file(filename) as f:
- ...
-
- .. versionadded:: 3.0
-
- :param filename: the name of the file to open (or ``'-'`` for stdin/stdout).
- :param mode: the mode in which to open the file.
- :param encoding: the encoding to use.
- :param errors: the error handling for this file.
- :param lazy: can be flipped to true to open the file lazily.
- :param atomic: in atomic mode writes go into a temporary file and it's
- moved on close.
- """
- if lazy:
- return LazyFile(filename, mode, encoding, errors, atomic=atomic)
- f, should_close = open_stream(filename, mode, encoding, errors,
- atomic=atomic)
- if not should_close:
- f = KeepOpenFile(f)
- return f
-
-
-def get_os_args():
- """This returns the argument part of sys.argv in the most appropriate
- form for processing. What this means is that this return value is in
- a format that works for Click to process but does not necessarily
- correspond well to what's actually standard for the interpreter.
-
- On most environments the return value is ``sys.argv[:1]`` unchanged.
- However if you are on Windows and running Python 2 the return value
- will actually be a list of unicode strings instead because the
- default behavior on that platform otherwise will not be able to
- carry all possible values that sys.argv can have.
-
- .. versionadded:: 6.0
- """
- # We can only extract the unicode argv if sys.argv has not been
- # changed since the startup of the application.
- if PY2 and WIN and _initial_argv_hash == _hash_py_argv():
- return _get_windows_argv()
- return sys.argv[1:]
-
-
-def format_filename(filename, shorten=False):
- """Formats a filename for user display. The main purpose of this
- function is to ensure that the filename can be displayed at all. This
- will decode the filename to unicode if necessary in a way that it will
- not fail. Optionally, it can shorten the filename to not include the
- full path to the filename.
-
- :param filename: formats a filename for UI display. This will also convert
- the filename into unicode without failing.
- :param shorten: this optionally shortens the filename to strip of the
- path that leads up to it.
- """
- if shorten:
- filename = os.path.basename(filename)
- return filename_to_ui(filename)
-
-
-def get_app_dir(app_name, roaming=True, force_posix=False):
- r"""Returns the config folder for the application. The default behavior
- is to return whatever is most appropriate for the operating system.
-
- To give you an idea, for an app called ``"Foo Bar"``, something like
- the following folders could be returned:
-
- Mac OS X:
- ``~/Library/Application Support/Foo Bar``
- Mac OS X (POSIX):
- ``~/.foo-bar``
- Unix:
- ``~/.config/foo-bar``
- Unix (POSIX):
- ``~/.foo-bar``
- Win XP (roaming):
- ``C:\Documents and Settings\<user>\Local Settings\Application Data\Foo Bar``
- Win XP (not roaming):
- ``C:\Documents and Settings\<user>\Application Data\Foo Bar``
- Win 7 (roaming):
- ``C:\Users\<user>\AppData\Roaming\Foo Bar``
- Win 7 (not roaming):
- ``C:\Users\<user>\AppData\Local\Foo Bar``
-
- .. versionadded:: 2.0
-
- :param app_name: the application name. This should be properly capitalized
- and can contain whitespace.
- :param roaming: controls if the folder should be roaming or not on Windows.
- Has no affect otherwise.
- :param force_posix: if this is set to `True` then on any POSIX system the
- folder will be stored in the home folder with a leading
- dot instead of the XDG config home or darwin's
- application support folder.
- """
- if WIN:
- key = roaming and 'APPDATA' or 'LOCALAPPDATA'
- folder = os.environ.get(key)
- if folder is None:
- folder = os.path.expanduser('~')
- return os.path.join(folder, app_name)
- if force_posix:
- return os.path.join(os.path.expanduser('~/.' + _posixify(app_name)))
- if sys.platform == 'darwin':
- return os.path.join(os.path.expanduser(
- '~/Library/Application Support'), app_name)
- return os.path.join(
- os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config')),
- _posixify(app_name))
-
-
-class PacifyFlushWrapper(object):
- """This wrapper is used to catch and suppress BrokenPipeErrors resulting
- from ``.flush()`` being called on broken pipe during the shutdown/final-GC
- of the Python interpreter. Notably ``.flush()`` is always called on
- ``sys.stdout`` and ``sys.stderr``. So as to have minimal impact on any
- other cleanup code, and the case where the underlying file is not a broken
- pipe, all calls and attributes are proxied.
- """
-
- def __init__(self, wrapped):
- self.wrapped = wrapped
-
- def flush(self):
- try:
- self.wrapped.flush()
- except IOError as e:
- import errno
- if e.errno != errno.EPIPE:
- raise
-
- def __getattr__(self, attr):
- return getattr(self.wrapped, attr)
diff --git a/python/dateutil/__init__.py b/python/dateutil/__init__.py
deleted file mode 100644
index 796ef3d..0000000
--- a/python/dateutil/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- coding: utf-8 -*-
-from ._version import VERSION as __version__
diff --git a/python/dateutil/_common.py b/python/dateutil/_common.py
deleted file mode 100644
index e8b4af7..0000000
--- a/python/dateutil/_common.py
+++ /dev/null
@@ -1,34 +0,0 @@
-"""
-Common code used in multiple modules.
-"""
-
-
-class weekday(object):
- __slots__ = ["weekday", "n"]
-
- def __init__(self, weekday, n=None):
- self.weekday = weekday
- self.n = n
-
- def __call__(self, n):
- if n == self.n:
- return self
- else:
- return self.__class__(self.weekday, n)
-
- def __eq__(self, other):
- try:
- if self.weekday != other.weekday or self.n != other.n:
- return False
- except AttributeError:
- return False
- return True
-
- __hash__ = None
-
- def __repr__(self):
- s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday]
- if not self.n:
- return s
- else:
- return "%s(%+d)" % (s, self.n)
diff --git a/python/dateutil/_version.py b/python/dateutil/_version.py
deleted file mode 100644
index c1a0357..0000000
--- a/python/dateutil/_version.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""
-Contains information about the dateutil version.
-"""
-
-VERSION_MAJOR = 2
-VERSION_MINOR = 6
-VERSION_PATCH = 1
-
-VERSION_TUPLE = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
-VERSION = '.'.join(map(str, VERSION_TUPLE))
diff --git a/python/dateutil/easter.py b/python/dateutil/easter.py
deleted file mode 100644
index e4def97..0000000
--- a/python/dateutil/easter.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-This module offers a generic easter computing method for any given year, using
-Western, Orthodox or Julian algorithms.
-"""
-
-import datetime
-
-__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
-
-EASTER_JULIAN = 1
-EASTER_ORTHODOX = 2
-EASTER_WESTERN = 3
-
-
-def easter(year, method=EASTER_WESTERN):
- """
- This method was ported from the work done by GM Arts,
- on top of the algorithm by Claus Tondering, which was
- based in part on the algorithm of Ouding (1940), as
- quoted in "Explanatory Supplement to the Astronomical
- Almanac", P. Kenneth Seidelmann, editor.
-
- This algorithm implements three different easter
- calculation methods:
-
- 1 - Original calculation in Julian calendar, valid in
- dates after 326 AD
- 2 - Original method, with date converted to Gregorian
- calendar, valid in years 1583 to 4099
- 3 - Revised method, in Gregorian calendar, valid in
- years 1583 to 4099 as well
-
- These methods are represented by the constants:
-
- * ``EASTER_JULIAN = 1``
- * ``EASTER_ORTHODOX = 2``
- * ``EASTER_WESTERN = 3``
-
- The default method is method 3.
-
- More about the algorithm may be found at:
-
- http://users.chariot.net.au/~gmarts/eastalg.htm
-
- and
-
- http://www.tondering.dk/claus/calendar.html
-
- """
-
- if not (1 <= method <= 3):
- raise ValueError("invalid method")
-
- # g - Golden year - 1
- # c - Century
- # h - (23 - Epact) mod 30
- # i - Number of days from March 21 to Paschal Full Moon
- # j - Weekday for PFM (0=Sunday, etc)
- # p - Number of days from March 21 to Sunday on or before PFM
- # (-6 to 28 methods 1 & 3, to 56 for method 2)
- # e - Extra days to add for method 2 (converting Julian
- # date to Gregorian date)
-
- y = year
- g = y % 19
- e = 0
- if method < 3:
- # Old method
- i = (19*g + 15) % 30
- j = (y + y//4 + i) % 7
- if method == 2:
- # Extra dates to convert Julian to Gregorian date
- e = 10
- if y > 1600:
- e = e + y//100 - 16 - (y//100 - 16)//4
- else:
- # New method
- c = y//100
- h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 30
- i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11))
- j = (y + y//4 + i + 2 - c + c//4) % 7
-
- # p can be from -6 to 56 corresponding to dates 22 March to 23 May
- # (later dates apply to method 2, although 23 May never actually occurs)
- p = i - j + e
- d = 1 + (p + 27 + (p + 6)//40) % 31
- m = 3 + (p + 26)//30
- return datetime.date(int(y), int(m), int(d))
diff --git a/python/dateutil/parser.py b/python/dateutil/parser.py
deleted file mode 100644
index 595331f..0000000
--- a/python/dateutil/parser.py
+++ /dev/null
@@ -1,1374 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-This module offers a generic date/time string parser which is able to parse
-most known formats to represent a date and/or time.
-
-This module attempts to be forgiving with regards to unlikely input formats,
-returning a datetime object even for dates which are ambiguous. If an element
-of a date/time stamp is omitted, the following rules are applied:
-- If AM or PM is left unspecified, a 24-hour clock is assumed, however, an hour
- on a 12-hour clock (``0 <= hour <= 12``) *must* be specified if AM or PM is
- specified.
-- If a time zone is omitted, a timezone-naive datetime is returned.
-
-If any other elements are missing, they are taken from the
-:class:`datetime.datetime` object passed to the parameter ``default``. If this
-results in a day number exceeding the valid number of days per month, the
-value falls back to the end of the month.
-
-Additional resources about date/time string formats can be found below:
-
-- `A summary of the international standard date and time notation
- <http://www.cl.cam.ac.uk/~mgk25/iso-time.html>`_
-- `W3C Date and Time Formats <http://www.w3.org/TR/NOTE-datetime>`_
-- `Time Formats (Planetary Rings Node) <http://pds-rings.seti.org/tools/time_formats.html>`_
-- `CPAN ParseDate module
- <http://search.cpan.org/~muir/Time-modules-2013.0912/lib/Time/ParseDate.pm>`_
-- `Java SimpleDateFormat Class
- <https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>`_
-"""
-from __future__ import unicode_literals
-
-import datetime
-import string
-import time
-import collections
-import re
-from io import StringIO
-from calendar import monthrange
-
-from six import text_type, binary_type, integer_types
-
-from . import relativedelta
-from . import tz
-
-__all__ = ["parse", "parserinfo"]
-
-
-class _timelex(object):
- # Fractional seconds are sometimes split by a comma
- _split_decimal = re.compile("([.,])")
-
- def __init__(self, instream):
- if isinstance(instream, binary_type):
- instream = instream.decode()
-
- if isinstance(instream, text_type):
- instream = StringIO(instream)
-
- if getattr(instream, 'read', None) is None:
- raise TypeError('Parser must be a string or character stream, not '
- '{itype}'.format(itype=instream.__class__.__name__))
-
- self.instream = instream
- self.charstack = []
- self.tokenstack = []
- self.eof = False
-
- def get_token(self):
- """
- This function breaks the time string into lexical units (tokens), which
- can be parsed by the parser. Lexical units are demarcated by changes in
- the character set, so any continuous string of letters is considered
- one unit, any continuous string of numbers is considered one unit.
-
- The main complication arises from the fact that dots ('.') can be used
- both as separators (e.g. "Sep.20.2009") or decimal points (e.g.
- "4:30:21.447"). As such, it is necessary to read the full context of
- any dot-separated strings before breaking it into tokens; as such, this
- function maintains a "token stack", for when the ambiguous context
- demands that multiple tokens be parsed at once.
- """
- if self.tokenstack:
- return self.tokenstack.pop(0)
-
- seenletters = False
- token = None
- state = None
-
- while not self.eof:
- # We only realize that we've reached the end of a token when we
- # find a character that's not part of the current token - since
- # that character may be part of the next token, it's stored in the
- # charstack.
- if self.charstack:
- nextchar = self.charstack.pop(0)
- else:
- nextchar = self.instream.read(1)
- while nextchar == '\x00':
- nextchar = self.instream.read(1)
-
- if not nextchar:
- self.eof = True
- break
- elif not state:
- # First character of the token - determines if we're starting
- # to parse a word, a number or something else.
- token = nextchar
- if self.isword(nextchar):
- state = 'a'
- elif self.isnum(nextchar):
- state = '0'
- elif self.isspace(nextchar):
- token = ' '
- break # emit token
- else:
- break # emit token
- elif state == 'a':
- # If we've already started reading a word, we keep reading
- # letters until we find something that's not part of a word.
- seenletters = True
- if self.isword(nextchar):
- token += nextchar
- elif nextchar == '.':
- token += nextchar
- state = 'a.'
- else:
- self.charstack.append(nextchar)
- break # emit token
- elif state == '0':
- # If we've already started reading a number, we keep reading
- # numbers until we find something that doesn't fit.
- if self.isnum(nextchar):
- token += nextchar
- elif nextchar == '.' or (nextchar == ',' and len(token) >= 2):
- token += nextchar
- state = '0.'
- else:
- self.charstack.append(nextchar)
- break # emit token
- elif state == 'a.':
- # If we've seen some letters and a dot separator, continue
- # parsing, and the tokens will be broken up later.
- seenletters = True
- if nextchar == '.' or self.isword(nextchar):
- token += nextchar
- elif self.isnum(nextchar) and token[-1] == '.':
- token += nextchar
- state = '0.'
- else:
- self.charstack.append(nextchar)
- break # emit token
- elif state == '0.':
- # If we've seen at least one dot separator, keep going, we'll
- # break up the tokens later.
- if nextchar == '.' or self.isnum(nextchar):
- token += nextchar
- elif self.isword(nextchar) and token[-1] == '.':
- token += nextchar
- state = 'a.'
- else:
- self.charstack.append(nextchar)
- break # emit token
-
- if (state in ('a.', '0.') and (seenletters or token.count('.') > 1 or
- token[-1] in '.,')):
- l = self._split_decimal.split(token)
- token = l[0]
- for tok in l[1:]:
- if tok:
- self.tokenstack.append(tok)
-
- if state == '0.' and token.count('.') == 0:
- token = token.replace(',', '.')
-
- return token
-
- def __iter__(self):
- return self
-
- def __next__(self):
- token = self.get_token()
- if token is None:
- raise StopIteration
-
- return token
-
- def next(self):
- return self.__next__() # Python 2.x support
-
- @classmethod
- def split(cls, s):
- return list(cls(s))
-
- @classmethod
- def isword(cls, nextchar):
- """ Whether or not the next character is part of a word """
- return nextchar.isalpha()
-
- @classmethod
- def isnum(cls, nextchar):
- """ Whether the next character is part of a number """
- return nextchar.isdigit()
-
- @classmethod
- def isspace(cls, nextchar):
- """ Whether the next character is whitespace """
- return nextchar.isspace()
-
-
-class _resultbase(object):
-
- def __init__(self):
- for attr in self.__slots__:
- setattr(self, attr, None)
-
- def _repr(self, classname):
- l = []
- for attr in self.__slots__:
- value = getattr(self, attr)
- if value is not None:
- l.append("%s=%s" % (attr, repr(value)))
- return "%s(%s)" % (classname, ", ".join(l))
-
- def __len__(self):
- return (sum(getattr(self, attr) is not None
- for attr in self.__slots__))
-
- def __repr__(self):
- return self._repr(self.__class__.__name__)
-
-
-class parserinfo(object):
- """
- Class which handles what inputs are accepted. Subclass this to customize
- the language and acceptable values for each parameter.
-
- :param dayfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the day (``True``) or month (``False``). If
- ``yearfirst`` is set to ``True``, this distinguishes between YDM
- and YMD. Default is ``False``.
-
- :param yearfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the year. If ``True``, the first number is taken
- to be the year, otherwise the last number is taken to be the year.
- Default is ``False``.
- """
-
- # m from a.m/p.m, t from ISO T separator
- JUMP = [" ", ".", ",", ";", "-", "/", "'",
- "at", "on", "and", "ad", "m", "t", "of",
- "st", "nd", "rd", "th"]
-
- WEEKDAYS = [("Mon", "Monday"),
- ("Tue", "Tuesday"),
- ("Wed", "Wednesday"),
- ("Thu", "Thursday"),
- ("Fri", "Friday"),
- ("Sat", "Saturday"),
- ("Sun", "Sunday")]
- MONTHS = [("Jan", "January"),
- ("Feb", "February"),
- ("Mar", "March"),
- ("Apr", "April"),
- ("May", "May"),
- ("Jun", "June"),
- ("Jul", "July"),
- ("Aug", "August"),
- ("Sep", "Sept", "September"),
- ("Oct", "October"),
- ("Nov", "November"),
- ("Dec", "December")]
- HMS = [("h", "hour", "hours"),
- ("m", "minute", "minutes"),
- ("s", "second", "seconds")]
- AMPM = [("am", "a"),
- ("pm", "p")]
- UTCZONE = ["UTC", "GMT", "Z"]
- PERTAIN = ["of"]
- TZOFFSET = {}
-
- def __init__(self, dayfirst=False, yearfirst=False):
- self._jump = self._convert(self.JUMP)
- self._weekdays = self._convert(self.WEEKDAYS)
- self._months = self._convert(self.MONTHS)
- self._hms = self._convert(self.HMS)
- self._ampm = self._convert(self.AMPM)
- self._utczone = self._convert(self.UTCZONE)
- self._pertain = self._convert(self.PERTAIN)
-
- self.dayfirst = dayfirst
- self.yearfirst = yearfirst
-
- self._year = time.localtime().tm_year
- self._century = self._year // 100 * 100
-
- def _convert(self, lst):
- dct = {}
- for i, v in enumerate(lst):
- if isinstance(v, tuple):
- for v in v:
- dct[v.lower()] = i
- else:
- dct[v.lower()] = i
- return dct
-
- def jump(self, name):
- return name.lower() in self._jump
-
- def weekday(self, name):
- if len(name) >= min(len(n) for n in self._weekdays.keys()):
- try:
- return self._weekdays[name.lower()]
- except KeyError:
- pass
- return None
-
- def month(self, name):
- if len(name) >= min(len(n) for n in self._months.keys()):
- try:
- return self._months[name.lower()] + 1
- except KeyError:
- pass
- return None
-
- def hms(self, name):
- try:
- return self._hms[name.lower()]
- except KeyError:
- return None
-
- def ampm(self, name):
- try:
- return self._ampm[name.lower()]
- except KeyError:
- return None
-
- def pertain(self, name):
- return name.lower() in self._pertain
-
- def utczone(self, name):
- return name.lower() in self._utczone
-
- def tzoffset(self, name):
- if name in self._utczone:
- return 0
-
- return self.TZOFFSET.get(name)
-
- def convertyear(self, year, century_specified=False):
- if year < 100 and not century_specified:
- year += self._century
- if abs(year - self._year) >= 50:
- if year < self._year:
- year += 100
- else:
- year -= 100
- return year
-
- def validate(self, res):
- # move to info
- if res.year is not None:
- res.year = self.convertyear(res.year, res.century_specified)
-
- if res.tzoffset == 0 and not res.tzname or res.tzname == 'Z':
- res.tzname = "UTC"
- res.tzoffset = 0
- elif res.tzoffset != 0 and res.tzname and self.utczone(res.tzname):
- res.tzoffset = 0
- return True
-
-
-class _ymd(list):
- def __init__(self, tzstr, *args, **kwargs):
- super(self.__class__, self).__init__(*args, **kwargs)
- self.century_specified = False
- self.tzstr = tzstr
-
- @staticmethod
- def token_could_be_year(token, year):
- try:
- return int(token) == year
- except ValueError:
- return False
-
- @staticmethod
- def find_potential_year_tokens(year, tokens):
- return [token for token in tokens if _ymd.token_could_be_year(token, year)]
-
- def find_probable_year_index(self, tokens):
- """
- attempt to deduce if a pre 100 year was lost
- due to padded zeros being taken off
- """
- for index, token in enumerate(self):
- potential_year_tokens = _ymd.find_potential_year_tokens(token, tokens)
- if len(potential_year_tokens) == 1 and len(potential_year_tokens[0]) > 2:
- return index
-
- def append(self, val):
- if hasattr(val, '__len__'):
- if val.isdigit() and len(val) > 2:
- self.century_specified = True
- elif val > 100:
- self.century_specified = True
-
- super(self.__class__, self).append(int(val))
-
- def resolve_ymd(self, mstridx, yearfirst, dayfirst):
- len_ymd = len(self)
- year, month, day = (None, None, None)
-
- if len_ymd > 3:
- raise ValueError("More than three YMD values")
- elif len_ymd == 1 or (mstridx != -1 and len_ymd == 2):
- # One member, or two members with a month string
- if mstridx != -1:
- month = self[mstridx]
- del self[mstridx]
-
- if len_ymd > 1 or mstridx == -1:
- if self[0] > 31:
- year = self[0]
- else:
- day = self[0]
-
- elif len_ymd == 2:
- # Two members with numbers
- if self[0] > 31:
- # 99-01
- year, month = self
- elif self[1] > 31:
- # 01-99
- month, year = self
- elif dayfirst and self[1] <= 12:
- # 13-01
- day, month = self
- else:
- # 01-13
- month, day = self
-
- elif len_ymd == 3:
- # Three members
- if mstridx == 0:
- month, day, year = self
- elif mstridx == 1:
- if self[0] > 31 or (yearfirst and self[2] <= 31):
- # 99-Jan-01
- year, month, day = self
- else:
- # 01-Jan-01
- # Give precendence to day-first, since
- # two-digit years is usually hand-written.
- day, month, year = self
-
- elif mstridx == 2:
- # WTF!?
- if self[1] > 31:
- # 01-99-Jan
- day, year, month = self
- else:
- # 99-01-Jan
- year, day, month = self
-
- else:
- if self[0] > 31 or \
- self.find_probable_year_index(_timelex.split(self.tzstr)) == 0 or \
- (yearfirst and self[1] <= 12 and self[2] <= 31):
- # 99-01-01
- if dayfirst and self[2] <= 12:
- year, day, month = self
- else:
- year, month, day = self
- elif self[0] > 12 or (dayfirst and self[1] <= 12):
- # 13-01-01
- day, month, year = self
- else:
- # 01-13-01
- month, day, year = self
-
- return year, month, day
-
-
-class parser(object):
- def __init__(self, info=None):
- self.info = info or parserinfo()
-
- def parse(self, timestr, default=None, ignoretz=False, tzinfos=None, **kwargs):
- """
- Parse the date/time string into a :class:`datetime.datetime` object.
-
- :param timestr:
- Any date/time string using the supported formats.
-
- :param default:
- The default datetime object, if this is a datetime object and not
- ``None``, elements specified in ``timestr`` replace elements in the
- default object.
-
- :param ignoretz:
- If set ``True``, time zones in parsed strings are ignored and a
- naive :class:`datetime.datetime` object is returned.
-
- :param tzinfos:
- Additional time zone names / aliases which may be present in the
- string. This argument maps time zone names (and optionally offsets
- from those time zones) to time zones. This parameter can be a
- dictionary with timezone aliases mapping time zone names to time
- zones or a function taking two parameters (``tzname`` and
- ``tzoffset``) and returning a time zone.
-
- The timezones to which the names are mapped can be an integer
- offset from UTC in minutes or a :class:`tzinfo` object.
-
- .. doctest::
- :options: +NORMALIZE_WHITESPACE
-
- >>> from dateutil.parser import parse
- >>> from dateutil.tz import gettz
- >>> tzinfos = {"BRST": -10800, "CST": gettz("America/Chicago")}
- >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos)
- datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -10800))
- >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos)
- datetime.datetime(2012, 1, 19, 17, 21,
- tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago'))
-
- This parameter is ignored if ``ignoretz`` is set.
-
- :param **kwargs:
- Keyword arguments as passed to ``_parse()``.
-
- :return:
- Returns a :class:`datetime.datetime` object or, if the
- ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the
- first element being a :class:`datetime.datetime` object, the second
- a tuple containing the fuzzy tokens.
-
- :raises ValueError:
- Raised for invalid or unknown string format, if the provided
- :class:`tzinfo` is not in a valid format, or if an invalid date
- would be created.
-
- :raises TypeError:
- Raised for non-string or character stream input.
-
- :raises OverflowError:
- Raised if the parsed date exceeds the largest valid C integer on
- your system.
- """
-
- if default is None:
- default = datetime.datetime.now().replace(hour=0, minute=0,
- second=0, microsecond=0)
-
- res, skipped_tokens = self._parse(timestr, **kwargs)
-
- if res is None:
- raise ValueError("Unknown string format")
-
- if len(res) == 0:
- raise ValueError("String does not contain a date.")
-
- repl = {}
- for attr in ("year", "month", "day", "hour",
- "minute", "second", "microsecond"):
- value = getattr(res, attr)
- if value is not None:
- repl[attr] = value
-
- if 'day' not in repl:
- # If the default day exceeds the last day of the month, fall back to
- # the end of the month.
- cyear = default.year if res.year is None else res.year
- cmonth = default.month if res.month is None else res.month
- cday = default.day if res.day is None else res.day
-
- if cday > monthrange(cyear, cmonth)[1]:
- repl['day'] = monthrange(cyear, cmonth)[1]
-
- ret = default.replace(**repl)
-
- if res.weekday is not None and not res.day:
- ret = ret+relativedelta.relativedelta(weekday=res.weekday)
-
- if not ignoretz:
- if (isinstance(tzinfos, collections.Callable) or
- tzinfos and res.tzname in tzinfos):
-
- if isinstance(tzinfos, collections.Callable):
- tzdata = tzinfos(res.tzname, res.tzoffset)
- else:
- tzdata = tzinfos.get(res.tzname)
-
- if isinstance(tzdata, datetime.tzinfo):
- tzinfo = tzdata
- elif isinstance(tzdata, text_type):
- tzinfo = tz.tzstr(tzdata)
- elif isinstance(tzdata, integer_types):
- tzinfo = tz.tzoffset(res.tzname, tzdata)
- else:
- raise ValueError("Offset must be tzinfo subclass, "
- "tz string, or int offset.")
- ret = ret.replace(tzinfo=tzinfo)
- elif res.tzname and res.tzname in time.tzname:
- ret = ret.replace(tzinfo=tz.tzlocal())
- elif res.tzoffset == 0:
- ret = ret.replace(tzinfo=tz.tzutc())
- elif res.tzoffset:
- ret = ret.replace(tzinfo=tz.tzoffset(res.tzname, res.tzoffset))
-
- if kwargs.get('fuzzy_with_tokens', False):
- return ret, skipped_tokens
- else:
- return ret
-
- class _result(_resultbase):
- __slots__ = ["year", "month", "day", "weekday",
- "hour", "minute", "second", "microsecond",
- "tzname", "tzoffset", "ampm"]
-
- def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False,
- fuzzy_with_tokens=False):
- """
- Private method which performs the heavy lifting of parsing, called from
- ``parse()``, which passes on its ``kwargs`` to this function.
-
- :param timestr:
- The string to parse.
-
- :param dayfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the day (``True``) or month (``False``). If
- ``yearfirst`` is set to ``True``, this distinguishes between YDM
- and YMD. If set to ``None``, this value is retrieved from the
- current :class:`parserinfo` object (which itself defaults to
- ``False``).
-
- :param yearfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the year. If ``True``, the first number is taken
- to be the year, otherwise the last number is taken to be the year.
- If this is set to ``None``, the value is retrieved from the current
- :class:`parserinfo` object (which itself defaults to ``False``).
-
- :param fuzzy:
- Whether to allow fuzzy parsing, allowing for string like "Today is
- January 1, 2047 at 8:21:00AM".
-
- :param fuzzy_with_tokens:
- If ``True``, ``fuzzy`` is automatically set to True, and the parser
- will return a tuple where the first element is the parsed
- :class:`datetime.datetime` datetimestamp and the second element is
- a tuple containing the portions of the string which were ignored:
-
- .. doctest::
-
- >>> from dateutil.parser import parse
- >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True)
- (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))
-
- """
- if fuzzy_with_tokens:
- fuzzy = True
-
- info = self.info
-
- if dayfirst is None:
- dayfirst = info.dayfirst
-
- if yearfirst is None:
- yearfirst = info.yearfirst
-
- res = self._result()
- l = _timelex.split(timestr) # Splits the timestr into tokens
-
- # keep up with the last token skipped so we can recombine
- # consecutively skipped tokens (-2 for when i begins at 0).
- last_skipped_token_i = -2
- skipped_tokens = list()
-
- try:
- # year/month/day list
- ymd = _ymd(timestr)
-
- # Index of the month string in ymd
- mstridx = -1
-
- len_l = len(l)
- i = 0
- while i < len_l:
-
- # Check if it's a number
- try:
- value_repr = l[i]
- value = float(value_repr)
- except ValueError:
- value = None
-
- if value is not None:
- # Token is a number
- len_li = len(l[i])
- i += 1
-
- if (len(ymd) == 3 and len_li in (2, 4)
- and res.hour is None and (i >= len_l or (l[i] != ':' and
- info.hms(l[i]) is None))):
- # 19990101T23[59]
- s = l[i-1]
- res.hour = int(s[:2])
-
- if len_li == 4:
- res.minute = int(s[2:])
-
- elif len_li == 6 or (len_li > 6 and l[i-1].find('.') == 6):
- # YYMMDD or HHMMSS[.ss]
- s = l[i-1]
-
- if not ymd and l[i-1].find('.') == -1:
- #ymd.append(info.convertyear(int(s[:2])))
-
- ymd.append(s[:2])
- ymd.append(s[2:4])
- ymd.append(s[4:])
- else:
- # 19990101T235959[.59]
- res.hour = int(s[:2])
- res.minute = int(s[2:4])
- res.second, res.microsecond = _parsems(s[4:])
-
- elif len_li in (8, 12, 14):
- # YYYYMMDD
- s = l[i-1]
- ymd.append(s[:4])
- ymd.append(s[4:6])
- ymd.append(s[6:8])
-
- if len_li > 8:
- res.hour = int(s[8:10])
- res.minute = int(s[10:12])
-
- if len_li > 12:
- res.second = int(s[12:])
-
- elif ((i < len_l and info.hms(l[i]) is not None) or
- (i+1 < len_l and l[i] == ' ' and
- info.hms(l[i+1]) is not None)):
-
- # HH[ ]h or MM[ ]m or SS[.ss][ ]s
- if l[i] == ' ':
- i += 1
-
- idx = info.hms(l[i])
-
- while True:
- if idx == 0:
- res.hour = int(value)
-
- if value % 1:
- res.minute = int(60*(value % 1))
-
- elif idx == 1:
- res.minute = int(value)
-
- if value % 1:
- res.second = int(60*(value % 1))
-
- elif idx == 2:
- res.second, res.microsecond = \
- _parsems(value_repr)
-
- i += 1
-
- if i >= len_l or idx == 2:
- break
-
- # 12h00
- try:
- value_repr = l[i]
- value = float(value_repr)
- except ValueError:
- break
- else:
- i += 1
- idx += 1
-
- if i < len_l:
- newidx = info.hms(l[i])
-
- if newidx is not None:
- idx = newidx
-
- elif (i == len_l and l[i-2] == ' ' and
- info.hms(l[i-3]) is not None):
- # X h MM or X m SS
- idx = info.hms(l[i-3])
-
- if idx == 0: # h
- res.minute = int(value)
-
- sec_remainder = value % 1
- if sec_remainder:
- res.second = int(60 * sec_remainder)
- elif idx == 1: # m
- res.second, res.microsecond = \
- _parsems(value_repr)
-
- # We don't need to advance the tokens here because the
- # i == len_l call indicates that we're looking at all
- # the tokens already.
-
- elif i+1 < len_l and l[i] == ':':
- # HH:MM[:SS[.ss]]
- res.hour = int(value)
- i += 1
- value = float(l[i])
- res.minute = int(value)
-
- if value % 1:
- res.second = int(60*(value % 1))
-
- i += 1
-
- if i < len_l and l[i] == ':':
- res.second, res.microsecond = _parsems(l[i+1])
- i += 2
-
- elif i < len_l and l[i] in ('-', '/', '.'):
- sep = l[i]
- ymd.append(value_repr)
- i += 1
-
- if i < len_l and not info.jump(l[i]):
- try:
- # 01-01[-01]
- ymd.append(l[i])
- except ValueError:
- # 01-Jan[-01]
- value = info.month(l[i])
-
- if value is not None:
- ymd.append(value)
- assert mstridx == -1
- mstridx = len(ymd)-1
- else:
- return None, None
-
- i += 1
-
- if i < len_l and l[i] == sep:
- # We have three members
- i += 1
- value = info.month(l[i])
-
- if value is not None:
- ymd.append(value)
- mstridx = len(ymd)-1
- assert mstridx == -1
- else:
- ymd.append(l[i])
-
- i += 1
- elif i >= len_l or info.jump(l[i]):
- if i+1 < len_l and info.ampm(l[i+1]) is not None:
- # 12 am
- res.hour = int(value)
-
- if res.hour < 12 and info.ampm(l[i+1]) == 1:
- res.hour += 12
- elif res.hour == 12 and info.ampm(l[i+1]) == 0:
- res.hour = 0
-
- i += 1
- else:
- # Year, month or day
- ymd.append(value)
- i += 1
- elif info.ampm(l[i]) is not None:
-
- # 12am
- res.hour = int(value)
-
- if res.hour < 12 and info.ampm(l[i]) == 1:
- res.hour += 12
- elif res.hour == 12 and info.ampm(l[i]) == 0:
- res.hour = 0
- i += 1
-
- elif not fuzzy:
- return None, None
- else:
- i += 1
- continue
-
- # Check weekday
- value = info.weekday(l[i])
- if value is not None:
- res.weekday = value
- i += 1
- continue
-
- # Check month name
- value = info.month(l[i])
- if value is not None:
- ymd.append(value)
- assert mstridx == -1
- mstridx = len(ymd)-1
-
- i += 1
- if i < len_l:
- if l[i] in ('-', '/'):
- # Jan-01[-99]
- sep = l[i]
- i += 1
- ymd.append(l[i])
- i += 1
-
- if i < len_l and l[i] == sep:
- # Jan-01-99
- i += 1
- ymd.append(l[i])
- i += 1
-
- elif (i+3 < len_l and l[i] == l[i+2] == ' '
- and info.pertain(l[i+1])):
- # Jan of 01
- # In this case, 01 is clearly year
- try:
- value = int(l[i+3])
- except ValueError:
- # Wrong guess
- pass
- else:
- # Convert it here to become unambiguous
- ymd.append(str(info.convertyear(value)))
- i += 4
- continue
-
- # Check am/pm
- value = info.ampm(l[i])
- if value is not None:
- # For fuzzy parsing, 'a' or 'am' (both valid English words)
- # may erroneously trigger the AM/PM flag. Deal with that
- # here.
- val_is_ampm = True
-
- # If there's already an AM/PM flag, this one isn't one.
- if fuzzy and res.ampm is not None:
- val_is_ampm = False
-
- # If AM/PM is found and hour is not, raise a ValueError
- if res.hour is None:
- if fuzzy:
- val_is_ampm = False
- else:
- raise ValueError('No hour specified with ' +
- 'AM or PM flag.')
- elif not 0 <= res.hour <= 12:
- # If AM/PM is found, it's a 12 hour clock, so raise
- # an error for invalid range
- if fuzzy:
- val_is_ampm = False
- else:
- raise ValueError('Invalid hour specified for ' +
- '12-hour clock.')
-
- if val_is_ampm:
- if value == 1 and res.hour < 12:
- res.hour += 12
- elif value == 0 and res.hour == 12:
- res.hour = 0
-
- res.ampm = value
-
- elif fuzzy:
- last_skipped_token_i = self._skip_token(skipped_tokens,
- last_skipped_token_i, i, l)
- i += 1
- continue
-
- # Check for a timezone name
- if (res.hour is not None and len(l[i]) <= 5 and
- res.tzname is None and res.tzoffset is None and
- not [x for x in l[i] if x not in
- string.ascii_uppercase]):
- res.tzname = l[i]
- res.tzoffset = info.tzoffset(res.tzname)
- i += 1
-
- # Check for something like GMT+3, or BRST+3. Notice
- # that it doesn't mean "I am 3 hours after GMT", but
- # "my time +3 is GMT". If found, we reverse the
- # logic so that timezone parsing code will get it
- # right.
- if i < len_l and l[i] in ('+', '-'):
- l[i] = ('+', '-')[l[i] == '+']
- res.tzoffset = None
- if info.utczone(res.tzname):
- # With something like GMT+3, the timezone
- # is *not* GMT.
- res.tzname = None
-
- continue
-
- # Check for a numbered timezone
- if res.hour is not None and l[i] in ('+', '-'):
- signal = (-1, 1)[l[i] == '+']
- i += 1
- len_li = len(l[i])
-
- if len_li == 4:
- # -0300
- res.tzoffset = int(l[i][:2])*3600+int(l[i][2:])*60
- elif i+1 < len_l and l[i+1] == ':':
- # -03:00
- res.tzoffset = int(l[i])*3600+int(l[i+2])*60
- i += 2
- elif len_li <= 2:
- # -[0]3
- res.tzoffset = int(l[i][:2])*3600
- else:
- return None, None
- i += 1
-
- res.tzoffset *= signal
-
- # Look for a timezone name between parenthesis
- if (i+3 < len_l and
- info.jump(l[i]) and l[i+1] == '(' and l[i+3] == ')' and
- 3 <= len(l[i+2]) <= 5 and
- not [x for x in l[i+2]
- if x not in string.ascii_uppercase]):
- # -0300 (BRST)
- res.tzname = l[i+2]
- i += 4
- continue
-
- # Check jumps
- if not (info.jump(l[i]) or fuzzy):
- return None, None
-
- last_skipped_token_i = self._skip_token(skipped_tokens,
- last_skipped_token_i, i, l)
- i += 1
-
- # Process year/month/day
- year, month, day = ymd.resolve_ymd(mstridx, yearfirst, dayfirst)
- if year is not None:
- res.year = year
- res.century_specified = ymd.century_specified
-
- if month is not None:
- res.month = month
-
- if day is not None:
- res.day = day
-
- except (IndexError, ValueError, AssertionError):
- return None, None
-
- if not info.validate(res):
- return None, None
-
- if fuzzy_with_tokens:
- return res, tuple(skipped_tokens)
- else:
- return res, None
-
- @staticmethod
- def _skip_token(skipped_tokens, last_skipped_token_i, i, l):
- if last_skipped_token_i == i - 1:
- # recombine the tokens
- skipped_tokens[-1] += l[i]
- else:
- # just append
- skipped_tokens.append(l[i])
- last_skipped_token_i = i
- return last_skipped_token_i
-
-
-DEFAULTPARSER = parser()
-
-
-def parse(timestr, parserinfo=None, **kwargs):
- """
-
- Parse a string in one of the supported formats, using the
- ``parserinfo`` parameters.
-
- :param timestr:
- A string containing a date/time stamp.
-
- :param parserinfo:
- A :class:`parserinfo` object containing parameters for the parser.
- If ``None``, the default arguments to the :class:`parserinfo`
- constructor are used.
-
- The ``**kwargs`` parameter takes the following keyword arguments:
-
- :param default:
- The default datetime object, if this is a datetime object and not
- ``None``, elements specified in ``timestr`` replace elements in the
- default object.
-
- :param ignoretz:
- If set ``True``, time zones in parsed strings are ignored and a naive
- :class:`datetime` object is returned.
-
- :param tzinfos:
- Additional time zone names / aliases which may be present in the
- string. This argument maps time zone names (and optionally offsets
- from those time zones) to time zones. This parameter can be a
- dictionary with timezone aliases mapping time zone names to time
- zones or a function taking two parameters (``tzname`` and
- ``tzoffset``) and returning a time zone.
-
- The timezones to which the names are mapped can be an integer
- offset from UTC in minutes or a :class:`tzinfo` object.
-
- .. doctest::
- :options: +NORMALIZE_WHITESPACE
-
- >>> from dateutil.parser import parse
- >>> from dateutil.tz import gettz
- >>> tzinfos = {"BRST": -10800, "CST": gettz("America/Chicago")}
- >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos)
- datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -10800))
- >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos)
- datetime.datetime(2012, 1, 19, 17, 21,
- tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago'))
-
- This parameter is ignored if ``ignoretz`` is set.
-
- :param dayfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the day (``True``) or month (``False``). If
- ``yearfirst`` is set to ``True``, this distinguishes between YDM and
- YMD. If set to ``None``, this value is retrieved from the current
- :class:`parserinfo` object (which itself defaults to ``False``).
-
- :param yearfirst:
- Whether to interpret the first value in an ambiguous 3-integer date
- (e.g. 01/05/09) as the year. If ``True``, the first number is taken to
- be the year, otherwise the last number is taken to be the year. If
- this is set to ``None``, the value is retrieved from the current
- :class:`parserinfo` object (which itself defaults to ``False``).
-
- :param fuzzy:
- Whether to allow fuzzy parsing, allowing for string like "Today is
- January 1, 2047 at 8:21:00AM".
-
- :param fuzzy_with_tokens:
- If ``True``, ``fuzzy`` is automatically set to True, and the parser
- will return a tuple where the first element is the parsed
- :class:`datetime.datetime` datetimestamp and the second element is
- a tuple containing the portions of the string which were ignored:
-
- .. doctest::
-
- >>> from dateutil.parser import parse
- >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True)
- (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))
-
- :return:
- Returns a :class:`datetime.datetime` object or, if the
- ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the
- first element being a :class:`datetime.datetime` object, the second
- a tuple containing the fuzzy tokens.
-
- :raises ValueError:
- Raised for invalid or unknown string format, if the provided
- :class:`tzinfo` is not in a valid format, or if an invalid date
- would be created.
-
- :raises OverflowError:
- Raised if the parsed date exceeds the largest valid C integer on
- your system.
- """
- if parserinfo:
- return parser(parserinfo).parse(timestr, **kwargs)
- else:
- return DEFAULTPARSER.parse(timestr, **kwargs)
-
-
-class _tzparser(object):
-
- class _result(_resultbase):
-
- __slots__ = ["stdabbr", "stdoffset", "dstabbr", "dstoffset",
- "start", "end"]
-
- class _attr(_resultbase):
- __slots__ = ["month", "week", "weekday",
- "yday", "jyday", "day", "time"]
-
- def __repr__(self):
- return self._repr("")
-
- def __init__(self):
- _resultbase.__init__(self)
- self.start = self._attr()
- self.end = self._attr()
-
- def parse(self, tzstr):
- res = self._result()
- l = _timelex.split(tzstr)
- try:
-
- len_l = len(l)
-
- i = 0
- while i < len_l:
- # BRST+3[BRDT[+2]]
- j = i
- while j < len_l and not [x for x in l[j]
- if x in "0123456789:,-+"]:
- j += 1
- if j != i:
- if not res.stdabbr:
- offattr = "stdoffset"
- res.stdabbr = "".join(l[i:j])
- else:
- offattr = "dstoffset"
- res.dstabbr = "".join(l[i:j])
- i = j
- if (i < len_l and (l[i] in ('+', '-') or l[i][0] in
- "0123456789")):
- if l[i] in ('+', '-'):
- # Yes, that's right. See the TZ variable
- # documentation.
- signal = (1, -1)[l[i] == '+']
- i += 1
- else:
- signal = -1
- len_li = len(l[i])
- if len_li == 4:
- # -0300
- setattr(res, offattr, (int(l[i][:2])*3600 +
- int(l[i][2:])*60)*signal)
- elif i+1 < len_l and l[i+1] == ':':
- # -03:00
- setattr(res, offattr,
- (int(l[i])*3600+int(l[i+2])*60)*signal)
- i += 2
- elif len_li <= 2:
- # -[0]3
- setattr(res, offattr,
- int(l[i][:2])*3600*signal)
- else:
- return None
- i += 1
- if res.dstabbr:
- break
- else:
- break
-
- if i < len_l:
- for j in range(i, len_l):
- if l[j] == ';':
- l[j] = ','
-
- assert l[i] == ','
-
- i += 1
-
- if i >= len_l:
- pass
- elif (8 <= l.count(',') <= 9 and
- not [y for x in l[i:] if x != ','
- for y in x if y not in "0123456789"]):
- # GMT0BST,3,0,30,3600,10,0,26,7200[,3600]
- for x in (res.start, res.end):
- x.month = int(l[i])
- i += 2
- if l[i] == '-':
- value = int(l[i+1])*-1
- i += 1
- else:
- value = int(l[i])
- i += 2
- if value:
- x.week = value
- x.weekday = (int(l[i])-1) % 7
- else:
- x.day = int(l[i])
- i += 2
- x.time = int(l[i])
- i += 2
- if i < len_l:
- if l[i] in ('-', '+'):
- signal = (-1, 1)[l[i] == "+"]
- i += 1
- else:
- signal = 1
- res.dstoffset = (res.stdoffset+int(l[i]))*signal
- elif (l.count(',') == 2 and l[i:].count('/') <= 2 and
- not [y for x in l[i:] if x not in (',', '/', 'J', 'M',
- '.', '-', ':')
- for y in x if y not in "0123456789"]):
- for x in (res.start, res.end):
- if l[i] == 'J':
- # non-leap year day (1 based)
- i += 1
- x.jyday = int(l[i])
- elif l[i] == 'M':
- # month[-.]week[-.]weekday
- i += 1
- x.month = int(l[i])
- i += 1
- assert l[i] in ('-', '.')
- i += 1
- x.week = int(l[i])
- if x.week == 5:
- x.week = -1
- i += 1
- assert l[i] in ('-', '.')
- i += 1
- x.weekday = (int(l[i])-1) % 7
- else:
- # year day (zero based)
- x.yday = int(l[i])+1
-
- i += 1
-
- if i < len_l and l[i] == '/':
- i += 1
- # start time
- len_li = len(l[i])
- if len_li == 4:
- # -0300
- x.time = (int(l[i][:2])*3600+int(l[i][2:])*60)
- elif i+1 < len_l and l[i+1] == ':':
- # -03:00
- x.time = int(l[i])*3600+int(l[i+2])*60
- i += 2
- if i+1 < len_l and l[i+1] == ':':
- i += 2
- x.time += int(l[i])
- elif len_li <= 2:
- # -[0]3
- x.time = (int(l[i][:2])*3600)
- else:
- return None
- i += 1
-
- assert i == len_l or l[i] == ','
-
- i += 1
-
- assert i >= len_l
-
- except (IndexError, ValueError, AssertionError):
- return None
-
- return res
-
-
-DEFAULTTZPARSER = _tzparser()
-
-
-def _parsetz(tzstr):
- return DEFAULTTZPARSER.parse(tzstr)
-
-
-def _parsems(value):
- """Parse a I[.F] seconds value into (seconds, microseconds)."""
- if "." not in value:
- return int(value), 0
- else:
- i, f = value.split(".")
- return int(i), int(f.ljust(6, "0")[:6])
-
-
-# vim:ts=4:sw=4:et
diff --git a/python/dateutil/relativedelta.py b/python/dateutil/relativedelta.py
deleted file mode 100644
index 0e66afc..0000000
--- a/python/dateutil/relativedelta.py
+++ /dev/null
@@ -1,549 +0,0 @@
-# -*- coding: utf-8 -*-
-import datetime
-import calendar
-
-import operator
-from math import copysign
-
-from six import integer_types
-from warnings import warn
-
-from ._common import weekday
-
-MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7))
-
-__all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
-
-
-class relativedelta(object):
- """
- The relativedelta type is based on the specification of the excellent
- work done by M.-A. Lemburg in his
- `mx.DateTime <http://www.egenix.com/files/python/mxDateTime.html>`_ extension.
- However, notice that this type does *NOT* implement the same algorithm as
- his work. Do *NOT* expect it to behave like mx.DateTime's counterpart.
-
- There are two different ways to build a relativedelta instance. The
- first one is passing it two date/datetime classes::
-
- relativedelta(datetime1, datetime2)
-
- The second one is passing it any number of the following keyword arguments::
-
- relativedelta(arg1=x,arg2=y,arg3=z...)
-
- year, month, day, hour, minute, second, microsecond:
- Absolute information (argument is singular); adding or subtracting a
- relativedelta with absolute information does not perform an aritmetic
- operation, but rather REPLACES the corresponding value in the
- original datetime with the value(s) in relativedelta.
-
- years, months, weeks, days, hours, minutes, seconds, microseconds:
- Relative information, may be negative (argument is plural); adding
- or subtracting a relativedelta with relative information performs
- the corresponding aritmetic operation on the original datetime value
- with the information in the relativedelta.
-
- weekday:
- One of the weekday instances (MO, TU, etc). These instances may
- receive a parameter N, specifying the Nth weekday, which could
- be positive or negative (like MO(+1) or MO(-2). Not specifying
- it is the same as specifying +1. You can also use an integer,
- where 0=MO.
-
- leapdays:
- Will add given days to the date found, if year is a leap
- year, and the date found is post 28 of february.
-
- yearday, nlyearday:
- Set the yearday or the non-leap year day (jump leap days).
- These are converted to day/month/leapdays information.
-
- Here is the behavior of operations with relativedelta:
-
- 1. Calculate the absolute year, using the 'year' argument, or the
- original datetime year, if the argument is not present.
-
- 2. Add the relative 'years' argument to the absolute year.
-
- 3. Do steps 1 and 2 for month/months.
-
- 4. Calculate the absolute day, using the 'day' argument, or the
- original datetime day, if the argument is not present. Then,
- subtract from the day until it fits in the year and month
- found after their operations.
-
- 5. Add the relative 'days' argument to the absolute day. Notice
- that the 'weeks' argument is multiplied by 7 and added to
- 'days'.
-
- 6. Do steps 1 and 2 for hour/hours, minute/minutes, second/seconds,
- microsecond/microseconds.
-
- 7. If the 'weekday' argument is present, calculate the weekday,
- with the given (wday, nth) tuple. wday is the index of the
- weekday (0-6, 0=Mon), and nth is the number of weeks to add
- forward or backward, depending on its signal. Notice that if
- the calculated date is already Monday, for example, using
- (0, 1) or (0, -1) won't change the day.
- """
-
- def __init__(self, dt1=None, dt2=None,
- years=0, months=0, days=0, leapdays=0, weeks=0,
- hours=0, minutes=0, seconds=0, microseconds=0,
- year=None, month=None, day=None, weekday=None,
- yearday=None, nlyearday=None,
- hour=None, minute=None, second=None, microsecond=None):
-
- # Check for non-integer values in integer-only quantities
- if any(x is not None and x != int(x) for x in (years, months)):
- raise ValueError("Non-integer years and months are "
- "ambiguous and not currently supported.")
-
- if dt1 and dt2:
- # datetime is a subclass of date. So both must be date
- if not (isinstance(dt1, datetime.date) and
- isinstance(dt2, datetime.date)):
- raise TypeError("relativedelta only diffs datetime/date")
-
- # We allow two dates, or two datetimes, so we coerce them to be
- # of the same type
- if (isinstance(dt1, datetime.datetime) !=
- isinstance(dt2, datetime.datetime)):
- if not isinstance(dt1, datetime.datetime):
- dt1 = datetime.datetime.fromordinal(dt1.toordinal())
- elif not isinstance(dt2, datetime.datetime):
- dt2 = datetime.datetime.fromordinal(dt2.toordinal())
-
- self.years = 0
- self.months = 0
- self.days = 0
- self.leapdays = 0
- self.hours = 0
- self.minutes = 0
- self.seconds = 0
- self.microseconds = 0
- self.year = None
- self.month = None
- self.day = None
- self.weekday = None
- self.hour = None
- self.minute = None
- self.second = None
- self.microsecond = None
- self._has_time = 0
-
- # Get year / month delta between the two
- months = (dt1.year - dt2.year) * 12 + (dt1.month - dt2.month)
- self._set_months(months)
-
- # Remove the year/month delta so the timedelta is just well-defined
- # time units (seconds, days and microseconds)
- dtm = self.__radd__(dt2)
-
- # If we've overshot our target, make an adjustment
- if dt1 < dt2:
- compare = operator.gt
- increment = 1
- else:
- compare = operator.lt
- increment = -1
-
- while compare(dt1, dtm):
- months += increment
- self._set_months(months)
- dtm = self.__radd__(dt2)
-
- # Get the timedelta between the "months-adjusted" date and dt1
- delta = dt1 - dtm
- self.seconds = delta.seconds + delta.days * 86400
- self.microseconds = delta.microseconds
- else:
- # Relative information
- self.years = years
- self.months = months
- self.days = days + weeks * 7
- self.leapdays = leapdays
- self.hours = hours
- self.minutes = minutes
- self.seconds = seconds
- self.microseconds = microseconds
-
- # Absolute information
- self.year = year
- self.month = month
- self.day = day
- self.hour = hour
- self.minute = minute
- self.second = second
- self.microsecond = microsecond
-
- if any(x is not None and int(x) != x
- for x in (year, month, day, hour,
- minute, second, microsecond)):
- # For now we'll deprecate floats - later it'll be an error.
- warn("Non-integer value passed as absolute information. " +
- "This is not a well-defined condition and will raise " +
- "errors in future versions.", DeprecationWarning)
-
- if isinstance(weekday, integer_types):
- self.weekday = weekdays[weekday]
- else:
- self.weekday = weekday
-
- yday = 0
- if nlyearday:
- yday = nlyearday
- elif yearday:
- yday = yearday
- if yearday > 59:
- self.leapdays = -1
- if yday:
- ydayidx = [31, 59, 90, 120, 151, 181, 212,
- 243, 273, 304, 334, 366]
- for idx, ydays in enumerate(ydayidx):
- if yday <= ydays:
- self.month = idx+1
- if idx == 0:
- self.day = yday
- else:
- self.day = yday-ydayidx[idx-1]
- break
- else:
- raise ValueError("invalid year day (%d)" % yday)
-
- self._fix()
-
- def _fix(self):
- if abs(self.microseconds) > 999999:
- s = _sign(self.microseconds)
- div, mod = divmod(self.microseconds * s, 1000000)
- self.microseconds = mod * s
- self.seconds += div * s
- if abs(self.seconds) > 59:
- s = _sign(self.seconds)
- div, mod = divmod(self.seconds * s, 60)
- self.seconds = mod * s
- self.minutes += div * s
- if abs(self.minutes) > 59:
- s = _sign(self.minutes)
- div, mod = divmod(self.minutes * s, 60)
- self.minutes = mod * s
- self.hours += div * s
- if abs(self.hours) > 23:
- s = _sign(self.hours)
- div, mod = divmod(self.hours * s, 24)
- self.hours = mod * s
- self.days += div * s
- if abs(self.months) > 11:
- s = _sign(self.months)
- div, mod = divmod(self.months * s, 12)
- self.months = mod * s
- self.years += div * s
- if (self.hours or self.minutes or self.seconds or self.microseconds
- or self.hour is not None or self.minute is not None or
- self.second is not None or self.microsecond is not None):
- self._has_time = 1
- else:
- self._has_time = 0
-
- @property
- def weeks(self):
- return self.days // 7
-
- @weeks.setter
- def weeks(self, value):
- self.days = self.days - (self.weeks * 7) + value * 7
-
- def _set_months(self, months):
- self.months = months
- if abs(self.months) > 11:
- s = _sign(self.months)
- div, mod = divmod(self.months * s, 12)
- self.months = mod * s
- self.years = div * s
- else:
- self.years = 0
-
- def normalized(self):
- """
- Return a version of this object represented entirely using integer
- values for the relative attributes.
-
- >>> relativedelta(days=1.5, hours=2).normalized()
- relativedelta(days=1, hours=14)
-
- :return:
- Returns a :class:`dateutil.relativedelta.relativedelta` object.
- """
- # Cascade remainders down (rounding each to roughly nearest microsecond)
- days = int(self.days)
-
- hours_f = round(self.hours + 24 * (self.days - days), 11)
- hours = int(hours_f)
-
- minutes_f = round(self.minutes + 60 * (hours_f - hours), 10)
- minutes = int(minutes_f)
-
- seconds_f = round(self.seconds + 60 * (minutes_f - minutes), 8)
- seconds = int(seconds_f)
-
- microseconds = round(self.microseconds + 1e6 * (seconds_f - seconds))
-
- # Constructor carries overflow back up with call to _fix()
- return self.__class__(years=self.years, months=self.months,
- days=days, hours=hours, minutes=minutes,
- seconds=seconds, microseconds=microseconds,
- leapdays=self.leapdays, year=self.year,
- month=self.month, day=self.day,
- weekday=self.weekday, hour=self.hour,
- minute=self.minute, second=self.second,
- microsecond=self.microsecond)
-
- def __add__(self, other):
- if isinstance(other, relativedelta):
- return self.__class__(years=other.years + self.years,
- months=other.months + self.months,
- days=other.days + self.days,
- hours=other.hours + self.hours,
- minutes=other.minutes + self.minutes,
- seconds=other.seconds + self.seconds,
- microseconds=(other.microseconds +
- self.microseconds),
- leapdays=other.leapdays or self.leapdays,
- year=(other.year if other.year is not None
- else self.year),
- month=(other.month if other.month is not None
- else self.month),
- day=(other.day if other.day is not None
- else self.day),
- weekday=(other.weekday if other.weekday is not None
- else self.weekday),
- hour=(other.hour if other.hour is not None
- else self.hour),
- minute=(other.minute if other.minute is not None
- else self.minute),
- second=(other.second if other.second is not None
- else self.second),
- microsecond=(other.microsecond if other.microsecond
- is not None else
- self.microsecond))
- if isinstance(other, datetime.timedelta):
- return self.__class__(years=self.years,
- months=self.months,
- days=self.days + other.days,
- hours=self.hours,
- minutes=self.minutes,
- seconds=self.seconds + other.seconds,
- microseconds=self.microseconds + other.microseconds,
- leapdays=self.leapdays,
- year=self.year,
- month=self.month,
- day=self.day,
- weekday=self.weekday,
- hour=self.hour,
- minute=self.minute,
- second=self.second,
- microsecond=self.microsecond)
- if not isinstance(other, datetime.date):
- return NotImplemented
- elif self._has_time and not isinstance(other, datetime.datetime):
- other = datetime.datetime.fromordinal(other.toordinal())
- year = (self.year or other.year)+self.years
- month = self.month or other.month
- if self.months:
- assert 1 <= abs(self.months) <= 12
- month += self.months
- if month > 12:
- year += 1
- month -= 12
- elif month < 1:
- year -= 1
- month += 12
- day = min(calendar.monthrange(year, month)[1],
- self.day or other.day)
- repl = {"year": year, "month": month, "day": day}
- for attr in ["hour", "minute", "second", "microsecond"]:
- value = getattr(self, attr)
- if value is not None:
- repl[attr] = value
- days = self.days
- if self.leapdays and month > 2 and calendar.isleap(year):
- days += self.leapdays
- ret = (other.replace(**repl)
- + datetime.timedelta(days=days,
- hours=self.hours,
- minutes=self.minutes,
- seconds=self.seconds,
- microseconds=self.microseconds))
- if self.weekday:
- weekday, nth = self.weekday.weekday, self.weekday.n or 1
- jumpdays = (abs(nth) - 1) * 7
- if nth > 0:
- jumpdays += (7 - ret.weekday() + weekday) % 7
- else:
- jumpdays += (ret.weekday() - weekday) % 7
- jumpdays *= -1
- ret += datetime.timedelta(days=jumpdays)
- return ret
-
- def __radd__(self, other):
- return self.__add__(other)
-
- def __rsub__(self, other):
- return self.__neg__().__radd__(other)
-
- def __sub__(self, other):
- if not isinstance(other, relativedelta):
- return NotImplemented # In case the other object defines __rsub__
- return self.__class__(years=self.years - other.years,
- months=self.months - other.months,
- days=self.days - other.days,
- hours=self.hours - other.hours,
- minutes=self.minutes - other.minutes,
- seconds=self.seconds - other.seconds,
- microseconds=self.microseconds - other.microseconds,
- leapdays=self.leapdays or other.leapdays,
- year=(self.year if self.year is not None
- else other.year),
- month=(self.month if self.month is not None else
- other.month),
- day=(self.day if self.day is not None else
- other.day),
- weekday=(self.weekday if self.weekday is not None else
- other.weekday),
- hour=(self.hour if self.hour is not None else
- other.hour),
- minute=(self.minute if self.minute is not None else
- other.minute),
- second=(self.second if self.second is not None else
- other.second),
- microsecond=(self.microsecond if self.microsecond
- is not None else
- other.microsecond))
-
- def __neg__(self):
- return self.__class__(years=-self.years,
- months=-self.months,
- days=-self.days,
- hours=-self.hours,
- minutes=-self.minutes,
- seconds=-self.seconds,
- microseconds=-self.microseconds,
- leapdays=self.leapdays,
- year=self.year,
- month=self.month,
- day=self.day,
- weekday=self.weekday,
- hour=self.hour,
- minute=self.minute,
- second=self.second,
- microsecond=self.microsecond)
-
- def __bool__(self):
- return not (not self.years and
- not self.months and
- not self.days and
- not self.hours and
- not self.minutes and
- not self.seconds and
- not self.microseconds and
- not self.leapdays and
- self.year is None and
- self.month is None and
- self.day is None and
- self.weekday is None and
- self.hour is None and
- self.minute is None and
- self.second is None and
- self.microsecond is None)
- # Compatibility with Python 2.x
- __nonzero__ = __bool__
-
- def __mul__(self, other):
- try:
- f = float(other)
- except TypeError:
- return NotImplemented
-
- return self.__class__(years=int(self.years * f),
- months=int(self.months * f),
- days=int(self.days * f),
- hours=int(self.hours * f),
- minutes=int(self.minutes * f),
- seconds=int(self.seconds * f),
- microseconds=int(self.microseconds * f),
- leapdays=self.leapdays,
- year=self.year,
- month=self.month,
- day=self.day,
- weekday=self.weekday,
- hour=self.hour,
- minute=self.minute,
- second=self.second,
- microsecond=self.microsecond)
-
- __rmul__ = __mul__
-
- def __eq__(self, other):
- if not isinstance(other, relativedelta):
- return NotImplemented
- if self.weekday or other.weekday:
- if not self.weekday or not other.weekday:
- return False
- if self.weekday.weekday != other.weekday.weekday:
- return False
- n1, n2 = self.weekday.n, other.weekday.n
- if n1 != n2 and not ((not n1 or n1 == 1) and (not n2 or n2 == 1)):
- return False
- return (self.years == other.years and
- self.months == other.months and
- self.days == other.days and
- self.hours == other.hours and
- self.minutes == other.minutes and
- self.seconds == other.seconds and
- self.microseconds == other.microseconds and
- self.leapdays == other.leapdays and
- self.year == other.year and
- self.month == other.month and
- self.day == other.day and
- self.hour == other.hour and
- self.minute == other.minute and
- self.second == other.second and
- self.microsecond == other.microsecond)
-
- __hash__ = None
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __div__(self, other):
- try:
- reciprocal = 1 / float(other)
- except TypeError:
- return NotImplemented
-
- return self.__mul__(reciprocal)
-
- __truediv__ = __div__
-
- def __repr__(self):
- l = []
- for attr in ["years", "months", "days", "leapdays",
- "hours", "minutes", "seconds", "microseconds"]:
- value = getattr(self, attr)
- if value:
- l.append("{attr}={value:+g}".format(attr=attr, value=value))
- for attr in ["year", "month", "day", "weekday",
- "hour", "minute", "second", "microsecond"]:
- value = getattr(self, attr)
- if value is not None:
- l.append("{attr}={value}".format(attr=attr, value=repr(value)))
- return "{classname}({attrs})".format(classname=self.__class__.__name__,
- attrs=", ".join(l))
-
-
-def _sign(x):
- return int(copysign(1, x))
-
-# vim:ts=4:sw=4:et
diff --git a/python/dateutil/rrule.py b/python/dateutil/rrule.py
deleted file mode 100644
index 429f8fc..0000000
--- a/python/dateutil/rrule.py
+++ /dev/null
@@ -1,1610 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-The rrule module offers a small, complete, and very fast, implementation of
-the recurrence rules documented in the
-`iCalendar RFC <http://www.ietf.org/rfc/rfc2445.txt>`_,
-including support for caching of results.
-"""
-import itertools
-import datetime
-import calendar
-import sys
-
-try:
- from math import gcd
-except ImportError:
- from fractions import gcd
-
-from six import advance_iterator, integer_types
-from six.moves import _thread, range
-import heapq
-
-from ._common import weekday as weekdaybase
-
-# For warning about deprecation of until and count
-from warnings import warn
-
-__all__ = ["rrule", "rruleset", "rrulestr",
- "YEARLY", "MONTHLY", "WEEKLY", "DAILY",
- "HOURLY", "MINUTELY", "SECONDLY",
- "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
-
-# Every mask is 7 days longer to handle cross-year weekly periods.
-M366MASK = tuple([1]*31+[2]*29+[3]*31+[4]*30+[5]*31+[6]*30 +
- [7]*31+[8]*31+[9]*30+[10]*31+[11]*30+[12]*31+[1]*7)
-M365MASK = list(M366MASK)
-M29, M30, M31 = list(range(1, 30)), list(range(1, 31)), list(range(1, 32))
-MDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7])
-MDAY365MASK = list(MDAY366MASK)
-M29, M30, M31 = list(range(-29, 0)), list(range(-30, 0)), list(range(-31, 0))
-NMDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7])
-NMDAY365MASK = list(NMDAY366MASK)
-M366RANGE = (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366)
-M365RANGE = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365)
-WDAYMASK = [0, 1, 2, 3, 4, 5, 6]*55
-del M29, M30, M31, M365MASK[59], MDAY365MASK[59], NMDAY365MASK[31]
-MDAY365MASK = tuple(MDAY365MASK)
-M365MASK = tuple(M365MASK)
-
-FREQNAMES = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY']
-
-(YEARLY,
- MONTHLY,
- WEEKLY,
- DAILY,
- HOURLY,
- MINUTELY,
- SECONDLY) = list(range(7))
-
-# Imported on demand.
-easter = None
-parser = None
-
-
-class weekday(weekdaybase):
- """
- This version of weekday does not allow n = 0.
- """
- def __init__(self, wkday, n=None):
- if n == 0:
- raise ValueError("Can't create weekday with n==0")
-
- super(weekday, self).__init__(wkday, n)
-
-
-MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7))
-
-
-def _invalidates_cache(f):
- """
- Decorator for rruleset methods which may invalidate the
- cached length.
- """
- def inner_func(self, *args, **kwargs):
- rv = f(self, *args, **kwargs)
- self._invalidate_cache()
- return rv
-
- return inner_func
-
-
-class rrulebase(object):
- def __init__(self, cache=False):
- if cache:
- self._cache = []
- self._cache_lock = _thread.allocate_lock()
- self._invalidate_cache()
- else:
- self._cache = None
- self._cache_complete = False
- self._len = None
-
- def __iter__(self):
- if self._cache_complete:
- return iter(self._cache)
- elif self._cache is None:
- return self._iter()
- else:
- return self._iter_cached()
-
- def _invalidate_cache(self):
- if self._cache is not None:
- self._cache = []
- self._cache_complete = False
- self._cache_gen = self._iter()
-
- if self._cache_lock.locked():
- self._cache_lock.release()
-
- self._len = None
-
- def _iter_cached(self):
- i = 0
- gen = self._cache_gen
- cache = self._cache
- acquire = self._cache_lock.acquire
- release = self._cache_lock.release
- while gen:
- if i == len(cache):
- acquire()
- if self._cache_complete:
- break
- try:
- for j in range(10):
- cache.append(advance_iterator(gen))
- except StopIteration:
- self._cache_gen = gen = None
- self._cache_complete = True
- break
- release()
- yield cache[i]
- i += 1
- while i < self._len:
- yield cache[i]
- i += 1
-
- def __getitem__(self, item):
- if self._cache_complete:
- return self._cache[item]
- elif isinstance(item, slice):
- if item.step and item.step < 0:
- return list(iter(self))[item]
- else:
- return list(itertools.islice(self,
- item.start or 0,
- item.stop or sys.maxsize,
- item.step or 1))
- elif item >= 0:
- gen = iter(self)
- try:
- for i in range(item+1):
- res = advance_iterator(gen)
- except StopIteration:
- raise IndexError
- return res
- else:
- return list(iter(self))[item]
-
- def __contains__(self, item):
- if self._cache_complete:
- return item in self._cache
- else:
- for i in self:
- if i == item:
- return True
- elif i > item:
- return False
- return False
-
- # __len__() introduces a large performance penality.
- def count(self):
- """ Returns the number of recurrences in this set. It will have go
- trough the whole recurrence, if this hasn't been done before. """
- if self._len is None:
- for x in self:
- pass
- return self._len
-
- def before(self, dt, inc=False):
- """ Returns the last recurrence before the given datetime instance. The
- inc keyword defines what happens if dt is an occurrence. With
- inc=True, if dt itself is an occurrence, it will be returned. """
- if self._cache_complete:
- gen = self._cache
- else:
- gen = self
- last = None
- if inc:
- for i in gen:
- if i > dt:
- break
- last = i
- else:
- for i in gen:
- if i >= dt:
- break
- last = i
- return last
-
- def after(self, dt, inc=False):
- """ Returns the first recurrence after the given datetime instance. The
- inc keyword defines what happens if dt is an occurrence. With
- inc=True, if dt itself is an occurrence, it will be returned. """
- if self._cache_complete:
- gen = self._cache
- else:
- gen = self
- if inc:
- for i in gen:
- if i >= dt:
- return i
- else:
- for i in gen:
- if i > dt:
- return i
- return None
-
- def xafter(self, dt, count=None, inc=False):
- """
- Generator which yields up to `count` recurrences after the given
- datetime instance, equivalent to `after`.
-
- :param dt:
- The datetime at which to start generating recurrences.
-
- :param count:
- The maximum number of recurrences to generate. If `None` (default),
- dates are generated until the recurrence rule is exhausted.
-
- :param inc:
- If `dt` is an instance of the rule and `inc` is `True`, it is
- included in the output.
-
- :yields: Yields a sequence of `datetime` objects.
- """
-
- if self._cache_complete:
- gen = self._cache
- else:
- gen = self
-
- # Select the comparison function
- if inc:
- comp = lambda dc, dtc: dc >= dtc
- else:
- comp = lambda dc, dtc: dc > dtc
-
- # Generate dates
- n = 0
- for d in gen:
- if comp(d, dt):
- if count is not None:
- n += 1
- if n > count:
- break
-
- yield d
-
- def between(self, after, before, inc=False, count=1):
- """ Returns all the occurrences of the rrule between after and before.
- The inc keyword defines what happens if after and/or before are
- themselves occurrences. With inc=True, they will be included in the
- list, if they are found in the recurrence set. """
- if self._cache_complete:
- gen = self._cache
- else:
- gen = self
- started = False
- l = []
- if inc:
- for i in gen:
- if i > before:
- break
- elif not started:
- if i >= after:
- started = True
- l.append(i)
- else:
- l.append(i)
- else:
- for i in gen:
- if i >= before:
- break
- elif not started:
- if i > after:
- started = True
- l.append(i)
- else:
- l.append(i)
- return l
-
-
-class rrule(rrulebase):
- """
- That's the base of the rrule operation. It accepts all the keywords
- defined in the RFC as its constructor parameters (except byday,
- which was renamed to byweekday) and more. The constructor prototype is::
-
- rrule(freq)
-
- Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
- or SECONDLY.
-
- .. note::
- Per RFC section 3.3.10, recurrence instances falling on invalid dates
- and times are ignored rather than coerced:
-
- Recurrence rules may generate recurrence instances with an invalid
- date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM
- on a day where the local time is moved forward by an hour at 1:00
- AM). Such recurrence instances MUST be ignored and MUST NOT be
- counted as part of the recurrence set.
-
- This can lead to possibly surprising behavior when, for example, the
- start date occurs at the end of the month:
-
- >>> from dateutil.rrule import rrule, MONTHLY
- >>> from datetime import datetime
- >>> start_date = datetime(2014, 12, 31)
- >>> list(rrule(freq=MONTHLY, count=4, dtstart=start_date))
- ... # doctest: +NORMALIZE_WHITESPACE
- [datetime.datetime(2014, 12, 31, 0, 0),
- datetime.datetime(2015, 1, 31, 0, 0),
- datetime.datetime(2015, 3, 31, 0, 0),
- datetime.datetime(2015, 5, 31, 0, 0)]
-
- Additionally, it supports the following keyword arguments:
-
- :param cache:
- If given, it must be a boolean value specifying to enable or disable
- caching of results. If you will use the same rrule instance multiple
- times, enabling caching will improve the performance considerably.
- :param dtstart:
- The recurrence start. Besides being the base for the recurrence,
- missing parameters in the final recurrence instances will also be
- extracted from this date. If not given, datetime.now() will be used
- instead.
- :param interval:
- The interval between each freq iteration. For example, when using
- YEARLY, an interval of 2 means once every two years, but with HOURLY,
- it means once every two hours. The default interval is 1.
- :param wkst:
- The week start day. Must be one of the MO, TU, WE constants, or an
- integer, specifying the first day of the week. This will affect
- recurrences based on weekly periods. The default week start is got
- from calendar.firstweekday(), and may be modified by
- calendar.setfirstweekday().
- :param count:
- How many occurrences will be generated.
-
- .. note::
- As of version 2.5.0, the use of the ``until`` keyword together
- with the ``count`` keyword is deprecated per RFC-2445 Sec. 4.3.10.
- :param until:
- If given, this must be a datetime instance, that will specify the
- limit of the recurrence. The last recurrence in the rule is the greatest
- datetime that is less than or equal to the value specified in the
- ``until`` parameter.
-
- .. note::
- As of version 2.5.0, the use of the ``until`` keyword together
- with the ``count`` keyword is deprecated per RFC-2445 Sec. 4.3.10.
- :param bysetpos:
- If given, it must be either an integer, or a sequence of integers,
- positive or negative. Each given integer will specify an occurrence
- number, corresponding to the nth occurrence of the rule inside the
- frequency period. For example, a bysetpos of -1 if combined with a
- MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
- result in the last work day of every month.
- :param bymonth:
- If given, it must be either an integer, or a sequence of integers,
- meaning the months to apply the recurrence to.
- :param bymonthday:
- If given, it must be either an integer, or a sequence of integers,
- meaning the month days to apply the recurrence to.
- :param byyearday:
- If given, it must be either an integer, or a sequence of integers,
- meaning the year days to apply the recurrence to.
- :param byweekno:
- If given, it must be either an integer, or a sequence of integers,
- meaning the week numbers to apply the recurrence to. Week numbers
- have the meaning described in ISO8601, that is, the first week of
- the year is that containing at least four days of the new year.
- :param byweekday:
- If given, it must be either an integer (0 == MO), a sequence of
- integers, one of the weekday constants (MO, TU, etc), or a sequence
- of these constants. When given, these variables will define the
- weekdays where the recurrence will be applied. It's also possible to
- use an argument n for the weekday instances, which will mean the nth
- occurrence of this weekday in the period. For example, with MONTHLY,
- or with YEARLY and BYMONTH, using FR(+1) in byweekday will specify the
- first friday of the month where the recurrence happens. Notice that in
- the RFC documentation, this is specified as BYDAY, but was renamed to
- avoid the ambiguity of that keyword.
- :param byhour:
- If given, it must be either an integer, or a sequence of integers,
- meaning the hours to apply the recurrence to.
- :param byminute:
- If given, it must be either an integer, or a sequence of integers,
- meaning the minutes to apply the recurrence to.
- :param bysecond:
- If given, it must be either an integer, or a sequence of integers,
- meaning the seconds to apply the recurrence to.
- :param byeaster:
- If given, it must be either an integer, or a sequence of integers,
- positive or negative. Each integer will define an offset from the
- Easter Sunday. Passing the offset 0 to byeaster will yield the Easter
- Sunday itself. This is an extension to the RFC specification.
- """
- def __init__(self, freq, dtstart=None,
- interval=1, wkst=None, count=None, until=None, bysetpos=None,
- bymonth=None, bymonthday=None, byyearday=None, byeaster=None,
- byweekno=None, byweekday=None,
- byhour=None, byminute=None, bysecond=None,
- cache=False):
- super(rrule, self).__init__(cache)
- global easter
- if not dtstart:
- dtstart = datetime.datetime.now().replace(microsecond=0)
- elif not isinstance(dtstart, datetime.datetime):
- dtstart = datetime.datetime.fromordinal(dtstart.toordinal())
- else:
- dtstart = dtstart.replace(microsecond=0)
- self._dtstart = dtstart
- self._tzinfo = dtstart.tzinfo
- self._freq = freq
- self._interval = interval
- self._count = count
-
- # Cache the original byxxx rules, if they are provided, as the _byxxx
- # attributes do not necessarily map to the inputs, and this can be
- # a problem in generating the strings. Only store things if they've
- # been supplied (the string retrieval will just use .get())
- self._original_rule = {}
-
- if until and not isinstance(until, datetime.datetime):
- until = datetime.datetime.fromordinal(until.toordinal())
- self._until = until
-
- if count is not None and until:
- warn("Using both 'count' and 'until' is inconsistent with RFC 2445"
- " and has been deprecated in dateutil. Future versions will "
- "raise an error.", DeprecationWarning)
-
- if wkst is None:
- self._wkst = calendar.firstweekday()
- elif isinstance(wkst, integer_types):
- self._wkst = wkst
- else:
- self._wkst = wkst.weekday
-
- if bysetpos is None:
- self._bysetpos = None
- elif isinstance(bysetpos, integer_types):
- if bysetpos == 0 or not (-366 <= bysetpos <= 366):
- raise ValueError("bysetpos must be between 1 and 366, "
- "or between -366 and -1")
- self._bysetpos = (bysetpos,)
- else:
- self._bysetpos = tuple(bysetpos)
- for pos in self._bysetpos:
- if pos == 0 or not (-366 <= pos <= 366):
- raise ValueError("bysetpos must be between 1 and 366, "
- "or between -366 and -1")
-
- if self._bysetpos:
- self._original_rule['bysetpos'] = self._bysetpos
-
- if (byweekno is None and byyearday is None and bymonthday is None and
- byweekday is None and byeaster is None):
- if freq == YEARLY:
- if bymonth is None:
- bymonth = dtstart.month
- self._original_rule['bymonth'] = None
- bymonthday = dtstart.day
- self._original_rule['bymonthday'] = None
- elif freq == MONTHLY:
- bymonthday = dtstart.day
- self._original_rule['bymonthday'] = None
- elif freq == WEEKLY:
- byweekday = dtstart.weekday()
- self._original_rule['byweekday'] = None
-
- # bymonth
- if bymonth is None:
- self._bymonth = None
- else:
- if isinstance(bymonth, integer_types):
- bymonth = (bymonth,)
-
- self._bymonth = tuple(sorted(set(bymonth)))
-
- if 'bymonth' not in self._original_rule:
- self._original_rule['bymonth'] = self._bymonth
-
- # byyearday
- if byyearday is None:
- self._byyearday = None
- else:
- if isinstance(byyearday, integer_types):
- byyearday = (byyearday,)
-
- self._byyearday = tuple(sorted(set(byyearday)))
- self._original_rule['byyearday'] = self._byyearday
-
- # byeaster
- if byeaster is not None:
- if not easter:
- from dateutil import easter
- if isinstance(byeaster, integer_types):
- self._byeaster = (byeaster,)
- else:
- self._byeaster = tuple(sorted(byeaster))
-
- self._original_rule['byeaster'] = self._byeaster
- else:
- self._byeaster = None
-
- # bymonthday
- if bymonthday is None:
- self._bymonthday = ()
- self._bynmonthday = ()
- else:
- if isinstance(bymonthday, integer_types):
- bymonthday = (bymonthday,)
-
- bymonthday = set(bymonthday) # Ensure it's unique
-
- self._bymonthday = tuple(sorted(x for x in bymonthday if x > 0))
- self._bynmonthday = tuple(sorted(x for x in bymonthday if x < 0))
-
- # Storing positive numbers first, then negative numbers
- if 'bymonthday' not in self._original_rule:
- self._original_rule['bymonthday'] = tuple(
- itertools.chain(self._bymonthday, self._bynmonthday))
-
- # byweekno
- if byweekno is None:
- self._byweekno = None
- else:
- if isinstance(byweekno, integer_types):
- byweekno = (byweekno,)
-
- self._byweekno = tuple(sorted(set(byweekno)))
-
- self._original_rule['byweekno'] = self._byweekno
-
- # byweekday / bynweekday
- if byweekday is None:
- self._byweekday = None
- self._bynweekday = None
- else:
- # If it's one of the valid non-sequence types, convert to a
- # single-element sequence before the iterator that builds the
- # byweekday set.
- if isinstance(byweekday, integer_types) or hasattr(byweekday, "n"):
- byweekday = (byweekday,)
-
- self._byweekday = set()
- self._bynweekday = set()
- for wday in byweekday:
- if isinstance(wday, integer_types):
- self._byweekday.add(wday)
- elif not wday.n or freq > MONTHLY:
- self._byweekday.add(wday.weekday)
- else:
- self._bynweekday.add((wday.weekday, wday.n))
-
- if not self._byweekday:
- self._byweekday = None
- elif not self._bynweekday:
- self._bynweekday = None
-
- if self._byweekday is not None:
- self._byweekday = tuple(sorted(self._byweekday))
- orig_byweekday = [weekday(x) for x in self._byweekday]
- else:
- orig_byweekday = tuple()
-
- if self._bynweekday is not None:
- self._bynweekday = tuple(sorted(self._bynweekday))
- orig_bynweekday = [weekday(*x) for x in self._bynweekday]
- else:
- orig_bynweekday = tuple()
-
- if 'byweekday' not in self._original_rule:
- self._original_rule['byweekday'] = tuple(itertools.chain(
- orig_byweekday, orig_bynweekday))
-
- # byhour
- if byhour is None:
- if freq < HOURLY:
- self._byhour = set((dtstart.hour,))
- else:
- self._byhour = None
- else:
- if isinstance(byhour, integer_types):
- byhour = (byhour,)
-
- if freq == HOURLY:
- self._byhour = self.__construct_byset(start=dtstart.hour,
- byxxx=byhour,
- base=24)
- else:
- self._byhour = set(byhour)
-
- self._byhour = tuple(sorted(self._byhour))
- self._original_rule['byhour'] = self._byhour
-
- # byminute
- if byminute is None:
- if freq < MINUTELY:
- self._byminute = set((dtstart.minute,))
- else:
- self._byminute = None
- else:
- if isinstance(byminute, integer_types):
- byminute = (byminute,)
-
- if freq == MINUTELY:
- self._byminute = self.__construct_byset(start=dtstart.minute,
- byxxx=byminute,
- base=60)
- else:
- self._byminute = set(byminute)
-
- self._byminute = tuple(sorted(self._byminute))
- self._original_rule['byminute'] = self._byminute
-
- # bysecond
- if bysecond is None:
- if freq < SECONDLY:
- self._bysecond = ((dtstart.second,))
- else:
- self._bysecond = None
- else:
- if isinstance(bysecond, integer_types):
- bysecond = (bysecond,)
-
- self._bysecond = set(bysecond)
-
- if freq == SECONDLY:
- self._bysecond = self.__construct_byset(start=dtstart.second,
- byxxx=bysecond,
- base=60)
- else:
- self._bysecond = set(bysecond)
-
- self._bysecond = tuple(sorted(self._bysecond))
- self._original_rule['bysecond'] = self._bysecond
-
- if self._freq >= HOURLY:
- self._timeset = None
- else:
- self._timeset = []
- for hour in self._byhour:
- for minute in self._byminute:
- for second in self._bysecond:
- self._timeset.append(
- datetime.time(hour, minute, second,
- tzinfo=self._tzinfo))
- self._timeset.sort()
- self._timeset = tuple(self._timeset)
-
- def __str__(self):
- """
- Output a string that would generate this RRULE if passed to rrulestr.
- This is mostly compatible with RFC2445, except for the
- dateutil-specific extension BYEASTER.
- """
-
- output = []
- h, m, s = [None] * 3
- if self._dtstart:
- output.append(self._dtstart.strftime('DTSTART:%Y%m%dT%H%M%S'))
- h, m, s = self._dtstart.timetuple()[3:6]
-
- parts = ['FREQ=' + FREQNAMES[self._freq]]
- if self._interval != 1:
- parts.append('INTERVAL=' + str(self._interval))
-
- if self._wkst:
- parts.append('WKST=' + repr(weekday(self._wkst))[0:2])
-
- if self._count is not None:
- parts.append('COUNT=' + str(self._count))
-
- if self._until:
- parts.append(self._until.strftime('UNTIL=%Y%m%dT%H%M%S'))
-
- if self._original_rule.get('byweekday') is not None:
- # The str() method on weekday objects doesn't generate
- # RFC2445-compliant strings, so we should modify that.
- original_rule = dict(self._original_rule)
- wday_strings = []
- for wday in original_rule['byweekday']:
- if wday.n:
- wday_strings.append('{n:+d}{wday}'.format(
- n=wday.n,
- wday=repr(wday)[0:2]))
- else:
- wday_strings.append(repr(wday))
-
- original_rule['byweekday'] = wday_strings
- else:
- original_rule = self._original_rule
-
- partfmt = '{name}={vals}'
- for name, key in [('BYSETPOS', 'bysetpos'),
- ('BYMONTH', 'bymonth'),
- ('BYMONTHDAY', 'bymonthday'),
- ('BYYEARDAY', 'byyearday'),
- ('BYWEEKNO', 'byweekno'),
- ('BYDAY', 'byweekday'),
- ('BYHOUR', 'byhour'),
- ('BYMINUTE', 'byminute'),
- ('BYSECOND', 'bysecond'),
- ('BYEASTER', 'byeaster')]:
- value = original_rule.get(key)
- if value:
- parts.append(partfmt.format(name=name, vals=(','.join(str(v)
- for v in value))))
-
- output.append(';'.join(parts))
- return '\n'.join(output)
-
- def replace(self, **kwargs):
- """Return new rrule with same attributes except for those attributes given new
- values by whichever keyword arguments are specified."""
- new_kwargs = {"interval": self._interval,
- "count": self._count,
- "dtstart": self._dtstart,
- "freq": self._freq,
- "until": self._until,
- "wkst": self._wkst,
- "cache": False if self._cache is None else True }
- new_kwargs.update(self._original_rule)
- new_kwargs.update(kwargs)
- return rrule(**new_kwargs)
-
- def _iter(self):
- year, month, day, hour, minute, second, weekday, yearday, _ = \
- self._dtstart.timetuple()
-
- # Some local variables to speed things up a bit
- freq = self._freq
- interval = self._interval
- wkst = self._wkst
- until = self._until
- bymonth = self._bymonth
- byweekno = self._byweekno
- byyearday = self._byyearday
- byweekday = self._byweekday
- byeaster = self._byeaster
- bymonthday = self._bymonthday
- bynmonthday = self._bynmonthday
- bysetpos = self._bysetpos
- byhour = self._byhour
- byminute = self._byminute
- bysecond = self._bysecond
-
- ii = _iterinfo(self)
- ii.rebuild(year, month)
-
- getdayset = {YEARLY: ii.ydayset,
- MONTHLY: ii.mdayset,
- WEEKLY: ii.wdayset,
- DAILY: ii.ddayset,
- HOURLY: ii.ddayset,
- MINUTELY: ii.ddayset,
- SECONDLY: ii.ddayset}[freq]
-
- if freq < HOURLY:
- timeset = self._timeset
- else:
- gettimeset = {HOURLY: ii.htimeset,
- MINUTELY: ii.mtimeset,
- SECONDLY: ii.stimeset}[freq]
- if ((freq >= HOURLY and
- self._byhour and hour not in self._byhour) or
- (freq >= MINUTELY and
- self._byminute and minute not in self._byminute) or
- (freq >= SECONDLY and
- self._bysecond and second not in self._bysecond)):
- timeset = ()
- else:
- timeset = gettimeset(hour, minute, second)
-
- total = 0
- count = self._count
- while True:
- # Get dayset with the right frequency
- dayset, start, end = getdayset(year, month, day)
-
- # Do the "hard" work ;-)
- filtered = False
- for i in dayset[start:end]:
- if ((bymonth and ii.mmask[i] not in bymonth) or
- (byweekno and not ii.wnomask[i]) or
- (byweekday and ii.wdaymask[i] not in byweekday) or
- (ii.nwdaymask and not ii.nwdaymask[i]) or
- (byeaster and not ii.eastermask[i]) or
- ((bymonthday or bynmonthday) and
- ii.mdaymask[i] not in bymonthday and
- ii.nmdaymask[i] not in bynmonthday) or
- (byyearday and
- ((i < ii.yearlen and i+1 not in byyearday and
- -ii.yearlen+i not in byyearday) or
- (i >= ii.yearlen and i+1-ii.yearlen not in byyearday and
- -ii.nextyearlen+i-ii.yearlen not in byyearday)))):
- dayset[i] = None
- filtered = True
-
- # Output results
- if bysetpos and timeset:
- poslist = []
- for pos in bysetpos:
- if pos < 0:
- daypos, timepos = divmod(pos, len(timeset))
- else:
- daypos, timepos = divmod(pos-1, len(timeset))
- try:
- i = [x for x in dayset[start:end]
- if x is not None][daypos]
- time = timeset[timepos]
- except IndexError:
- pass
- else:
- date = datetime.date.fromordinal(ii.yearordinal+i)
- res = datetime.datetime.combine(date, time)
- if res not in poslist:
- poslist.append(res)
- poslist.sort()
- for res in poslist:
- if until and res > until:
- self._len = total
- return
- elif res >= self._dtstart:
- if count is not None:
- count -= 1
- if count < 0:
- self._len = total
- return
- total += 1
- yield res
- else:
- for i in dayset[start:end]:
- if i is not None:
- date = datetime.date.fromordinal(ii.yearordinal + i)
- for time in timeset:
- res = datetime.datetime.combine(date, time)
- if until and res > until:
- self._len = total
- return
- elif res >= self._dtstart:
- if count is not None:
- count -= 1
- if count < 0:
- self._len = total
- return
-
- total += 1
- yield res
-
- # Handle frequency and interval
- fixday = False
- if freq == YEARLY:
- year += interval
- if year > datetime.MAXYEAR:
- self._len = total
- return
- ii.rebuild(year, month)
- elif freq == MONTHLY:
- month += interval
- if month > 12:
- div, mod = divmod(month, 12)
- month = mod
- year += div
- if month == 0:
- month = 12
- year -= 1
- if year > datetime.MAXYEAR:
- self._len = total
- return
- ii.rebuild(year, month)
- elif freq == WEEKLY:
- if wkst > weekday:
- day += -(weekday+1+(6-wkst))+self._interval*7
- else:
- day += -(weekday-wkst)+self._interval*7
- weekday = wkst
- fixday = True
- elif freq == DAILY:
- day += interval
- fixday = True
- elif freq == HOURLY:
- if filtered:
- # Jump to one iteration before next day
- hour += ((23-hour)//interval)*interval
-
- if byhour:
- ndays, hour = self.__mod_distance(value=hour,
- byxxx=self._byhour,
- base=24)
- else:
- ndays, hour = divmod(hour+interval, 24)
-
- if ndays:
- day += ndays
- fixday = True
-
- timeset = gettimeset(hour, minute, second)
- elif freq == MINUTELY:
- if filtered:
- # Jump to one iteration before next day
- minute += ((1439-(hour*60+minute))//interval)*interval
-
- valid = False
- rep_rate = (24*60)
- for j in range(rep_rate // gcd(interval, rep_rate)):
- if byminute:
- nhours, minute = \
- self.__mod_distance(value=minute,
- byxxx=self._byminute,
- base=60)
- else:
- nhours, minute = divmod(minute+interval, 60)
-
- div, hour = divmod(hour+nhours, 24)
- if div:
- day += div
- fixday = True
- filtered = False
-
- if not byhour or hour in byhour:
- valid = True
- break
-
- if not valid:
- raise ValueError('Invalid combination of interval and ' +
- 'byhour resulting in empty rule.')
-
- timeset = gettimeset(hour, minute, second)
- elif freq == SECONDLY:
- if filtered:
- # Jump to one iteration before next day
- second += (((86399 - (hour * 3600 + minute * 60 + second))
- // interval) * interval)
-
- rep_rate = (24 * 3600)
- valid = False
- for j in range(0, rep_rate // gcd(interval, rep_rate)):
- if bysecond:
- nminutes, second = \
- self.__mod_distance(value=second,
- byxxx=self._bysecond,
- base=60)
- else:
- nminutes, second = divmod(second+interval, 60)
-
- div, minute = divmod(minute+nminutes, 60)
- if div:
- hour += div
- div, hour = divmod(hour, 24)
- if div:
- day += div
- fixday = True
-
- if ((not byhour or hour in byhour) and
- (not byminute or minute in byminute) and
- (not bysecond or second in bysecond)):
- valid = True
- break
-
- if not valid:
- raise ValueError('Invalid combination of interval, ' +
- 'byhour and byminute resulting in empty' +
- ' rule.')
-
- timeset = gettimeset(hour, minute, second)
-
- if fixday and day > 28:
- daysinmonth = calendar.monthrange(year, month)[1]
- if day > daysinmonth:
- while day > daysinmonth:
- day -= daysinmonth
- month += 1
- if month == 13:
- month = 1
- year += 1
- if year > datetime.MAXYEAR:
- self._len = total
- return
- daysinmonth = calendar.monthrange(year, month)[1]
- ii.rebuild(year, month)
-
- def __construct_byset(self, start, byxxx, base):
- """
- If a `BYXXX` sequence is passed to the constructor at the same level as
- `FREQ` (e.g. `FREQ=HOURLY,BYHOUR={2,4,7},INTERVAL=3`), there are some
- specifications which cannot be reached given some starting conditions.
-
- This occurs whenever the interval is not coprime with the base of a
- given unit and the difference between the starting position and the
- ending position is not coprime with the greatest common denominator
- between the interval and the base. For example, with a FREQ of hourly
- starting at 17:00 and an interval of 4, the only valid values for
- BYHOUR would be {21, 1, 5, 9, 13, 17}, because 4 and 24 are not
- coprime.
-
- :param start:
- Specifies the starting position.
- :param byxxx:
- An iterable containing the list of allowed values.
- :param base:
- The largest allowable value for the specified frequency (e.g.
- 24 hours, 60 minutes).
-
- This does not preserve the type of the iterable, returning a set, since
- the values should be unique and the order is irrelevant, this will
- speed up later lookups.
-
- In the event of an empty set, raises a :exception:`ValueError`, as this
- results in an empty rrule.
- """
-
- cset = set()
-
- # Support a single byxxx value.
- if isinstance(byxxx, integer_types):
- byxxx = (byxxx, )
-
- for num in byxxx:
- i_gcd = gcd(self._interval, base)
- # Use divmod rather than % because we need to wrap negative nums.
- if i_gcd == 1 or divmod(num - start, i_gcd)[1] == 0:
- cset.add(num)
-
- if len(cset) == 0:
- raise ValueError("Invalid rrule byxxx generates an empty set.")
-
- return cset
-
- def __mod_distance(self, value, byxxx, base):
- """
- Calculates the next value in a sequence where the `FREQ` parameter is
- specified along with a `BYXXX` parameter at the same "level"
- (e.g. `HOURLY` specified with `BYHOUR`).
-
- :param value:
- The old value of the component.
- :param byxxx:
- The `BYXXX` set, which should have been generated by
- `rrule._construct_byset`, or something else which checks that a
- valid rule is present.
- :param base:
- The largest allowable value for the specified frequency (e.g.
- 24 hours, 60 minutes).
-
- If a valid value is not found after `base` iterations (the maximum
- number before the sequence would start to repeat), this raises a
- :exception:`ValueError`, as no valid values were found.
-
- This returns a tuple of `divmod(n*interval, base)`, where `n` is the
- smallest number of `interval` repetitions until the next specified
- value in `byxxx` is found.
- """
- accumulator = 0
- for ii in range(1, base + 1):
- # Using divmod() over % to account for negative intervals
- div, value = divmod(value + self._interval, base)
- accumulator += div
- if value in byxxx:
- return (accumulator, value)
-
-
-class _iterinfo(object):
- __slots__ = ["rrule", "lastyear", "lastmonth",
- "yearlen", "nextyearlen", "yearordinal", "yearweekday",
- "mmask", "mrange", "mdaymask", "nmdaymask",
- "wdaymask", "wnomask", "nwdaymask", "eastermask"]
-
- def __init__(self, rrule):
- for attr in self.__slots__:
- setattr(self, attr, None)
- self.rrule = rrule
-
- def rebuild(self, year, month):
- # Every mask is 7 days longer to handle cross-year weekly periods.
- rr = self.rrule
- if year != self.lastyear:
- self.yearlen = 365 + calendar.isleap(year)
- self.nextyearlen = 365 + calendar.isleap(year + 1)
- firstyday = datetime.date(year, 1, 1)
- self.yearordinal = firstyday.toordinal()
- self.yearweekday = firstyday.weekday()
-
- wday = datetime.date(year, 1, 1).weekday()
- if self.yearlen == 365:
- self.mmask = M365MASK
- self.mdaymask = MDAY365MASK
- self.nmdaymask = NMDAY365MASK
- self.wdaymask = WDAYMASK[wday:]
- self.mrange = M365RANGE
- else:
- self.mmask = M366MASK
- self.mdaymask = MDAY366MASK
- self.nmdaymask = NMDAY366MASK
- self.wdaymask = WDAYMASK[wday:]
- self.mrange = M366RANGE
-
- if not rr._byweekno:
- self.wnomask = None
- else:
- self.wnomask = [0]*(self.yearlen+7)
- # no1wkst = firstwkst = self.wdaymask.index(rr._wkst)
- no1wkst = firstwkst = (7-self.yearweekday+rr._wkst) % 7
- if no1wkst >= 4:
- no1wkst = 0
- # Number of days in the year, plus the days we got
- # from last year.
- wyearlen = self.yearlen+(self.yearweekday-rr._wkst) % 7
- else:
- # Number of days in the year, minus the days we
- # left in last year.
- wyearlen = self.yearlen-no1wkst
- div, mod = divmod(wyearlen, 7)
- numweeks = div+mod//4
- for n in rr._byweekno:
- if n < 0:
- n += numweeks+1
- if not (0 < n <= numweeks):
- continue
- if n > 1:
- i = no1wkst+(n-1)*7
- if no1wkst != firstwkst:
- i -= 7-firstwkst
- else:
- i = no1wkst
- for j in range(7):
- self.wnomask[i] = 1
- i += 1
- if self.wdaymask[i] == rr._wkst:
- break
- if 1 in rr._byweekno:
- # Check week number 1 of next year as well
- # TODO: Check -numweeks for next year.
- i = no1wkst+numweeks*7
- if no1wkst != firstwkst:
- i -= 7-firstwkst
- if i < self.yearlen:
- # If week starts in next year, we
- # don't care about it.
- for j in range(7):
- self.wnomask[i] = 1
- i += 1
- if self.wdaymask[i] == rr._wkst:
- break
- if no1wkst:
- # Check last week number of last year as
- # well. If no1wkst is 0, either the year
- # started on week start, or week number 1
- # got days from last year, so there are no
- # days from last year's last week number in
- # this year.
- if -1 not in rr._byweekno:
- lyearweekday = datetime.date(year-1, 1, 1).weekday()
- lno1wkst = (7-lyearweekday+rr._wkst) % 7
- lyearlen = 365+calendar.isleap(year-1)
- if lno1wkst >= 4:
- lno1wkst = 0
- lnumweeks = 52+(lyearlen +
- (lyearweekday-rr._wkst) % 7) % 7//4
- else:
- lnumweeks = 52+(self.yearlen-no1wkst) % 7//4
- else:
- lnumweeks = -1
- if lnumweeks in rr._byweekno:
- for i in range(no1wkst):
- self.wnomask[i] = 1
-
- if (rr._bynweekday and (month != self.lastmonth or
- year != self.lastyear)):
- ranges = []
- if rr._freq == YEARLY:
- if rr._bymonth:
- for month in rr._bymonth:
- ranges.append(self.mrange[month-1:month+1])
- else:
- ranges = [(0, self.yearlen)]
- elif rr._freq == MONTHLY:
- ranges = [self.mrange[month-1:month+1]]
- if ranges:
- # Weekly frequency won't get here, so we may not
- # care about cross-year weekly periods.
- self.nwdaymask = [0]*self.yearlen
- for first, last in ranges:
- last -= 1
- for wday, n in rr._bynweekday:
- if n < 0:
- i = last+(n+1)*7
- i -= (self.wdaymask[i]-wday) % 7
- else:
- i = first+(n-1)*7
- i += (7-self.wdaymask[i]+wday) % 7
- if first <= i <= last:
- self.nwdaymask[i] = 1
-
- if rr._byeaster:
- self.eastermask = [0]*(self.yearlen+7)
- eyday = easter.easter(year).toordinal()-self.yearordinal
- for offset in rr._byeaster:
- self.eastermask[eyday+offset] = 1
-
- self.lastyear = year
- self.lastmonth = month
-
- def ydayset(self, year, month, day):
- return list(range(self.yearlen)), 0, self.yearlen
-
- def mdayset(self, year, month, day):
- dset = [None]*self.yearlen
- start, end = self.mrange[month-1:month+1]
- for i in range(start, end):
- dset[i] = i
- return dset, start, end
-
- def wdayset(self, year, month, day):
- # We need to handle cross-year weeks here.
- dset = [None]*(self.yearlen+7)
- i = datetime.date(year, month, day).toordinal()-self.yearordinal
- start = i
- for j in range(7):
- dset[i] = i
- i += 1
- # if (not (0 <= i < self.yearlen) or
- # self.wdaymask[i] == self.rrule._wkst):
- # This will cross the year boundary, if necessary.
- if self.wdaymask[i] == self.rrule._wkst:
- break
- return dset, start, i
-
- def ddayset(self, year, month, day):
- dset = [None] * self.yearlen
- i = datetime.date(year, month, day).toordinal() - self.yearordinal
- dset[i] = i
- return dset, i, i + 1
-
- def htimeset(self, hour, minute, second):
- tset = []
- rr = self.rrule
- for minute in rr._byminute:
- for second in rr._bysecond:
- tset.append(datetime.time(hour, minute, second,
- tzinfo=rr._tzinfo))
- tset.sort()
- return tset
-
- def mtimeset(self, hour, minute, second):
- tset = []
- rr = self.rrule
- for second in rr._bysecond:
- tset.append(datetime.time(hour, minute, second, tzinfo=rr._tzinfo))
- tset.sort()
- return tset
-
- def stimeset(self, hour, minute, second):
- return (datetime.time(hour, minute, second,
- tzinfo=self.rrule._tzinfo),)
-
-
-class rruleset(rrulebase):
- """ The rruleset type allows more complex recurrence setups, mixing
- multiple rules, dates, exclusion rules, and exclusion dates. The type
- constructor takes the following keyword arguments:
-
- :param cache: If True, caching of results will be enabled, improving
- performance of multiple queries considerably. """
-
- class _genitem(object):
- def __init__(self, genlist, gen):
- try:
- self.dt = advance_iterator(gen)
- genlist.append(self)
- except StopIteration:
- pass
- self.genlist = genlist
- self.gen = gen
-
- def __next__(self):
- try:
- self.dt = advance_iterator(self.gen)
- except StopIteration:
- if self.genlist[0] is self:
- heapq.heappop(self.genlist)
- else:
- self.genlist.remove(self)
- heapq.heapify(self.genlist)
-
- next = __next__
-
- def __lt__(self, other):
- return self.dt < other.dt
-
- def __gt__(self, other):
- return self.dt > other.dt
-
- def __eq__(self, other):
- return self.dt == other.dt
-
- def __ne__(self, other):
- return self.dt != other.dt
-
- def __init__(self, cache=False):
- super(rruleset, self).__init__(cache)
- self._rrule = []
- self._rdate = []
- self._exrule = []
- self._exdate = []
-
- @_invalidates_cache
- def rrule(self, rrule):
- """ Include the given :py:class:`rrule` instance in the recurrence set
- generation. """
- self._rrule.append(rrule)
-
- @_invalidates_cache
- def rdate(self, rdate):
- """ Include the given :py:class:`datetime` instance in the recurrence
- set generation. """
- self._rdate.append(rdate)
-
- @_invalidates_cache
- def exrule(self, exrule):
- """ Include the given rrule instance in the recurrence set exclusion
- list. Dates which are part of the given recurrence rules will not
- be generated, even if some inclusive rrule or rdate matches them.
- """
- self._exrule.append(exrule)
-
- @_invalidates_cache
- def exdate(self, exdate):
- """ Include the given datetime instance in the recurrence set
- exclusion list. Dates included that way will not be generated,
- even if some inclusive rrule or rdate matches them. """
- self._exdate.append(exdate)
-
- def _iter(self):
- rlist = []
- self._rdate.sort()
- self._genitem(rlist, iter(self._rdate))
- for gen in [iter(x) for x in self._rrule]:
- self._genitem(rlist, gen)
- exlist = []
- self._exdate.sort()
- self._genitem(exlist, iter(self._exdate))
- for gen in [iter(x) for x in self._exrule]:
- self._genitem(exlist, gen)
- lastdt = None
- total = 0
- heapq.heapify(rlist)
- heapq.heapify(exlist)
- while rlist:
- ritem = rlist[0]
- if not lastdt or lastdt != ritem.dt:
- while exlist and exlist[0] < ritem:
- exitem = exlist[0]
- advance_iterator(exitem)
- if exlist and exlist[0] is exitem:
- heapq.heapreplace(exlist, exitem)
- if not exlist or ritem != exlist[0]:
- total += 1
- yield ritem.dt
- lastdt = ritem.dt
- advance_iterator(ritem)
- if rlist and rlist[0] is ritem:
- heapq.heapreplace(rlist, ritem)
- self._len = total
-
-
-class _rrulestr(object):
-
- _freq_map = {"YEARLY": YEARLY,
- "MONTHLY": MONTHLY,
- "WEEKLY": WEEKLY,
- "DAILY": DAILY,
- "HOURLY": HOURLY,
- "MINUTELY": MINUTELY,
- "SECONDLY": SECONDLY}
-
- _weekday_map = {"MO": 0, "TU": 1, "WE": 2, "TH": 3,
- "FR": 4, "SA": 5, "SU": 6}
-
- def _handle_int(self, rrkwargs, name, value, **kwargs):
- rrkwargs[name.lower()] = int(value)
-
- def _handle_int_list(self, rrkwargs, name, value, **kwargs):
- rrkwargs[name.lower()] = [int(x) for x in value.split(',')]
-
- _handle_INTERVAL = _handle_int
- _handle_COUNT = _handle_int
- _handle_BYSETPOS = _handle_int_list
- _handle_BYMONTH = _handle_int_list
- _handle_BYMONTHDAY = _handle_int_list
- _handle_BYYEARDAY = _handle_int_list
- _handle_BYEASTER = _handle_int_list
- _handle_BYWEEKNO = _handle_int_list
- _handle_BYHOUR = _handle_int_list
- _handle_BYMINUTE = _handle_int_list
- _handle_BYSECOND = _handle_int_list
-
- def _handle_FREQ(self, rrkwargs, name, value, **kwargs):
- rrkwargs["freq"] = self._freq_map[value]
-
- def _handle_UNTIL(self, rrkwargs, name, value, **kwargs):
- global parser
- if not parser:
- from dateutil import parser
- try:
- rrkwargs["until"] = parser.parse(value,
- ignoretz=kwargs.get("ignoretz"),
- tzinfos=kwargs.get("tzinfos"))
- except ValueError:
- raise ValueError("invalid until date")
-
- def _handle_WKST(self, rrkwargs, name, value, **kwargs):
- rrkwargs["wkst"] = self._weekday_map[value]
-
- def _handle_BYWEEKDAY(self, rrkwargs, name, value, **kwargs):
- """
- Two ways to specify this: +1MO or MO(+1)
- """
- l = []
- for wday in value.split(','):
- if '(' in wday:
- # If it's of the form TH(+1), etc.
- splt = wday.split('(')
- w = splt[0]
- n = int(splt[1][:-1])
- elif len(wday):
- # If it's of the form +1MO
- for i in range(len(wday)):
- if wday[i] not in '+-0123456789':
- break
- n = wday[:i] or None
- w = wday[i:]
- if n:
- n = int(n)
- else:
- raise ValueError("Invalid (empty) BYDAY specification.")
-
- l.append(weekdays[self._weekday_map[w]](n))
- rrkwargs["byweekday"] = l
-
- _handle_BYDAY = _handle_BYWEEKDAY
-
- def _parse_rfc_rrule(self, line,
- dtstart=None,
- cache=False,
- ignoretz=False,
- tzinfos=None):
- if line.find(':') != -1:
- name, value = line.split(':')
- if name != "RRULE":
- raise ValueError("unknown parameter name")
- else:
- value = line
- rrkwargs = {}
- for pair in value.split(';'):
- name, value = pair.split('=')
- name = name.upper()
- value = value.upper()
- try:
- getattr(self, "_handle_"+name)(rrkwargs, name, value,
- ignoretz=ignoretz,
- tzinfos=tzinfos)
- except AttributeError:
- raise ValueError("unknown parameter '%s'" % name)
- except (KeyError, ValueError):
- raise ValueError("invalid '%s': %s" % (name, value))
- return rrule(dtstart=dtstart, cache=cache, **rrkwargs)
-
- def _parse_rfc(self, s,
- dtstart=None,
- cache=False,
- unfold=False,
- forceset=False,
- compatible=False,
- ignoretz=False,
- tzinfos=None):
- global parser
- if compatible:
- forceset = True
- unfold = True
- s = s.upper()
- if not s.strip():
- raise ValueError("empty string")
- if unfold:
- lines = s.splitlines()
- i = 0
- while i < len(lines):
- line = lines[i].rstrip()
- if not line:
- del lines[i]
- elif i > 0 and line[0] == " ":
- lines[i-1] += line[1:]
- del lines[i]
- else:
- i += 1
- else:
- lines = s.split()
- if (not forceset and len(lines) == 1 and (s.find(':') == -1 or
- s.startswith('RRULE:'))):
- return self._parse_rfc_rrule(lines[0], cache=cache,
- dtstart=dtstart, ignoretz=ignoretz,
- tzinfos=tzinfos)
- else:
- rrulevals = []
- rdatevals = []
- exrulevals = []
- exdatevals = []
- for line in lines:
- if not line:
- continue
- if line.find(':') == -1:
- name = "RRULE"
- value = line
- else:
- name, value = line.split(':', 1)
- parms = name.split(';')
- if not parms:
- raise ValueError("empty property name")
- name = parms[0]
- parms = parms[1:]
- if name == "RRULE":
- for parm in parms:
- raise ValueError("unsupported RRULE parm: "+parm)
- rrulevals.append(value)
- elif name == "RDATE":
- for parm in parms:
- if parm != "VALUE=DATE-TIME":
- raise ValueError("unsupported RDATE parm: "+parm)
- rdatevals.append(value)
- elif name == "EXRULE":
- for parm in parms:
- raise ValueError("unsupported EXRULE parm: "+parm)
- exrulevals.append(value)
- elif name == "EXDATE":
- for parm in parms:
- if parm != "VALUE=DATE-TIME":
- raise ValueError("unsupported EXDATE parm: "+parm)
- exdatevals.append(value)
- elif name == "DTSTART":
- for parm in parms:
- raise ValueError("unsupported DTSTART parm: "+parm)
- if not parser:
- from dateutil import parser
- dtstart = parser.parse(value, ignoretz=ignoretz,
- tzinfos=tzinfos)
- else:
- raise ValueError("unsupported property: "+name)
- if (forceset or len(rrulevals) > 1 or rdatevals
- or exrulevals or exdatevals):
- if not parser and (rdatevals or exdatevals):
- from dateutil import parser
- rset = rruleset(cache=cache)
- for value in rrulevals:
- rset.rrule(self._parse_rfc_rrule(value, dtstart=dtstart,
- ignoretz=ignoretz,
- tzinfos=tzinfos))
- for value in rdatevals:
- for datestr in value.split(','):
- rset.rdate(parser.parse(datestr,
- ignoretz=ignoretz,
- tzinfos=tzinfos))
- for value in exrulevals:
- rset.exrule(self._parse_rfc_rrule(value, dtstart=dtstart,
- ignoretz=ignoretz,
- tzinfos=tzinfos))
- for value in exdatevals:
- for datestr in value.split(','):
- rset.exdate(parser.parse(datestr,
- ignoretz=ignoretz,
- tzinfos=tzinfos))
- if compatible and dtstart:
- rset.rdate(dtstart)
- return rset
- else:
- return self._parse_rfc_rrule(rrulevals[0],
- dtstart=dtstart,
- cache=cache,
- ignoretz=ignoretz,
- tzinfos=tzinfos)
-
- def __call__(self, s, **kwargs):
- return self._parse_rfc(s, **kwargs)
-
-
-rrulestr = _rrulestr()
-
-# vim:ts=4:sw=4:et
diff --git a/python/dateutil/tz/__init__.py b/python/dateutil/tz/__init__.py
deleted file mode 100644
index b0a5043..0000000
--- a/python/dateutil/tz/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from .tz import *
-
-__all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
- "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz",
- "enfold", "datetime_ambiguous", "datetime_exists"]
diff --git a/python/dateutil/tz/_common.py b/python/dateutil/tz/_common.py
deleted file mode 100644
index f1cf2af..0000000
--- a/python/dateutil/tz/_common.py
+++ /dev/null
@@ -1,394 +0,0 @@
-from six import PY3
-
-from functools import wraps
-
-from datetime import datetime, timedelta, tzinfo
-
-
-ZERO = timedelta(0)
-
-__all__ = ['tzname_in_python2', 'enfold']
-
-
-def tzname_in_python2(namefunc):
- """Change unicode output into bytestrings in Python 2
-
- tzname() API changed in Python 3. It used to return bytes, but was changed
- to unicode strings
- """
- def adjust_encoding(*args, **kwargs):
- name = namefunc(*args, **kwargs)
- if name is not None and not PY3:
- name = name.encode()
-
- return name
-
- return adjust_encoding
-
-
-# The following is adapted from Alexander Belopolsky's tz library
-# https://github.com/abalkin/tz
-if hasattr(datetime, 'fold'):
- # This is the pre-python 3.6 fold situation
- def enfold(dt, fold=1):
- """
- Provides a unified interface for assigning the ``fold`` attribute to
- datetimes both before and after the implementation of PEP-495.
-
- :param fold:
- The value for the ``fold`` attribute in the returned datetime. This
- should be either 0 or 1.
-
- :return:
- Returns an object for which ``getattr(dt, 'fold', 0)`` returns
- ``fold`` for all versions of Python. In versions prior to
- Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
- subclass of :py:class:`datetime.datetime` with the ``fold``
- attribute added, if ``fold`` is 1.
-
- .. versionadded:: 2.6.0
- """
- return dt.replace(fold=fold)
-
-else:
- class _DatetimeWithFold(datetime):
- """
- This is a class designed to provide a PEP 495-compliant interface for
- Python versions before 3.6. It is used only for dates in a fold, so
- the ``fold`` attribute is fixed at ``1``.
-
- .. versionadded:: 2.6.0
- """
- __slots__ = ()
-
- @property
- def fold(self):
- return 1
-
- def enfold(dt, fold=1):
- """
- Provides a unified interface for assigning the ``fold`` attribute to
- datetimes both before and after the implementation of PEP-495.
-
- :param fold:
- The value for the ``fold`` attribute in the returned datetime. This
- should be either 0 or 1.
-
- :return:
- Returns an object for which ``getattr(dt, 'fold', 0)`` returns
- ``fold`` for all versions of Python. In versions prior to
- Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
- subclass of :py:class:`datetime.datetime` with the ``fold``
- attribute added, if ``fold`` is 1.
-
- .. versionadded:: 2.6.0
- """
- if getattr(dt, 'fold', 0) == fold:
- return dt
-
- args = dt.timetuple()[:6]
- args += (dt.microsecond, dt.tzinfo)
-
- if fold:
- return _DatetimeWithFold(*args)
- else:
- return datetime(*args)
-
-
-def _validate_fromutc_inputs(f):
- """
- The CPython version of ``fromutc`` checks that the input is a ``datetime``
- object and that ``self`` is attached as its ``tzinfo``.
- """
- @wraps(f)
- def fromutc(self, dt):
- if not isinstance(dt, datetime):
- raise TypeError("fromutc() requires a datetime argument")
- if dt.tzinfo is not self:
- raise ValueError("dt.tzinfo is not self")
-
- return f(self, dt)
-
- return fromutc
-
-
-class _tzinfo(tzinfo):
- """
- Base class for all ``dateutil`` ``tzinfo`` objects.
- """
-
- def is_ambiguous(self, dt):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
-
- dt = dt.replace(tzinfo=self)
-
- wall_0 = enfold(dt, fold=0)
- wall_1 = enfold(dt, fold=1)
-
- same_offset = wall_0.utcoffset() == wall_1.utcoffset()
- same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)
-
- return same_dt and not same_offset
-
- def _fold_status(self, dt_utc, dt_wall):
- """
- Determine the fold status of a "wall" datetime, given a representation
- of the same datetime as a (naive) UTC datetime. This is calculated based
- on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
- datetimes, and that this offset is the actual number of hours separating
- ``dt_utc`` and ``dt_wall``.
-
- :param dt_utc:
- Representation of the datetime as UTC
-
- :param dt_wall:
- Representation of the datetime as "wall time". This parameter must
- either have a `fold` attribute or have a fold-naive
- :class:`datetime.tzinfo` attached, otherwise the calculation may
- fail.
- """
- if self.is_ambiguous(dt_wall):
- delta_wall = dt_wall - dt_utc
- _fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst()))
- else:
- _fold = 0
-
- return _fold
-
- def _fold(self, dt):
- return getattr(dt, 'fold', 0)
-
- def _fromutc(self, dt):
- """
- Given a timezone-aware datetime in a given timezone, calculates a
- timezone-aware datetime in a new timezone.
-
- Since this is the one time that we *know* we have an unambiguous
- datetime object, we take this opportunity to determine whether the
- datetime is ambiguous and in a "fold" state (e.g. if it's the first
- occurence, chronologically, of the ambiguous datetime).
-
- :param dt:
- A timezone-aware :class:`datetime.datetime` object.
- """
-
- # Re-implement the algorithm from Python's datetime.py
- dtoff = dt.utcoffset()
- if dtoff is None:
- raise ValueError("fromutc() requires a non-None utcoffset() "
- "result")
-
- # The original datetime.py code assumes that `dst()` defaults to
- # zero during ambiguous times. PEP 495 inverts this presumption, so
- # for pre-PEP 495 versions of python, we need to tweak the algorithm.
- dtdst = dt.dst()
- if dtdst is None:
- raise ValueError("fromutc() requires a non-None dst() result")
- delta = dtoff - dtdst
-
- dt += delta
- # Set fold=1 so we can default to being in the fold for
- # ambiguous dates.
- dtdst = enfold(dt, fold=1).dst()
- if dtdst is None:
- raise ValueError("fromutc(): dt.dst gave inconsistent "
- "results; cannot convert")
- return dt + dtdst
-
- @_validate_fromutc_inputs
- def fromutc(self, dt):
- """
- Given a timezone-aware datetime in a given timezone, calculates a
- timezone-aware datetime in a new timezone.
-
- Since this is the one time that we *know* we have an unambiguous
- datetime object, we take this opportunity to determine whether the
- datetime is ambiguous and in a "fold" state (e.g. if it's the first
- occurance, chronologically, of the ambiguous datetime).
-
- :param dt:
- A timezone-aware :class:`datetime.datetime` object.
- """
- dt_wall = self._fromutc(dt)
-
- # Calculate the fold status given the two datetimes.
- _fold = self._fold_status(dt, dt_wall)
-
- # Set the default fold value for ambiguous dates
- return enfold(dt_wall, fold=_fold)
-
-
-class tzrangebase(_tzinfo):
- """
- This is an abstract base class for time zones represented by an annual
- transition into and out of DST. Child classes should implement the following
- methods:
-
- * ``__init__(self, *args, **kwargs)``
- * ``transitions(self, year)`` - this is expected to return a tuple of
- datetimes representing the DST on and off transitions in standard
- time.
-
- A fully initialized ``tzrangebase`` subclass should also provide the
- following attributes:
- * ``hasdst``: Boolean whether or not the zone uses DST.
- * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
- representing the respective UTC offsets.
- * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
- abbreviations in DST and STD, respectively.
- * ``_hasdst``: Whether or not the zone has DST.
-
- .. versionadded:: 2.6.0
- """
- def __init__(self):
- raise NotImplementedError('tzrangebase is an abstract base class')
-
- def utcoffset(self, dt):
- isdst = self._isdst(dt)
-
- if isdst is None:
- return None
- elif isdst:
- return self._dst_offset
- else:
- return self._std_offset
-
- def dst(self, dt):
- isdst = self._isdst(dt)
-
- if isdst is None:
- return None
- elif isdst:
- return self._dst_base_offset
- else:
- return ZERO
-
- @tzname_in_python2
- def tzname(self, dt):
- if self._isdst(dt):
- return self._dst_abbr
- else:
- return self._std_abbr
-
- def fromutc(self, dt):
- """ Given a datetime in UTC, return local time """
- if not isinstance(dt, datetime):
- raise TypeError("fromutc() requires a datetime argument")
-
- if dt.tzinfo is not self:
- raise ValueError("dt.tzinfo is not self")
-
- # Get transitions - if there are none, fixed offset
- transitions = self.transitions(dt.year)
- if transitions is None:
- return dt + self.utcoffset(dt)
-
- # Get the transition times in UTC
- dston, dstoff = transitions
-
- dston -= self._std_offset
- dstoff -= self._std_offset
-
- utc_transitions = (dston, dstoff)
- dt_utc = dt.replace(tzinfo=None)
-
- isdst = self._naive_isdst(dt_utc, utc_transitions)
-
- if isdst:
- dt_wall = dt + self._dst_offset
- else:
- dt_wall = dt + self._std_offset
-
- _fold = int(not isdst and self.is_ambiguous(dt_wall))
-
- return enfold(dt_wall, fold=_fold)
-
- def is_ambiguous(self, dt):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
- if not self.hasdst:
- return False
-
- start, end = self.transitions(dt.year)
-
- dt = dt.replace(tzinfo=None)
- return (end <= dt < end + self._dst_base_offset)
-
- def _isdst(self, dt):
- if not self.hasdst:
- return False
- elif dt is None:
- return None
-
- transitions = self.transitions(dt.year)
-
- if transitions is None:
- return False
-
- dt = dt.replace(tzinfo=None)
-
- isdst = self._naive_isdst(dt, transitions)
-
- # Handle ambiguous dates
- if not isdst and self.is_ambiguous(dt):
- return not self._fold(dt)
- else:
- return isdst
-
- def _naive_isdst(self, dt, transitions):
- dston, dstoff = transitions
-
- dt = dt.replace(tzinfo=None)
-
- if dston < dstoff:
- isdst = dston <= dt < dstoff
- else:
- isdst = not dstoff <= dt < dston
-
- return isdst
-
- @property
- def _dst_base_offset(self):
- return self._dst_offset - self._std_offset
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __repr__(self):
- return "%s(...)" % self.__class__.__name__
-
- __reduce__ = object.__reduce__
-
-
-def _total_seconds(td):
- # Python 2.6 doesn't have a total_seconds() method on timedelta objects
- return ((td.seconds + td.days * 86400) * 1000000 +
- td.microseconds) // 1000000
-
-
-_total_seconds = getattr(timedelta, 'total_seconds', _total_seconds)
diff --git a/python/dateutil/tz/tz.py b/python/dateutil/tz/tz.py
deleted file mode 100644
index 9468282..0000000
--- a/python/dateutil/tz/tz.py
+++ /dev/null
@@ -1,1511 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-This module offers timezone implementations subclassing the abstract
-:py:`datetime.tzinfo` type. There are classes to handle tzfile format files
-(usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ
-environment string (in all known formats), given ranges (with help from
-relative deltas), local machine timezone, fixed offset timezone, and UTC
-timezone.
-"""
-import datetime
-import struct
-import time
-import sys
-import os
-import bisect
-
-from six import string_types
-from ._common import tzname_in_python2, _tzinfo, _total_seconds
-from ._common import tzrangebase, enfold
-from ._common import _validate_fromutc_inputs
-
-try:
- from .win import tzwin, tzwinlocal
-except ImportError:
- tzwin = tzwinlocal = None
-
-ZERO = datetime.timedelta(0)
-EPOCH = datetime.datetime.utcfromtimestamp(0)
-EPOCHORDINAL = EPOCH.toordinal()
-
-
-class tzutc(datetime.tzinfo):
- """
- This is a tzinfo object that represents the UTC time zone.
- """
- def utcoffset(self, dt):
- return ZERO
-
- def dst(self, dt):
- return ZERO
-
- @tzname_in_python2
- def tzname(self, dt):
- return "UTC"
-
- def is_ambiguous(self, dt):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
- return False
-
- @_validate_fromutc_inputs
- def fromutc(self, dt):
- """
- Fast track version of fromutc() returns the original ``dt`` object for
- any valid :py:class:`datetime.datetime` object.
- """
- return dt
-
- def __eq__(self, other):
- if not isinstance(other, (tzutc, tzoffset)):
- return NotImplemented
-
- return (isinstance(other, tzutc) or
- (isinstance(other, tzoffset) and other._offset == ZERO))
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __repr__(self):
- return "%s()" % self.__class__.__name__
-
- __reduce__ = object.__reduce__
-
-
-class tzoffset(datetime.tzinfo):
- """
- A simple class for representing a fixed offset from UTC.
-
- :param name:
- The timezone name, to be returned when ``tzname()`` is called.
-
- :param offset:
- The time zone offset in seconds, or (since version 2.6.0, represented
- as a :py:class:`datetime.timedelta` object.
- """
- def __init__(self, name, offset):
- self._name = name
-
- try:
- # Allow a timedelta
- offset = _total_seconds(offset)
- except (TypeError, AttributeError):
- pass
- self._offset = datetime.timedelta(seconds=offset)
-
- def utcoffset(self, dt):
- return self._offset
-
- def dst(self, dt):
- return ZERO
-
- @tzname_in_python2
- def tzname(self, dt):
- return self._name
-
- @_validate_fromutc_inputs
- def fromutc(self, dt):
- return dt + self._offset
-
- def is_ambiguous(self, dt):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
- return False
-
- def __eq__(self, other):
- if not isinstance(other, tzoffset):
- return NotImplemented
-
- return self._offset == other._offset
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __repr__(self):
- return "%s(%s, %s)" % (self.__class__.__name__,
- repr(self._name),
- int(_total_seconds(self._offset)))
-
- __reduce__ = object.__reduce__
-
-
-class tzlocal(_tzinfo):
- """
- A :class:`tzinfo` subclass built around the ``time`` timezone functions.
- """
- def __init__(self):
- super(tzlocal, self).__init__()
-
- self._std_offset = datetime.timedelta(seconds=-time.timezone)
- if time.daylight:
- self._dst_offset = datetime.timedelta(seconds=-time.altzone)
- else:
- self._dst_offset = self._std_offset
-
- self._dst_saved = self._dst_offset - self._std_offset
- self._hasdst = bool(self._dst_saved)
-
- def utcoffset(self, dt):
- if dt is None and self._hasdst:
- return None
-
- if self._isdst(dt):
- return self._dst_offset
- else:
- return self._std_offset
-
- def dst(self, dt):
- if dt is None and self._hasdst:
- return None
-
- if self._isdst(dt):
- return self._dst_offset - self._std_offset
- else:
- return ZERO
-
- @tzname_in_python2
- def tzname(self, dt):
- return time.tzname[self._isdst(dt)]
-
- def is_ambiguous(self, dt):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
- naive_dst = self._naive_is_dst(dt)
- return (not naive_dst and
- (naive_dst != self._naive_is_dst(dt - self._dst_saved)))
-
- def _naive_is_dst(self, dt):
- timestamp = _datetime_to_timestamp(dt)
- return time.localtime(timestamp + time.timezone).tm_isdst
-
- def _isdst(self, dt, fold_naive=True):
- # We can't use mktime here. It is unstable when deciding if
- # the hour near to a change is DST or not.
- #
- # timestamp = time.mktime((dt.year, dt.month, dt.day, dt.hour,
- # dt.minute, dt.second, dt.weekday(), 0, -1))
- # return time.localtime(timestamp).tm_isdst
- #
- # The code above yields the following result:
- #
- # >>> import tz, datetime
- # >>> t = tz.tzlocal()
- # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
- # 'BRDT'
- # >>> datetime.datetime(2003,2,16,0,tzinfo=t).tzname()
- # 'BRST'
- # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
- # 'BRST'
- # >>> datetime.datetime(2003,2,15,22,tzinfo=t).tzname()
- # 'BRDT'
- # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
- # 'BRDT'
- #
- # Here is a more stable implementation:
- #
- if not self._hasdst:
- return False
-
- # Check for ambiguous times:
- dstval = self._naive_is_dst(dt)
- fold = getattr(dt, 'fold', None)
-
- if self.is_ambiguous(dt):
- if fold is not None:
- return not self._fold(dt)
- else:
- return True
-
- return dstval
-
- def __eq__(self, other):
- if not isinstance(other, tzlocal):
- return NotImplemented
-
- return (self._std_offset == other._std_offset and
- self._dst_offset == other._dst_offset)
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __repr__(self):
- return "%s()" % self.__class__.__name__
-
- __reduce__ = object.__reduce__
-
-
-class _ttinfo(object):
- __slots__ = ["offset", "delta", "isdst", "abbr",
- "isstd", "isgmt", "dstoffset"]
-
- def __init__(self):
- for attr in self.__slots__:
- setattr(self, attr, None)
-
- def __repr__(self):
- l = []
- for attr in self.__slots__:
- value = getattr(self, attr)
- if value is not None:
- l.append("%s=%s" % (attr, repr(value)))
- return "%s(%s)" % (self.__class__.__name__, ", ".join(l))
-
- def __eq__(self, other):
- if not isinstance(other, _ttinfo):
- return NotImplemented
-
- return (self.offset == other.offset and
- self.delta == other.delta and
- self.isdst == other.isdst and
- self.abbr == other.abbr and
- self.isstd == other.isstd and
- self.isgmt == other.isgmt and
- self.dstoffset == other.dstoffset)
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __getstate__(self):
- state = {}
- for name in self.__slots__:
- state[name] = getattr(self, name, None)
- return state
-
- def __setstate__(self, state):
- for name in self.__slots__:
- if name in state:
- setattr(self, name, state[name])
-
-
-class _tzfile(object):
- """
- Lightweight class for holding the relevant transition and time zone
- information read from binary tzfiles.
- """
- attrs = ['trans_list', 'trans_list_utc', 'trans_idx', 'ttinfo_list',
- 'ttinfo_std', 'ttinfo_dst', 'ttinfo_before', 'ttinfo_first']
-
- def __init__(self, **kwargs):
- for attr in self.attrs:
- setattr(self, attr, kwargs.get(attr, None))
-
-
-class tzfile(_tzinfo):
- """
- This is a ``tzinfo`` subclass thant allows one to use the ``tzfile(5)``
- format timezone files to extract current and historical zone information.
-
- :param fileobj:
- This can be an opened file stream or a file name that the time zone
- information can be read from.
-
- :param filename:
- This is an optional parameter specifying the source of the time zone
- information in the event that ``fileobj`` is a file object. If omitted
- and ``fileobj`` is a file stream, this parameter will be set either to
- ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``.
-
- See `Sources for Time Zone and Daylight Saving Time Data
- <http://www.twinsun.com/tz/tz-link.htm>`_ for more information. Time zone
- files can be compiled from the `IANA Time Zone database files
- <https://www.iana.org/time-zones>`_ with the `zic time zone compiler
- <https://www.freebsd.org/cgi/man.cgi?query=zic&sektion=8>`_
- """
-
- def __init__(self, fileobj, filename=None):
- super(tzfile, self).__init__()
-
- file_opened_here = False
- if isinstance(fileobj, string_types):
- self._filename = fileobj
- fileobj = open(fileobj, 'rb')
- file_opened_here = True
- elif filename is not None:
- self._filename = filename
- elif hasattr(fileobj, "name"):
- self._filename = fileobj.name
- else:
- self._filename = repr(fileobj)
-
- if fileobj is not None:
- if not file_opened_here:
- fileobj = _ContextWrapper(fileobj)
-
- with fileobj as file_stream:
- tzobj = self._read_tzfile(file_stream)
-
- self._set_tzdata(tzobj)
-
- def _set_tzdata(self, tzobj):
- """ Set the time zone data of this object from a _tzfile object """
- # Copy the relevant attributes over as private attributes
- for attr in _tzfile.attrs:
- setattr(self, '_' + attr, getattr(tzobj, attr))
-
- def _read_tzfile(self, fileobj):
- out = _tzfile()
-
- # From tzfile(5):
- #
- # The time zone information files used by tzset(3)
- # begin with the magic characters "TZif" to identify
- # them as time zone information files, followed by
- # sixteen bytes reserved for future use, followed by
- # six four-byte values of type long, written in a
- # ``standard'' byte order (the high-order byte
- # of the value is written first).
- if fileobj.read(4).decode() != "TZif":
- raise ValueError("magic not found")
-
- fileobj.read(16)
-
- (
- # The number of UTC/local indicators stored in the file.
- ttisgmtcnt,
-
- # The number of standard/wall indicators stored in the file.
- ttisstdcnt,
-
- # The number of leap seconds for which data is
- # stored in the file.
- leapcnt,
-
- # The number of "transition times" for which data
- # is stored in the file.
- timecnt,
-
- # The number of "local time types" for which data
- # is stored in the file (must not be zero).
- typecnt,
-
- # The number of characters of "time zone
- # abbreviation strings" stored in the file.
- charcnt,
-
- ) = struct.unpack(">6l", fileobj.read(24))
-
- # The above header is followed by tzh_timecnt four-byte
- # values of type long, sorted in ascending order.
- # These values are written in ``standard'' byte order.
- # Each is used as a transition time (as returned by
- # time(2)) at which the rules for computing local time
- # change.
-
- if timecnt:
- out.trans_list_utc = list(struct.unpack(">%dl" % timecnt,
- fileobj.read(timecnt*4)))
- else:
- out.trans_list_utc = []
-
- # Next come tzh_timecnt one-byte values of type unsigned
- # char; each one tells which of the different types of
- # ``local time'' types described in the file is associated
- # with the same-indexed transition time. These values
- # serve as indices into an array of ttinfo structures that
- # appears next in the file.
-
- if timecnt:
- out.trans_idx = struct.unpack(">%dB" % timecnt,
- fileobj.read(timecnt))
- else:
- out.trans_idx = []
-
- # Each ttinfo structure is written as a four-byte value
- # for tt_gmtoff of type long, in a standard byte
- # order, followed by a one-byte value for tt_isdst
- # and a one-byte value for tt_abbrind. In each
- # structure, tt_gmtoff gives the number of
- # seconds to be added to UTC, tt_isdst tells whether
- # tm_isdst should be set by localtime(3), and
- # tt_abbrind serves as an index into the array of
- # time zone abbreviation characters that follow the
- # ttinfo structure(s) in the file.
-
- ttinfo = []
-
- for i in range(typecnt):
- ttinfo.append(struct.unpack(">lbb", fileobj.read(6)))
-
- abbr = fileobj.read(charcnt).decode()
-
- # Then there are tzh_leapcnt pairs of four-byte
- # values, written in standard byte order; the
- # first value of each pair gives the time (as
- # returned by time(2)) at which a leap second
- # occurs; the second gives the total number of
- # leap seconds to be applied after the given time.
- # The pairs of values are sorted in ascending order
- # by time.
-
- # Not used, for now (but seek for correct file position)
- if leapcnt:
- fileobj.seek(leapcnt * 8, os.SEEK_CUR)
-
- # Then there are tzh_ttisstdcnt standard/wall
- # indicators, each stored as a one-byte value;
- # they tell whether the transition times associated
- # with local time types were specified as standard
- # time or wall clock time, and are used when
- # a time zone file is used in handling POSIX-style
- # time zone environment variables.
-
- if ttisstdcnt:
- isstd = struct.unpack(">%db" % ttisstdcnt,
- fileobj.read(ttisstdcnt))
-
- # Finally, there are tzh_ttisgmtcnt UTC/local
- # indicators, each stored as a one-byte value;
- # they tell whether the transition times associated
- # with local time types were specified as UTC or
- # local time, and are used when a time zone file
- # is used in handling POSIX-style time zone envi-
- # ronment variables.
-
- if ttisgmtcnt:
- isgmt = struct.unpack(">%db" % ttisgmtcnt,
- fileobj.read(ttisgmtcnt))
-
- # Build ttinfo list
- out.ttinfo_list = []
- for i in range(typecnt):
- gmtoff, isdst, abbrind = ttinfo[i]
- # Round to full-minutes if that's not the case. Python's
- # datetime doesn't accept sub-minute timezones. Check
- # http://python.org/sf/1447945 for some information.
- gmtoff = 60 * ((gmtoff + 30) // 60)
- tti = _ttinfo()
- tti.offset = gmtoff
- tti.dstoffset = datetime.timedelta(0)
- tti.delta = datetime.timedelta(seconds=gmtoff)
- tti.isdst = isdst
- tti.abbr = abbr[abbrind:abbr.find('\x00', abbrind)]
- tti.isstd = (ttisstdcnt > i and isstd[i] != 0)
- tti.isgmt = (ttisgmtcnt > i and isgmt[i] != 0)
- out.ttinfo_list.append(tti)
-
- # Replace ttinfo indexes for ttinfo objects.
- out.trans_idx = [out.ttinfo_list[idx] for idx in out.trans_idx]
-
- # Set standard, dst, and before ttinfos. before will be
- # used when a given time is before any transitions,
- # and will be set to the first non-dst ttinfo, or to
- # the first dst, if all of them are dst.
- out.ttinfo_std = None
- out.ttinfo_dst = None
- out.ttinfo_before = None
- if out.ttinfo_list:
- if not out.trans_list_utc:
- out.ttinfo_std = out.ttinfo_first = out.ttinfo_list[0]
- else:
- for i in range(timecnt-1, -1, -1):
- tti = out.trans_idx[i]
- if not out.ttinfo_std and not tti.isdst:
- out.ttinfo_std = tti
- elif not out.ttinfo_dst and tti.isdst:
- out.ttinfo_dst = tti
-
- if out.ttinfo_std and out.ttinfo_dst:
- break
- else:
- if out.ttinfo_dst and not out.ttinfo_std:
- out.ttinfo_std = out.ttinfo_dst
-
- for tti in out.ttinfo_list:
- if not tti.isdst:
- out.ttinfo_before = tti
- break
- else:
- out.ttinfo_before = out.ttinfo_list[0]
-
- # Now fix transition times to become relative to wall time.
- #
- # I'm not sure about this. In my tests, the tz source file
- # is setup to wall time, and in the binary file isstd and
- # isgmt are off, so it should be in wall time. OTOH, it's
- # always in gmt time. Let me know if you have comments
- # about this.
- laststdoffset = None
- out.trans_list = []
- for i, tti in enumerate(out.trans_idx):
- if not tti.isdst:
- offset = tti.offset
- laststdoffset = offset
- else:
- if laststdoffset is not None:
- # Store the DST offset as well and update it in the list
- tti.dstoffset = tti.offset - laststdoffset
- out.trans_idx[i] = tti
-
- offset = laststdoffset or 0
-
- out.trans_list.append(out.trans_list_utc[i] + offset)
-
- # In case we missed any DST offsets on the way in for some reason, make
- # a second pass over the list, looking for the /next/ DST offset.
- laststdoffset = None
- for i in reversed(range(len(out.trans_idx))):
- tti = out.trans_idx[i]
- if tti.isdst:
- if not (tti.dstoffset or laststdoffset is None):
- tti.dstoffset = tti.offset - laststdoffset
- else:
- laststdoffset = tti.offset
-
- if not isinstance(tti.dstoffset, datetime.timedelta):
- tti.dstoffset = datetime.timedelta(seconds=tti.dstoffset)
-
- out.trans_idx[i] = tti
-
- out.trans_idx = tuple(out.trans_idx)
- out.trans_list = tuple(out.trans_list)
- out.trans_list_utc = tuple(out.trans_list_utc)
-
- return out
-
- def _find_last_transition(self, dt, in_utc=False):
- # If there's no list, there are no transitions to find
- if not self._trans_list:
- return None
-
- timestamp = _datetime_to_timestamp(dt)
-
- # Find where the timestamp fits in the transition list - if the
- # timestamp is a transition time, it's part of the "after" period.
- trans_list = self._trans_list_utc if in_utc else self._trans_list
- idx = bisect.bisect_right(trans_list, timestamp)
-
- # We want to know when the previous transition was, so subtract off 1
- return idx - 1
-
- def _get_ttinfo(self, idx):
- # For no list or after the last transition, default to _ttinfo_std
- if idx is None or (idx + 1) >= len(self._trans_list):
- return self._ttinfo_std
-
- # If there is a list and the time is before it, return _ttinfo_before
- if idx < 0:
- return self._ttinfo_before
-
- return self._trans_idx[idx]
-
- def _find_ttinfo(self, dt):
- idx = self._resolve_ambiguous_time(dt)
-
- return self._get_ttinfo(idx)
-
- def fromutc(self, dt):
- """
- The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`.
-
- :param dt:
- A :py:class:`datetime.datetime` object.
-
- :raises TypeError:
- Raised if ``dt`` is not a :py:class:`datetime.datetime` object.
-
- :raises ValueError:
- Raised if this is called with a ``dt`` which does not have this
- ``tzinfo`` attached.
-
- :return:
- Returns a :py:class:`datetime.datetime` object representing the
- wall time in ``self``'s time zone.
- """
- # These isinstance checks are in datetime.tzinfo, so we'll preserve
- # them, even if we don't care about duck typing.
- if not isinstance(dt, datetime.datetime):
- raise TypeError("fromutc() requires a datetime argument")
-
- if dt.tzinfo is not self:
- raise ValueError("dt.tzinfo is not self")
-
- # First treat UTC as wall time and get the transition we're in.
- idx = self._find_last_transition(dt, in_utc=True)
- tti = self._get_ttinfo(idx)
-
- dt_out = dt + datetime.timedelta(seconds=tti.offset)
-
- fold = self.is_ambiguous(dt_out, idx=idx)
-
- return enfold(dt_out, fold=int(fold))
-
- def is_ambiguous(self, dt, idx=None):
- """
- Whether or not the "wall time" of a given datetime is ambiguous in this
- zone.
-
- :param dt:
- A :py:class:`datetime.datetime`, naive or time zone aware.
-
-
- :return:
- Returns ``True`` if ambiguous, ``False`` otherwise.
-
- .. versionadded:: 2.6.0
- """
- if idx is None:
- idx = self._find_last_transition(dt)
-
- # Calculate the difference in offsets from current to previous
- timestamp = _datetime_to_timestamp(dt)
- tti = self._get_ttinfo(idx)
-
- if idx is None or idx <= 0:
- return False
-
- od = self._get_ttinfo(idx - 1).offset - tti.offset
- tt = self._trans_list[idx] # Transition time
-
- return timestamp < tt + od
-
- def _resolve_ambiguous_time(self, dt):
- idx = self._find_last_transition(dt)
-
- # If we have no transitions, return the index
- _fold = self._fold(dt)
- if idx is None or idx == 0:
- return idx
-
- # If it's ambiguous and we're in a fold, shift to a different index.
- idx_offset = int(not _fold and self.is_ambiguous(dt, idx))
-
- return idx - idx_offset
-
- def utcoffset(self, dt):
- if dt is None:
- return None
-
- if not self._ttinfo_std:
- return ZERO
-
- return self._find_ttinfo(dt).delta
-
- def dst(self, dt):
- if dt is None:
- return None
-
- if not self._ttinfo_dst:
- return ZERO
-
- tti = self._find_ttinfo(dt)
-
- if not tti.isdst:
- return ZERO
-
- # The documentation says that utcoffset()-dst() must
- # be constant for every dt.
- return tti.dstoffset
-
- @tzname_in_python2
- def tzname(self, dt):
- if not self._ttinfo_std or dt is None:
- return None
- return self._find_ttinfo(dt).abbr
-
- def __eq__(self, other):
- if not isinstance(other, tzfile):
- return NotImplemented
- return (self._trans_list == other._trans_list and
- self._trans_idx == other._trans_idx and
- self._ttinfo_list == other._ttinfo_list)
-
- __hash__ = None
-
- def __ne__(self, other):
- return not (self == other)
-
- def __repr__(self):
- return "%s(%s)" % (self.__class__.__name__, repr(self._filename))
-
- def __reduce__(self):
- return self.__reduce_ex__(None)
-
- def __reduce_ex__(self, protocol):
- return (self.__class__, (None, self._filename), self.__dict__)
-
-
-class tzrange(tzrangebase):
- """
- The ``tzrange`` object is a time zone specified by a set of offsets and
- abbreviations, equivalent to the way the ``TZ`` variable can be specified
- in POSIX-like systems, but using Python delta objects to specify DST
- start, end and offsets.
-
- :param stdabbr:
- The abbreviation for standard time (e.g. ``'EST'``).
-
- :param stdoffset:
- An integer or :class:`datetime.timedelta` object or equivalent
- specifying the base offset from UTC.
-
- If unspecified, +00:00 is used.
-
- :param dstabbr:
- The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).
-
- If specified, with no other DST information, DST is assumed to occur
- and the default behavior or ``dstoffset``, ``start`` and ``end`` is
- used. If unspecified and no other DST information is specified, it
- is assumed that this zone has no DST.
-
- If this is unspecified and other DST information is *is* specified,
- DST occurs in the zone but the time zone abbreviation is left
- unchanged.
-
- :param dstoffset:
- A an integer or :class:`datetime.timedelta` object or equivalent
- specifying the UTC offset during DST. If unspecified and any other DST
- information is specified, it is assumed to be the STD offset +1 hour.
-
- :param start:
- A :class:`relativedelta.relativedelta` object or equivalent specifying
- the time and time of year that daylight savings time starts. To specify,
- for example, that DST starts at 2AM on the 2nd Sunday in March, pass:
-
- ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``
-
- If unspecified and any other DST information is specified, the default
- value is 2 AM on the first Sunday in April.
-
- :param end:
- A :class:`relativedelta.relativedelta` object or equivalent representing
- the time and time of year that daylight savings time ends, with the
- same specification method as in ``start``. One note is that this should
- point to the first time in the *standard* zone, so if a transition
- occurs at 2AM in the DST zone and the clocks are set back 1 hour to 1AM,
- set the `hours` parameter to +1.
-
-
- **Examples:**
-
- .. testsetup:: tzrange
-
- from dateutil.tz import tzrange, tzstr
-
- .. doctest:: tzrange
-
- >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
- True
-
- >>> from dateutil.relativedelta import *
- >>> range1 = tzrange("EST", -18000, "EDT")
- >>> range2 = tzrange("EST", -18000, "EDT", -14400,
- ... relativedelta(hours=+2, month=4, day=1,
- ... weekday=SU(+1)),
- ... relativedelta(hours=+1, month=10, day=31,
- ... weekday=SU(-1)))
- >>> tzstr('EST5EDT') == range1 == range2
- True
-
- """
- def __init__(self, stdabbr, stdoffset=None,
- dstabbr=None, dstoffset=None,
- start=None, end=None):
-
- global relativedelta
- from dateutil import relativedelta
-
- self._std_abbr = stdabbr
- self._dst_abbr = dstabbr
-
- try:
- stdoffset = _total_seconds(stdoffset)
- except (TypeError, AttributeError):
- pass
-
- try:
- dstoffset = _total_seconds(dstoffset)
- except (TypeError, AttributeError):
- pass
-
- if stdoffset is not None:
- self._std_offset = datetime.timedelta(seconds=stdoffset)
- else:
- self._std_offset = ZERO
-
- if dstoffset is not None:
- self._dst_offset = datetime.timedelta(seconds=dstoffset)
- elif dstabbr and stdoffset is not None:
- self._dst_offset = self._std_offset + datetime.timedelta(hours=+1)
- else:
- self._dst_offset = ZERO
-
- if dstabbr and start is None:
- self._start_delta = relativedelta.relativedelta(
- hours=+2, month=4, day=1, weekday=relativedelta.SU(+1))
- else:
- self._start_delta = start
-
- if dstabbr and end is None:
- self._end_delta = relativedelta.relativedelta(
- hours=+1, month=10, day=31, weekday=relativedelta.SU(-1))
- else:
- self._end_delta = end
-
- self._dst_base_offset_ = self._dst_offset - self._std_offset
- self.hasdst = bool(self._start_delta)
-
- def transitions(self, year):
- """
- For a given year, get the DST on and off transition times, expressed
- always on the standard time side. For zones with no transitions, this
- function returns ``None``.
-
- :param year:
- The year whose transitions you would like to query.
-
- :return:
- Returns a :class:`tuple` of :class:`datetime.datetime` objects,
- ``(dston, dstoff)`` for zones with an annual DST transition, or
- ``None`` for fixed offset zones.
- """
- if not self.hasdst:
- return None
-
- base_year = datetime.datetime(year, 1, 1)
-
- start = base_year + self._start_delta
- end = base_year + self._end_delta
-
- return (start, end)
-
- def __eq__(self, other):
- if not isinstance(other, tzrange):
- return NotImplemented
-
- return (self._std_abbr == other._std_abbr and
- self._dst_abbr == other._dst_abbr and
- self._std_offset == other._std_offset and
- self._dst_offset == other._dst_offset and
- self._start_delta == other._start_delta and
- self._end_delta == other._end_delta)
-
- @property
- def _dst_base_offset(self):
- return self._dst_base_offset_
-
-
-class tzstr(tzrange):
- """
- ``tzstr`` objects are time zone objects specified by a time-zone string as
- it would be passed to a ``TZ`` variable on POSIX-style systems (see
- the `GNU C Library: TZ Variable`_ for more details).
-
- There is one notable exception, which is that POSIX-style time zones use an
- inverted offset format, so normally ``GMT+3`` would be parsed as an offset
- 3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
- offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
- behavior, pass a ``True`` value to ``posix_offset``.
-
- The :class:`tzrange` object provides the same functionality, but is
- specified using :class:`relativedelta.relativedelta` objects. rather than
- strings.
-
- :param s:
- A time zone string in ``TZ`` variable format. This can be a
- :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: :class:`unicode`)
- or a stream emitting unicode characters (e.g. :class:`StringIO`).
-
- :param posix_offset:
- Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
- ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
- POSIX standard.
-
- .. _`GNU C Library: TZ Variable`:
- https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
- """
- def __init__(self, s, posix_offset=False):
- global parser
- from dateutil import parser
-
- self._s = s
-
- res = parser._parsetz(s)
- if res is None:
- raise ValueError("unknown string format")
-
- # Here we break the compatibility with the TZ variable handling.
- # GMT-3 actually *means* the timezone -3.
- if res.stdabbr in ("GMT", "UTC") and not posix_offset:
- res.stdoffset *= -1
-
- # We must initialize it first, since _delta() needs
- # _std_offset and _dst_offset set. Use False in start/end
- # to avoid building it two times.
- tzrange.__init__(self, res.stdabbr, res.stdoffset,
- res.dstabbr, res.dstoffset,
- start=False, end=False)
-
- if not res.dstabbr:
- self._start_delta = None
- self._end_delta = None
- else:
- self._start_delta = self._delta(res.start)
- if self._start_delta:
- self._end_delta = self._delta(res.end, isend=1)
-
- self.hasdst = bool(self._start_delta)
-
- def _delta(self, x, isend=0):
- from dateutil import relativedelta
- kwargs = {}
- if x.month is not None:
- kwargs["month"] = x.month
- if x.weekday is not None:
- kwargs["weekday"] = relativedelta.weekday(x.weekday, x.week)
- if x.week > 0:
- kwargs["day"] = 1
- else:
- kwargs["day"] = 31
- elif x.day:
- kwargs["day"] = x.day
- elif x.yday is not None:
- kwargs["yearday"] = x.yday
- elif x.jyday is not None:
- kwargs["nlyearday"] = x.jyday
- if not kwargs:
- # Default is to start on first sunday of april, and end
- # on last sunday of october.
- if not isend:
- kwargs["month"] = 4
- kwargs["day"] = 1
- kwargs["weekday"] = relativedelta.SU(+1)
- else:
- kwargs["month"] = 10
- kwargs["day"] = 31
- kwargs["weekday"] = relativedelta.SU(-1)
- if x.time is not None:
- kwargs["seconds"] = x.time
- else:
- # Default is 2AM.
- kwargs["seconds"] = 7200
- if isend:
- # Convert to standard time, to follow the documented way
- # of working with the extra hour. See the documentation
- # of the tzinfo class.
- delta = self._dst_offset - self._std_offset
- kwargs["seconds"] -= delta.seconds + delta.days * 86400
- return relativedelta.relativedelta(**kwargs)
-
- def __repr__(self):
- return "%s(%s)" % (self.__class__.__name__, repr(self._s))
-
-
-class _tzicalvtzcomp(object):
- def __init__(self, tzoffsetfrom, tzoffsetto, isdst,
- tzname=None, rrule=None):
- self.tzoffsetfrom = datetime.timedelta(seconds=tzoffsetfrom)
- self.tzoffsetto = datetime.timedelta(seconds=tzoffsetto)
- self.tzoffsetdiff = self.tzoffsetto - self.tzoffsetfrom
- self.isdst = isdst
- self.tzname = tzname
- self.rrule = rrule
-
-
-class _tzicalvtz(_tzinfo):
- def __init__(self, tzid, comps=[]):
- super(_tzicalvtz, self).__init__()
-
- self._tzid = tzid
- self._comps = comps
- self._cachedate = []
- self._cachecomp = []
-
- def _find_comp(self, dt):
- if len(self._comps) == 1:
- return self._comps[0]
-
- dt = dt.replace(tzinfo=None)
-
- try:
- return self._cachecomp[self._cachedate.index((dt, self._fold(dt)))]
- except ValueError:
- pass
-
- lastcompdt = None
- lastcomp = None
-
- for comp in self._comps:
- compdt = self._find_compdt(comp, dt)
-
- if compdt and (not lastcompdt or lastcompdt < compdt):
- lastcompdt = compdt
- lastcomp = comp
-
- if not lastcomp:
- # RFC says nothing about what to do when a given
- # time is before the first onset date. We'll look for the
- # first standard component, or the first component, if
- # none is found.
- for comp in self._comps:
- if not comp.isdst:
- lastcomp = comp
- break
- else:
- lastcomp = comp[0]
-
- self._cachedate.insert(0, (dt, self._fold(dt)))
- self._cachecomp.insert(0, lastcomp)
-
- if len(self._cachedate) > 10:
- self._cachedate.pop()
- self._cachecomp.pop()
-
- return lastcomp
-
- def _find_compdt(self, comp, dt):
- if comp.tzoffsetdiff < ZERO and self._fold(dt):
- dt -= comp.tzoffsetdiff
-
- compdt = comp.rrule.before(dt, inc=True)
-
- return compdt
-
- def utcoffset(self, dt):
- if dt is None:
- return None
-
- return self._find_comp(dt).tzoffsetto
-
- def dst(self, dt):
- comp = self._find_comp(dt)
- if comp.isdst:
- return comp.tzoffsetdiff
- else:
- return ZERO
-
- @tzname_in_python2
- def tzname(self, dt):
- return self._find_comp(dt).tzname
-
- def __repr__(self):
- return "<tzicalvtz %s>" % repr(self._tzid)
-
- __reduce__ = object.__reduce__
-
-
-class tzical(object):
- """
- This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure
- as set out in `RFC 2445`_ Section 4.6.5 into one or more `tzinfo` objects.
-
- :param `fileobj`:
- A file or stream in iCalendar format, which should be UTF-8 encoded
- with CRLF endings.
-
- .. _`RFC 2445`: https://www.ietf.org/rfc/rfc2445.txt
- """
- def __init__(self, fileobj):
- global rrule
- from dateutil import rrule
-
- if isinstance(fileobj, string_types):
- self._s = fileobj
- # ical should be encoded in UTF-8 with CRLF
- fileobj = open(fileobj, 'r')
- else:
- self._s = getattr(fileobj, 'name', repr(fileobj))
- fileobj = _ContextWrapper(fileobj)
-
- self._vtz = {}
-
- with fileobj as fobj:
- self._parse_rfc(fobj.read())
-
- def keys(self):
- """
- Retrieves the available time zones as a list.
- """
- return list(self._vtz.keys())
-
- def get(self, tzid=None):
- """
- Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.
-
- :param tzid:
- If there is exactly one time zone available, omitting ``tzid``
- or passing :py:const:`None` value returns it. Otherwise a valid
- key (which can be retrieved from :func:`keys`) is required.
-
- :raises ValueError:
- Raised if ``tzid`` is not specified but there are either more
- or fewer than 1 zone defined.
-
- :returns:
- Returns either a :py:class:`datetime.tzinfo` object representing
- the relevant time zone or :py:const:`None` if the ``tzid`` was
- not found.
- """
- if tzid is None:
- if len(self._vtz) == 0:
- raise ValueError("no timezones defined")
- elif len(self._vtz) > 1:
- raise ValueError("more than one timezone available")
- tzid = next(iter(self._vtz))
-
- return self._vtz.get(tzid)
-
- def _parse_offset(self, s):
- s = s.strip()
- if not s:
- raise ValueError("empty offset")
- if s[0] in ('+', '-'):
- signal = (-1, +1)[s[0] == '+']
- s = s[1:]
- else:
- signal = +1
- if len(s) == 4:
- return (int(s[:2]) * 3600 + int(s[2:]) * 60) * signal
- elif len(s) == 6:
- return (int(s[:2]) * 3600 + int(s[2:4]) * 60 + int(s[4:])) * signal
- else:
- raise ValueError("invalid offset: " + s)
-
- def _parse_rfc(self, s):
- lines = s.splitlines()
- if not lines:
- raise ValueError("empty string")
-
- # Unfold
- i = 0
- while i < len(lines):
- line = lines[i].rstrip()
- if not line:
- del lines[i]
- elif i > 0 and line[0] == " ":
- lines[i-1] += line[1:]
- del lines[i]
- else:
- i += 1
-
- tzid = None
- comps = []
- invtz = False
- comptype = None
- for line in lines:
- if not line:
- continue
- name, value = line.split(':', 1)
- parms = name.split(';')
- if not parms:
- raise ValueError("empty property name")
- name = parms[0].upper()
- parms = parms[1:]
- if invtz:
- if name == "BEGIN":
- if value in ("STANDARD", "DAYLIGHT"):
- # Process component
- pass
- else:
- raise ValueError("unknown component: "+value)
- comptype = value
- founddtstart = False
- tzoffsetfrom = None
- tzoffsetto = None
- rrulelines = []
- tzname = None
- elif name == "END":
- if value == "VTIMEZONE":
- if comptype:
- raise ValueError("component not closed: "+comptype)
- if not tzid:
- raise ValueError("mandatory TZID not found")
- if not comps:
- raise ValueError(
- "at least one component is needed")
- # Process vtimezone
- self._vtz[tzid] = _tzicalvtz(tzid, comps)
- invtz = False
- elif value == comptype:
- if not founddtstart:
- raise ValueError("mandatory DTSTART not found")
- if tzoffsetfrom is None:
- raise ValueError(
- "mandatory TZOFFSETFROM not found")
- if tzoffsetto is None:
- raise ValueError(
- "mandatory TZOFFSETFROM not found")
- # Process component
- rr = None
- if rrulelines:
- rr = rrule.rrulestr("\n".join(rrulelines),
- compatible=True,
- ignoretz=True,
- cache=True)
- comp = _tzicalvtzcomp(tzoffsetfrom, tzoffsetto,
- (comptype == "DAYLIGHT"),
- tzname, rr)
- comps.append(comp)
- comptype = None
- else:
- raise ValueError("invalid component end: "+value)
- elif comptype:
- if name == "DTSTART":
- rrulelines.append(line)
- founddtstart = True
- elif name in ("RRULE", "RDATE", "EXRULE", "EXDATE"):
- rrulelines.append(line)
- elif name == "TZOFFSETFROM":
- if parms:
- raise ValueError(
- "unsupported %s parm: %s " % (name, parms[0]))
- tzoffsetfrom = self._parse_offset(value)
- elif name == "TZOFFSETTO":
- if parms:
- raise ValueError(
- "unsupported TZOFFSETTO parm: "+parms[0])
- tzoffsetto = self._parse_offset(value)
- elif name == "TZNAME":
- if parms:
- raise ValueError(
- "unsupported TZNAME parm: "+parms[0])
- tzname = value
- elif name == "COMMENT":
- pass
- else:
- raise ValueError("unsupported property: "+name)
- else:
- if name == "TZID":
- if parms:
- raise ValueError(
- "unsupported TZID parm: "+parms[0])
- tzid = value
- elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"):
- pass
- else:
- raise ValueError("unsupported property: "+name)
- elif name == "BEGIN" and value == "VTIMEZONE":
- tzid = None
- comps = []
- invtz = True
-
- def __repr__(self):
- return "%s(%s)" % (self.__class__.__name__, repr(self._s))
-
-
-if sys.platform != "win32":
- TZFILES = ["/etc/localtime", "localtime"]
- TZPATHS = ["/usr/share/zoneinfo",
- "/usr/lib/zoneinfo",
- "/usr/share/lib/zoneinfo",
- "/etc/zoneinfo"]
-else:
- TZFILES = []
- TZPATHS = []
-
-
-def gettz(name=None):
- tz = None
- if not name:
- try:
- name = os.environ["TZ"]
- except KeyError:
- pass
- if name is None or name == ":":
- for filepath in TZFILES:
- if not os.path.isabs(filepath):
- filename = filepath
- for path in TZPATHS:
- filepath = os.path.join(path, filename)
- if os.path.isfile(filepath):
- break
- else:
- continue
- if os.path.isfile(filepath):
- try:
- tz = tzfile(filepath)
- break
- except (IOError, OSError, ValueError):
- pass
- else:
- tz = tzlocal()
- else:
- if name.startswith(":"):
- name = name[:-1]
- if os.path.isabs(name):
- if os.path.isfile(name):
- tz = tzfile(name)
- else:
- tz = None
- else:
- for path in TZPATHS:
- filepath = os.path.join(path, name)
- if not os.path.isfile(filepath):
- filepath = filepath.replace(' ', '_')
- if not os.path.isfile(filepath):
- continue
- try:
- tz = tzfile(filepath)
- break
- except (IOError, OSError, ValueError):
- pass
- else:
- tz = None
- if tzwin is not None:
- try:
- tz = tzwin(name)
- except WindowsError:
- tz = None
-
- if not tz:
- from dateutil.zoneinfo import get_zonefile_instance
- tz = get_zonefile_instance().get(name)
-
- if not tz:
- for c in name:
- # name must have at least one offset to be a tzstr
- if c in "0123456789":
- try:
- tz = tzstr(name)
- except ValueError:
- pass
- break
- else:
- if name in ("GMT", "UTC"):
- tz = tzutc()
- elif name in time.tzname:
- tz = tzlocal()
- return tz
-
-
-def datetime_exists(dt, tz=None):
- """
- Given a datetime and a time zone, determine whether or not a given datetime
- would fall in a gap.
-
- :param dt:
- A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
- is provided.)
-
- :param tz:
- A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
- ``None`` or not provided, the datetime's own time zone will be used.
-
- :return:
- Returns a boolean value whether or not the "wall time" exists in ``tz``.
- """
- if tz is None:
- if dt.tzinfo is None:
- raise ValueError('Datetime is naive and no time zone provided.')
- tz = dt.tzinfo
-
- dt = dt.replace(tzinfo=None)
-
- # This is essentially a test of whether or not the datetime can survive
- # a round trip to UTC.
- dt_rt = dt.replace(tzinfo=tz).astimezone(tzutc()).astimezone(tz)
- dt_rt = dt_rt.replace(tzinfo=None)
-
- return dt == dt_rt
-
-
-def datetime_ambiguous(dt, tz=None):
- """
- Given a datetime and a time zone, determine whether or not a given datetime
- is ambiguous (i.e if there are two times differentiated only by their DST
- status).
-
- :param dt:
- A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
- is provided.)
-
- :param tz:
- A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
- ``None`` or not provided, the datetime's own time zone will be used.
-
- :return:
- Returns a boolean value whether or not the "wall time" is ambiguous in
- ``tz``.
-
- .. versionadded:: 2.6.0
- """
- if tz is None:
- if dt.tzinfo is None:
- raise ValueError('Datetime is naive and no time zone provided.')
-
- tz = dt.tzinfo
-
- # If a time zone defines its own "is_ambiguous" function, we'll use that.
- is_ambiguous_fn = getattr(tz, 'is_ambiguous', None)
- if is_ambiguous_fn is not None:
- try:
- return tz.is_ambiguous(dt)
- except:
- pass
-
- # If it doesn't come out and tell us it's ambiguous, we'll just check if
- # the fold attribute has any effect on this particular date and time.
- dt = dt.replace(tzinfo=tz)
- wall_0 = enfold(dt, fold=0)
- wall_1 = enfold(dt, fold=1)
-
- same_offset = wall_0.utcoffset() == wall_1.utcoffset()
- same_dst = wall_0.dst() == wall_1.dst()
-
- return not (same_offset and same_dst)
-
-
-def _datetime_to_timestamp(dt):
- """
- Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds
- since January 1, 1970, ignoring the time zone.
- """
- return _total_seconds((dt.replace(tzinfo=None) - EPOCH))
-
-
-class _ContextWrapper(object):
- """
- Class for wrapping contexts so that they are passed through in a
- with statement.
- """
- def __init__(self, context):
- self.context = context
-
- def __enter__(self):
- return self.context
-
- def __exit__(*args, **kwargs):
- pass
-
-# vim:ts=4:sw=4:et
diff --git a/python/dateutil/tz/win.py b/python/dateutil/tz/win.py
deleted file mode 100644
index 36a1c26..0000000
--- a/python/dateutil/tz/win.py
+++ /dev/null
@@ -1,332 +0,0 @@
-# This code was originally contributed by Jeffrey Harris.
-import datetime
-import struct
-
-from six.moves import winreg
-from six import text_type
-
-try:
- import ctypes
- from ctypes import wintypes
-except ValueError:
- # ValueError is raised on non-Windows systems for some horrible reason.
- raise ImportError("Running tzwin on non-Windows system")
-
-from ._common import tzrangebase
-
-__all__ = ["tzwin", "tzwinlocal", "tzres"]
-
-ONEWEEK = datetime.timedelta(7)
-
-TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
-TZKEYNAME9X = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones"
-TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
-
-
-def _settzkeyname():
- handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
- try:
- winreg.OpenKey(handle, TZKEYNAMENT).Close()
- TZKEYNAME = TZKEYNAMENT
- except WindowsError:
- TZKEYNAME = TZKEYNAME9X
- handle.Close()
- return TZKEYNAME
-
-
-TZKEYNAME = _settzkeyname()
-
-
-class tzres(object):
- """
- Class for accessing `tzres.dll`, which contains timezone name related
- resources.
-
- .. versionadded:: 2.5.0
- """
- p_wchar = ctypes.POINTER(wintypes.WCHAR) # Pointer to a wide char
-
- def __init__(self, tzres_loc='tzres.dll'):
- # Load the user32 DLL so we can load strings from tzres
- user32 = ctypes.WinDLL('user32')
-
- # Specify the LoadStringW function
- user32.LoadStringW.argtypes = (wintypes.HINSTANCE,
- wintypes.UINT,
- wintypes.LPWSTR,
- ctypes.c_int)
-
- self.LoadStringW = user32.LoadStringW
- self._tzres = ctypes.WinDLL(tzres_loc)
- self.tzres_loc = tzres_loc
-
- def load_name(self, offset):
- """
- Load a timezone name from a DLL offset (integer).
-
- >>> from dateutil.tzwin import tzres
- >>> tzr = tzres()
- >>> print(tzr.load_name(112))
- 'Eastern Standard Time'
-
- :param offset:
- A positive integer value referring to a string from the tzres dll.
-
- ..note:
- Offsets found in the registry are generally of the form
- `@tzres.dll,-114`. The offset in this case if 114, not -114.
-
- """
- resource = self.p_wchar()
- lpBuffer = ctypes.cast(ctypes.byref(resource), wintypes.LPWSTR)
- nchar = self.LoadStringW(self._tzres._handle, offset, lpBuffer, 0)
- return resource[:nchar]
-
- def name_from_string(self, tzname_str):
- """
- Parse strings as returned from the Windows registry into the time zone
- name as defined in the registry.
-
- >>> from dateutil.tzwin import tzres
- >>> tzr = tzres()
- >>> print(tzr.name_from_string('@tzres.dll,-251'))
- 'Dateline Daylight Time'
- >>> print(tzr.name_from_string('Eastern Standard Time'))
- 'Eastern Standard Time'
-
- :param tzname_str:
- A timezone name string as returned from a Windows registry key.
-
- :return:
- Returns the localized timezone string from tzres.dll if the string
- is of the form `@tzres.dll,-offset`, else returns the input string.
- """
- if not tzname_str.startswith('@'):
- return tzname_str
-
- name_splt = tzname_str.split(',-')
- try:
- offset = int(name_splt[1])
- except:
- raise ValueError("Malformed timezone string.")
-
- return self.load_name(offset)
-
-
-class tzwinbase(tzrangebase):
- """tzinfo class based on win32's timezones available in the registry."""
- def __init__(self):
- raise NotImplementedError('tzwinbase is an abstract base class')
-
- def __eq__(self, other):
- # Compare on all relevant dimensions, including name.
- if not isinstance(other, tzwinbase):
- return NotImplemented
-
- return (self._std_offset == other._std_offset and
- self._dst_offset == other._dst_offset and
- self._stddayofweek == other._stddayofweek and
- self._dstdayofweek == other._dstdayofweek and
- self._stdweeknumber == other._stdweeknumber and
- self._dstweeknumber == other._dstweeknumber and
- self._stdhour == other._stdhour and
- self._dsthour == other._dsthour and
- self._stdminute == other._stdminute and
- self._dstminute == other._dstminute and
- self._std_abbr == other._std_abbr and
- self._dst_abbr == other._dst_abbr)
-
- @staticmethod
- def list():
- """Return a list of all time zones known to the system."""
- with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
- with winreg.OpenKey(handle, TZKEYNAME) as tzkey:
- result = [winreg.EnumKey(tzkey, i)
- for i in range(winreg.QueryInfoKey(tzkey)[0])]
- return result
-
- def display(self):
- return self._display
-
- def transitions(self, year):
- """
- For a given year, get the DST on and off transition times, expressed
- always on the standard time side. For zones with no transitions, this
- function returns ``None``.
-
- :param year:
- The year whose transitions you would like to query.
-
- :return:
- Returns a :class:`tuple` of :class:`datetime.datetime` objects,
- ``(dston, dstoff)`` for zones with an annual DST transition, or
- ``None`` for fixed offset zones.
- """
-
- if not self.hasdst:
- return None
-
- dston = picknthweekday(year, self._dstmonth, self._dstdayofweek,
- self._dsthour, self._dstminute,
- self._dstweeknumber)
-
- dstoff = picknthweekday(year, self._stdmonth, self._stddayofweek,
- self._stdhour, self._stdminute,
- self._stdweeknumber)
-
- # Ambiguous dates default to the STD side
- dstoff -= self._dst_base_offset
-
- return dston, dstoff
-
- def _get_hasdst(self):
- return self._dstmonth != 0
-
- @property
- def _dst_base_offset(self):
- return self._dst_base_offset_
-
-
-class tzwin(tzwinbase):
-
- def __init__(self, name):
- self._name = name
-
- # multiple contexts only possible in 2.7 and 3.1, we still support 2.6
- with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
- tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
- with winreg.OpenKey(handle, tzkeyname) as tzkey:
- keydict = valuestodict(tzkey)
-
- self._std_abbr = keydict["Std"]
- self._dst_abbr = keydict["Dlt"]
-
- self._display = keydict["Display"]
-
- # See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
- tup = struct.unpack("=3l16h", keydict["TZI"])
- stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
- dstoffset = stdoffset-tup[2] # + DaylightBias * -1
- self._std_offset = datetime.timedelta(minutes=stdoffset)
- self._dst_offset = datetime.timedelta(minutes=dstoffset)
-
- # for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
- # http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
- (self._stdmonth,
- self._stddayofweek, # Sunday = 0
- self._stdweeknumber, # Last = 5
- self._stdhour,
- self._stdminute) = tup[4:9]
-
- (self._dstmonth,
- self._dstdayofweek, # Sunday = 0
- self._dstweeknumber, # Last = 5
- self._dsthour,
- self._dstminute) = tup[12:17]
-
- self._dst_base_offset_ = self._dst_offset - self._std_offset
- self.hasdst = self._get_hasdst()
-
- def __repr__(self):
- return "tzwin(%s)" % repr(self._name)
-
- def __reduce__(self):
- return (self.__class__, (self._name,))
-
-
-class tzwinlocal(tzwinbase):
- def __init__(self):
- with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
- with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey:
- keydict = valuestodict(tzlocalkey)
-
- self._std_abbr = keydict["StandardName"]
- self._dst_abbr = keydict["DaylightName"]
-
- try:
- tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME,
- sn=self._std_abbr)
- with winreg.OpenKey(handle, tzkeyname) as tzkey:
- _keydict = valuestodict(tzkey)
- self._display = _keydict["Display"]
- except OSError:
- self._display = None
-
- stdoffset = -keydict["Bias"]-keydict["StandardBias"]
- dstoffset = stdoffset-keydict["DaylightBias"]
-
- self._std_offset = datetime.timedelta(minutes=stdoffset)
- self._dst_offset = datetime.timedelta(minutes=dstoffset)
-
- # For reasons unclear, in this particular key, the day of week has been
- # moved to the END of the SYSTEMTIME structure.
- tup = struct.unpack("=8h", keydict["StandardStart"])
-
- (self._stdmonth,
- self._stdweeknumber, # Last = 5
- self._stdhour,
- self._stdminute) = tup[1:5]
-
- self._stddayofweek = tup[7]
-
- tup = struct.unpack("=8h", keydict["DaylightStart"])
-
- (self._dstmonth,
- self._dstweeknumber, # Last = 5
- self._dsthour,
- self._dstminute) = tup[1:5]
-
- self._dstdayofweek = tup[7]
-
- self._dst_base_offset_ = self._dst_offset - self._std_offset
- self.hasdst = self._get_hasdst()
-
- def __repr__(self):
- return "tzwinlocal()"
-
- def __str__(self):
- # str will return the standard name, not the daylight name.
- return "tzwinlocal(%s)" % repr(self._std_abbr)
-
- def __reduce__(self):
- return (self.__class__, ())
-
-
-def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
- """ dayofweek == 0 means Sunday, whichweek 5 means last instance """
- first = datetime.datetime(year, month, 1, hour, minute)
-
- # This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6),
- # Because 7 % 7 = 0
- weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
- wd = weekdayone + ((whichweek - 1) * ONEWEEK)
- if (wd.month != month):
- wd -= ONEWEEK
-
- return wd
-
-
-def valuestodict(key):
- """Convert a registry key's values to a dictionary."""
- dout = {}
- size = winreg.QueryInfoKey(key)[1]
- tz_res = None
-
- for i in range(size):
- key_name, value, dtype = winreg.EnumValue(key, i)
- if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN:
- # If it's a DWORD (32-bit integer), it's stored as unsigned - convert
- # that to a proper signed integer
- if value & (1 << 31):
- value = value - (1 << 32)
- elif dtype == winreg.REG_SZ:
- # If it's a reference to the tzres DLL, load the actual string
- if value.startswith('@tzres'):
- tz_res = tz_res or tzres()
- value = tz_res.name_from_string(value)
-
- value = value.rstrip('\x00') # Remove trailing nulls
-
- dout[key_name] = value
-
- return dout
diff --git a/python/dateutil/tzwin.py b/python/dateutil/tzwin.py
deleted file mode 100644
index cebc673..0000000
--- a/python/dateutil/tzwin.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# tzwin has moved to dateutil.tz.win
-from .tz.win import *
diff --git a/python/dateutil/zoneinfo/__init__.py b/python/dateutil/zoneinfo/__init__.py
deleted file mode 100644
index a2ed4f9..0000000
--- a/python/dateutil/zoneinfo/__init__.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# -*- coding: utf-8 -*-
-import warnings
-import json
-
-from tarfile import TarFile
-from pkgutil import get_data
-from io import BytesIO
-from contextlib import closing
-
-from dateutil.tz import tzfile
-
-__all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata", "rebuild"]
-
-ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
-METADATA_FN = 'METADATA'
-
-# python2.6 compatability. Note that TarFile.__exit__ != TarFile.close, but
-# it's close enough for python2.6
-tar_open = TarFile.open
-if not hasattr(TarFile, '__exit__'):
- def tar_open(*args, **kwargs):
- return closing(TarFile.open(*args, **kwargs))
-
-
-class tzfile(tzfile):
- def __reduce__(self):
- return (gettz, (self._filename,))
-
-
-def getzoneinfofile_stream():
- try:
- return BytesIO(get_data(__name__, ZONEFILENAME))
- except IOError as e: # TODO switch to FileNotFoundError?
- warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
- return None
-
-
-class ZoneInfoFile(object):
- def __init__(self, zonefile_stream=None):
- if zonefile_stream is not None:
- with tar_open(fileobj=zonefile_stream, mode='r') as tf:
- # dict comprehension does not work on python2.6
- # TODO: get back to the nicer syntax when we ditch python2.6
- # self.zones = {zf.name: tzfile(tf.extractfile(zf),
- # filename = zf.name)
- # for zf in tf.getmembers() if zf.isfile()}
- self.zones = dict((zf.name, tzfile(tf.extractfile(zf),
- filename=zf.name))
- for zf in tf.getmembers()
- if zf.isfile() and zf.name != METADATA_FN)
- # deal with links: They'll point to their parent object. Less
- # waste of memory
- # links = {zl.name: self.zones[zl.linkname]
- # for zl in tf.getmembers() if zl.islnk() or zl.issym()}
- links = dict((zl.name, self.zones[zl.linkname])
- for zl in tf.getmembers() if
- zl.islnk() or zl.issym())
- self.zones.update(links)
- try:
- metadata_json = tf.extractfile(tf.getmember(METADATA_FN))
- metadata_str = metadata_json.read().decode('UTF-8')
- self.metadata = json.loads(metadata_str)
- except KeyError:
- # no metadata in tar file
- self.metadata = None
- else:
- self.zones = dict()
- self.metadata = None
-
- def get(self, name, default=None):
- """
- Wrapper for :func:`ZoneInfoFile.zones.get`. This is a convenience method
- for retrieving zones from the zone dictionary.
-
- :param name:
- The name of the zone to retrieve. (Generally IANA zone names)
-
- :param default:
- The value to return in the event of a missing key.
-
- .. versionadded:: 2.6.0
-
- """
- return self.zones.get(name, default)
-
-
-# The current API has gettz as a module function, although in fact it taps into
-# a stateful class. So as a workaround for now, without changing the API, we
-# will create a new "global" class instance the first time a user requests a
-# timezone. Ugly, but adheres to the api.
-#
-# TODO: Remove after deprecation period.
-_CLASS_ZONE_INSTANCE = list()
-
-
-def get_zonefile_instance(new_instance=False):
- """
- This is a convenience function which provides a :class:`ZoneInfoFile`
- instance using the data provided by the ``dateutil`` package. By default, it
- caches a single instance of the ZoneInfoFile object and returns that.
-
- :param new_instance:
- If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
- used as the cached instance for the next call. Otherwise, new instances
- are created only as necessary.
-
- :return:
- Returns a :class:`ZoneInfoFile` object.
-
- .. versionadded:: 2.6
- """
- if new_instance:
- zif = None
- else:
- zif = getattr(get_zonefile_instance, '_cached_instance', None)
-
- if zif is None:
- zif = ZoneInfoFile(getzoneinfofile_stream())
-
- get_zonefile_instance._cached_instance = zif
-
- return zif
-
-
-def gettz(name):
- """
- This retrieves a time zone from the local zoneinfo tarball that is packaged
- with dateutil.
-
- :param name:
- An IANA-style time zone name, as found in the zoneinfo file.
-
- :return:
- Returns a :class:`dateutil.tz.tzfile` time zone object.
-
- .. warning::
- It is generally inadvisable to use this function, and it is only
- provided for API compatibility with earlier versions. This is *not*
- equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
- time zone based on the inputs, favoring system zoneinfo. This is ONLY
- for accessing the dateutil-specific zoneinfo (which may be out of
- date compared to the system zoneinfo).
-
- .. deprecated:: 2.6
- If you need to use a specific zoneinfofile over the system zoneinfo,
- instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
- :func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
-
- Use :func:`get_zonefile_instance` to retrieve an instance of the
- dateutil-provided zoneinfo.
- """
- warnings.warn("zoneinfo.gettz() will be removed in future versions, "
- "to use the dateutil-provided zoneinfo files, instantiate a "
- "ZoneInfoFile object and use ZoneInfoFile.zones.get() "
- "instead. See the documentation for details.",
- DeprecationWarning)
-
- if len(_CLASS_ZONE_INSTANCE) == 0:
- _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
- return _CLASS_ZONE_INSTANCE[0].zones.get(name)
-
-
-def gettz_db_metadata():
- """ Get the zonefile metadata
-
- See `zonefile_metadata`_
-
- :returns:
- A dictionary with the database metadata
-
- .. deprecated:: 2.6
- See deprecation warning in :func:`zoneinfo.gettz`. To get metadata,
- query the attribute ``zoneinfo.ZoneInfoFile.metadata``.
- """
- warnings.warn("zoneinfo.gettz_db_metadata() will be removed in future "
- "versions, to use the dateutil-provided zoneinfo files, "
- "ZoneInfoFile object and query the 'metadata' attribute "
- "instead. See the documentation for details.",
- DeprecationWarning)
-
- if len(_CLASS_ZONE_INSTANCE) == 0:
- _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
- return _CLASS_ZONE_INSTANCE[0].metadata
diff --git a/python/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz b/python/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
deleted file mode 100644
index 613c0ff..0000000
--- a/python/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
+++ /dev/null
Binary files differ
diff --git a/python/dateutil/zoneinfo/rebuild.py b/python/dateutil/zoneinfo/rebuild.py
deleted file mode 100644
index 9d53bb8..0000000
--- a/python/dateutil/zoneinfo/rebuild.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import logging
-import os
-import tempfile
-import shutil
-import json
-from subprocess import check_call
-
-from dateutil.zoneinfo import tar_open, METADATA_FN, ZONEFILENAME
-
-
-def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None):
- """Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*
-
- filename is the timezone tarball from ftp.iana.org/tz.
-
- """
- tmpdir = tempfile.mkdtemp()
- zonedir = os.path.join(tmpdir, "zoneinfo")
- moduledir = os.path.dirname(__file__)
- try:
- with tar_open(filename) as tf:
- for name in zonegroups:
- tf.extract(name, tmpdir)
- filepaths = [os.path.join(tmpdir, n) for n in zonegroups]
- try:
- check_call(["zic", "-d", zonedir] + filepaths)
- except OSError as e:
- _print_on_nosuchfile(e)
- raise
- # write metadata file
- with open(os.path.join(zonedir, METADATA_FN), 'w') as f:
- json.dump(metadata, f, indent=4, sort_keys=True)
- target = os.path.join(moduledir, ZONEFILENAME)
- with tar_open(target, "w:%s" % format) as tf:
- for entry in os.listdir(zonedir):
- entrypath = os.path.join(zonedir, entry)
- tf.add(entrypath, entry)
- finally:
- shutil.rmtree(tmpdir)
-
-
-def _print_on_nosuchfile(e):
- """Print helpful troubleshooting message
-
- e is an exception raised by subprocess.check_call()
-
- """
- if e.errno == 2:
- logging.error(
- "Could not find zic. Perhaps you need to install "
- "libc-bin or some other package that provides it, "
- "or it's not in your PATH?")
diff --git a/python/defusedxml/ElementTree.py b/python/defusedxml/ElementTree.py
deleted file mode 100644
index 41b2ea8..0000000
--- a/python/defusedxml/ElementTree.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.etree.ElementTree facade
-"""
-from __future__ import print_function, absolute_import
-
-import sys
-from xml.etree.ElementTree import TreeBuilder as _TreeBuilder
-from xml.etree.ElementTree import parse as _parse
-from xml.etree.ElementTree import tostring
-
-from .common import PY3
-
-
-if PY3:
- import importlib
-else:
- from xml.etree.ElementTree import XMLParser as _XMLParser
- from xml.etree.ElementTree import iterparse as _iterparse
- from xml.etree.ElementTree import ParseError
-
-
-from .common import (DTDForbidden, EntitiesForbidden,
- ExternalReferenceForbidden, _generate_etree_functions)
-
-__origin__ = "xml.etree.ElementTree"
-
-
-def _get_py3_cls():
- """Python 3.3 hides the pure Python code but defusedxml requires it.
-
- The code is based on test.support.import_fresh_module().
- """
- pymodname = "xml.etree.ElementTree"
- cmodname = "_elementtree"
-
- pymod = sys.modules.pop(pymodname, None)
- cmod = sys.modules.pop(cmodname, None)
-
- sys.modules[cmodname] = None
- pure_pymod = importlib.import_module(pymodname)
- if cmod is not None:
- sys.modules[cmodname] = cmod
- else:
- sys.modules.pop(cmodname)
- sys.modules[pymodname] = pymod
-
- _XMLParser = pure_pymod.XMLParser
- _iterparse = pure_pymod.iterparse
- ParseError = pure_pymod.ParseError
-
- return _XMLParser, _iterparse, ParseError
-
-
-if PY3:
- _XMLParser, _iterparse, ParseError = _get_py3_cls()
-
-
-class DefusedXMLParser(_XMLParser):
-
- def __init__(self, html=0, target=None, encoding=None,
- forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- # Python 2.x old style class
- _XMLParser.__init__(self, html, target, encoding)
- self.forbid_dtd = forbid_dtd
- self.forbid_entities = forbid_entities
- self.forbid_external = forbid_external
- if PY3:
- parser = self.parser
- else:
- parser = self._parser
- if self.forbid_dtd:
- parser.StartDoctypeDeclHandler = self.defused_start_doctype_decl
- if self.forbid_entities:
- parser.EntityDeclHandler = self.defused_entity_decl
- parser.UnparsedEntityDeclHandler = self.defused_unparsed_entity_decl
- if self.forbid_external:
- parser.ExternalEntityRefHandler = self.defused_external_entity_ref_handler
-
- def defused_start_doctype_decl(self, name, sysid, pubid,
- has_internal_subset):
- raise DTDForbidden(name, sysid, pubid)
-
- def defused_entity_decl(self, name, is_parameter_entity, value, base,
- sysid, pubid, notation_name):
- raise EntitiesForbidden(name, value, base, sysid, pubid, notation_name)
-
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid,
- notation_name):
- # expat 1.2
- raise EntitiesForbidden(name, None, base, sysid, pubid, notation_name)
-
- def defused_external_entity_ref_handler(self, context, base, sysid,
- pubid):
- raise ExternalReferenceForbidden(context, base, sysid, pubid)
-
-
-# aliases
-XMLTreeBuilder = XMLParse = DefusedXMLParser
-
-parse, iterparse, fromstring = _generate_etree_functions(DefusedXMLParser,
- _TreeBuilder, _parse,
- _iterparse)
-XML = fromstring
-
-
-__all__ = ['XML', 'XMLParse', 'XMLTreeBuilder', 'fromstring', 'iterparse',
- 'parse', 'tostring']
diff --git a/python/defusedxml/__init__.py b/python/defusedxml/__init__.py
deleted file mode 100644
index 590a5a9..0000000
--- a/python/defusedxml/__init__.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defuse XML bomb denial of service vulnerabilities
-"""
-from __future__ import print_function, absolute_import
-
-from .common import (DefusedXmlException, DTDForbidden, EntitiesForbidden,
- ExternalReferenceForbidden, NotSupportedError,
- _apply_defusing)
-
-
-def defuse_stdlib():
- """Monkey patch and defuse all stdlib packages
-
- :warning: The monkey patch is an EXPERIMETNAL feature.
- """
- defused = {}
-
- from . import cElementTree
- from . import ElementTree
- from . import minidom
- from . import pulldom
- from . import sax
- from . import expatbuilder
- from . import expatreader
- from . import xmlrpc
-
- xmlrpc.monkey_patch()
- defused[xmlrpc] = None
-
- for defused_mod in [cElementTree, ElementTree, minidom, pulldom, sax,
- expatbuilder, expatreader]:
- stdlib_mod = _apply_defusing(defused_mod)
- defused[defused_mod] = stdlib_mod
-
- return defused
-
-
-__version__ = "0.5.0"
-
-__all__ = ['DefusedXmlException', 'DTDForbidden', 'EntitiesForbidden',
- 'ExternalReferenceForbidden', 'NotSupportedError']
diff --git a/python/defusedxml/cElementTree.py b/python/defusedxml/cElementTree.py
deleted file mode 100644
index cc13689..0000000
--- a/python/defusedxml/cElementTree.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.etree.cElementTree
-"""
-from __future__ import absolute_import
-
-from xml.etree.cElementTree import TreeBuilder as _TreeBuilder
-from xml.etree.cElementTree import parse as _parse
-from xml.etree.cElementTree import tostring
-# iterparse from ElementTree!
-from xml.etree.ElementTree import iterparse as _iterparse
-
-from .ElementTree import DefusedXMLParser
-from .common import _generate_etree_functions
-
-__origin__ = "xml.etree.cElementTree"
-
-
-XMLTreeBuilder = XMLParse = DefusedXMLParser
-
-parse, iterparse, fromstring = _generate_etree_functions(DefusedXMLParser,
- _TreeBuilder, _parse,
- _iterparse)
-XML = fromstring
-
-__all__ = ['XML', 'XMLParse', 'XMLTreeBuilder', 'fromstring', 'iterparse',
- 'parse', 'tostring']
diff --git a/python/defusedxml/common.py b/python/defusedxml/common.py
deleted file mode 100644
index 668b609..0000000
--- a/python/defusedxml/common.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Common constants, exceptions and helpe functions
-"""
-import sys
-
-PY3 = sys.version_info[0] == 3
-
-
-class DefusedXmlException(ValueError):
- """Base exception
- """
-
- def __repr__(self):
- return str(self)
-
-
-class DTDForbidden(DefusedXmlException):
- """Document type definition is forbidden
- """
-
- def __init__(self, name, sysid, pubid):
- super(DTDForbidden, self).__init__()
- self.name = name
- self.sysid = sysid
- self.pubid = pubid
-
- def __str__(self):
- tpl = "DTDForbidden(name='{}', system_id={!r}, public_id={!r})"
- return tpl.format(self.name, self.sysid, self.pubid)
-
-
-class EntitiesForbidden(DefusedXmlException):
- """Entity definition is forbidden
- """
-
- def __init__(self, name, value, base, sysid, pubid, notation_name):
- super(EntitiesForbidden, self).__init__()
- self.name = name
- self.value = value
- self.base = base
- self.sysid = sysid
- self.pubid = pubid
- self.notation_name = notation_name
-
- def __str__(self):
- tpl = "EntitiesForbidden(name='{}', system_id={!r}, public_id={!r})"
- return tpl.format(self.name, self.sysid, self.pubid)
-
-
-class ExternalReferenceForbidden(DefusedXmlException):
- """Resolving an external reference is forbidden
- """
-
- def __init__(self, context, base, sysid, pubid):
- super(ExternalReferenceForbidden, self).__init__()
- self.context = context
- self.base = base
- self.sysid = sysid
- self.pubid = pubid
-
- def __str__(self):
- tpl = "ExternalReferenceForbidden(system_id='{}', public_id={})"
- return tpl.format(self.sysid, self.pubid)
-
-
-class NotSupportedError(DefusedXmlException):
- """The operation is not supported
- """
-
-
-def _apply_defusing(defused_mod):
- assert defused_mod is sys.modules[defused_mod.__name__]
- stdlib_name = defused_mod.__origin__
- __import__(stdlib_name, {}, {}, ["*"])
- stdlib_mod = sys.modules[stdlib_name]
- stdlib_names = set(dir(stdlib_mod))
- for name, obj in vars(defused_mod).items():
- if name.startswith("_") or name not in stdlib_names:
- continue
- setattr(stdlib_mod, name, obj)
- return stdlib_mod
-
-
-def _generate_etree_functions(DefusedXMLParser, _TreeBuilder,
- _parse, _iterparse):
- """Factory for functions needed by etree, dependent on whether
- cElementTree or ElementTree is used."""
-
- def parse(source, parser=None, forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- if parser is None:
- parser = DefusedXMLParser(target=_TreeBuilder(),
- forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- return _parse(source, parser)
-
- def iterparse(source, events=None, parser=None, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- if parser is None:
- parser = DefusedXMLParser(target=_TreeBuilder(),
- forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- return _iterparse(source, events, parser)
-
- def fromstring(text, forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- parser = DefusedXMLParser(target=_TreeBuilder(),
- forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- parser.feed(text)
- return parser.close()
-
- return parse, iterparse, fromstring
diff --git a/python/defusedxml/expatbuilder.py b/python/defusedxml/expatbuilder.py
deleted file mode 100644
index 0eb6b91..0000000
--- a/python/defusedxml/expatbuilder.py
+++ /dev/null
@@ -1,110 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.dom.expatbuilder
-"""
-from __future__ import print_function, absolute_import
-
-from xml.dom.expatbuilder import ExpatBuilder as _ExpatBuilder
-from xml.dom.expatbuilder import Namespaces as _Namespaces
-
-from .common import (DTDForbidden, EntitiesForbidden,
- ExternalReferenceForbidden)
-
-__origin__ = "xml.dom.expatbuilder"
-
-
-class DefusedExpatBuilder(_ExpatBuilder):
- """Defused document builder"""
-
- def __init__(self, options=None, forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- _ExpatBuilder.__init__(self, options)
- self.forbid_dtd = forbid_dtd
- self.forbid_entities = forbid_entities
- self.forbid_external = forbid_external
-
- def defused_start_doctype_decl(self, name, sysid, pubid,
- has_internal_subset):
- raise DTDForbidden(name, sysid, pubid)
-
- def defused_entity_decl(self, name, is_parameter_entity, value, base,
- sysid, pubid, notation_name):
- raise EntitiesForbidden(name, value, base, sysid, pubid, notation_name)
-
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid,
- notation_name):
- # expat 1.2
- raise EntitiesForbidden(name, None, base, sysid, pubid, notation_name)
-
- def defused_external_entity_ref_handler(self, context, base, sysid,
- pubid):
- raise ExternalReferenceForbidden(context, base, sysid, pubid)
-
- def install(self, parser):
- _ExpatBuilder.install(self, parser)
-
- if self.forbid_dtd:
- parser.StartDoctypeDeclHandler = self.defused_start_doctype_decl
- if self.forbid_entities:
- # if self._options.entities:
- parser.EntityDeclHandler = self.defused_entity_decl
- parser.UnparsedEntityDeclHandler = self.defused_unparsed_entity_decl
- if self.forbid_external:
- parser.ExternalEntityRefHandler = self.defused_external_entity_ref_handler
-
-
-class DefusedExpatBuilderNS(_Namespaces, DefusedExpatBuilder):
- """Defused document builder that supports namespaces."""
-
- def install(self, parser):
- DefusedExpatBuilder.install(self, parser)
- if self._options.namespace_declarations:
- parser.StartNamespaceDeclHandler = (
- self.start_namespace_decl_handler)
-
- def reset(self):
- DefusedExpatBuilder.reset(self)
- self._initNamespaces()
-
-
-def parse(file, namespaces=True, forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- """Parse a document, returning the resulting Document node.
-
- 'file' may be either a file name or an open file object.
- """
- if namespaces:
- build_builder = DefusedExpatBuilderNS
- else:
- build_builder = DefusedExpatBuilder
- builder = build_builder(forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
-
- if isinstance(file, str):
- fp = open(file, 'rb')
- try:
- result = builder.parseFile(fp)
- finally:
- fp.close()
- else:
- result = builder.parseFile(file)
- return result
-
-
-def parseString(string, namespaces=True, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- """Parse a document from a string, returning the resulting
- Document node.
- """
- if namespaces:
- build_builder = DefusedExpatBuilderNS
- else:
- build_builder = DefusedExpatBuilder
- builder = build_builder(forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- return builder.parseString(string)
diff --git a/python/defusedxml/expatreader.py b/python/defusedxml/expatreader.py
deleted file mode 100644
index ef6bc39..0000000
--- a/python/defusedxml/expatreader.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.sax.expatreader
-"""
-from __future__ import print_function, absolute_import
-
-from xml.sax.expatreader import ExpatParser as _ExpatParser
-
-from .common import (DTDForbidden, EntitiesForbidden,
- ExternalReferenceForbidden)
-
-__origin__ = "xml.sax.expatreader"
-
-
-class DefusedExpatParser(_ExpatParser):
- """Defused SAX driver for the pyexpat C module."""
-
- def __init__(self, namespaceHandling=0, bufsize=2 ** 16 - 20,
- forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- _ExpatParser.__init__(self, namespaceHandling, bufsize)
- self.forbid_dtd = forbid_dtd
- self.forbid_entities = forbid_entities
- self.forbid_external = forbid_external
-
- def defused_start_doctype_decl(self, name, sysid, pubid,
- has_internal_subset):
- raise DTDForbidden(name, sysid, pubid)
-
- def defused_entity_decl(self, name, is_parameter_entity, value, base,
- sysid, pubid, notation_name):
- raise EntitiesForbidden(name, value, base, sysid, pubid, notation_name)
-
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid,
- notation_name):
- # expat 1.2
- raise EntitiesForbidden(name, None, base, sysid, pubid, notation_name)
-
- def defused_external_entity_ref_handler(self, context, base, sysid,
- pubid):
- raise ExternalReferenceForbidden(context, base, sysid, pubid)
-
- def reset(self):
- _ExpatParser.reset(self)
- parser = self._parser
- if self.forbid_dtd:
- parser.StartDoctypeDeclHandler = self.defused_start_doctype_decl
- if self.forbid_entities:
- parser.EntityDeclHandler = self.defused_entity_decl
- parser.UnparsedEntityDeclHandler = self.defused_unparsed_entity_decl
- if self.forbid_external:
- parser.ExternalEntityRefHandler = self.defused_external_entity_ref_handler
-
-
-def create_parser(*args, **kwargs):
- return DefusedExpatParser(*args, **kwargs)
diff --git a/python/defusedxml/lxml.py b/python/defusedxml/lxml.py
deleted file mode 100644
index 7f3ee0b..0000000
--- a/python/defusedxml/lxml.py
+++ /dev/null
@@ -1,153 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Example code for lxml.etree protection
-
-The code has NO protection against decompression bombs.
-"""
-from __future__ import print_function, absolute_import
-
-import threading
-from lxml import etree as _etree
-
-from .common import DTDForbidden, EntitiesForbidden, NotSupportedError
-
-LXML3 = _etree.LXML_VERSION[0] >= 3
-
-__origin__ = "lxml.etree"
-
-tostring = _etree.tostring
-
-
-class RestrictedElement(_etree.ElementBase):
- """A restricted Element class that filters out instances of some classes
- """
- __slots__ = ()
- # blacklist = (etree._Entity, etree._ProcessingInstruction, etree._Comment)
- blacklist = _etree._Entity
-
- def _filter(self, iterator):
- blacklist = self.blacklist
- for child in iterator:
- if isinstance(child, blacklist):
- continue
- yield child
-
- def __iter__(self):
- iterator = super(RestrictedElement, self).__iter__()
- return self._filter(iterator)
-
- def iterchildren(self, tag=None, reversed=False):
- iterator = super(RestrictedElement, self).iterchildren(
- tag=tag, reversed=reversed)
- return self._filter(iterator)
-
- def iter(self, tag=None, *tags):
- iterator = super(RestrictedElement, self).iter(tag=tag, *tags)
- return self._filter(iterator)
-
- def iterdescendants(self, tag=None, *tags):
- iterator = super(RestrictedElement,
- self).iterdescendants(tag=tag, *tags)
- return self._filter(iterator)
-
- def itersiblings(self, tag=None, preceding=False):
- iterator = super(RestrictedElement, self).itersiblings(
- tag=tag, preceding=preceding)
- return self._filter(iterator)
-
- def getchildren(self):
- iterator = super(RestrictedElement, self).__iter__()
- return list(self._filter(iterator))
-
- def getiterator(self, tag=None):
- iterator = super(RestrictedElement, self).getiterator(tag)
- return self._filter(iterator)
-
-
-class GlobalParserTLS(threading.local):
- """Thread local context for custom parser instances
- """
- parser_config = {
- 'resolve_entities': False,
- # 'remove_comments': True,
- # 'remove_pis': True,
- }
-
- element_class = RestrictedElement
-
- def createDefaultParser(self):
- parser = _etree.XMLParser(**self.parser_config)
- element_class = self.element_class
- if self.element_class is not None:
- lookup = _etree.ElementDefaultClassLookup(element=element_class)
- parser.set_element_class_lookup(lookup)
- return parser
-
- def setDefaultParser(self, parser):
- self._default_parser = parser
-
- def getDefaultParser(self):
- parser = getattr(self, "_default_parser", None)
- if parser is None:
- parser = self.createDefaultParser()
- self.setDefaultParser(parser)
- return parser
-
-
-_parser_tls = GlobalParserTLS()
-getDefaultParser = _parser_tls.getDefaultParser
-
-
-def check_docinfo(elementtree, forbid_dtd=False, forbid_entities=True):
- """Check docinfo of an element tree for DTD and entity declarations
-
- The check for entity declarations needs lxml 3 or newer. lxml 2.x does
- not support dtd.iterentities().
- """
- docinfo = elementtree.docinfo
- if docinfo.doctype:
- if forbid_dtd:
- raise DTDForbidden(docinfo.doctype,
- docinfo.system_url,
- docinfo.public_id)
- if forbid_entities and not LXML3:
- # lxml < 3 has no iterentities()
- raise NotSupportedError("Unable to check for entity declarations "
- "in lxml 2.x")
-
- if forbid_entities:
- for dtd in docinfo.internalDTD, docinfo.externalDTD:
- if dtd is None:
- continue
- for entity in dtd.iterentities():
- raise EntitiesForbidden(entity.name, entity.content, None,
- None, None, None)
-
-
-def parse(source, parser=None, base_url=None, forbid_dtd=False,
- forbid_entities=True):
- if parser is None:
- parser = getDefaultParser()
- elementtree = _etree.parse(source, parser, base_url=base_url)
- check_docinfo(elementtree, forbid_dtd, forbid_entities)
- return elementtree
-
-
-def fromstring(text, parser=None, base_url=None, forbid_dtd=False,
- forbid_entities=True):
- if parser is None:
- parser = getDefaultParser()
- rootelement = _etree.fromstring(text, parser, base_url=base_url)
- elementtree = rootelement.getroottree()
- check_docinfo(elementtree, forbid_dtd, forbid_entities)
- return rootelement
-
-
-XML = fromstring
-
-
-def iterparse(*args, **kwargs):
- raise NotSupportedError("defused lxml.etree.iterparse not available")
diff --git a/python/defusedxml/minidom.py b/python/defusedxml/minidom.py
deleted file mode 100644
index 0fd8684..0000000
--- a/python/defusedxml/minidom.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.dom.minidom
-"""
-from __future__ import print_function, absolute_import
-
-from xml.dom.minidom import _do_pulldom_parse
-from . import expatbuilder as _expatbuilder
-from . import pulldom as _pulldom
-
-__origin__ = "xml.dom.minidom"
-
-
-def parse(file, parser=None, bufsize=None, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- """Parse a file into a DOM by filename or file object."""
- if parser is None and not bufsize:
- return _expatbuilder.parse(file, forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- else:
- return _do_pulldom_parse(_pulldom.parse, (file,),
- {'parser': parser, 'bufsize': bufsize,
- 'forbid_dtd': forbid_dtd, 'forbid_entities': forbid_entities,
- 'forbid_external': forbid_external})
-
-
-def parseString(string, parser=None, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- """Parse a file into a DOM from a string."""
- if parser is None:
- return _expatbuilder.parseString(string, forbid_dtd=forbid_dtd,
- forbid_entities=forbid_entities,
- forbid_external=forbid_external)
- else:
- return _do_pulldom_parse(_pulldom.parseString, (string,),
- {'parser': parser, 'forbid_dtd': forbid_dtd,
- 'forbid_entities': forbid_entities,
- 'forbid_external': forbid_external})
diff --git a/python/defusedxml/pulldom.py b/python/defusedxml/pulldom.py
deleted file mode 100644
index fc9e466..0000000
--- a/python/defusedxml/pulldom.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.dom.pulldom
-"""
-from __future__ import print_function, absolute_import
-
-from xml.dom.pulldom import parse as _parse
-from xml.dom.pulldom import parseString as _parseString
-from .sax import make_parser
-
-__origin__ = "xml.dom.pulldom"
-
-
-def parse(stream_or_string, parser=None, bufsize=None, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- if parser is None:
- parser = make_parser()
- parser.forbid_dtd = forbid_dtd
- parser.forbid_entities = forbid_entities
- parser.forbid_external = forbid_external
- return _parse(stream_or_string, parser, bufsize)
-
-
-def parseString(string, parser=None, forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- if parser is None:
- parser = make_parser()
- parser.forbid_dtd = forbid_dtd
- parser.forbid_entities = forbid_entities
- parser.forbid_external = forbid_external
- return _parseString(string, parser)
diff --git a/python/defusedxml/sax.py b/python/defusedxml/sax.py
deleted file mode 100644
index 534d0ca..0000000
--- a/python/defusedxml/sax.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xml.sax
-"""
-from __future__ import print_function, absolute_import
-
-from xml.sax import InputSource as _InputSource
-from xml.sax import ErrorHandler as _ErrorHandler
-
-from . import expatreader
-
-__origin__ = "xml.sax"
-
-
-def parse(source, handler, errorHandler=_ErrorHandler(), forbid_dtd=False,
- forbid_entities=True, forbid_external=True):
- parser = make_parser()
- parser.setContentHandler(handler)
- parser.setErrorHandler(errorHandler)
- parser.forbid_dtd = forbid_dtd
- parser.forbid_entities = forbid_entities
- parser.forbid_external = forbid_external
- parser.parse(source)
-
-
-def parseString(string, handler, errorHandler=_ErrorHandler(),
- forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- from io import BytesIO
-
- if errorHandler is None:
- errorHandler = _ErrorHandler()
- parser = make_parser()
- parser.setContentHandler(handler)
- parser.setErrorHandler(errorHandler)
- parser.forbid_dtd = forbid_dtd
- parser.forbid_entities = forbid_entities
- parser.forbid_external = forbid_external
-
- inpsrc = _InputSource()
- inpsrc.setByteStream(BytesIO(string))
- parser.parse(inpsrc)
-
-
-def make_parser(parser_list=[]):
- return expatreader.create_parser()
diff --git a/python/defusedxml/xmlrpc.py b/python/defusedxml/xmlrpc.py
deleted file mode 100644
index 2a456e6..0000000
--- a/python/defusedxml/xmlrpc.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# defusedxml
-#
-# Copyright (c) 2013 by Christian Heimes <christian@python.org>
-# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/psf/license for licensing details.
-"""Defused xmlrpclib
-
-Also defuses gzip bomb
-"""
-from __future__ import print_function, absolute_import
-
-import io
-
-from .common import (
- DTDForbidden, EntitiesForbidden, ExternalReferenceForbidden, PY3)
-
-if PY3:
- __origin__ = "xmlrpc.client"
- from xmlrpc.client import ExpatParser
- from xmlrpc import client as xmlrpc_client
- from xmlrpc import server as xmlrpc_server
- from xmlrpc.client import gzip_decode as _orig_gzip_decode
- from xmlrpc.client import GzipDecodedResponse as _OrigGzipDecodedResponse
-else:
- __origin__ = "xmlrpclib"
- from xmlrpclib import ExpatParser
- import xmlrpclib as xmlrpc_client
- xmlrpc_server = None
- from xmlrpclib import gzip_decode as _orig_gzip_decode
- from xmlrpclib import GzipDecodedResponse as _OrigGzipDecodedResponse
-
-try:
- import gzip
-except ImportError:
- gzip = None
-
-
-# Limit maximum request size to prevent resource exhaustion DoS
-# Also used to limit maximum amount of gzip decoded data in order to prevent
-# decompression bombs
-# A value of -1 or smaller disables the limit
-MAX_DATA = 30 * 1024 * 1024 # 30 MB
-
-
-def defused_gzip_decode(data, limit=None):
- """gzip encoded data -> unencoded data
-
- Decode data using the gzip content encoding as described in RFC 1952
- """
- if not gzip:
- raise NotImplementedError
- if limit is None:
- limit = MAX_DATA
- f = io.BytesIO(data)
- gzf = gzip.GzipFile(mode="rb", fileobj=f)
- try:
- if limit < 0: # no limit
- decoded = gzf.read()
- else:
- decoded = gzf.read(limit + 1)
- except IOError:
- raise ValueError("invalid data")
- f.close()
- gzf.close()
- if limit >= 0 and len(decoded) > limit:
- raise ValueError("max gzipped payload length exceeded")
- return decoded
-
-
-class DefusedGzipDecodedResponse(gzip.GzipFile if gzip else object):
- """a file-like object to decode a response encoded with the gzip
- method, as described in RFC 1952.
- """
-
- def __init__(self, response, limit=None):
- # response doesn't support tell() and read(), required by
- # GzipFile
- if not gzip:
- raise NotImplementedError
- self.limit = limit = limit if limit is not None else MAX_DATA
- if limit < 0: # no limit
- data = response.read()
- self.readlength = None
- else:
- data = response.read(limit + 1)
- self.readlength = 0
- if limit >= 0 and len(data) > limit:
- raise ValueError("max payload length exceeded")
- self.stringio = io.BytesIO(data)
- gzip.GzipFile.__init__(self, mode="rb", fileobj=self.stringio)
-
- def read(self, n):
- if self.limit >= 0:
- left = self.limit - self.readlength
- n = min(n, left + 1)
- data = gzip.GzipFile.read(self, n)
- self.readlength += len(data)
- if self.readlength > self.limit:
- raise ValueError("max payload length exceeded")
- return data
- else:
- return gzip.GzipFile.read(self, n)
-
- def close(self):
- gzip.GzipFile.close(self)
- self.stringio.close()
-
-
-class DefusedExpatParser(ExpatParser):
-
- def __init__(self, target, forbid_dtd=False, forbid_entities=True,
- forbid_external=True):
- ExpatParser.__init__(self, target)
- self.forbid_dtd = forbid_dtd
- self.forbid_entities = forbid_entities
- self.forbid_external = forbid_external
- parser = self._parser
- if self.forbid_dtd:
- parser.StartDoctypeDeclHandler = self.defused_start_doctype_decl
- if self.forbid_entities:
- parser.EntityDeclHandler = self.defused_entity_decl
- parser.UnparsedEntityDeclHandler = self.defused_unparsed_entity_decl
- if self.forbid_external:
- parser.ExternalEntityRefHandler = self.defused_external_entity_ref_handler
-
- def defused_start_doctype_decl(self, name, sysid, pubid,
- has_internal_subset):
- raise DTDForbidden(name, sysid, pubid)
-
- def defused_entity_decl(self, name, is_parameter_entity, value, base,
- sysid, pubid, notation_name):
- raise EntitiesForbidden(name, value, base, sysid, pubid, notation_name)
-
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid,
- notation_name):
- # expat 1.2
- raise EntitiesForbidden(name, None, base, sysid, pubid, notation_name)
-
- def defused_external_entity_ref_handler(self, context, base, sysid,
- pubid):
- raise ExternalReferenceForbidden(context, base, sysid, pubid)
-
-
-def monkey_patch():
- xmlrpc_client.FastParser = DefusedExpatParser
- xmlrpc_client.GzipDecodedResponse = DefusedGzipDecodedResponse
- xmlrpc_client.gzip_decode = defused_gzip_decode
- if xmlrpc_server:
- xmlrpc_server.gzip_decode = defused_gzip_decode
-
-
-def unmonkey_patch():
- xmlrpc_client.FastParser = None
- xmlrpc_client.GzipDecodedResponse = _OrigGzipDecodedResponse
- xmlrpc_client.gzip_decode = _orig_gzip_decode
- if xmlrpc_server:
- xmlrpc_server.gzip_decode = _orig_gzip_decode
diff --git a/python/flask/__init__.py b/python/flask/__init__.py
deleted file mode 100644
index 59f0fff..0000000
--- a/python/flask/__init__.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask
- ~~~~~
-
- A microframework based on Werkzeug. It's extensively documented
- and follows best practice patterns.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-__version__ = '1.0.3'
-
-# utilities we import from Werkzeug and Jinja2 that are unused
-# in the module but are exported as public interface.
-from werkzeug.exceptions import abort
-from werkzeug.utils import redirect
-from jinja2 import Markup, escape
-
-from .app import Flask, Request, Response
-from .config import Config
-from .helpers import url_for, flash, send_file, send_from_directory, \
- get_flashed_messages, get_template_attribute, make_response, safe_join, \
- stream_with_context
-from .globals import current_app, g, request, session, _request_ctx_stack, \
- _app_ctx_stack
-from .ctx import has_request_context, has_app_context, \
- after_this_request, copy_current_request_context
-from .blueprints import Blueprint
-from .templating import render_template, render_template_string
-
-# the signals
-from .signals import signals_available, template_rendered, request_started, \
- request_finished, got_request_exception, request_tearing_down, \
- appcontext_tearing_down, appcontext_pushed, \
- appcontext_popped, message_flashed, before_render_template
-
-# We're not exposing the actual json module but a convenient wrapper around
-# it.
-from . import json
-
-# This was the only thing that Flask used to export at one point and it had
-# a more generic name.
-jsonify = json.jsonify
-
-# backwards compat, goes away in 1.0
-from .sessions import SecureCookieSession as Session
-json_available = True
diff --git a/python/flask/__main__.py b/python/flask/__main__.py
deleted file mode 100644
index 4aee654..0000000
--- a/python/flask/__main__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.__main__
- ~~~~~~~~~~~~~~
-
- Alias for flask.run for the command line.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-if __name__ == '__main__':
- from .cli import main
- main(as_module=True)
diff --git a/python/flask/_compat.py b/python/flask/_compat.py
deleted file mode 100644
index dfbaae9..0000000
--- a/python/flask/_compat.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask._compat
- ~~~~~~~~~~~~~
-
- Some py2/py3 compatibility support based on a stripped down
- version of six so we don't have to depend on a specific version
- of it.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import sys
-
-PY2 = sys.version_info[0] == 2
-_identity = lambda x: x
-
-
-if not PY2:
- text_type = str
- string_types = (str,)
- integer_types = (int,)
-
- iterkeys = lambda d: iter(d.keys())
- itervalues = lambda d: iter(d.values())
- iteritems = lambda d: iter(d.items())
-
- from inspect import getfullargspec as getargspec
- from io import StringIO
- import collections.abc as collections_abc
-
- def reraise(tp, value, tb=None):
- if value.__traceback__ is not tb:
- raise value.with_traceback(tb)
- raise value
-
- implements_to_string = _identity
-
-else:
- text_type = unicode
- string_types = (str, unicode)
- integer_types = (int, long)
-
- iterkeys = lambda d: d.iterkeys()
- itervalues = lambda d: d.itervalues()
- iteritems = lambda d: d.iteritems()
-
- from inspect import getargspec
- from cStringIO import StringIO
- import collections as collections_abc
-
- exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
-
- def implements_to_string(cls):
- cls.__unicode__ = cls.__str__
- cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
- return cls
-
-
-def with_metaclass(meta, *bases):
- """Create a base class with a metaclass."""
- # This requires a bit of explanation: the basic idea is to make a
- # dummy metaclass for one level of class instantiation that replaces
- # itself with the actual metaclass.
- class metaclass(type):
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
- return type.__new__(metaclass, 'temporary_class', (), {})
-
-
-# Certain versions of pypy have a bug where clearing the exception stack
-# breaks the __exit__ function in a very peculiar way. The second level of
-# exception blocks is necessary because pypy seems to forget to check if an
-# exception happened until the next bytecode instruction?
-#
-# Relevant PyPy bugfix commit:
-# https://bitbucket.org/pypy/pypy/commits/77ecf91c635a287e88e60d8ddb0f4e9df4003301
-# According to ronan on #pypy IRC, it is released in PyPy2 2.3 and later
-# versions.
-#
-# Ubuntu 14.04 has PyPy 2.2.1, which does exhibit this bug.
-BROKEN_PYPY_CTXMGR_EXIT = False
-if hasattr(sys, 'pypy_version_info'):
- class _Mgr(object):
- def __enter__(self):
- return self
- def __exit__(self, *args):
- if hasattr(sys, 'exc_clear'):
- # Python 3 (PyPy3) doesn't have exc_clear
- sys.exc_clear()
- try:
- try:
- with _Mgr():
- raise AssertionError()
- except:
- raise
- except TypeError:
- BROKEN_PYPY_CTXMGR_EXIT = True
- except AssertionError:
- pass
diff --git a/python/flask/app.py b/python/flask/app.py
deleted file mode 100644
index c570a95..0000000
--- a/python/flask/app.py
+++ /dev/null
@@ -1,2334 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.app
- ~~~~~~~~~
-
- This module implements the central WSGI application object.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import os
-import sys
-import warnings
-from datetime import timedelta
-from functools import update_wrapper
-from itertools import chain
-from threading import Lock
-
-from werkzeug.datastructures import Headers, ImmutableDict
-from werkzeug.exceptions import BadRequest, BadRequestKeyError, HTTPException, \
- InternalServerError, MethodNotAllowed, default_exceptions
-from werkzeug.routing import BuildError, Map, RequestRedirect, \
- RoutingException, Rule
-
-from . import cli, json
-from ._compat import integer_types, reraise, string_types, text_type
-from .config import Config, ConfigAttribute
-from .ctx import AppContext, RequestContext, _AppCtxGlobals
-from .globals import _request_ctx_stack, g, request, session
-from .helpers import (
- _PackageBoundObject,
- _endpoint_from_view_func, find_package, get_env, get_debug_flag,
- get_flashed_messages, locked_cached_property, url_for, get_load_dotenv
-)
-from .logging import create_logger
-from .sessions import SecureCookieSessionInterface
-from .signals import appcontext_tearing_down, got_request_exception, \
- request_finished, request_started, request_tearing_down
-from .templating import DispatchingJinjaLoader, Environment, \
- _default_template_ctx_processor
-from .wrappers import Request, Response
-
-# a singleton sentinel value for parameter defaults
-_sentinel = object()
-
-
-def _make_timedelta(value):
- if not isinstance(value, timedelta):
- return timedelta(seconds=value)
- return value
-
-
-def setupmethod(f):
- """Wraps a method so that it performs a check in debug mode if the
- first request was already handled.
- """
- def wrapper_func(self, *args, **kwargs):
- if self.debug and self._got_first_request:
- raise AssertionError('A setup function was called after the '
- 'first request was handled. This usually indicates a bug '
- 'in the application where a module was not imported '
- 'and decorators or other functionality was called too late.\n'
- 'To fix this make sure to import all your view modules, '
- 'database models and everything related at a central place '
- 'before the application starts serving requests.')
- return f(self, *args, **kwargs)
- return update_wrapper(wrapper_func, f)
-
-
-class Flask(_PackageBoundObject):
- """The flask object implements a WSGI application and acts as the central
- object. It is passed the name of the module or package of the
- application. Once it is created it will act as a central registry for
- the view functions, the URL rules, template configuration and much more.
-
- The name of the package is used to resolve resources from inside the
- package or the folder the module is contained in depending on if the
- package parameter resolves to an actual python package (a folder with
- an :file:`__init__.py` file inside) or a standard module (just a ``.py`` file).
-
- For more information about resource loading, see :func:`open_resource`.
-
- Usually you create a :class:`Flask` instance in your main module or
- in the :file:`__init__.py` file of your package like this::
-
- from flask import Flask
- app = Flask(__name__)
-
- .. admonition:: About the First Parameter
-
- The idea of the first parameter is to give Flask an idea of what
- belongs to your application. This name is used to find resources
- on the filesystem, can be used by extensions to improve debugging
- information and a lot more.
-
- So it's important what you provide there. If you are using a single
- module, `__name__` is always the correct value. If you however are
- using a package, it's usually recommended to hardcode the name of
- your package there.
-
- For example if your application is defined in :file:`yourapplication/app.py`
- you should create it with one of the two versions below::
-
- app = Flask('yourapplication')
- app = Flask(__name__.split('.')[0])
-
- Why is that? The application will work even with `__name__`, thanks
- to how resources are looked up. However it will make debugging more
- painful. Certain extensions can make assumptions based on the
- import name of your application. For example the Flask-SQLAlchemy
- extension will look for the code in your application that triggered
- an SQL query in debug mode. If the import name is not properly set
- up, that debugging information is lost. (For example it would only
- pick up SQL queries in `yourapplication.app` and not
- `yourapplication.views.frontend`)
-
- .. versionadded:: 0.7
- The `static_url_path`, `static_folder`, and `template_folder`
- parameters were added.
-
- .. versionadded:: 0.8
- The `instance_path` and `instance_relative_config` parameters were
- added.
-
- .. versionadded:: 0.11
- The `root_path` parameter was added.
-
- .. versionadded:: 1.0
- The ``host_matching`` and ``static_host`` parameters were added.
-
- .. versionadded:: 1.0
- The ``subdomain_matching`` parameter was added. Subdomain
- matching needs to be enabled manually now. Setting
- :data:`SERVER_NAME` does not implicitly enable it.
-
- :param import_name: the name of the application package
- :param static_url_path: can be used to specify a different path for the
- static files on the web. Defaults to the name
- of the `static_folder` folder.
- :param static_folder: the folder with static files that should be served
- at `static_url_path`. Defaults to the ``'static'``
- folder in the root path of the application.
- :param static_host: the host to use when adding the static route.
- Defaults to None. Required when using ``host_matching=True``
- with a ``static_folder`` configured.
- :param host_matching: set ``url_map.host_matching`` attribute.
- Defaults to False.
- :param subdomain_matching: consider the subdomain relative to
- :data:`SERVER_NAME` when matching routes. Defaults to False.
- :param template_folder: the folder that contains the templates that should
- be used by the application. Defaults to
- ``'templates'`` folder in the root path of the
- application.
- :param instance_path: An alternative instance path for the application.
- By default the folder ``'instance'`` next to the
- package or module is assumed to be the instance
- path.
- :param instance_relative_config: if set to ``True`` relative filenames
- for loading the config are assumed to
- be relative to the instance path instead
- of the application root.
- :param root_path: Flask by default will automatically calculate the path
- to the root of the application. In certain situations
- this cannot be achieved (for instance if the package
- is a Python 3 namespace package) and needs to be
- manually defined.
- """
-
- #: The class that is used for request objects. See :class:`~flask.Request`
- #: for more information.
- request_class = Request
-
- #: The class that is used for response objects. See
- #: :class:`~flask.Response` for more information.
- response_class = Response
-
- #: The class that is used for the Jinja environment.
- #:
- #: .. versionadded:: 0.11
- jinja_environment = Environment
-
- #: The class that is used for the :data:`~flask.g` instance.
- #:
- #: Example use cases for a custom class:
- #:
- #: 1. Store arbitrary attributes on flask.g.
- #: 2. Add a property for lazy per-request database connectors.
- #: 3. Return None instead of AttributeError on unexpected attributes.
- #: 4. Raise exception if an unexpected attr is set, a "controlled" flask.g.
- #:
- #: In Flask 0.9 this property was called `request_globals_class` but it
- #: was changed in 0.10 to :attr:`app_ctx_globals_class` because the
- #: flask.g object is now application context scoped.
- #:
- #: .. versionadded:: 0.10
- app_ctx_globals_class = _AppCtxGlobals
-
- #: The class that is used for the ``config`` attribute of this app.
- #: Defaults to :class:`~flask.Config`.
- #:
- #: Example use cases for a custom class:
- #:
- #: 1. Default values for certain config options.
- #: 2. Access to config values through attributes in addition to keys.
- #:
- #: .. versionadded:: 0.11
- config_class = Config
-
- #: The testing flag. Set this to ``True`` to enable the test mode of
- #: Flask extensions (and in the future probably also Flask itself).
- #: For example this might activate test helpers that have an
- #: additional runtime cost which should not be enabled by default.
- #:
- #: If this is enabled and PROPAGATE_EXCEPTIONS is not changed from the
- #: default it's implicitly enabled.
- #:
- #: This attribute can also be configured from the config with the
- #: ``TESTING`` configuration key. Defaults to ``False``.
- testing = ConfigAttribute('TESTING')
-
- #: If a secret key is set, cryptographic components can use this to
- #: sign cookies and other things. Set this to a complex random value
- #: when you want to use the secure cookie for instance.
- #:
- #: This attribute can also be configured from the config with the
- #: :data:`SECRET_KEY` configuration key. Defaults to ``None``.
- secret_key = ConfigAttribute('SECRET_KEY')
-
- #: The secure cookie uses this for the name of the session cookie.
- #:
- #: This attribute can also be configured from the config with the
- #: ``SESSION_COOKIE_NAME`` configuration key. Defaults to ``'session'``
- session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME')
-
- #: A :class:`~datetime.timedelta` which is used to set the expiration
- #: date of a permanent session. The default is 31 days which makes a
- #: permanent session survive for roughly one month.
- #:
- #: This attribute can also be configured from the config with the
- #: ``PERMANENT_SESSION_LIFETIME`` configuration key. Defaults to
- #: ``timedelta(days=31)``
- permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME',
- get_converter=_make_timedelta)
-
- #: A :class:`~datetime.timedelta` which is used as default cache_timeout
- #: for the :func:`send_file` functions. The default is 12 hours.
- #:
- #: This attribute can also be configured from the config with the
- #: ``SEND_FILE_MAX_AGE_DEFAULT`` configuration key. This configuration
- #: variable can also be set with an integer value used as seconds.
- #: Defaults to ``timedelta(hours=12)``
- send_file_max_age_default = ConfigAttribute('SEND_FILE_MAX_AGE_DEFAULT',
- get_converter=_make_timedelta)
-
- #: Enable this if you want to use the X-Sendfile feature. Keep in
- #: mind that the server has to support this. This only affects files
- #: sent with the :func:`send_file` method.
- #:
- #: .. versionadded:: 0.2
- #:
- #: This attribute can also be configured from the config with the
- #: ``USE_X_SENDFILE`` configuration key. Defaults to ``False``.
- use_x_sendfile = ConfigAttribute('USE_X_SENDFILE')
-
- #: The JSON encoder class to use. Defaults to :class:`~flask.json.JSONEncoder`.
- #:
- #: .. versionadded:: 0.10
- json_encoder = json.JSONEncoder
-
- #: The JSON decoder class to use. Defaults to :class:`~flask.json.JSONDecoder`.
- #:
- #: .. versionadded:: 0.10
- json_decoder = json.JSONDecoder
-
- #: Options that are passed directly to the Jinja2 environment.
- jinja_options = ImmutableDict(
- extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_']
- )
-
- #: Default configuration parameters.
- default_config = ImmutableDict({
- 'ENV': None,
- 'DEBUG': None,
- 'TESTING': False,
- 'PROPAGATE_EXCEPTIONS': None,
- 'PRESERVE_CONTEXT_ON_EXCEPTION': None,
- 'SECRET_KEY': None,
- 'PERMANENT_SESSION_LIFETIME': timedelta(days=31),
- 'USE_X_SENDFILE': False,
- 'SERVER_NAME': None,
- 'APPLICATION_ROOT': '/',
- 'SESSION_COOKIE_NAME': 'session',
- 'SESSION_COOKIE_DOMAIN': None,
- 'SESSION_COOKIE_PATH': None,
- 'SESSION_COOKIE_HTTPONLY': True,
- 'SESSION_COOKIE_SECURE': False,
- 'SESSION_COOKIE_SAMESITE': None,
- 'SESSION_REFRESH_EACH_REQUEST': True,
- 'MAX_CONTENT_LENGTH': None,
- 'SEND_FILE_MAX_AGE_DEFAULT': timedelta(hours=12),
- 'TRAP_BAD_REQUEST_ERRORS': None,
- 'TRAP_HTTP_EXCEPTIONS': False,
- 'EXPLAIN_TEMPLATE_LOADING': False,
- 'PREFERRED_URL_SCHEME': 'http',
- 'JSON_AS_ASCII': True,
- 'JSON_SORT_KEYS': True,
- 'JSONIFY_PRETTYPRINT_REGULAR': False,
- 'JSONIFY_MIMETYPE': 'application/json',
- 'TEMPLATES_AUTO_RELOAD': None,
- 'MAX_COOKIE_SIZE': 4093,
- })
-
- #: The rule object to use for URL rules created. This is used by
- #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`.
- #:
- #: .. versionadded:: 0.7
- url_rule_class = Rule
-
- #: the test client that is used with when `test_client` is used.
- #:
- #: .. versionadded:: 0.7
- test_client_class = None
-
- #: The :class:`~click.testing.CliRunner` subclass, by default
- #: :class:`~flask.testing.FlaskCliRunner` that is used by
- #: :meth:`test_cli_runner`. Its ``__init__`` method should take a
- #: Flask app object as the first argument.
- #:
- #: .. versionadded:: 1.0
- test_cli_runner_class = None
-
- #: the session interface to use. By default an instance of
- #: :class:`~flask.sessions.SecureCookieSessionInterface` is used here.
- #:
- #: .. versionadded:: 0.8
- session_interface = SecureCookieSessionInterface()
-
- # TODO remove the next three attrs when Sphinx :inherited-members: works
- # https://github.com/sphinx-doc/sphinx/issues/741
-
- #: The name of the package or module that this app belongs to. Do not
- #: change this once it is set by the constructor.
- import_name = None
-
- #: Location of the template files to be added to the template lookup.
- #: ``None`` if templates should not be added.
- template_folder = None
-
- #: Absolute path to the package on the filesystem. Used to look up
- #: resources contained in the package.
- root_path = None
-
- def __init__(
- self,
- import_name,
- static_url_path=None,
- static_folder='static',
- static_host=None,
- host_matching=False,
- subdomain_matching=False,
- template_folder='templates',
- instance_path=None,
- instance_relative_config=False,
- root_path=None
- ):
- _PackageBoundObject.__init__(
- self,
- import_name,
- template_folder=template_folder,
- root_path=root_path
- )
-
- if static_url_path is not None:
- self.static_url_path = static_url_path
-
- if static_folder is not None:
- self.static_folder = static_folder
-
- if instance_path is None:
- instance_path = self.auto_find_instance_path()
- elif not os.path.isabs(instance_path):
- raise ValueError(
- 'If an instance path is provided it must be absolute.'
- ' A relative path was given instead.'
- )
-
- #: Holds the path to the instance folder.
- #:
- #: .. versionadded:: 0.8
- self.instance_path = instance_path
-
- #: The configuration dictionary as :class:`Config`. This behaves
- #: exactly like a regular dictionary but supports additional methods
- #: to load a config from files.
- self.config = self.make_config(instance_relative_config)
-
- #: A dictionary of all view functions registered. The keys will
- #: be function names which are also used to generate URLs and
- #: the values are the function objects themselves.
- #: To register a view function, use the :meth:`route` decorator.
- self.view_functions = {}
-
- #: A dictionary of all registered error handlers. The key is ``None``
- #: for error handlers active on the application, otherwise the key is
- #: the name of the blueprint. Each key points to another dictionary
- #: where the key is the status code of the http exception. The
- #: special key ``None`` points to a list of tuples where the first item
- #: is the class for the instance check and the second the error handler
- #: function.
- #:
- #: To register an error handler, use the :meth:`errorhandler`
- #: decorator.
- self.error_handler_spec = {}
-
- #: A list of functions that are called when :meth:`url_for` raises a
- #: :exc:`~werkzeug.routing.BuildError`. Each function registered here
- #: is called with `error`, `endpoint` and `values`. If a function
- #: returns ``None`` or raises a :exc:`BuildError` the next function is
- #: tried.
- #:
- #: .. versionadded:: 0.9
- self.url_build_error_handlers = []
-
- #: A dictionary with lists of functions that will be called at the
- #: beginning of each request. The key of the dictionary is the name of
- #: the blueprint this function is active for, or ``None`` for all
- #: requests. To register a function, use the :meth:`before_request`
- #: decorator.
- self.before_request_funcs = {}
-
- #: A list of functions that will be called at the beginning of the
- #: first request to this instance. To register a function, use the
- #: :meth:`before_first_request` decorator.
- #:
- #: .. versionadded:: 0.8
- self.before_first_request_funcs = []
-
- #: A dictionary with lists of functions that should be called after
- #: each request. The key of the dictionary is the name of the blueprint
- #: this function is active for, ``None`` for all requests. This can for
- #: example be used to close database connections. To register a function
- #: here, use the :meth:`after_request` decorator.
- self.after_request_funcs = {}
-
- #: A dictionary with lists of functions that are called after
- #: each request, even if an exception has occurred. The key of the
- #: dictionary is the name of the blueprint this function is active for,
- #: ``None`` for all requests. These functions are not allowed to modify
- #: the request, and their return values are ignored. If an exception
- #: occurred while processing the request, it gets passed to each
- #: teardown_request function. To register a function here, use the
- #: :meth:`teardown_request` decorator.
- #:
- #: .. versionadded:: 0.7
- self.teardown_request_funcs = {}
-
- #: A list of functions that are called when the application context
- #: is destroyed. Since the application context is also torn down
- #: if the request ends this is the place to store code that disconnects
- #: from databases.
- #:
- #: .. versionadded:: 0.9
- self.teardown_appcontext_funcs = []
-
- #: A dictionary with lists of functions that are called before the
- #: :attr:`before_request_funcs` functions. The key of the dictionary is
- #: the name of the blueprint this function is active for, or ``None``
- #: for all requests. To register a function, use
- #: :meth:`url_value_preprocessor`.
- #:
- #: .. versionadded:: 0.7
- self.url_value_preprocessors = {}
-
- #: A dictionary with lists of functions that can be used as URL value
- #: preprocessors. The key ``None`` here is used for application wide
- #: callbacks, otherwise the key is the name of the blueprint.
- #: Each of these functions has the chance to modify the dictionary
- #: of URL values before they are used as the keyword arguments of the
- #: view function. For each function registered this one should also
- #: provide a :meth:`url_defaults` function that adds the parameters
- #: automatically again that were removed that way.
- #:
- #: .. versionadded:: 0.7
- self.url_default_functions = {}
-
- #: A dictionary with list of functions that are called without argument
- #: to populate the template context. The key of the dictionary is the
- #: name of the blueprint this function is active for, ``None`` for all
- #: requests. Each returns a dictionary that the template context is
- #: updated with. To register a function here, use the
- #: :meth:`context_processor` decorator.
- self.template_context_processors = {
- None: [_default_template_ctx_processor]
- }
-
- #: A list of shell context processor functions that should be run
- #: when a shell context is created.
- #:
- #: .. versionadded:: 0.11
- self.shell_context_processors = []
-
- #: all the attached blueprints in a dictionary by name. Blueprints
- #: can be attached multiple times so this dictionary does not tell
- #: you how often they got attached.
- #:
- #: .. versionadded:: 0.7
- self.blueprints = {}
- self._blueprint_order = []
-
- #: a place where extensions can store application specific state. For
- #: example this is where an extension could store database engines and
- #: similar things. For backwards compatibility extensions should register
- #: themselves like this::
- #:
- #: if not hasattr(app, 'extensions'):
- #: app.extensions = {}
- #: app.extensions['extensionname'] = SomeObject()
- #:
- #: The key must match the name of the extension module. For example in
- #: case of a "Flask-Foo" extension in `flask_foo`, the key would be
- #: ``'foo'``.
- #:
- #: .. versionadded:: 0.7
- self.extensions = {}
-
- #: The :class:`~werkzeug.routing.Map` for this instance. You can use
- #: this to change the routing converters after the class was created
- #: but before any routes are connected. Example::
- #:
- #: from werkzeug.routing import BaseConverter
- #:
- #: class ListConverter(BaseConverter):
- #: def to_python(self, value):
- #: return value.split(',')
- #: def to_url(self, values):
- #: return ','.join(super(ListConverter, self).to_url(value)
- #: for value in values)
- #:
- #: app = Flask(__name__)
- #: app.url_map.converters['list'] = ListConverter
- self.url_map = Map()
-
- self.url_map.host_matching = host_matching
- self.subdomain_matching = subdomain_matching
-
- # tracks internally if the application already handled at least one
- # request.
- self._got_first_request = False
- self._before_request_lock = Lock()
-
- # Add a static route using the provided static_url_path, static_host,
- # and static_folder if there is a configured static_folder.
- # Note we do this without checking if static_folder exists.
- # For one, it might be created while the server is running (e.g. during
- # development). Also, Google App Engine stores static files somewhere
- if self.has_static_folder:
- assert bool(static_host) == host_matching, 'Invalid static_host/host_matching combination'
- self.add_url_rule(
- self.static_url_path + '/<path:filename>',
- endpoint='static',
- host=static_host,
- view_func=self.send_static_file
- )
-
- #: The click command line context for this application. Commands
- #: registered here show up in the :command:`flask` command once the
- #: application has been discovered. The default commands are
- #: provided by Flask itself and can be overridden.
- #:
- #: This is an instance of a :class:`click.Group` object.
- self.cli = cli.AppGroup(self.name)
-
- @locked_cached_property
- def name(self):
- """The name of the application. This is usually the import name
- with the difference that it's guessed from the run file if the
- import name is main. This name is used as a display name when
- Flask needs the name of the application. It can be set and overridden
- to change the value.
-
- .. versionadded:: 0.8
- """
- if self.import_name == '__main__':
- fn = getattr(sys.modules['__main__'], '__file__', None)
- if fn is None:
- return '__main__'
- return os.path.splitext(os.path.basename(fn))[0]
- return self.import_name
-
- @property
- def propagate_exceptions(self):
- """Returns the value of the ``PROPAGATE_EXCEPTIONS`` configuration
- value in case it's set, otherwise a sensible default is returned.
-
- .. versionadded:: 0.7
- """
- rv = self.config['PROPAGATE_EXCEPTIONS']
- if rv is not None:
- return rv
- return self.testing or self.debug
-
- @property
- def preserve_context_on_exception(self):
- """Returns the value of the ``PRESERVE_CONTEXT_ON_EXCEPTION``
- configuration value in case it's set, otherwise a sensible default
- is returned.
-
- .. versionadded:: 0.7
- """
- rv = self.config['PRESERVE_CONTEXT_ON_EXCEPTION']
- if rv is not None:
- return rv
- return self.debug
-
- @locked_cached_property
- def logger(self):
- """The ``'flask.app'`` logger, a standard Python
- :class:`~logging.Logger`.
-
- In debug mode, the logger's :attr:`~logging.Logger.level` will be set
- to :data:`~logging.DEBUG`.
-
- If there are no handlers configured, a default handler will be added.
- See :ref:`logging` for more information.
-
- .. versionchanged:: 1.0
- Behavior was simplified. The logger is always named
- ``flask.app``. The level is only set during configuration, it
- doesn't check ``app.debug`` each time. Only one format is used,
- not different ones depending on ``app.debug``. No handlers are
- removed, and a handler is only added if no handlers are already
- configured.
-
- .. versionadded:: 0.3
- """
- return create_logger(self)
-
- @locked_cached_property
- def jinja_env(self):
- """The Jinja2 environment used to load templates."""
- return self.create_jinja_environment()
-
- @property
- def got_first_request(self):
- """This attribute is set to ``True`` if the application started
- handling the first request.
-
- .. versionadded:: 0.8
- """
- return self._got_first_request
-
- def make_config(self, instance_relative=False):
- """Used to create the config attribute by the Flask constructor.
- The `instance_relative` parameter is passed in from the constructor
- of Flask (there named `instance_relative_config`) and indicates if
- the config should be relative to the instance path or the root path
- of the application.
-
- .. versionadded:: 0.8
- """
- root_path = self.root_path
- if instance_relative:
- root_path = self.instance_path
- defaults = dict(self.default_config)
- defaults['ENV'] = get_env()
- defaults['DEBUG'] = get_debug_flag()
- return self.config_class(root_path, defaults)
-
- def auto_find_instance_path(self):
- """Tries to locate the instance path if it was not provided to the
- constructor of the application class. It will basically calculate
- the path to a folder named ``instance`` next to your main file or
- the package.
-
- .. versionadded:: 0.8
- """
- prefix, package_path = find_package(self.import_name)
- if prefix is None:
- return os.path.join(package_path, 'instance')
- return os.path.join(prefix, 'var', self.name + '-instance')
-
- def open_instance_resource(self, resource, mode='rb'):
- """Opens a resource from the application's instance folder
- (:attr:`instance_path`). Otherwise works like
- :meth:`open_resource`. Instance resources can also be opened for
- writing.
-
- :param resource: the name of the resource. To access resources within
- subfolders use forward slashes as separator.
- :param mode: resource file opening mode, default is 'rb'.
- """
- return open(os.path.join(self.instance_path, resource), mode)
-
- def _get_templates_auto_reload(self):
- """Reload templates when they are changed. Used by
- :meth:`create_jinja_environment`.
-
- This attribute can be configured with :data:`TEMPLATES_AUTO_RELOAD`. If
- not set, it will be enabled in debug mode.
-
- .. versionadded:: 1.0
- This property was added but the underlying config and behavior
- already existed.
- """
- rv = self.config['TEMPLATES_AUTO_RELOAD']
- return rv if rv is not None else self.debug
-
- def _set_templates_auto_reload(self, value):
- self.config['TEMPLATES_AUTO_RELOAD'] = value
-
- templates_auto_reload = property(
- _get_templates_auto_reload, _set_templates_auto_reload
- )
- del _get_templates_auto_reload, _set_templates_auto_reload
-
- def create_jinja_environment(self):
- """Creates the Jinja2 environment based on :attr:`jinja_options`
- and :meth:`select_jinja_autoescape`. Since 0.7 this also adds
- the Jinja2 globals and filters after initialization. Override
- this function to customize the behavior.
-
- .. versionadded:: 0.5
- .. versionchanged:: 0.11
- ``Environment.auto_reload`` set in accordance with
- ``TEMPLATES_AUTO_RELOAD`` configuration option.
- """
- options = dict(self.jinja_options)
-
- if 'autoescape' not in options:
- options['autoescape'] = self.select_jinja_autoescape
-
- if 'auto_reload' not in options:
- options['auto_reload'] = self.templates_auto_reload
-
- rv = self.jinja_environment(self, **options)
- rv.globals.update(
- url_for=url_for,
- get_flashed_messages=get_flashed_messages,
- config=self.config,
- # request, session and g are normally added with the
- # context processor for efficiency reasons but for imported
- # templates we also want the proxies in there.
- request=request,
- session=session,
- g=g
- )
- rv.filters['tojson'] = json.tojson_filter
- return rv
-
- def create_global_jinja_loader(self):
- """Creates the loader for the Jinja2 environment. Can be used to
- override just the loader and keeping the rest unchanged. It's
- discouraged to override this function. Instead one should override
- the :meth:`jinja_loader` function instead.
-
- The global loader dispatches between the loaders of the application
- and the individual blueprints.
-
- .. versionadded:: 0.7
- """
- return DispatchingJinjaLoader(self)
-
- def select_jinja_autoescape(self, filename):
- """Returns ``True`` if autoescaping should be active for the given
- template name. If no template name is given, returns `True`.
-
- .. versionadded:: 0.5
- """
- if filename is None:
- return True
- return filename.endswith(('.html', '.htm', '.xml', '.xhtml'))
-
- def update_template_context(self, context):
- """Update the template context with some commonly used variables.
- This injects request, session, config and g into the template
- context as well as everything template context processors want
- to inject. Note that the as of Flask 0.6, the original values
- in the context will not be overridden if a context processor
- decides to return a value with the same key.
-
- :param context: the context as a dictionary that is updated in place
- to add extra variables.
- """
- funcs = self.template_context_processors[None]
- reqctx = _request_ctx_stack.top
- if reqctx is not None:
- bp = reqctx.request.blueprint
- if bp is not None and bp in self.template_context_processors:
- funcs = chain(funcs, self.template_context_processors[bp])
- orig_ctx = context.copy()
- for func in funcs:
- context.update(func())
- # make sure the original values win. This makes it possible to
- # easier add new variables in context processors without breaking
- # existing views.
- context.update(orig_ctx)
-
- def make_shell_context(self):
- """Returns the shell context for an interactive shell for this
- application. This runs all the registered shell context
- processors.
-
- .. versionadded:: 0.11
- """
- rv = {'app': self, 'g': g}
- for processor in self.shell_context_processors:
- rv.update(processor())
- return rv
-
- #: What environment the app is running in. Flask and extensions may
- #: enable behaviors based on the environment, such as enabling debug
- #: mode. This maps to the :data:`ENV` config key. This is set by the
- #: :envvar:`FLASK_ENV` environment variable and may not behave as
- #: expected if set in code.
- #:
- #: **Do not enable development when deploying in production.**
- #:
- #: Default: ``'production'``
- env = ConfigAttribute('ENV')
-
- def _get_debug(self):
- return self.config['DEBUG']
-
- def _set_debug(self, value):
- self.config['DEBUG'] = value
- self.jinja_env.auto_reload = self.templates_auto_reload
-
- #: Whether debug mode is enabled. When using ``flask run`` to start
- #: the development server, an interactive debugger will be shown for
- #: unhandled exceptions, and the server will be reloaded when code
- #: changes. This maps to the :data:`DEBUG` config key. This is
- #: enabled when :attr:`env` is ``'development'`` and is overridden
- #: by the ``FLASK_DEBUG`` environment variable. It may not behave as
- #: expected if set in code.
- #:
- #: **Do not enable debug mode when deploying in production.**
- #:
- #: Default: ``True`` if :attr:`env` is ``'development'``, or
- #: ``False`` otherwise.
- debug = property(_get_debug, _set_debug)
- del _get_debug, _set_debug
-
- def run(self, host=None, port=None, debug=None,
- load_dotenv=True, **options):
- """Runs the application on a local development server.
-
- Do not use ``run()`` in a production setting. It is not intended to
- meet security and performance requirements for a production server.
- Instead, see :ref:`deployment` for WSGI server recommendations.
-
- If the :attr:`debug` flag is set the server will automatically reload
- for code changes and show a debugger in case an exception happened.
-
- If you want to run the application in debug mode, but disable the
- code execution on the interactive debugger, you can pass
- ``use_evalex=False`` as parameter. This will keep the debugger's
- traceback screen active, but disable code execution.
-
- It is not recommended to use this function for development with
- automatic reloading as this is badly supported. Instead you should
- be using the :command:`flask` command line script's ``run`` support.
-
- .. admonition:: Keep in Mind
-
- Flask will suppress any server error with a generic error page
- unless it is in debug mode. As such to enable just the
- interactive debugger without the code reloading, you have to
- invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
- Setting ``use_debugger`` to ``True`` without being in debug mode
- won't catch any exceptions because there won't be any to
- catch.
-
- :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
- have the server available externally as well. Defaults to
- ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
- if present.
- :param port: the port of the webserver. Defaults to ``5000`` or the
- port defined in the ``SERVER_NAME`` config variable if present.
- :param debug: if given, enable or disable debug mode. See
- :attr:`debug`.
- :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
- files to set environment variables. Will also change the working
- directory to the directory containing the first file found.
- :param options: the options to be forwarded to the underlying Werkzeug
- server. See :func:`werkzeug.serving.run_simple` for more
- information.
-
- .. versionchanged:: 1.0
- If installed, python-dotenv will be used to load environment
- variables from :file:`.env` and :file:`.flaskenv` files.
-
- If set, the :envvar:`FLASK_ENV` and :envvar:`FLASK_DEBUG`
- environment variables will override :attr:`env` and
- :attr:`debug`.
-
- Threaded mode is enabled by default.
-
- .. versionchanged:: 0.10
- The default port is now picked from the ``SERVER_NAME``
- variable.
- """
- # Change this into a no-op if the server is invoked from the
- # command line. Have a look at cli.py for more information.
- if os.environ.get('FLASK_RUN_FROM_CLI') == 'true':
- from .debughelpers import explain_ignored_app_run
- explain_ignored_app_run()
- return
-
- if get_load_dotenv(load_dotenv):
- cli.load_dotenv()
-
- # if set, let env vars override previous values
- if 'FLASK_ENV' in os.environ:
- self.env = get_env()
- self.debug = get_debug_flag()
- elif 'FLASK_DEBUG' in os.environ:
- self.debug = get_debug_flag()
-
- # debug passed to method overrides all other sources
- if debug is not None:
- self.debug = bool(debug)
-
- _host = '127.0.0.1'
- _port = 5000
- server_name = self.config.get('SERVER_NAME')
- sn_host, sn_port = None, None
-
- if server_name:
- sn_host, _, sn_port = server_name.partition(':')
-
- host = host or sn_host or _host
- port = int(port or sn_port or _port)
-
- options.setdefault('use_reloader', self.debug)
- options.setdefault('use_debugger', self.debug)
- options.setdefault('threaded', True)
-
- cli.show_server_banner(self.env, self.debug, self.name, False)
-
- from werkzeug.serving import run_simple
-
- try:
- run_simple(host, port, self, **options)
- finally:
- # reset the first request information if the development server
- # reset normally. This makes it possible to restart the server
- # without reloader and that stuff from an interactive shell.
- self._got_first_request = False
-
- def test_client(self, use_cookies=True, **kwargs):
- """Creates a test client for this application. For information
- about unit testing head over to :ref:`testing`.
-
- Note that if you are testing for assertions or exceptions in your
- application code, you must set ``app.testing = True`` in order for the
- exceptions to propagate to the test client. Otherwise, the exception
- will be handled by the application (not visible to the test client) and
- the only indication of an AssertionError or other exception will be a
- 500 status code response to the test client. See the :attr:`testing`
- attribute. For example::
-
- app.testing = True
- client = app.test_client()
-
- The test client can be used in a ``with`` block to defer the closing down
- of the context until the end of the ``with`` block. This is useful if
- you want to access the context locals for testing::
-
- with app.test_client() as c:
- rv = c.get('/?vodka=42')
- assert request.args['vodka'] == '42'
-
- Additionally, you may pass optional keyword arguments that will then
- be passed to the application's :attr:`test_client_class` constructor.
- For example::
-
- from flask.testing import FlaskClient
-
- class CustomClient(FlaskClient):
- def __init__(self, *args, **kwargs):
- self._authentication = kwargs.pop("authentication")
- super(CustomClient,self).__init__( *args, **kwargs)
-
- app.test_client_class = CustomClient
- client = app.test_client(authentication='Basic ....')
-
- See :class:`~flask.testing.FlaskClient` for more information.
-
- .. versionchanged:: 0.4
- added support for ``with`` block usage for the client.
-
- .. versionadded:: 0.7
- The `use_cookies` parameter was added as well as the ability
- to override the client to be used by setting the
- :attr:`test_client_class` attribute.
-
- .. versionchanged:: 0.11
- Added `**kwargs` to support passing additional keyword arguments to
- the constructor of :attr:`test_client_class`.
- """
- cls = self.test_client_class
- if cls is None:
- from flask.testing import FlaskClient as cls
- return cls(self, self.response_class, use_cookies=use_cookies, **kwargs)
-
- def test_cli_runner(self, **kwargs):
- """Create a CLI runner for testing CLI commands.
- See :ref:`testing-cli`.
-
- Returns an instance of :attr:`test_cli_runner_class`, by default
- :class:`~flask.testing.FlaskCliRunner`. The Flask app object is
- passed as the first argument.
-
- .. versionadded:: 1.0
- """
- cls = self.test_cli_runner_class
-
- if cls is None:
- from flask.testing import FlaskCliRunner as cls
-
- return cls(self, **kwargs)
-
- def open_session(self, request):
- """Creates or opens a new session. Default implementation stores all
- session data in a signed cookie. This requires that the
- :attr:`secret_key` is set. Instead of overriding this method
- we recommend replacing the :class:`session_interface`.
-
- .. deprecated: 1.0
- Will be removed in 1.1. Use ``session_interface.open_session``
- instead.
-
- :param request: an instance of :attr:`request_class`.
- """
-
- warnings.warn(DeprecationWarning(
- '"open_session" is deprecated and will be removed in 1.1. Use'
- ' "session_interface.open_session" instead.'
- ))
- return self.session_interface.open_session(self, request)
-
- def save_session(self, session, response):
- """Saves the session if it needs updates. For the default
- implementation, check :meth:`open_session`. Instead of overriding this
- method we recommend replacing the :class:`session_interface`.
-
- .. deprecated: 1.0
- Will be removed in 1.1. Use ``session_interface.save_session``
- instead.
-
- :param session: the session to be saved (a
- :class:`~werkzeug.contrib.securecookie.SecureCookie`
- object)
- :param response: an instance of :attr:`response_class`
- """
-
- warnings.warn(DeprecationWarning(
- '"save_session" is deprecated and will be removed in 1.1. Use'
- ' "session_interface.save_session" instead.'
- ))
- return self.session_interface.save_session(self, session, response)
-
- def make_null_session(self):
- """Creates a new instance of a missing session. Instead of overriding
- this method we recommend replacing the :class:`session_interface`.
-
- .. deprecated: 1.0
- Will be removed in 1.1. Use ``session_interface.make_null_session``
- instead.
-
- .. versionadded:: 0.7
- """
-
- warnings.warn(DeprecationWarning(
- '"make_null_session" is deprecated and will be removed in 1.1. Use'
- ' "session_interface.make_null_session" instead.'
- ))
- return self.session_interface.make_null_session(self)
-
- @setupmethod
- def register_blueprint(self, blueprint, **options):
- """Register a :class:`~flask.Blueprint` on the application. Keyword
- arguments passed to this method will override the defaults set on the
- blueprint.
-
- Calls the blueprint's :meth:`~flask.Blueprint.register` method after
- recording the blueprint in the application's :attr:`blueprints`.
-
- :param blueprint: The blueprint to register.
- :param url_prefix: Blueprint routes will be prefixed with this.
- :param subdomain: Blueprint routes will match on this subdomain.
- :param url_defaults: Blueprint routes will use these default values for
- view arguments.
- :param options: Additional keyword arguments are passed to
- :class:`~flask.blueprints.BlueprintSetupState`. They can be
- accessed in :meth:`~flask.Blueprint.record` callbacks.
-
- .. versionadded:: 0.7
- """
- first_registration = False
-
- if blueprint.name in self.blueprints:
- assert self.blueprints[blueprint.name] is blueprint, (
- 'A name collision occurred between blueprints %r and %r. Both'
- ' share the same name "%s". Blueprints that are created on the'
- ' fly need unique names.' % (
- blueprint, self.blueprints[blueprint.name], blueprint.name
- )
- )
- else:
- self.blueprints[blueprint.name] = blueprint
- self._blueprint_order.append(blueprint)
- first_registration = True
-
- blueprint.register(self, options, first_registration)
-
- def iter_blueprints(self):
- """Iterates over all blueprints by the order they were registered.
-
- .. versionadded:: 0.11
- """
- return iter(self._blueprint_order)
-
- @setupmethod
- def add_url_rule(self, rule, endpoint=None, view_func=None,
- provide_automatic_options=None, **options):
- """Connects a URL rule. Works exactly like the :meth:`route`
- decorator. If a view_func is provided it will be registered with the
- endpoint.
-
- Basically this example::
-
- @app.route('/')
- def index():
- pass
-
- Is equivalent to the following::
-
- def index():
- pass
- app.add_url_rule('/', 'index', index)
-
- If the view_func is not provided you will need to connect the endpoint
- to a view function like so::
-
- app.view_functions['index'] = index
-
- Internally :meth:`route` invokes :meth:`add_url_rule` so if you want
- to customize the behavior via subclassing you only need to change
- this method.
-
- For more information refer to :ref:`url-route-registrations`.
-
- .. versionchanged:: 0.2
- `view_func` parameter added.
-
- .. versionchanged:: 0.6
- ``OPTIONS`` is added automatically as method.
-
- :param rule: the URL rule as string
- :param endpoint: the endpoint for the registered URL rule. Flask
- itself assumes the name of the view function as
- endpoint
- :param view_func: the function to call when serving a request to the
- provided endpoint
- :param provide_automatic_options: controls whether the ``OPTIONS``
- method should be added automatically. This can also be controlled
- by setting the ``view_func.provide_automatic_options = False``
- before adding the rule.
- :param options: the options to be forwarded to the underlying
- :class:`~werkzeug.routing.Rule` object. A change
- to Werkzeug is handling of method options. methods
- is a list of methods this rule should be limited
- to (``GET``, ``POST`` etc.). By default a rule
- just listens for ``GET`` (and implicitly ``HEAD``).
- Starting with Flask 0.6, ``OPTIONS`` is implicitly
- added and handled by the standard request handling.
- """
- if endpoint is None:
- endpoint = _endpoint_from_view_func(view_func)
- options['endpoint'] = endpoint
- methods = options.pop('methods', None)
-
- # if the methods are not given and the view_func object knows its
- # methods we can use that instead. If neither exists, we go with
- # a tuple of only ``GET`` as default.
- if methods is None:
- methods = getattr(view_func, 'methods', None) or ('GET',)
- if isinstance(methods, string_types):
- raise TypeError('Allowed methods have to be iterables of strings, '
- 'for example: @app.route(..., methods=["POST"])')
- methods = set(item.upper() for item in methods)
-
- # Methods that should always be added
- required_methods = set(getattr(view_func, 'required_methods', ()))
-
- # starting with Flask 0.8 the view_func object can disable and
- # force-enable the automatic options handling.
- if provide_automatic_options is None:
- provide_automatic_options = getattr(view_func,
- 'provide_automatic_options', None)
-
- if provide_automatic_options is None:
- if 'OPTIONS' not in methods:
- provide_automatic_options = True
- required_methods.add('OPTIONS')
- else:
- provide_automatic_options = False
-
- # Add the required methods now.
- methods |= required_methods
-
- rule = self.url_rule_class(rule, methods=methods, **options)
- rule.provide_automatic_options = provide_automatic_options
-
- self.url_map.add(rule)
- if view_func is not None:
- old_func = self.view_functions.get(endpoint)
- if old_func is not None and old_func != view_func:
- raise AssertionError('View function mapping is overwriting an '
- 'existing endpoint function: %s' % endpoint)
- self.view_functions[endpoint] = view_func
-
- def route(self, rule, **options):
- """A decorator that is used to register a view function for a
- given URL rule. This does the same thing as :meth:`add_url_rule`
- but is intended for decorator usage::
-
- @app.route('/')
- def index():
- return 'Hello World'
-
- For more information refer to :ref:`url-route-registrations`.
-
- :param rule: the URL rule as string
- :param endpoint: the endpoint for the registered URL rule. Flask
- itself assumes the name of the view function as
- endpoint
- :param options: the options to be forwarded to the underlying
- :class:`~werkzeug.routing.Rule` object. A change
- to Werkzeug is handling of method options. methods
- is a list of methods this rule should be limited
- to (``GET``, ``POST`` etc.). By default a rule
- just listens for ``GET`` (and implicitly ``HEAD``).
- Starting with Flask 0.6, ``OPTIONS`` is implicitly
- added and handled by the standard request handling.
- """
- def decorator(f):
- endpoint = options.pop('endpoint', None)
- self.add_url_rule(rule, endpoint, f, **options)
- return f
- return decorator
-
- @setupmethod
- def endpoint(self, endpoint):
- """A decorator to register a function as an endpoint.
- Example::
-
- @app.endpoint('example.endpoint')
- def example():
- return "example"
-
- :param endpoint: the name of the endpoint
- """
- def decorator(f):
- self.view_functions[endpoint] = f
- return f
- return decorator
-
- @staticmethod
- def _get_exc_class_and_code(exc_class_or_code):
- """Ensure that we register only exceptions as handler keys"""
- if isinstance(exc_class_or_code, integer_types):
- exc_class = default_exceptions[exc_class_or_code]
- else:
- exc_class = exc_class_or_code
-
- assert issubclass(exc_class, Exception)
-
- if issubclass(exc_class, HTTPException):
- return exc_class, exc_class.code
- else:
- return exc_class, None
-
- @setupmethod
- def errorhandler(self, code_or_exception):
- """Register a function to handle errors by code or exception class.
-
- A decorator that is used to register a function given an
- error code. Example::
-
- @app.errorhandler(404)
- def page_not_found(error):
- return 'This page does not exist', 404
-
- You can also register handlers for arbitrary exceptions::
-
- @app.errorhandler(DatabaseError)
- def special_exception_handler(error):
- return 'Database connection failed', 500
-
- .. versionadded:: 0.7
- Use :meth:`register_error_handler` instead of modifying
- :attr:`error_handler_spec` directly, for application wide error
- handlers.
-
- .. versionadded:: 0.7
- One can now additionally also register custom exception types
- that do not necessarily have to be a subclass of the
- :class:`~werkzeug.exceptions.HTTPException` class.
-
- :param code_or_exception: the code as integer for the handler, or
- an arbitrary exception
- """
- def decorator(f):
- self._register_error_handler(None, code_or_exception, f)
- return f
- return decorator
-
- @setupmethod
- def register_error_handler(self, code_or_exception, f):
- """Alternative error attach function to the :meth:`errorhandler`
- decorator that is more straightforward to use for non decorator
- usage.
-
- .. versionadded:: 0.7
- """
- self._register_error_handler(None, code_or_exception, f)
-
- @setupmethod
- def _register_error_handler(self, key, code_or_exception, f):
- """
- :type key: None|str
- :type code_or_exception: int|T<=Exception
- :type f: callable
- """
- if isinstance(code_or_exception, HTTPException): # old broken behavior
- raise ValueError(
- 'Tried to register a handler for an exception instance {0!r}.'
- ' Handlers can only be registered for exception classes or'
- ' HTTP error codes.'.format(code_or_exception)
- )
-
- try:
- exc_class, code = self._get_exc_class_and_code(code_or_exception)
- except KeyError:
- raise KeyError(
- "'{0}' is not a recognized HTTP error code. Use a subclass of"
- " HTTPException with that code instead.".format(code_or_exception)
- )
-
- handlers = self.error_handler_spec.setdefault(key, {}).setdefault(code, {})
- handlers[exc_class] = f
-
- @setupmethod
- def template_filter(self, name=None):
- """A decorator that is used to register custom template filter.
- You can specify a name for the filter, otherwise the function
- name will be used. Example::
-
- @app.template_filter()
- def reverse(s):
- return s[::-1]
-
- :param name: the optional name of the filter, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_template_filter(f, name=name)
- return f
- return decorator
-
- @setupmethod
- def add_template_filter(self, f, name=None):
- """Register a custom template filter. Works exactly like the
- :meth:`template_filter` decorator.
-
- :param name: the optional name of the filter, otherwise the
- function name will be used.
- """
- self.jinja_env.filters[name or f.__name__] = f
-
- @setupmethod
- def template_test(self, name=None):
- """A decorator that is used to register custom template test.
- You can specify a name for the test, otherwise the function
- name will be used. Example::
-
- @app.template_test()
- def is_prime(n):
- if n == 2:
- return True
- for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
- if n % i == 0:
- return False
- return True
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the test, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_template_test(f, name=name)
- return f
- return decorator
-
- @setupmethod
- def add_template_test(self, f, name=None):
- """Register a custom template test. Works exactly like the
- :meth:`template_test` decorator.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the test, otherwise the
- function name will be used.
- """
- self.jinja_env.tests[name or f.__name__] = f
-
- @setupmethod
- def template_global(self, name=None):
- """A decorator that is used to register a custom template global function.
- You can specify a name for the global function, otherwise the function
- name will be used. Example::
-
- @app.template_global()
- def double(n):
- return 2 * n
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the global function, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_template_global(f, name=name)
- return f
- return decorator
-
- @setupmethod
- def add_template_global(self, f, name=None):
- """Register a custom template global function. Works exactly like the
- :meth:`template_global` decorator.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the global function, otherwise the
- function name will be used.
- """
- self.jinja_env.globals[name or f.__name__] = f
-
- @setupmethod
- def before_request(self, f):
- """Registers a function to run before each request.
-
- For example, this can be used to open a database connection, or to load
- the logged in user from the session.
-
- The function will be called without any arguments. If it returns a
- non-None value, the value is handled as if it was the return value from
- the view, and further request handling is stopped.
- """
- self.before_request_funcs.setdefault(None, []).append(f)
- return f
-
- @setupmethod
- def before_first_request(self, f):
- """Registers a function to be run before the first request to this
- instance of the application.
-
- The function will be called without any arguments and its return
- value is ignored.
-
- .. versionadded:: 0.8
- """
- self.before_first_request_funcs.append(f)
- return f
-
- @setupmethod
- def after_request(self, f):
- """Register a function to be run after each request.
-
- Your function must take one parameter, an instance of
- :attr:`response_class` and return a new response object or the
- same (see :meth:`process_response`).
-
- As of Flask 0.7 this function might not be executed at the end of the
- request in case an unhandled exception occurred.
- """
- self.after_request_funcs.setdefault(None, []).append(f)
- return f
-
- @setupmethod
- def teardown_request(self, f):
- """Register a function to be run at the end of each request,
- regardless of whether there was an exception or not. These functions
- are executed when the request context is popped, even if not an
- actual request was performed.
-
- Example::
-
- ctx = app.test_request_context()
- ctx.push()
- ...
- ctx.pop()
-
- When ``ctx.pop()`` is executed in the above example, the teardown
- functions are called just before the request context moves from the
- stack of active contexts. This becomes relevant if you are using
- such constructs in tests.
-
- Generally teardown functions must take every necessary step to avoid
- that they will fail. If they do execute code that might fail they
- will have to surround the execution of these code by try/except
- statements and log occurring errors.
-
- When a teardown function was called because of an exception it will
- be passed an error object.
-
- The return values of teardown functions are ignored.
-
- .. admonition:: Debug Note
-
- In debug mode Flask will not tear down a request on an exception
- immediately. Instead it will keep it alive so that the interactive
- debugger can still access it. This behavior can be controlled
- by the ``PRESERVE_CONTEXT_ON_EXCEPTION`` configuration variable.
- """
- self.teardown_request_funcs.setdefault(None, []).append(f)
- return f
-
- @setupmethod
- def teardown_appcontext(self, f):
- """Registers a function to be called when the application context
- ends. These functions are typically also called when the request
- context is popped.
-
- Example::
-
- ctx = app.app_context()
- ctx.push()
- ...
- ctx.pop()
-
- When ``ctx.pop()`` is executed in the above example, the teardown
- functions are called just before the app context moves from the
- stack of active contexts. This becomes relevant if you are using
- such constructs in tests.
-
- Since a request context typically also manages an application
- context it would also be called when you pop a request context.
-
- When a teardown function was called because of an unhandled exception
- it will be passed an error object. If an :meth:`errorhandler` is
- registered, it will handle the exception and the teardown will not
- receive it.
-
- The return values of teardown functions are ignored.
-
- .. versionadded:: 0.9
- """
- self.teardown_appcontext_funcs.append(f)
- return f
-
- @setupmethod
- def context_processor(self, f):
- """Registers a template context processor function."""
- self.template_context_processors[None].append(f)
- return f
-
- @setupmethod
- def shell_context_processor(self, f):
- """Registers a shell context processor function.
-
- .. versionadded:: 0.11
- """
- self.shell_context_processors.append(f)
- return f
-
- @setupmethod
- def url_value_preprocessor(self, f):
- """Register a URL value preprocessor function for all view
- functions in the application. These functions will be called before the
- :meth:`before_request` functions.
-
- The function can modify the values captured from the matched url before
- they are passed to the view. For example, this can be used to pop a
- common language code value and place it in ``g`` rather than pass it to
- every view.
-
- The function is passed the endpoint name and values dict. The return
- value is ignored.
- """
- self.url_value_preprocessors.setdefault(None, []).append(f)
- return f
-
- @setupmethod
- def url_defaults(self, f):
- """Callback function for URL defaults for all view functions of the
- application. It's called with the endpoint and values and should
- update the values passed in place.
- """
- self.url_default_functions.setdefault(None, []).append(f)
- return f
-
- def _find_error_handler(self, e):
- """Return a registered error handler for an exception in this order:
- blueprint handler for a specific code, app handler for a specific code,
- blueprint handler for an exception class, app handler for an exception
- class, or ``None`` if a suitable handler is not found.
- """
- exc_class, code = self._get_exc_class_and_code(type(e))
-
- for name, c in (
- (request.blueprint, code), (None, code),
- (request.blueprint, None), (None, None)
- ):
- handler_map = self.error_handler_spec.setdefault(name, {}).get(c)
-
- if not handler_map:
- continue
-
- for cls in exc_class.__mro__:
- handler = handler_map.get(cls)
-
- if handler is not None:
- return handler
-
- def handle_http_exception(self, e):
- """Handles an HTTP exception. By default this will invoke the
- registered error handlers and fall back to returning the
- exception as response.
-
- .. versionchanged:: 1.0.3
- ``RoutingException``, used internally for actions such as
- slash redirects during routing, is not passed to error
- handlers.
-
- .. versionchanged:: 1.0
- Exceptions are looked up by code *and* by MRO, so
- ``HTTPExcpetion`` subclasses can be handled with a catch-all
- handler for the base ``HTTPException``.
-
- .. versionadded:: 0.3
- """
- # Proxy exceptions don't have error codes. We want to always return
- # those unchanged as errors
- if e.code is None:
- return e
-
- # RoutingExceptions are used internally to trigger routing
- # actions, such as slash redirects raising RequestRedirect. They
- # are not raised or handled in user code.
- if isinstance(e, RoutingException):
- return e
-
- handler = self._find_error_handler(e)
- if handler is None:
- return e
- return handler(e)
-
- def trap_http_exception(self, e):
- """Checks if an HTTP exception should be trapped or not. By default
- this will return ``False`` for all exceptions except for a bad request
- key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to ``True``. It
- also returns ``True`` if ``TRAP_HTTP_EXCEPTIONS`` is set to ``True``.
-
- This is called for all HTTP exceptions raised by a view function.
- If it returns ``True`` for any exception the error handler for this
- exception is not called and it shows up as regular exception in the
- traceback. This is helpful for debugging implicitly raised HTTP
- exceptions.
-
- .. versionchanged:: 1.0
- Bad request errors are not trapped by default in debug mode.
-
- .. versionadded:: 0.8
- """
- if self.config['TRAP_HTTP_EXCEPTIONS']:
- return True
-
- trap_bad_request = self.config['TRAP_BAD_REQUEST_ERRORS']
-
- # if unset, trap key errors in debug mode
- if (
- trap_bad_request is None and self.debug
- and isinstance(e, BadRequestKeyError)
- ):
- return True
-
- if trap_bad_request:
- return isinstance(e, BadRequest)
-
- return False
-
- def handle_user_exception(self, e):
- """This method is called whenever an exception occurs that
- should be handled. A special case is :class:`~werkzeug
- .exceptions.HTTPException` which is forwarded to the
- :meth:`handle_http_exception` method. This function will either
- return a response value or reraise the exception with the same
- traceback.
-
- .. versionchanged:: 1.0
- Key errors raised from request data like ``form`` show the
- bad key in debug mode rather than a generic bad request
- message.
-
- .. versionadded:: 0.7
- """
- exc_type, exc_value, tb = sys.exc_info()
- assert exc_value is e
- # ensure not to trash sys.exc_info() at that point in case someone
- # wants the traceback preserved in handle_http_exception. Of course
- # we cannot prevent users from trashing it themselves in a custom
- # trap_http_exception method so that's their fault then.
-
- if isinstance(e, BadRequestKeyError):
- if self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]:
- # Werkzeug < 0.15 doesn't add the KeyError to the 400
- # message, add it in manually.
- description = e.get_description()
-
- if e.args[0] not in description:
- e.description = "KeyError: '{}'".format(*e.args)
- else:
- # Werkzeug >= 0.15 does add it, remove it in production
- e.args = ()
-
- if isinstance(e, HTTPException) and not self.trap_http_exception(e):
- return self.handle_http_exception(e)
-
- handler = self._find_error_handler(e)
-
- if handler is None:
- reraise(exc_type, exc_value, tb)
- return handler(e)
-
- def handle_exception(self, e):
- """Default exception handling that kicks in when an exception
- occurs that is not caught. In debug mode the exception will
- be re-raised immediately, otherwise it is logged and the handler
- for a 500 internal server error is used. If no such handler
- exists, a default 500 internal server error message is displayed.
-
- .. versionadded:: 0.3
- """
- exc_type, exc_value, tb = sys.exc_info()
-
- got_request_exception.send(self, exception=e)
- handler = self._find_error_handler(InternalServerError())
-
- if self.propagate_exceptions:
- # if we want to repropagate the exception, we can attempt to
- # raise it with the whole traceback in case we can do that
- # (the function was actually called from the except part)
- # otherwise, we just raise the error again
- if exc_value is e:
- reraise(exc_type, exc_value, tb)
- else:
- raise e
-
- self.log_exception((exc_type, exc_value, tb))
- if handler is None:
- return InternalServerError()
- return self.finalize_request(handler(e), from_error_handler=True)
-
- def log_exception(self, exc_info):
- """Logs an exception. This is called by :meth:`handle_exception`
- if debugging is disabled and right before the handler is called.
- The default implementation logs the exception as error on the
- :attr:`logger`.
-
- .. versionadded:: 0.8
- """
- self.logger.error('Exception on %s [%s]' % (
- request.path,
- request.method
- ), exc_info=exc_info)
-
- def raise_routing_exception(self, request):
- """Exceptions that are recording during routing are reraised with
- this method. During debug we are not reraising redirect requests
- for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
- a different error instead to help debug situations.
-
- :internal:
- """
- if not self.debug \
- or not isinstance(request.routing_exception, RequestRedirect) \
- or request.method in ('GET', 'HEAD', 'OPTIONS'):
- raise request.routing_exception
-
- from .debughelpers import FormDataRoutingRedirect
- raise FormDataRoutingRedirect(request)
-
- def dispatch_request(self):
- """Does the request dispatching. Matches the URL and returns the
- return value of the view or error handler. This does not have to
- be a response object. In order to convert the return value to a
- proper response object, call :func:`make_response`.
-
- .. versionchanged:: 0.7
- This no longer does the exception handling, this code was
- moved to the new :meth:`full_dispatch_request`.
- """
- req = _request_ctx_stack.top.request
- if req.routing_exception is not None:
- self.raise_routing_exception(req)
- rule = req.url_rule
- # if we provide automatic options for this URL and the
- # request came with the OPTIONS method, reply automatically
- if getattr(rule, 'provide_automatic_options', False) \
- and req.method == 'OPTIONS':
- return self.make_default_options_response()
- # otherwise dispatch to the handler for that endpoint
- return self.view_functions[rule.endpoint](**req.view_args)
-
- def full_dispatch_request(self):
- """Dispatches the request and on top of that performs request
- pre and postprocessing as well as HTTP exception catching and
- error handling.
-
- .. versionadded:: 0.7
- """
- self.try_trigger_before_first_request_functions()
- try:
- request_started.send(self)
- rv = self.preprocess_request()
- if rv is None:
- rv = self.dispatch_request()
- except Exception as e:
- rv = self.handle_user_exception(e)
- return self.finalize_request(rv)
-
- def finalize_request(self, rv, from_error_handler=False):
- """Given the return value from a view function this finalizes
- the request by converting it into a response and invoking the
- postprocessing functions. This is invoked for both normal
- request dispatching as well as error handlers.
-
- Because this means that it might be called as a result of a
- failure a special safe mode is available which can be enabled
- with the `from_error_handler` flag. If enabled, failures in
- response processing will be logged and otherwise ignored.
-
- :internal:
- """
- response = self.make_response(rv)
- try:
- response = self.process_response(response)
- request_finished.send(self, response=response)
- except Exception:
- if not from_error_handler:
- raise
- self.logger.exception('Request finalizing failed with an '
- 'error while handling an error')
- return response
-
- def try_trigger_before_first_request_functions(self):
- """Called before each request and will ensure that it triggers
- the :attr:`before_first_request_funcs` and only exactly once per
- application instance (which means process usually).
-
- :internal:
- """
- if self._got_first_request:
- return
- with self._before_request_lock:
- if self._got_first_request:
- return
- for func in self.before_first_request_funcs:
- func()
- self._got_first_request = True
-
- def make_default_options_response(self):
- """This method is called to create the default ``OPTIONS`` response.
- This can be changed through subclassing to change the default
- behavior of ``OPTIONS`` responses.
-
- .. versionadded:: 0.7
- """
- adapter = _request_ctx_stack.top.url_adapter
- if hasattr(adapter, 'allowed_methods'):
- methods = adapter.allowed_methods()
- else:
- # fallback for Werkzeug < 0.7
- methods = []
- try:
- adapter.match(method='--')
- except MethodNotAllowed as e:
- methods = e.valid_methods
- except HTTPException as e:
- pass
- rv = self.response_class()
- rv.allow.update(methods)
- return rv
-
- def should_ignore_error(self, error):
- """This is called to figure out if an error should be ignored
- or not as far as the teardown system is concerned. If this
- function returns ``True`` then the teardown handlers will not be
- passed the error.
-
- .. versionadded:: 0.10
- """
- return False
-
- def make_response(self, rv):
- """Convert the return value from a view function to an instance of
- :attr:`response_class`.
-
- :param rv: the return value from the view function. The view function
- must return a response. Returning ``None``, or the view ending
- without returning, is not allowed. The following types are allowed
- for ``view_rv``:
-
- ``str`` (``unicode`` in Python 2)
- A response object is created with the string encoded to UTF-8
- as the body.
-
- ``bytes`` (``str`` in Python 2)
- A response object is created with the bytes as the body.
-
- ``tuple``
- Either ``(body, status, headers)``, ``(body, status)``, or
- ``(body, headers)``, where ``body`` is any of the other types
- allowed here, ``status`` is a string or an integer, and
- ``headers`` is a dictionary or a list of ``(key, value)``
- tuples. If ``body`` is a :attr:`response_class` instance,
- ``status`` overwrites the exiting value and ``headers`` are
- extended.
-
- :attr:`response_class`
- The object is returned unchanged.
-
- other :class:`~werkzeug.wrappers.Response` class
- The object is coerced to :attr:`response_class`.
-
- :func:`callable`
- The function is called as a WSGI application. The result is
- used to create a response object.
-
- .. versionchanged:: 0.9
- Previously a tuple was interpreted as the arguments for the
- response object.
- """
-
- status = headers = None
-
- # unpack tuple returns
- if isinstance(rv, tuple):
- len_rv = len(rv)
-
- # a 3-tuple is unpacked directly
- if len_rv == 3:
- rv, status, headers = rv
- # decide if a 2-tuple has status or headers
- elif len_rv == 2:
- if isinstance(rv[1], (Headers, dict, tuple, list)):
- rv, headers = rv
- else:
- rv, status = rv
- # other sized tuples are not allowed
- else:
- raise TypeError(
- 'The view function did not return a valid response tuple.'
- ' The tuple must have the form (body, status, headers),'
- ' (body, status), or (body, headers).'
- )
-
- # the body must not be None
- if rv is None:
- raise TypeError(
- 'The view function did not return a valid response. The'
- ' function either returned None or ended without a return'
- ' statement.'
- )
-
- # make sure the body is an instance of the response class
- if not isinstance(rv, self.response_class):
- if isinstance(rv, (text_type, bytes, bytearray)):
- # let the response class set the status and headers instead of
- # waiting to do it manually, so that the class can handle any
- # special logic
- rv = self.response_class(rv, status=status, headers=headers)
- status = headers = None
- else:
- # evaluate a WSGI callable, or coerce a different response
- # class to the correct type
- try:
- rv = self.response_class.force_type(rv, request.environ)
- except TypeError as e:
- new_error = TypeError(
- '{e}\nThe view function did not return a valid'
- ' response. The return type must be a string, tuple,'
- ' Response instance, or WSGI callable, but it was a'
- ' {rv.__class__.__name__}.'.format(e=e, rv=rv)
- )
- reraise(TypeError, new_error, sys.exc_info()[2])
-
- # prefer the status if it was provided
- if status is not None:
- if isinstance(status, (text_type, bytes, bytearray)):
- rv.status = status
- else:
- rv.status_code = status
-
- # extend existing headers with provided headers
- if headers:
- rv.headers.extend(headers)
-
- return rv
-
- def create_url_adapter(self, request):
- """Creates a URL adapter for the given request. The URL adapter
- is created at a point where the request context is not yet set
- up so the request is passed explicitly.
-
- .. versionadded:: 0.6
-
- .. versionchanged:: 0.9
- This can now also be called without a request object when the
- URL adapter is created for the application context.
-
- .. versionchanged:: 1.0
- :data:`SERVER_NAME` no longer implicitly enables subdomain
- matching. Use :attr:`subdomain_matching` instead.
- """
- if request is not None:
- # If subdomain matching is disabled (the default), use the
- # default subdomain in all cases. This should be the default
- # in Werkzeug but it currently does not have that feature.
- subdomain = ((self.url_map.default_subdomain or None)
- if not self.subdomain_matching else None)
- return self.url_map.bind_to_environ(
- request.environ,
- server_name=self.config['SERVER_NAME'],
- subdomain=subdomain)
- # We need at the very least the server name to be set for this
- # to work.
- if self.config['SERVER_NAME'] is not None:
- return self.url_map.bind(
- self.config['SERVER_NAME'],
- script_name=self.config['APPLICATION_ROOT'],
- url_scheme=self.config['PREFERRED_URL_SCHEME'])
-
- def inject_url_defaults(self, endpoint, values):
- """Injects the URL defaults for the given endpoint directly into
- the values dictionary passed. This is used internally and
- automatically called on URL building.
-
- .. versionadded:: 0.7
- """
- funcs = self.url_default_functions.get(None, ())
- if '.' in endpoint:
- bp = endpoint.rsplit('.', 1)[0]
- funcs = chain(funcs, self.url_default_functions.get(bp, ()))
- for func in funcs:
- func(endpoint, values)
-
- def handle_url_build_error(self, error, endpoint, values):
- """Handle :class:`~werkzeug.routing.BuildError` on :meth:`url_for`.
- """
- exc_type, exc_value, tb = sys.exc_info()
- for handler in self.url_build_error_handlers:
- try:
- rv = handler(error, endpoint, values)
- if rv is not None:
- return rv
- except BuildError as e:
- # make error available outside except block (py3)
- error = e
-
- # At this point we want to reraise the exception. If the error is
- # still the same one we can reraise it with the original traceback,
- # otherwise we raise it from here.
- if error is exc_value:
- reraise(exc_type, exc_value, tb)
- raise error
-
- def preprocess_request(self):
- """Called before the request is dispatched. Calls
- :attr:`url_value_preprocessors` registered with the app and the
- current blueprint (if any). Then calls :attr:`before_request_funcs`
- registered with the app and the blueprint.
-
- If any :meth:`before_request` handler returns a non-None value, the
- value is handled as if it was the return value from the view, and
- further request handling is stopped.
- """
-
- bp = _request_ctx_stack.top.request.blueprint
-
- funcs = self.url_value_preprocessors.get(None, ())
- if bp is not None and bp in self.url_value_preprocessors:
- funcs = chain(funcs, self.url_value_preprocessors[bp])
- for func in funcs:
- func(request.endpoint, request.view_args)
-
- funcs = self.before_request_funcs.get(None, ())
- if bp is not None and bp in self.before_request_funcs:
- funcs = chain(funcs, self.before_request_funcs[bp])
- for func in funcs:
- rv = func()
- if rv is not None:
- return rv
-
- def process_response(self, response):
- """Can be overridden in order to modify the response object
- before it's sent to the WSGI server. By default this will
- call all the :meth:`after_request` decorated functions.
-
- .. versionchanged:: 0.5
- As of Flask 0.5 the functions registered for after request
- execution are called in reverse order of registration.
-
- :param response: a :attr:`response_class` object.
- :return: a new response object or the same, has to be an
- instance of :attr:`response_class`.
- """
- ctx = _request_ctx_stack.top
- bp = ctx.request.blueprint
- funcs = ctx._after_request_functions
- if bp is not None and bp in self.after_request_funcs:
- funcs = chain(funcs, reversed(self.after_request_funcs[bp]))
- if None in self.after_request_funcs:
- funcs = chain(funcs, reversed(self.after_request_funcs[None]))
- for handler in funcs:
- response = handler(response)
- if not self.session_interface.is_null_session(ctx.session):
- self.session_interface.save_session(self, ctx.session, response)
- return response
-
- def do_teardown_request(self, exc=_sentinel):
- """Called after the request is dispatched and the response is
- returned, right before the request context is popped.
-
- This calls all functions decorated with
- :meth:`teardown_request`, and :meth:`Blueprint.teardown_request`
- if a blueprint handled the request. Finally, the
- :data:`request_tearing_down` signal is sent.
-
- This is called by
- :meth:`RequestContext.pop() <flask.ctx.RequestContext.pop>`,
- which may be delayed during testing to maintain access to
- resources.
-
- :param exc: An unhandled exception raised while dispatching the
- request. Detected from the current exception information if
- not passed. Passed to each teardown function.
-
- .. versionchanged:: 0.9
- Added the ``exc`` argument.
- """
- if exc is _sentinel:
- exc = sys.exc_info()[1]
- funcs = reversed(self.teardown_request_funcs.get(None, ()))
- bp = _request_ctx_stack.top.request.blueprint
- if bp is not None and bp in self.teardown_request_funcs:
- funcs = chain(funcs, reversed(self.teardown_request_funcs[bp]))
- for func in funcs:
- func(exc)
- request_tearing_down.send(self, exc=exc)
-
- def do_teardown_appcontext(self, exc=_sentinel):
- """Called right before the application context is popped.
-
- When handling a request, the application context is popped
- after the request context. See :meth:`do_teardown_request`.
-
- This calls all functions decorated with
- :meth:`teardown_appcontext`. Then the
- :data:`appcontext_tearing_down` signal is sent.
-
- This is called by
- :meth:`AppContext.pop() <flask.ctx.AppContext.pop>`.
-
- .. versionadded:: 0.9
- """
- if exc is _sentinel:
- exc = sys.exc_info()[1]
- for func in reversed(self.teardown_appcontext_funcs):
- func(exc)
- appcontext_tearing_down.send(self, exc=exc)
-
- def app_context(self):
- """Create an :class:`~flask.ctx.AppContext`. Use as a ``with``
- block to push the context, which will make :data:`current_app`
- point at this application.
-
- An application context is automatically pushed by
- :meth:`RequestContext.push() <flask.ctx.RequestContext.push>`
- when handling a request, and when running a CLI command. Use
- this to manually create a context outside of these situations.
-
- ::
-
- with app.app_context():
- init_db()
-
- See :doc:`/appcontext`.
-
- .. versionadded:: 0.9
- """
- return AppContext(self)
-
- def request_context(self, environ):
- """Create a :class:`~flask.ctx.RequestContext` representing a
- WSGI environment. Use a ``with`` block to push the context,
- which will make :data:`request` point at this request.
-
- See :doc:`/reqcontext`.
-
- Typically you should not call this from your own code. A request
- context is automatically pushed by the :meth:`wsgi_app` when
- handling a request. Use :meth:`test_request_context` to create
- an environment and context instead of this method.
-
- :param environ: a WSGI environment
- """
- return RequestContext(self, environ)
-
- def test_request_context(self, *args, **kwargs):
- """Create a :class:`~flask.ctx.RequestContext` for a WSGI
- environment created from the given values. This is mostly useful
- during testing, where you may want to run a function that uses
- request data without dispatching a full request.
-
- See :doc:`/reqcontext`.
-
- Use a ``with`` block to push the context, which will make
- :data:`request` point at the request for the created
- environment. ::
-
- with test_request_context(...):
- generate_report()
-
- When using the shell, it may be easier to push and pop the
- context manually to avoid indentation. ::
-
- ctx = app.test_request_context(...)
- ctx.push()
- ...
- ctx.pop()
-
- Takes the same arguments as Werkzeug's
- :class:`~werkzeug.test.EnvironBuilder`, with some defaults from
- the application. See the linked Werkzeug docs for most of the
- available arguments. Flask-specific behavior is listed here.
-
- :param path: URL path being requested.
- :param base_url: Base URL where the app is being served, which
- ``path`` is relative to. If not given, built from
- :data:`PREFERRED_URL_SCHEME`, ``subdomain``,
- :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`.
- :param subdomain: Subdomain name to append to
- :data:`SERVER_NAME`.
- :param url_scheme: Scheme to use instead of
- :data:`PREFERRED_URL_SCHEME`.
- :param data: The request body, either as a string or a dict of
- form keys and values.
- :param json: If given, this is serialized as JSON and passed as
- ``data``. Also defaults ``content_type`` to
- ``application/json``.
- :param args: other positional arguments passed to
- :class:`~werkzeug.test.EnvironBuilder`.
- :param kwargs: other keyword arguments passed to
- :class:`~werkzeug.test.EnvironBuilder`.
- """
- from flask.testing import make_test_environ_builder
-
- builder = make_test_environ_builder(self, *args, **kwargs)
-
- try:
- return self.request_context(builder.get_environ())
- finally:
- builder.close()
-
- def wsgi_app(self, environ, start_response):
- """The actual WSGI application. This is not implemented in
- :meth:`__call__` so that middlewares can be applied without
- losing a reference to the app object. Instead of doing this::
-
- app = MyMiddleware(app)
-
- It's a better idea to do this instead::
-
- app.wsgi_app = MyMiddleware(app.wsgi_app)
-
- Then you still have the original application object around and
- can continue to call methods on it.
-
- .. versionchanged:: 0.7
- Teardown events for the request and app contexts are called
- even if an unhandled error occurs. Other events may not be
- called depending on when an error occurs during dispatch.
- See :ref:`callbacks-and-errors`.
-
- :param environ: A WSGI environment.
- :param start_response: A callable accepting a status code,
- a list of headers, and an optional exception context to
- start the response.
- """
- ctx = self.request_context(environ)
- error = None
- try:
- try:
- ctx.push()
- response = self.full_dispatch_request()
- except Exception as e:
- error = e
- response = self.handle_exception(e)
- except:
- error = sys.exc_info()[1]
- raise
- return response(environ, start_response)
- finally:
- if self.should_ignore_error(error):
- error = None
- ctx.auto_pop(error)
-
- def __call__(self, environ, start_response):
- """The WSGI server calls the Flask application object as the
- WSGI application. This calls :meth:`wsgi_app` which can be
- wrapped to applying middleware."""
- return self.wsgi_app(environ, start_response)
-
- def __repr__(self):
- return '<%s %r>' % (
- self.__class__.__name__,
- self.name,
- )
diff --git a/python/flask/blueprints.py b/python/flask/blueprints.py
deleted file mode 100644
index c2158fe..0000000
--- a/python/flask/blueprints.py
+++ /dev/null
@@ -1,447 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.blueprints
- ~~~~~~~~~~~~~~~~
-
- Blueprints are the recommended way to implement larger or more
- pluggable applications in Flask 0.7 and later.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-from functools import update_wrapper
-
-from .helpers import _PackageBoundObject, _endpoint_from_view_func
-
-
-class BlueprintSetupState(object):
- """Temporary holder object for registering a blueprint with the
- application. An instance of this class is created by the
- :meth:`~flask.Blueprint.make_setup_state` method and later passed
- to all register callback functions.
- """
-
- def __init__(self, blueprint, app, options, first_registration):
- #: a reference to the current application
- self.app = app
-
- #: a reference to the blueprint that created this setup state.
- self.blueprint = blueprint
-
- #: a dictionary with all options that were passed to the
- #: :meth:`~flask.Flask.register_blueprint` method.
- self.options = options
-
- #: as blueprints can be registered multiple times with the
- #: application and not everything wants to be registered
- #: multiple times on it, this attribute can be used to figure
- #: out if the blueprint was registered in the past already.
- self.first_registration = first_registration
-
- subdomain = self.options.get('subdomain')
- if subdomain is None:
- subdomain = self.blueprint.subdomain
-
- #: The subdomain that the blueprint should be active for, ``None``
- #: otherwise.
- self.subdomain = subdomain
-
- url_prefix = self.options.get('url_prefix')
- if url_prefix is None:
- url_prefix = self.blueprint.url_prefix
- #: The prefix that should be used for all URLs defined on the
- #: blueprint.
- self.url_prefix = url_prefix
-
- #: A dictionary with URL defaults that is added to each and every
- #: URL that was defined with the blueprint.
- self.url_defaults = dict(self.blueprint.url_values_defaults)
- self.url_defaults.update(self.options.get('url_defaults', ()))
-
- def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
- """A helper method to register a rule (and optionally a view function)
- to the application. The endpoint is automatically prefixed with the
- blueprint's name.
- """
- if self.url_prefix is not None:
- if rule:
- rule = '/'.join((
- self.url_prefix.rstrip('/'), rule.lstrip('/')))
- else:
- rule = self.url_prefix
- options.setdefault('subdomain', self.subdomain)
- if endpoint is None:
- endpoint = _endpoint_from_view_func(view_func)
- defaults = self.url_defaults
- if 'defaults' in options:
- defaults = dict(defaults, **options.pop('defaults'))
- self.app.add_url_rule(rule, '%s.%s' % (self.blueprint.name, endpoint),
- view_func, defaults=defaults, **options)
-
-
-class Blueprint(_PackageBoundObject):
- """Represents a blueprint. A blueprint is an object that records
- functions that will be called with the
- :class:`~flask.blueprints.BlueprintSetupState` later to register functions
- or other things on the main application. See :ref:`blueprints` for more
- information.
-
- .. versionadded:: 0.7
- """
-
- warn_on_modifications = False
- _got_registered_once = False
-
- #: Blueprint local JSON decoder class to use.
- #: Set to ``None`` to use the app's :class:`~flask.app.Flask.json_encoder`.
- json_encoder = None
- #: Blueprint local JSON decoder class to use.
- #: Set to ``None`` to use the app's :class:`~flask.app.Flask.json_decoder`.
- json_decoder = None
-
- # TODO remove the next three attrs when Sphinx :inherited-members: works
- # https://github.com/sphinx-doc/sphinx/issues/741
-
- #: The name of the package or module that this app belongs to. Do not
- #: change this once it is set by the constructor.
- import_name = None
-
- #: Location of the template files to be added to the template lookup.
- #: ``None`` if templates should not be added.
- template_folder = None
-
- #: Absolute path to the package on the filesystem. Used to look up
- #: resources contained in the package.
- root_path = None
-
- def __init__(self, name, import_name, static_folder=None,
- static_url_path=None, template_folder=None,
- url_prefix=None, subdomain=None, url_defaults=None,
- root_path=None):
- _PackageBoundObject.__init__(self, import_name, template_folder,
- root_path=root_path)
- self.name = name
- self.url_prefix = url_prefix
- self.subdomain = subdomain
- self.static_folder = static_folder
- self.static_url_path = static_url_path
- self.deferred_functions = []
- if url_defaults is None:
- url_defaults = {}
- self.url_values_defaults = url_defaults
-
- def record(self, func):
- """Registers a function that is called when the blueprint is
- registered on the application. This function is called with the
- state as argument as returned by the :meth:`make_setup_state`
- method.
- """
- if self._got_registered_once and self.warn_on_modifications:
- from warnings import warn
- warn(Warning('The blueprint was already registered once '
- 'but is getting modified now. These changes '
- 'will not show up.'))
- self.deferred_functions.append(func)
-
- def record_once(self, func):
- """Works like :meth:`record` but wraps the function in another
- function that will ensure the function is only called once. If the
- blueprint is registered a second time on the application, the
- function passed is not called.
- """
- def wrapper(state):
- if state.first_registration:
- func(state)
- return self.record(update_wrapper(wrapper, func))
-
- def make_setup_state(self, app, options, first_registration=False):
- """Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState`
- object that is later passed to the register callback functions.
- Subclasses can override this to return a subclass of the setup state.
- """
- return BlueprintSetupState(self, app, options, first_registration)
-
- def register(self, app, options, first_registration=False):
- """Called by :meth:`Flask.register_blueprint` to register all views
- and callbacks registered on the blueprint with the application. Creates
- a :class:`.BlueprintSetupState` and calls each :meth:`record` callback
- with it.
-
- :param app: The application this blueprint is being registered with.
- :param options: Keyword arguments forwarded from
- :meth:`~Flask.register_blueprint`.
- :param first_registration: Whether this is the first time this
- blueprint has been registered on the application.
- """
- self._got_registered_once = True
- state = self.make_setup_state(app, options, first_registration)
-
- if self.has_static_folder:
- state.add_url_rule(
- self.static_url_path + '/<path:filename>',
- view_func=self.send_static_file, endpoint='static'
- )
-
- for deferred in self.deferred_functions:
- deferred(state)
-
- def route(self, rule, **options):
- """Like :meth:`Flask.route` but for a blueprint. The endpoint for the
- :func:`url_for` function is prefixed with the name of the blueprint.
- """
- def decorator(f):
- endpoint = options.pop("endpoint", f.__name__)
- self.add_url_rule(rule, endpoint, f, **options)
- return f
- return decorator
-
- def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
- """Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for
- the :func:`url_for` function is prefixed with the name of the blueprint.
- """
- if endpoint:
- assert '.' not in endpoint, "Blueprint endpoints should not contain dots"
- if view_func and hasattr(view_func, '__name__'):
- assert '.' not in view_func.__name__, "Blueprint view function name should not contain dots"
- self.record(lambda s:
- s.add_url_rule(rule, endpoint, view_func, **options))
-
- def endpoint(self, endpoint):
- """Like :meth:`Flask.endpoint` but for a blueprint. This does not
- prefix the endpoint with the blueprint name, this has to be done
- explicitly by the user of this method. If the endpoint is prefixed
- with a `.` it will be registered to the current blueprint, otherwise
- it's an application independent endpoint.
- """
- def decorator(f):
- def register_endpoint(state):
- state.app.view_functions[endpoint] = f
- self.record_once(register_endpoint)
- return f
- return decorator
-
- def app_template_filter(self, name=None):
- """Register a custom template filter, available application wide. Like
- :meth:`Flask.template_filter` but for a blueprint.
-
- :param name: the optional name of the filter, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_app_template_filter(f, name=name)
- return f
- return decorator
-
- def add_app_template_filter(self, f, name=None):
- """Register a custom template filter, available application wide. Like
- :meth:`Flask.add_template_filter` but for a blueprint. Works exactly
- like the :meth:`app_template_filter` decorator.
-
- :param name: the optional name of the filter, otherwise the
- function name will be used.
- """
- def register_template(state):
- state.app.jinja_env.filters[name or f.__name__] = f
- self.record_once(register_template)
-
- def app_template_test(self, name=None):
- """Register a custom template test, available application wide. Like
- :meth:`Flask.template_test` but for a blueprint.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the test, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_app_template_test(f, name=name)
- return f
- return decorator
-
- def add_app_template_test(self, f, name=None):
- """Register a custom template test, available application wide. Like
- :meth:`Flask.add_template_test` but for a blueprint. Works exactly
- like the :meth:`app_template_test` decorator.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the test, otherwise the
- function name will be used.
- """
- def register_template(state):
- state.app.jinja_env.tests[name or f.__name__] = f
- self.record_once(register_template)
-
- def app_template_global(self, name=None):
- """Register a custom template global, available application wide. Like
- :meth:`Flask.template_global` but for a blueprint.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the global, otherwise the
- function name will be used.
- """
- def decorator(f):
- self.add_app_template_global(f, name=name)
- return f
- return decorator
-
- def add_app_template_global(self, f, name=None):
- """Register a custom template global, available application wide. Like
- :meth:`Flask.add_template_global` but for a blueprint. Works exactly
- like the :meth:`app_template_global` decorator.
-
- .. versionadded:: 0.10
-
- :param name: the optional name of the global, otherwise the
- function name will be used.
- """
- def register_template(state):
- state.app.jinja_env.globals[name or f.__name__] = f
- self.record_once(register_template)
-
- def before_request(self, f):
- """Like :meth:`Flask.before_request` but for a blueprint. This function
- is only executed before each request that is handled by a function of
- that blueprint.
- """
- self.record_once(lambda s: s.app.before_request_funcs
- .setdefault(self.name, []).append(f))
- return f
-
- def before_app_request(self, f):
- """Like :meth:`Flask.before_request`. Such a function is executed
- before each request, even if outside of a blueprint.
- """
- self.record_once(lambda s: s.app.before_request_funcs
- .setdefault(None, []).append(f))
- return f
-
- def before_app_first_request(self, f):
- """Like :meth:`Flask.before_first_request`. Such a function is
- executed before the first request to the application.
- """
- self.record_once(lambda s: s.app.before_first_request_funcs.append(f))
- return f
-
- def after_request(self, f):
- """Like :meth:`Flask.after_request` but for a blueprint. This function
- is only executed after each request that is handled by a function of
- that blueprint.
- """
- self.record_once(lambda s: s.app.after_request_funcs
- .setdefault(self.name, []).append(f))
- return f
-
- def after_app_request(self, f):
- """Like :meth:`Flask.after_request` but for a blueprint. Such a function
- is executed after each request, even if outside of the blueprint.
- """
- self.record_once(lambda s: s.app.after_request_funcs
- .setdefault(None, []).append(f))
- return f
-
- def teardown_request(self, f):
- """Like :meth:`Flask.teardown_request` but for a blueprint. This
- function is only executed when tearing down requests handled by a
- function of that blueprint. Teardown request functions are executed
- when the request context is popped, even when no actual request was
- performed.
- """
- self.record_once(lambda s: s.app.teardown_request_funcs
- .setdefault(self.name, []).append(f))
- return f
-
- def teardown_app_request(self, f):
- """Like :meth:`Flask.teardown_request` but for a blueprint. Such a
- function is executed when tearing down each request, even if outside of
- the blueprint.
- """
- self.record_once(lambda s: s.app.teardown_request_funcs
- .setdefault(None, []).append(f))
- return f
-
- def context_processor(self, f):
- """Like :meth:`Flask.context_processor` but for a blueprint. This
- function is only executed for requests handled by a blueprint.
- """
- self.record_once(lambda s: s.app.template_context_processors
- .setdefault(self.name, []).append(f))
- return f
-
- def app_context_processor(self, f):
- """Like :meth:`Flask.context_processor` but for a blueprint. Such a
- function is executed each request, even if outside of the blueprint.
- """
- self.record_once(lambda s: s.app.template_context_processors
- .setdefault(None, []).append(f))
- return f
-
- def app_errorhandler(self, code):
- """Like :meth:`Flask.errorhandler` but for a blueprint. This
- handler is used for all requests, even if outside of the blueprint.
- """
- def decorator(f):
- self.record_once(lambda s: s.app.errorhandler(code)(f))
- return f
- return decorator
-
- def url_value_preprocessor(self, f):
- """Registers a function as URL value preprocessor for this
- blueprint. It's called before the view functions are called and
- can modify the url values provided.
- """
- self.record_once(lambda s: s.app.url_value_preprocessors
- .setdefault(self.name, []).append(f))
- return f
-
- def url_defaults(self, f):
- """Callback function for URL defaults for this blueprint. It's called
- with the endpoint and values and should update the values passed
- in place.
- """
- self.record_once(lambda s: s.app.url_default_functions
- .setdefault(self.name, []).append(f))
- return f
-
- def app_url_value_preprocessor(self, f):
- """Same as :meth:`url_value_preprocessor` but application wide.
- """
- self.record_once(lambda s: s.app.url_value_preprocessors
- .setdefault(None, []).append(f))
- return f
-
- def app_url_defaults(self, f):
- """Same as :meth:`url_defaults` but application wide.
- """
- self.record_once(lambda s: s.app.url_default_functions
- .setdefault(None, []).append(f))
- return f
-
- def errorhandler(self, code_or_exception):
- """Registers an error handler that becomes active for this blueprint
- only. Please be aware that routing does not happen local to a
- blueprint so an error handler for 404 usually is not handled by
- a blueprint unless it is caused inside a view function. Another
- special case is the 500 internal server error which is always looked
- up from the application.
-
- Otherwise works as the :meth:`~flask.Flask.errorhandler` decorator
- of the :class:`~flask.Flask` object.
- """
- def decorator(f):
- self.record_once(lambda s: s.app._register_error_handler(
- self.name, code_or_exception, f))
- return f
- return decorator
-
- def register_error_handler(self, code_or_exception, f):
- """Non-decorator version of the :meth:`errorhandler` error attach
- function, akin to the :meth:`~flask.Flask.register_error_handler`
- application-wide function of the :class:`~flask.Flask` object but
- for error handlers limited to this blueprint.
-
- .. versionadded:: 0.11
- """
- self.record_once(lambda s: s.app._register_error_handler(
- self.name, code_or_exception, f))
diff --git a/python/flask/cli.py b/python/flask/cli.py
deleted file mode 100644
index 3eb93b3..0000000
--- a/python/flask/cli.py
+++ /dev/null
@@ -1,910 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.cli
- ~~~~~~~~~
-
- A simple command line application to run flask apps.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-from __future__ import print_function
-
-import ast
-import inspect
-import os
-import platform
-import re
-import ssl
-import sys
-import traceback
-from functools import update_wrapper
-from operator import attrgetter
-from threading import Lock, Thread
-
-import click
-from werkzeug.utils import import_string
-
-from . import __version__
-from ._compat import getargspec, iteritems, reraise, text_type
-from .globals import current_app
-from .helpers import get_debug_flag, get_env, get_load_dotenv
-
-try:
- import dotenv
-except ImportError:
- dotenv = None
-
-
-class NoAppException(click.UsageError):
- """Raised if an application cannot be found or loaded."""
-
-
-def find_best_app(script_info, module):
- """Given a module instance this tries to find the best possible
- application in the module or raises an exception.
- """
- from . import Flask
-
- # Search for the most common names first.
- for attr_name in ('app', 'application'):
- app = getattr(module, attr_name, None)
-
- if isinstance(app, Flask):
- return app
-
- # Otherwise find the only object that is a Flask instance.
- matches = [
- v for k, v in iteritems(module.__dict__) if isinstance(v, Flask)
- ]
-
- if len(matches) == 1:
- return matches[0]
- elif len(matches) > 1:
- raise NoAppException(
- 'Detected multiple Flask applications in module "{module}". Use '
- '"FLASK_APP={module}:name" to specify the correct '
- 'one.'.format(module=module.__name__)
- )
-
- # Search for app factory functions.
- for attr_name in ('create_app', 'make_app'):
- app_factory = getattr(module, attr_name, None)
-
- if inspect.isfunction(app_factory):
- try:
- app = call_factory(script_info, app_factory)
-
- if isinstance(app, Flask):
- return app
- except TypeError:
- if not _called_with_wrong_args(app_factory):
- raise
- raise NoAppException(
- 'Detected factory "{factory}" in module "{module}", but '
- 'could not call it without arguments. Use '
- '"FLASK_APP=\'{module}:{factory}(args)\'" to specify '
- 'arguments.'.format(
- factory=attr_name, module=module.__name__
- )
- )
-
- raise NoAppException(
- 'Failed to find Flask application or factory in module "{module}". '
- 'Use "FLASK_APP={module}:name to specify one.'.format(
- module=module.__name__
- )
- )
-
-
-def call_factory(script_info, app_factory, arguments=()):
- """Takes an app factory, a ``script_info` object and optionally a tuple
- of arguments. Checks for the existence of a script_info argument and calls
- the app_factory depending on that and the arguments provided.
- """
- args_spec = getargspec(app_factory)
- arg_names = args_spec.args
- arg_defaults = args_spec.defaults
-
- if 'script_info' in arg_names:
- return app_factory(*arguments, script_info=script_info)
- elif arguments:
- return app_factory(*arguments)
- elif not arguments and len(arg_names) == 1 and arg_defaults is None:
- return app_factory(script_info)
-
- return app_factory()
-
-
-def _called_with_wrong_args(factory):
- """Check whether calling a function raised a ``TypeError`` because
- the call failed or because something in the factory raised the
- error.
-
- :param factory: the factory function that was called
- :return: true if the call failed
- """
- tb = sys.exc_info()[2]
-
- try:
- while tb is not None:
- if tb.tb_frame.f_code is factory.__code__:
- # in the factory, it was called successfully
- return False
-
- tb = tb.tb_next
-
- # didn't reach the factory
- return True
- finally:
- del tb
-
-
-def find_app_by_string(script_info, module, app_name):
- """Checks if the given string is a variable name or a function. If it is a
- function, it checks for specified arguments and whether it takes a
- ``script_info`` argument and calls the function with the appropriate
- arguments.
- """
- from flask import Flask
- match = re.match(r'^ *([^ ()]+) *(?:\((.*?) *,? *\))? *$', app_name)
-
- if not match:
- raise NoAppException(
- '"{name}" is not a valid variable name or function '
- 'expression.'.format(name=app_name)
- )
-
- name, args = match.groups()
-
- try:
- attr = getattr(module, name)
- except AttributeError as e:
- raise NoAppException(e.args[0])
-
- if inspect.isfunction(attr):
- if args:
- try:
- args = ast.literal_eval('({args},)'.format(args=args))
- except (ValueError, SyntaxError)as e:
- raise NoAppException(
- 'Could not parse the arguments in '
- '"{app_name}".'.format(e=e, app_name=app_name)
- )
- else:
- args = ()
-
- try:
- app = call_factory(script_info, attr, args)
- except TypeError as e:
- if not _called_with_wrong_args(attr):
- raise
-
- raise NoAppException(
- '{e}\nThe factory "{app_name}" in module "{module}" could not '
- 'be called with the specified arguments.'.format(
- e=e, app_name=app_name, module=module.__name__
- )
- )
- else:
- app = attr
-
- if isinstance(app, Flask):
- return app
-
- raise NoAppException(
- 'A valid Flask application was not obtained from '
- '"{module}:{app_name}".'.format(
- module=module.__name__, app_name=app_name
- )
- )
-
-
-def prepare_import(path):
- """Given a filename this will try to calculate the python path, add it
- to the search path and return the actual module name that is expected.
- """
- path = os.path.realpath(path)
-
- if os.path.splitext(path)[1] == '.py':
- path = os.path.splitext(path)[0]
-
- if os.path.basename(path) == '__init__':
- path = os.path.dirname(path)
-
- module_name = []
-
- # move up until outside package structure (no __init__.py)
- while True:
- path, name = os.path.split(path)
- module_name.append(name)
-
- if not os.path.exists(os.path.join(path, '__init__.py')):
- break
-
- if sys.path[0] != path:
- sys.path.insert(0, path)
-
- return '.'.join(module_name[::-1])
-
-
-def locate_app(script_info, module_name, app_name, raise_if_not_found=True):
- __traceback_hide__ = True
-
- try:
- __import__(module_name)
- except ImportError:
- # Reraise the ImportError if it occurred within the imported module.
- # Determine this by checking whether the trace has a depth > 1.
- if sys.exc_info()[-1].tb_next:
- raise NoAppException(
- 'While importing "{name}", an ImportError was raised:'
- '\n\n{tb}'.format(name=module_name, tb=traceback.format_exc())
- )
- elif raise_if_not_found:
- raise NoAppException(
- 'Could not import "{name}".'.format(name=module_name)
- )
- else:
- return
-
- module = sys.modules[module_name]
-
- if app_name is None:
- return find_best_app(script_info, module)
- else:
- return find_app_by_string(script_info, module, app_name)
-
-
-def get_version(ctx, param, value):
- if not value or ctx.resilient_parsing:
- return
- import werkzeug
- message = (
- 'Python %(python)s\n'
- 'Flask %(flask)s\n'
- 'Werkzeug %(werkzeug)s'
- )
- click.echo(message % {
- 'python': platform.python_version(),
- 'flask': __version__,
- 'werkzeug': werkzeug.__version__,
- }, color=ctx.color)
- ctx.exit()
-
-
-version_option = click.Option(
- ['--version'],
- help='Show the flask version',
- expose_value=False,
- callback=get_version,
- is_flag=True,
- is_eager=True
-)
-
-
-class DispatchingApp(object):
- """Special application that dispatches to a Flask application which
- is imported by name in a background thread. If an error happens
- it is recorded and shown as part of the WSGI handling which in case
- of the Werkzeug debugger means that it shows up in the browser.
- """
-
- def __init__(self, loader, use_eager_loading=False):
- self.loader = loader
- self._app = None
- self._lock = Lock()
- self._bg_loading_exc_info = None
- if use_eager_loading:
- self._load_unlocked()
- else:
- self._load_in_background()
-
- def _load_in_background(self):
- def _load_app():
- __traceback_hide__ = True
- with self._lock:
- try:
- self._load_unlocked()
- except Exception:
- self._bg_loading_exc_info = sys.exc_info()
- t = Thread(target=_load_app, args=())
- t.start()
-
- def _flush_bg_loading_exception(self):
- __traceback_hide__ = True
- exc_info = self._bg_loading_exc_info
- if exc_info is not None:
- self._bg_loading_exc_info = None
- reraise(*exc_info)
-
- def _load_unlocked(self):
- __traceback_hide__ = True
- self._app = rv = self.loader()
- self._bg_loading_exc_info = None
- return rv
-
- def __call__(self, environ, start_response):
- __traceback_hide__ = True
- if self._app is not None:
- return self._app(environ, start_response)
- self._flush_bg_loading_exception()
- with self._lock:
- if self._app is not None:
- rv = self._app
- else:
- rv = self._load_unlocked()
- return rv(environ, start_response)
-
-
-class ScriptInfo(object):
- """Helper object to deal with Flask applications. This is usually not
- necessary to interface with as it's used internally in the dispatching
- to click. In future versions of Flask this object will most likely play
- a bigger role. Typically it's created automatically by the
- :class:`FlaskGroup` but you can also manually create it and pass it
- onwards as click object.
- """
-
- def __init__(self, app_import_path=None, create_app=None,
- set_debug_flag=True):
- #: Optionally the import path for the Flask application.
- self.app_import_path = app_import_path or os.environ.get('FLASK_APP')
- #: Optionally a function that is passed the script info to create
- #: the instance of the application.
- self.create_app = create_app
- #: A dictionary with arbitrary data that can be associated with
- #: this script info.
- self.data = {}
- self.set_debug_flag = set_debug_flag
- self._loaded_app = None
-
- def load_app(self):
- """Loads the Flask app (if not yet loaded) and returns it. Calling
- this multiple times will just result in the already loaded app to
- be returned.
- """
- __traceback_hide__ = True
-
- if self._loaded_app is not None:
- return self._loaded_app
-
- app = None
-
- if self.create_app is not None:
- app = call_factory(self, self.create_app)
- else:
- if self.app_import_path:
- path, name = (re.split(r':(?![\\/])', self.app_import_path, 1) + [None])[:2]
- import_name = prepare_import(path)
- app = locate_app(self, import_name, name)
- else:
- for path in ('wsgi.py', 'app.py'):
- import_name = prepare_import(path)
- app = locate_app(self, import_name, None,
- raise_if_not_found=False)
-
- if app:
- break
-
- if not app:
- raise NoAppException(
- 'Could not locate a Flask application. You did not provide '
- 'the "FLASK_APP" environment variable, and a "wsgi.py" or '
- '"app.py" module was not found in the current directory.'
- )
-
- if self.set_debug_flag:
- # Update the app's debug flag through the descriptor so that
- # other values repopulate as well.
- app.debug = get_debug_flag()
-
- self._loaded_app = app
- return app
-
-
-pass_script_info = click.make_pass_decorator(ScriptInfo, ensure=True)
-
-
-def with_appcontext(f):
- """Wraps a callback so that it's guaranteed to be executed with the
- script's application context. If callbacks are registered directly
- to the ``app.cli`` object then they are wrapped with this function
- by default unless it's disabled.
- """
- @click.pass_context
- def decorator(__ctx, *args, **kwargs):
- with __ctx.ensure_object(ScriptInfo).load_app().app_context():
- return __ctx.invoke(f, *args, **kwargs)
- return update_wrapper(decorator, f)
-
-
-class AppGroup(click.Group):
- """This works similar to a regular click :class:`~click.Group` but it
- changes the behavior of the :meth:`command` decorator so that it
- automatically wraps the functions in :func:`with_appcontext`.
-
- Not to be confused with :class:`FlaskGroup`.
- """
-
- def command(self, *args, **kwargs):
- """This works exactly like the method of the same name on a regular
- :class:`click.Group` but it wraps callbacks in :func:`with_appcontext`
- unless it's disabled by passing ``with_appcontext=False``.
- """
- wrap_for_ctx = kwargs.pop('with_appcontext', True)
- def decorator(f):
- if wrap_for_ctx:
- f = with_appcontext(f)
- return click.Group.command(self, *args, **kwargs)(f)
- return decorator
-
- def group(self, *args, **kwargs):
- """This works exactly like the method of the same name on a regular
- :class:`click.Group` but it defaults the group class to
- :class:`AppGroup`.
- """
- kwargs.setdefault('cls', AppGroup)
- return click.Group.group(self, *args, **kwargs)
-
-
-class FlaskGroup(AppGroup):
- """Special subclass of the :class:`AppGroup` group that supports
- loading more commands from the configured Flask app. Normally a
- developer does not have to interface with this class but there are
- some very advanced use cases for which it makes sense to create an
- instance of this.
-
- For information as of why this is useful see :ref:`custom-scripts`.
-
- :param add_default_commands: if this is True then the default run and
- shell commands wil be added.
- :param add_version_option: adds the ``--version`` option.
- :param create_app: an optional callback that is passed the script info and
- returns the loaded app.
- :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
- files to set environment variables. Will also change the working
- directory to the directory containing the first file found.
- :param set_debug_flag: Set the app's debug flag based on the active
- environment
-
- .. versionchanged:: 1.0
- If installed, python-dotenv will be used to load environment variables
- from :file:`.env` and :file:`.flaskenv` files.
- """
-
- def __init__(self, add_default_commands=True, create_app=None,
- add_version_option=True, load_dotenv=True,
- set_debug_flag=True, **extra):
- params = list(extra.pop('params', None) or ())
-
- if add_version_option:
- params.append(version_option)
-
- AppGroup.__init__(self, params=params, **extra)
- self.create_app = create_app
- self.load_dotenv = load_dotenv
- self.set_debug_flag = set_debug_flag
-
- if add_default_commands:
- self.add_command(run_command)
- self.add_command(shell_command)
- self.add_command(routes_command)
-
- self._loaded_plugin_commands = False
-
- def _load_plugin_commands(self):
- if self._loaded_plugin_commands:
- return
- try:
- import pkg_resources
- except ImportError:
- self._loaded_plugin_commands = True
- return
-
- for ep in pkg_resources.iter_entry_points('flask.commands'):
- self.add_command(ep.load(), ep.name)
- self._loaded_plugin_commands = True
-
- def get_command(self, ctx, name):
- self._load_plugin_commands()
-
- # We load built-in commands first as these should always be the
- # same no matter what the app does. If the app does want to
- # override this it needs to make a custom instance of this group
- # and not attach the default commands.
- #
- # This also means that the script stays functional in case the
- # application completely fails.
- rv = AppGroup.get_command(self, ctx, name)
- if rv is not None:
- return rv
-
- info = ctx.ensure_object(ScriptInfo)
- try:
- rv = info.load_app().cli.get_command(ctx, name)
- if rv is not None:
- return rv
- except NoAppException:
- pass
-
- def list_commands(self, ctx):
- self._load_plugin_commands()
-
- # The commands available is the list of both the application (if
- # available) plus the builtin commands.
- rv = set(click.Group.list_commands(self, ctx))
- info = ctx.ensure_object(ScriptInfo)
- try:
- rv.update(info.load_app().cli.list_commands(ctx))
- except Exception:
- # Here we intentionally swallow all exceptions as we don't
- # want the help page to break if the app does not exist.
- # If someone attempts to use the command we try to create
- # the app again and this will give us the error.
- # However, we will not do so silently because that would confuse
- # users.
- traceback.print_exc()
- return sorted(rv)
-
- def main(self, *args, **kwargs):
- # Set a global flag that indicates that we were invoked from the
- # command line interface. This is detected by Flask.run to make the
- # call into a no-op. This is necessary to avoid ugly errors when the
- # script that is loaded here also attempts to start a server.
- os.environ['FLASK_RUN_FROM_CLI'] = 'true'
-
- if get_load_dotenv(self.load_dotenv):
- load_dotenv()
-
- obj = kwargs.get('obj')
-
- if obj is None:
- obj = ScriptInfo(create_app=self.create_app,
- set_debug_flag=self.set_debug_flag)
-
- kwargs['obj'] = obj
- kwargs.setdefault('auto_envvar_prefix', 'FLASK')
- return super(FlaskGroup, self).main(*args, **kwargs)
-
-
-def _path_is_ancestor(path, other):
- """Take ``other`` and remove the length of ``path`` from it. Then join it
- to ``path``. If it is the original value, ``path`` is an ancestor of
- ``other``."""
- return os.path.join(path, other[len(path):].lstrip(os.sep)) == other
-
-
-def load_dotenv(path=None):
- """Load "dotenv" files in order of precedence to set environment variables.
-
- If an env var is already set it is not overwritten, so earlier files in the
- list are preferred over later files.
-
- Changes the current working directory to the location of the first file
- found, with the assumption that it is in the top level project directory
- and will be where the Python path should import local packages from.
-
- This is a no-op if `python-dotenv`_ is not installed.
-
- .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
-
- :param path: Load the file at this location instead of searching.
- :return: ``True`` if a file was loaded.
-
- .. versionadded:: 1.0
- """
- if dotenv is None:
- if path or os.path.exists('.env') or os.path.exists('.flaskenv'):
- click.secho(
- ' * Tip: There are .env files present.'
- ' Do "pip install python-dotenv" to use them.',
- fg='yellow')
- return
-
- if path is not None:
- return dotenv.load_dotenv(path)
-
- new_dir = None
-
- for name in ('.env', '.flaskenv'):
- path = dotenv.find_dotenv(name, usecwd=True)
-
- if not path:
- continue
-
- if new_dir is None:
- new_dir = os.path.dirname(path)
-
- dotenv.load_dotenv(path)
-
- if new_dir and os.getcwd() != new_dir:
- os.chdir(new_dir)
-
- return new_dir is not None # at least one file was located and loaded
-
-
-def show_server_banner(env, debug, app_import_path, eager_loading):
- """Show extra startup messages the first time the server is run,
- ignoring the reloader.
- """
- if os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
- return
-
- if app_import_path is not None:
- message = ' * Serving Flask app "{0}"'.format(app_import_path)
-
- if not eager_loading:
- message += ' (lazy loading)'
-
- click.echo(message)
-
- click.echo(' * Environment: {0}'.format(env))
-
- if env == 'production':
- click.secho(
- ' WARNING: This is a development server. '
- 'Do not use it in a production deployment.', fg='red')
- click.secho(' Use a production WSGI server instead.', dim=True)
-
- if debug is not None:
- click.echo(' * Debug mode: {0}'.format('on' if debug else 'off'))
-
-
-class CertParamType(click.ParamType):
- """Click option type for the ``--cert`` option. Allows either an
- existing file, the string ``'adhoc'``, or an import for a
- :class:`~ssl.SSLContext` object.
- """
-
- name = 'path'
-
- def __init__(self):
- self.path_type = click.Path(
- exists=True, dir_okay=False, resolve_path=True)
-
- def convert(self, value, param, ctx):
- try:
- return self.path_type(value, param, ctx)
- except click.BadParameter:
- value = click.STRING(value, param, ctx).lower()
-
- if value == 'adhoc':
- try:
- import OpenSSL
- except ImportError:
- raise click.BadParameter(
- 'Using ad-hoc certificates requires pyOpenSSL.',
- ctx, param)
-
- return value
-
- obj = import_string(value, silent=True)
-
- if sys.version_info < (2, 7, 9):
- if obj:
- return obj
- else:
- if isinstance(obj, ssl.SSLContext):
- return obj
-
- raise
-
-
-def _validate_key(ctx, param, value):
- """The ``--key`` option must be specified when ``--cert`` is a file.
- Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
- """
- cert = ctx.params.get('cert')
- is_adhoc = cert == 'adhoc'
-
- if sys.version_info < (2, 7, 9):
- is_context = cert and not isinstance(cert, (text_type, bytes))
- else:
- is_context = isinstance(cert, ssl.SSLContext)
-
- if value is not None:
- if is_adhoc:
- raise click.BadParameter(
- 'When "--cert" is "adhoc", "--key" is not used.',
- ctx, param)
-
- if is_context:
- raise click.BadParameter(
- 'When "--cert" is an SSLContext object, "--key is not used.',
- ctx, param)
-
- if not cert:
- raise click.BadParameter(
- '"--cert" must also be specified.',
- ctx, param)
-
- ctx.params['cert'] = cert, value
-
- else:
- if cert and not (is_adhoc or is_context):
- raise click.BadParameter(
- 'Required when using "--cert".',
- ctx, param)
-
- return value
-
-
-@click.command('run', short_help='Run a development server.')
-@click.option('--host', '-h', default='127.0.0.1',
- help='The interface to bind to.')
-@click.option('--port', '-p', default=5000,
- help='The port to bind to.')
-@click.option('--cert', type=CertParamType(),
- help='Specify a certificate file to use HTTPS.')
-@click.option('--key',
- type=click.Path(exists=True, dir_okay=False, resolve_path=True),
- callback=_validate_key, expose_value=False,
- help='The key file to use when specifying a certificate.')
-@click.option('--reload/--no-reload', default=None,
- help='Enable or disable the reloader. By default the reloader '
- 'is active if debug is enabled.')
-@click.option('--debugger/--no-debugger', default=None,
- help='Enable or disable the debugger. By default the debugger '
- 'is active if debug is enabled.')
-@click.option('--eager-loading/--lazy-loader', default=None,
- help='Enable or disable eager loading. By default eager '
- 'loading is enabled if the reloader is disabled.')
-@click.option('--with-threads/--without-threads', default=True,
- help='Enable or disable multithreading.')
-@pass_script_info
-def run_command(info, host, port, reload, debugger, eager_loading,
- with_threads, cert):
- """Run a local development server.
-
- This server is for development purposes only. It does not provide
- the stability, security, or performance of production WSGI servers.
-
- The reloader and debugger are enabled by default if
- FLASK_ENV=development or FLASK_DEBUG=1.
- """
- debug = get_debug_flag()
-
- if reload is None:
- reload = debug
-
- if debugger is None:
- debugger = debug
-
- if eager_loading is None:
- eager_loading = not reload
-
- show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
- app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
-
- from werkzeug.serving import run_simple
- run_simple(host, port, app, use_reloader=reload, use_debugger=debugger,
- threaded=with_threads, ssl_context=cert)
-
-
-@click.command('shell', short_help='Run a shell in the app context.')
-@with_appcontext
-def shell_command():
- """Run an interactive Python shell in the context of a given
- Flask application. The application will populate the default
- namespace of this shell according to it's configuration.
-
- This is useful for executing small snippets of management code
- without having to manually configure the application.
- """
- import code
- from flask.globals import _app_ctx_stack
- app = _app_ctx_stack.top.app
- banner = 'Python %s on %s\nApp: %s [%s]\nInstance: %s' % (
- sys.version,
- sys.platform,
- app.import_name,
- app.env,
- app.instance_path,
- )
- ctx = {}
-
- # Support the regular Python interpreter startup script if someone
- # is using it.
- startup = os.environ.get('PYTHONSTARTUP')
- if startup and os.path.isfile(startup):
- with open(startup, 'r') as f:
- eval(compile(f.read(), startup, 'exec'), ctx)
-
- ctx.update(app.make_shell_context())
-
- code.interact(banner=banner, local=ctx)
-
-
-@click.command('routes', short_help='Show the routes for the app.')
-@click.option(
- '--sort', '-s',
- type=click.Choice(('endpoint', 'methods', 'rule', 'match')),
- default='endpoint',
- help=(
- 'Method to sort routes by. "match" is the order that Flask will match '
- 'routes when dispatching a request.'
- )
-)
-@click.option(
- '--all-methods',
- is_flag=True,
- help="Show HEAD and OPTIONS methods."
-)
-@with_appcontext
-def routes_command(sort, all_methods):
- """Show all registered routes with endpoints and methods."""
-
- rules = list(current_app.url_map.iter_rules())
- if not rules:
- click.echo('No routes were registered.')
- return
-
- ignored_methods = set(() if all_methods else ('HEAD', 'OPTIONS'))
-
- if sort in ('endpoint', 'rule'):
- rules = sorted(rules, key=attrgetter(sort))
- elif sort == 'methods':
- rules = sorted(rules, key=lambda rule: sorted(rule.methods))
-
- rule_methods = [
- ', '.join(sorted(rule.methods - ignored_methods)) for rule in rules
- ]
-
- headers = ('Endpoint', 'Methods', 'Rule')
- widths = (
- max(len(rule.endpoint) for rule in rules),
- max(len(methods) for methods in rule_methods),
- max(len(rule.rule) for rule in rules),
- )
- widths = [max(len(h), w) for h, w in zip(headers, widths)]
- row = '{{0:<{0}}} {{1:<{1}}} {{2:<{2}}}'.format(*widths)
-
- click.echo(row.format(*headers).strip())
- click.echo(row.format(*('-' * width for width in widths)))
-
- for rule, methods in zip(rules, rule_methods):
- click.echo(row.format(rule.endpoint, methods, rule.rule).rstrip())
-
-
-cli = FlaskGroup(help="""\
-A general utility script for Flask applications.
-
-Provides commands from Flask, extensions, and the application. Loads the
-application defined in the FLASK_APP environment variable, or from a wsgi.py
-file. Setting the FLASK_ENV environment variable to 'development' will enable
-debug mode.
-
-\b
- {prefix}{cmd} FLASK_APP=hello.py
- {prefix}{cmd} FLASK_ENV=development
- {prefix}flask run
-""".format(
- cmd='export' if os.name == 'posix' else 'set',
- prefix='$ ' if os.name == 'posix' else '> '
-))
-
-
-def main(as_module=False):
- args = sys.argv[1:]
-
- if as_module:
- this_module = 'flask'
-
- if sys.version_info < (2, 7):
- this_module += '.cli'
-
- name = 'python -m ' + this_module
-
- # Python rewrites "python -m flask" to the path to the file in argv.
- # Restore the original command so that the reloader works.
- sys.argv = ['-m', this_module] + args
- else:
- name = None
-
- cli.main(args=args, prog_name=name)
-
-
-if __name__ == '__main__':
- main(as_module=True)
diff --git a/python/flask/config.py b/python/flask/config.py
deleted file mode 100644
index a5475ed..0000000
--- a/python/flask/config.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.config
- ~~~~~~~~~~~~
-
- Implements the configuration related objects.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import os
-import types
-import errno
-
-from werkzeug.utils import import_string
-from ._compat import string_types, iteritems
-from . import json
-
-
-class ConfigAttribute(object):
- """Makes an attribute forward to the config"""
-
- def __init__(self, name, get_converter=None):
- self.__name__ = name
- self.get_converter = get_converter
-
- def __get__(self, obj, type=None):
- if obj is None:
- return self
- rv = obj.config[self.__name__]
- if self.get_converter is not None:
- rv = self.get_converter(rv)
- return rv
-
- def __set__(self, obj, value):
- obj.config[self.__name__] = value
-
-
-class Config(dict):
- """Works exactly like a dict but provides ways to fill it from files
- or special dictionaries. There are two common patterns to populate the
- config.
-
- Either you can fill the config from a config file::
-
- app.config.from_pyfile('yourconfig.cfg')
-
- Or alternatively you can define the configuration options in the
- module that calls :meth:`from_object` or provide an import path to
- a module that should be loaded. It is also possible to tell it to
- use the same module and with that provide the configuration values
- just before the call::
-
- DEBUG = True
- SECRET_KEY = 'development key'
- app.config.from_object(__name__)
-
- In both cases (loading from any Python file or loading from modules),
- only uppercase keys are added to the config. This makes it possible to use
- lowercase values in the config file for temporary values that are not added
- to the config or to define the config keys in the same file that implements
- the application.
-
- Probably the most interesting way to load configurations is from an
- environment variable pointing to a file::
-
- app.config.from_envvar('YOURAPPLICATION_SETTINGS')
-
- In this case before launching the application you have to set this
- environment variable to the file you want to use. On Linux and OS X
- use the export statement::
-
- export YOURAPPLICATION_SETTINGS='/path/to/config/file'
-
- On windows use `set` instead.
-
- :param root_path: path to which files are read relative from. When the
- config object is created by the application, this is
- the application's :attr:`~flask.Flask.root_path`.
- :param defaults: an optional dictionary of default values
- """
-
- def __init__(self, root_path, defaults=None):
- dict.__init__(self, defaults or {})
- self.root_path = root_path
-
- def from_envvar(self, variable_name, silent=False):
- """Loads a configuration from an environment variable pointing to
- a configuration file. This is basically just a shortcut with nicer
- error messages for this line of code::
-
- app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS'])
-
- :param variable_name: name of the environment variable
- :param silent: set to ``True`` if you want silent failure for missing
- files.
- :return: bool. ``True`` if able to load config, ``False`` otherwise.
- """
- rv = os.environ.get(variable_name)
- if not rv:
- if silent:
- return False
- raise RuntimeError('The environment variable %r is not set '
- 'and as such configuration could not be '
- 'loaded. Set this variable and make it '
- 'point to a configuration file' %
- variable_name)
- return self.from_pyfile(rv, silent=silent)
-
- def from_pyfile(self, filename, silent=False):
- """Updates the values in the config from a Python file. This function
- behaves as if the file was imported as module with the
- :meth:`from_object` function.
-
- :param filename: the filename of the config. This can either be an
- absolute filename or a filename relative to the
- root path.
- :param silent: set to ``True`` if you want silent failure for missing
- files.
-
- .. versionadded:: 0.7
- `silent` parameter.
- """
- filename = os.path.join(self.root_path, filename)
- d = types.ModuleType('config')
- d.__file__ = filename
- try:
- with open(filename, mode='rb') as config_file:
- exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
- except IOError as e:
- if silent and e.errno in (
- errno.ENOENT, errno.EISDIR, errno.ENOTDIR
- ):
- return False
- e.strerror = 'Unable to load configuration file (%s)' % e.strerror
- raise
- self.from_object(d)
- return True
-
- def from_object(self, obj):
- """Updates the values from the given object. An object can be of one
- of the following two types:
-
- - a string: in this case the object with that name will be imported
- - an actual object reference: that object is used directly
-
- Objects are usually either modules or classes. :meth:`from_object`
- loads only the uppercase attributes of the module/class. A ``dict``
- object will not work with :meth:`from_object` because the keys of a
- ``dict`` are not attributes of the ``dict`` class.
-
- Example of module-based configuration::
-
- app.config.from_object('yourapplication.default_config')
- from yourapplication import default_config
- app.config.from_object(default_config)
-
- Nothing is done to the object before loading. If the object is a
- class and has ``@property`` attributes, it needs to be
- instantiated before being passed to this method.
-
- You should not use this function to load the actual configuration but
- rather configuration defaults. The actual config should be loaded
- with :meth:`from_pyfile` and ideally from a location not within the
- package because the package might be installed system wide.
-
- See :ref:`config-dev-prod` for an example of class-based configuration
- using :meth:`from_object`.
-
- :param obj: an import name or object
- """
- if isinstance(obj, string_types):
- obj = import_string(obj)
- for key in dir(obj):
- if key.isupper():
- self[key] = getattr(obj, key)
-
- def from_json(self, filename, silent=False):
- """Updates the values in the config from a JSON file. This function
- behaves as if the JSON object was a dictionary and passed to the
- :meth:`from_mapping` function.
-
- :param filename: the filename of the JSON file. This can either be an
- absolute filename or a filename relative to the
- root path.
- :param silent: set to ``True`` if you want silent failure for missing
- files.
-
- .. versionadded:: 0.11
- """
- filename = os.path.join(self.root_path, filename)
-
- try:
- with open(filename) as json_file:
- obj = json.loads(json_file.read())
- except IOError as e:
- if silent and e.errno in (errno.ENOENT, errno.EISDIR):
- return False
- e.strerror = 'Unable to load configuration file (%s)' % e.strerror
- raise
- return self.from_mapping(obj)
-
- def from_mapping(self, *mapping, **kwargs):
- """Updates the config like :meth:`update` ignoring items with non-upper
- keys.
-
- .. versionadded:: 0.11
- """
- mappings = []
- if len(mapping) == 1:
- if hasattr(mapping[0], 'items'):
- mappings.append(mapping[0].items())
- else:
- mappings.append(mapping[0])
- elif len(mapping) > 1:
- raise TypeError(
- 'expected at most 1 positional argument, got %d' % len(mapping)
- )
- mappings.append(kwargs.items())
- for mapping in mappings:
- for (key, value) in mapping:
- if key.isupper():
- self[key] = value
- return True
-
- def get_namespace(self, namespace, lowercase=True, trim_namespace=True):
- """Returns a dictionary containing a subset of configuration options
- that match the specified namespace/prefix. Example usage::
-
- app.config['IMAGE_STORE_TYPE'] = 'fs'
- app.config['IMAGE_STORE_PATH'] = '/var/app/images'
- app.config['IMAGE_STORE_BASE_URL'] = 'http://img.website.com'
- image_store_config = app.config.get_namespace('IMAGE_STORE_')
-
- The resulting dictionary `image_store_config` would look like::
-
- {
- 'type': 'fs',
- 'path': '/var/app/images',
- 'base_url': 'http://img.website.com'
- }
-
- This is often useful when configuration options map directly to
- keyword arguments in functions or class constructors.
-
- :param namespace: a configuration namespace
- :param lowercase: a flag indicating if the keys of the resulting
- dictionary should be lowercase
- :param trim_namespace: a flag indicating if the keys of the resulting
- dictionary should not include the namespace
-
- .. versionadded:: 0.11
- """
- rv = {}
- for k, v in iteritems(self):
- if not k.startswith(namespace):
- continue
- if trim_namespace:
- key = k[len(namespace):]
- else:
- key = k
- if lowercase:
- key = key.lower()
- rv[key] = v
- return rv
-
- def __repr__(self):
- return '<%s %s>' % (self.__class__.__name__, dict.__repr__(self))
diff --git a/python/flask/ctx.py b/python/flask/ctx.py
deleted file mode 100644
index ec8e787..0000000
--- a/python/flask/ctx.py
+++ /dev/null
@@ -1,457 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.ctx
- ~~~~~~~~~
-
- Implements the objects required to keep the context.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import sys
-from functools import update_wrapper
-
-from werkzeug.exceptions import HTTPException
-
-from .globals import _request_ctx_stack, _app_ctx_stack
-from .signals import appcontext_pushed, appcontext_popped
-from ._compat import BROKEN_PYPY_CTXMGR_EXIT, reraise
-
-
-# a singleton sentinel value for parameter defaults
-_sentinel = object()
-
-
-class _AppCtxGlobals(object):
- """A plain object. Used as a namespace for storing data during an
- application context.
-
- Creating an app context automatically creates this object, which is
- made available as the :data:`g` proxy.
-
- .. describe:: 'key' in g
-
- Check whether an attribute is present.
-
- .. versionadded:: 0.10
-
- .. describe:: iter(g)
-
- Return an iterator over the attribute names.
-
- .. versionadded:: 0.10
- """
-
- def get(self, name, default=None):
- """Get an attribute by name, or a default value. Like
- :meth:`dict.get`.
-
- :param name: Name of attribute to get.
- :param default: Value to return if the attribute is not present.
-
- .. versionadded:: 0.10
- """
- return self.__dict__.get(name, default)
-
- def pop(self, name, default=_sentinel):
- """Get and remove an attribute by name. Like :meth:`dict.pop`.
-
- :param name: Name of attribute to pop.
- :param default: Value to return if the attribute is not present,
- instead of raise a ``KeyError``.
-
- .. versionadded:: 0.11
- """
- if default is _sentinel:
- return self.__dict__.pop(name)
- else:
- return self.__dict__.pop(name, default)
-
- def setdefault(self, name, default=None):
- """Get the value of an attribute if it is present, otherwise
- set and return a default value. Like :meth:`dict.setdefault`.
-
- :param name: Name of attribute to get.
- :param: default: Value to set and return if the attribute is not
- present.
-
- .. versionadded:: 0.11
- """
- return self.__dict__.setdefault(name, default)
-
- def __contains__(self, item):
- return item in self.__dict__
-
- def __iter__(self):
- return iter(self.__dict__)
-
- def __repr__(self):
- top = _app_ctx_stack.top
- if top is not None:
- return '<flask.g of %r>' % top.app.name
- return object.__repr__(self)
-
-
-def after_this_request(f):
- """Executes a function after this request. This is useful to modify
- response objects. The function is passed the response object and has
- to return the same or a new one.
-
- Example::
-
- @app.route('/')
- def index():
- @after_this_request
- def add_header(response):
- response.headers['X-Foo'] = 'Parachute'
- return response
- return 'Hello World!'
-
- This is more useful if a function other than the view function wants to
- modify a response. For instance think of a decorator that wants to add
- some headers without converting the return value into a response object.
-
- .. versionadded:: 0.9
- """
- _request_ctx_stack.top._after_request_functions.append(f)
- return f
-
-
-def copy_current_request_context(f):
- """A helper function that decorates a function to retain the current
- request context. This is useful when working with greenlets. The moment
- the function is decorated a copy of the request context is created and
- then pushed when the function is called.
-
- Example::
-
- import gevent
- from flask import copy_current_request_context
-
- @app.route('/')
- def index():
- @copy_current_request_context
- def do_some_work():
- # do some work here, it can access flask.request like you
- # would otherwise in the view function.
- ...
- gevent.spawn(do_some_work)
- return 'Regular response'
-
- .. versionadded:: 0.10
- """
- top = _request_ctx_stack.top
- if top is None:
- raise RuntimeError('This decorator can only be used at local scopes '
- 'when a request context is on the stack. For instance within '
- 'view functions.')
- reqctx = top.copy()
- def wrapper(*args, **kwargs):
- with reqctx:
- return f(*args, **kwargs)
- return update_wrapper(wrapper, f)
-
-
-def has_request_context():
- """If you have code that wants to test if a request context is there or
- not this function can be used. For instance, you may want to take advantage
- of request information if the request object is available, but fail
- silently if it is unavailable.
-
- ::
-
- class User(db.Model):
-
- def __init__(self, username, remote_addr=None):
- self.username = username
- if remote_addr is None and has_request_context():
- remote_addr = request.remote_addr
- self.remote_addr = remote_addr
-
- Alternatively you can also just test any of the context bound objects
- (such as :class:`request` or :class:`g`) for truthness::
-
- class User(db.Model):
-
- def __init__(self, username, remote_addr=None):
- self.username = username
- if remote_addr is None and request:
- remote_addr = request.remote_addr
- self.remote_addr = remote_addr
-
- .. versionadded:: 0.7
- """
- return _request_ctx_stack.top is not None
-
-
-def has_app_context():
- """Works like :func:`has_request_context` but for the application
- context. You can also just do a boolean check on the
- :data:`current_app` object instead.
-
- .. versionadded:: 0.9
- """
- return _app_ctx_stack.top is not None
-
-
-class AppContext(object):
- """The application context binds an application object implicitly
- to the current thread or greenlet, similar to how the
- :class:`RequestContext` binds request information. The application
- context is also implicitly created if a request context is created
- but the application is not on top of the individual application
- context.
- """
-
- def __init__(self, app):
- self.app = app
- self.url_adapter = app.create_url_adapter(None)
- self.g = app.app_ctx_globals_class()
-
- # Like request context, app contexts can be pushed multiple times
- # but there a basic "refcount" is enough to track them.
- self._refcnt = 0
-
- def push(self):
- """Binds the app context to the current context."""
- self._refcnt += 1
- if hasattr(sys, 'exc_clear'):
- sys.exc_clear()
- _app_ctx_stack.push(self)
- appcontext_pushed.send(self.app)
-
- def pop(self, exc=_sentinel):
- """Pops the app context."""
- try:
- self._refcnt -= 1
- if self._refcnt <= 0:
- if exc is _sentinel:
- exc = sys.exc_info()[1]
- self.app.do_teardown_appcontext(exc)
- finally:
- rv = _app_ctx_stack.pop()
- assert rv is self, 'Popped wrong app context. (%r instead of %r)' \
- % (rv, self)
- appcontext_popped.send(self.app)
-
- def __enter__(self):
- self.push()
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.pop(exc_value)
-
- if BROKEN_PYPY_CTXMGR_EXIT and exc_type is not None:
- reraise(exc_type, exc_value, tb)
-
-
-class RequestContext(object):
- """The request context contains all request relevant information. It is
- created at the beginning of the request and pushed to the
- `_request_ctx_stack` and removed at the end of it. It will create the
- URL adapter and request object for the WSGI environment provided.
-
- Do not attempt to use this class directly, instead use
- :meth:`~flask.Flask.test_request_context` and
- :meth:`~flask.Flask.request_context` to create this object.
-
- When the request context is popped, it will evaluate all the
- functions registered on the application for teardown execution
- (:meth:`~flask.Flask.teardown_request`).
-
- The request context is automatically popped at the end of the request
- for you. In debug mode the request context is kept around if
- exceptions happen so that interactive debuggers have a chance to
- introspect the data. With 0.4 this can also be forced for requests
- that did not fail and outside of ``DEBUG`` mode. By setting
- ``'flask._preserve_context'`` to ``True`` on the WSGI environment the
- context will not pop itself at the end of the request. This is used by
- the :meth:`~flask.Flask.test_client` for example to implement the
- deferred cleanup functionality.
-
- You might find this helpful for unittests where you need the
- information from the context local around for a little longer. Make
- sure to properly :meth:`~werkzeug.LocalStack.pop` the stack yourself in
- that situation, otherwise your unittests will leak memory.
- """
-
- def __init__(self, app, environ, request=None):
- self.app = app
- if request is None:
- request = app.request_class(environ)
- self.request = request
- self.url_adapter = app.create_url_adapter(self.request)
- self.flashes = None
- self.session = None
-
- # Request contexts can be pushed multiple times and interleaved with
- # other request contexts. Now only if the last level is popped we
- # get rid of them. Additionally if an application context is missing
- # one is created implicitly so for each level we add this information
- self._implicit_app_ctx_stack = []
-
- # indicator if the context was preserved. Next time another context
- # is pushed the preserved context is popped.
- self.preserved = False
-
- # remembers the exception for pop if there is one in case the context
- # preservation kicks in.
- self._preserved_exc = None
-
- # Functions that should be executed after the request on the response
- # object. These will be called before the regular "after_request"
- # functions.
- self._after_request_functions = []
-
- self.match_request()
-
- def _get_g(self):
- return _app_ctx_stack.top.g
- def _set_g(self, value):
- _app_ctx_stack.top.g = value
- g = property(_get_g, _set_g)
- del _get_g, _set_g
-
- def copy(self):
- """Creates a copy of this request context with the same request object.
- This can be used to move a request context to a different greenlet.
- Because the actual request object is the same this cannot be used to
- move a request context to a different thread unless access to the
- request object is locked.
-
- .. versionadded:: 0.10
- """
- return self.__class__(self.app,
- environ=self.request.environ,
- request=self.request
- )
-
- def match_request(self):
- """Can be overridden by a subclass to hook into the matching
- of the request.
- """
- try:
- url_rule, self.request.view_args = \
- self.url_adapter.match(return_rule=True)
- self.request.url_rule = url_rule
- except HTTPException as e:
- self.request.routing_exception = e
-
- def push(self):
- """Binds the request context to the current context."""
- # If an exception occurs in debug mode or if context preservation is
- # activated under exception situations exactly one context stays
- # on the stack. The rationale is that you want to access that
- # information under debug situations. However if someone forgets to
- # pop that context again we want to make sure that on the next push
- # it's invalidated, otherwise we run at risk that something leaks
- # memory. This is usually only a problem in test suite since this
- # functionality is not active in production environments.
- top = _request_ctx_stack.top
- if top is not None and top.preserved:
- top.pop(top._preserved_exc)
-
- # Before we push the request context we have to ensure that there
- # is an application context.
- app_ctx = _app_ctx_stack.top
- if app_ctx is None or app_ctx.app != self.app:
- app_ctx = self.app.app_context()
- app_ctx.push()
- self._implicit_app_ctx_stack.append(app_ctx)
- else:
- self._implicit_app_ctx_stack.append(None)
-
- if hasattr(sys, 'exc_clear'):
- sys.exc_clear()
-
- _request_ctx_stack.push(self)
-
- # Open the session at the moment that the request context is available.
- # This allows a custom open_session method to use the request context.
- # Only open a new session if this is the first time the request was
- # pushed, otherwise stream_with_context loses the session.
- if self.session is None:
- session_interface = self.app.session_interface
- self.session = session_interface.open_session(
- self.app, self.request
- )
-
- if self.session is None:
- self.session = session_interface.make_null_session(self.app)
-
- def pop(self, exc=_sentinel):
- """Pops the request context and unbinds it by doing that. This will
- also trigger the execution of functions registered by the
- :meth:`~flask.Flask.teardown_request` decorator.
-
- .. versionchanged:: 0.9
- Added the `exc` argument.
- """
- app_ctx = self._implicit_app_ctx_stack.pop()
-
- try:
- clear_request = False
- if not self._implicit_app_ctx_stack:
- self.preserved = False
- self._preserved_exc = None
- if exc is _sentinel:
- exc = sys.exc_info()[1]
- self.app.do_teardown_request(exc)
-
- # If this interpreter supports clearing the exception information
- # we do that now. This will only go into effect on Python 2.x,
- # on 3.x it disappears automatically at the end of the exception
- # stack.
- if hasattr(sys, 'exc_clear'):
- sys.exc_clear()
-
- request_close = getattr(self.request, 'close', None)
- if request_close is not None:
- request_close()
- clear_request = True
- finally:
- rv = _request_ctx_stack.pop()
-
- # get rid of circular dependencies at the end of the request
- # so that we don't require the GC to be active.
- if clear_request:
- rv.request.environ['werkzeug.request'] = None
-
- # Get rid of the app as well if necessary.
- if app_ctx is not None:
- app_ctx.pop(exc)
-
- assert rv is self, 'Popped wrong request context. ' \
- '(%r instead of %r)' % (rv, self)
-
- def auto_pop(self, exc):
- if self.request.environ.get('flask._preserve_context') or \
- (exc is not None and self.app.preserve_context_on_exception):
- self.preserved = True
- self._preserved_exc = exc
- else:
- self.pop(exc)
-
- def __enter__(self):
- self.push()
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- # do not pop the request stack if we are in debug mode and an
- # exception happened. This will allow the debugger to still
- # access the request object in the interactive shell. Furthermore
- # the context can be force kept alive for the test client.
- # See flask.testing for how this works.
- self.auto_pop(exc_value)
-
- if BROKEN_PYPY_CTXMGR_EXIT and exc_type is not None:
- reraise(exc_type, exc_value, tb)
-
- def __repr__(self):
- return '<%s \'%s\' [%s] of %s>' % (
- self.__class__.__name__,
- self.request.url,
- self.request.method,
- self.app.name,
- )
diff --git a/python/flask/debughelpers.py b/python/flask/debughelpers.py
deleted file mode 100644
index e9765f2..0000000
--- a/python/flask/debughelpers.py
+++ /dev/null
@@ -1,168 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.debughelpers
- ~~~~~~~~~~~~~~~~~~
-
- Various helpers to make the development experience better.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import os
-from warnings import warn
-
-from ._compat import implements_to_string, text_type
-from .app import Flask
-from .blueprints import Blueprint
-from .globals import _request_ctx_stack
-
-
-class UnexpectedUnicodeError(AssertionError, UnicodeError):
- """Raised in places where we want some better error reporting for
- unexpected unicode or binary data.
- """
-
-
-@implements_to_string
-class DebugFilesKeyError(KeyError, AssertionError):
- """Raised from request.files during debugging. The idea is that it can
- provide a better error message than just a generic KeyError/BadRequest.
- """
-
- def __init__(self, request, key):
- form_matches = request.form.getlist(key)
- buf = ['You tried to access the file "%s" in the request.files '
- 'dictionary but it does not exist. The mimetype for the request '
- 'is "%s" instead of "multipart/form-data" which means that no '
- 'file contents were transmitted. To fix this error you should '
- 'provide enctype="multipart/form-data" in your form.' %
- (key, request.mimetype)]
- if form_matches:
- buf.append('\n\nThe browser instead transmitted some file names. '
- 'This was submitted: %s' % ', '.join('"%s"' % x
- for x in form_matches))
- self.msg = ''.join(buf)
-
- def __str__(self):
- return self.msg
-
-
-class FormDataRoutingRedirect(AssertionError):
- """This exception is raised by Flask in debug mode if it detects a
- redirect caused by the routing system when the request method is not
- GET, HEAD or OPTIONS. Reasoning: form data will be dropped.
- """
-
- def __init__(self, request):
- exc = request.routing_exception
- buf = ['A request was sent to this URL (%s) but a redirect was '
- 'issued automatically by the routing system to "%s".'
- % (request.url, exc.new_url)]
-
- # In case just a slash was appended we can be extra helpful
- if request.base_url + '/' == exc.new_url.split('?')[0]:
- buf.append(' The URL was defined with a trailing slash so '
- 'Flask will automatically redirect to the URL '
- 'with the trailing slash if it was accessed '
- 'without one.')
-
- buf.append(' Make sure to directly send your %s-request to this URL '
- 'since we can\'t make browsers or HTTP clients redirect '
- 'with form data reliably or without user interaction.' %
- request.method)
- buf.append('\n\nNote: this exception is only raised in debug mode')
- AssertionError.__init__(self, ''.join(buf).encode('utf-8'))
-
-
-def attach_enctype_error_multidict(request):
- """Since Flask 0.8 we're monkeypatching the files object in case a
- request is detected that does not use multipart form data but the files
- object is accessed.
- """
- oldcls = request.files.__class__
- class newcls(oldcls):
- def __getitem__(self, key):
- try:
- return oldcls.__getitem__(self, key)
- except KeyError:
- if key not in request.form:
- raise
- raise DebugFilesKeyError(request, key)
- newcls.__name__ = oldcls.__name__
- newcls.__module__ = oldcls.__module__
- request.files.__class__ = newcls
-
-
-def _dump_loader_info(loader):
- yield 'class: %s.%s' % (type(loader).__module__, type(loader).__name__)
- for key, value in sorted(loader.__dict__.items()):
- if key.startswith('_'):
- continue
- if isinstance(value, (tuple, list)):
- if not all(isinstance(x, (str, text_type)) for x in value):
- continue
- yield '%s:' % key
- for item in value:
- yield ' - %s' % item
- continue
- elif not isinstance(value, (str, text_type, int, float, bool)):
- continue
- yield '%s: %r' % (key, value)
-
-
-def explain_template_loading_attempts(app, template, attempts):
- """This should help developers understand what failed"""
- info = ['Locating template "%s":' % template]
- total_found = 0
- blueprint = None
- reqctx = _request_ctx_stack.top
- if reqctx is not None and reqctx.request.blueprint is not None:
- blueprint = reqctx.request.blueprint
-
- for idx, (loader, srcobj, triple) in enumerate(attempts):
- if isinstance(srcobj, Flask):
- src_info = 'application "%s"' % srcobj.import_name
- elif isinstance(srcobj, Blueprint):
- src_info = 'blueprint "%s" (%s)' % (srcobj.name,
- srcobj.import_name)
- else:
- src_info = repr(srcobj)
-
- info.append('% 5d: trying loader of %s' % (
- idx + 1, src_info))
-
- for line in _dump_loader_info(loader):
- info.append(' %s' % line)
-
- if triple is None:
- detail = 'no match'
- else:
- detail = 'found (%r)' % (triple[1] or '<string>')
- total_found += 1
- info.append(' -> %s' % detail)
-
- seems_fishy = False
- if total_found == 0:
- info.append('Error: the template could not be found.')
- seems_fishy = True
- elif total_found > 1:
- info.append('Warning: multiple loaders returned a match for the template.')
- seems_fishy = True
-
- if blueprint is not None and seems_fishy:
- info.append(' The template was looked up from an endpoint that '
- 'belongs to the blueprint "%s".' % blueprint)
- info.append(' Maybe you did not place a template in the right folder?')
- info.append(' See http://flask.pocoo.org/docs/blueprints/#templates')
-
- app.logger.info('\n'.join(info))
-
-
-def explain_ignored_app_run():
- if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
- warn(Warning('Silently ignoring app.run() because the '
- 'application is run from the flask command line '
- 'executable. Consider putting app.run() behind an '
- 'if __name__ == "__main__" guard to silence this '
- 'warning.'), stacklevel=3)
diff --git a/python/flask/globals.py b/python/flask/globals.py
deleted file mode 100644
index 7d50a6f..0000000
--- a/python/flask/globals.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.globals
- ~~~~~~~~~~~~~
-
- Defines all the global objects that are proxies to the current
- active context.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-from functools import partial
-from werkzeug.local import LocalStack, LocalProxy
-
-
-_request_ctx_err_msg = '''\
-Working outside of request context.
-
-This typically means that you attempted to use functionality that needed
-an active HTTP request. Consult the documentation on testing for
-information about how to avoid this problem.\
-'''
-_app_ctx_err_msg = '''\
-Working outside of application context.
-
-This typically means that you attempted to use functionality that needed
-to interface with the current application object in some way. To solve
-this, set up an application context with app.app_context(). See the
-documentation for more information.\
-'''
-
-
-def _lookup_req_object(name):
- top = _request_ctx_stack.top
- if top is None:
- raise RuntimeError(_request_ctx_err_msg)
- return getattr(top, name)
-
-
-def _lookup_app_object(name):
- top = _app_ctx_stack.top
- if top is None:
- raise RuntimeError(_app_ctx_err_msg)
- return getattr(top, name)
-
-
-def _find_app():
- top = _app_ctx_stack.top
- if top is None:
- raise RuntimeError(_app_ctx_err_msg)
- return top.app
-
-
-# context locals
-_request_ctx_stack = LocalStack()
-_app_ctx_stack = LocalStack()
-current_app = LocalProxy(_find_app)
-request = LocalProxy(partial(_lookup_req_object, 'request'))
-session = LocalProxy(partial(_lookup_req_object, 'session'))
-g = LocalProxy(partial(_lookup_app_object, 'g'))
diff --git a/python/flask/helpers.py b/python/flask/helpers.py
deleted file mode 100644
index 158edc5..0000000
--- a/python/flask/helpers.py
+++ /dev/null
@@ -1,1051 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.helpers
- ~~~~~~~~~~~~~
-
- Implements various helpers.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import os
-import socket
-import sys
-import pkgutil
-import posixpath
-import mimetypes
-from time import time
-from zlib import adler32
-from threading import RLock
-import unicodedata
-from werkzeug.routing import BuildError
-from functools import update_wrapper
-
-from werkzeug.urls import url_quote
-from werkzeug.datastructures import Headers, Range
-from werkzeug.exceptions import BadRequest, NotFound, \
- RequestedRangeNotSatisfiable
-
-from werkzeug.wsgi import wrap_file
-from jinja2 import FileSystemLoader
-
-from .signals import message_flashed
-from .globals import session, _request_ctx_stack, _app_ctx_stack, \
- current_app, request
-from ._compat import string_types, text_type, PY2
-
-# sentinel
-_missing = object()
-
-
-# what separators does this operating system provide that are not a slash?
-# this is used by the send_from_directory function to ensure that nobody is
-# able to access files from outside the filesystem.
-_os_alt_seps = list(sep for sep in [os.path.sep, os.path.altsep]
- if sep not in (None, '/'))
-
-
-def get_env():
- """Get the environment the app is running in, indicated by the
- :envvar:`FLASK_ENV` environment variable. The default is
- ``'production'``.
- """
- return os.environ.get('FLASK_ENV') or 'production'
-
-
-def get_debug_flag():
- """Get whether debug mode should be enabled for the app, indicated
- by the :envvar:`FLASK_DEBUG` environment variable. The default is
- ``True`` if :func:`.get_env` returns ``'development'``, or ``False``
- otherwise.
- """
- val = os.environ.get('FLASK_DEBUG')
-
- if not val:
- return get_env() == 'development'
-
- return val.lower() not in ('0', 'false', 'no')
-
-
-def get_load_dotenv(default=True):
- """Get whether the user has disabled loading dotenv files by setting
- :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load the
- files.
-
- :param default: What to return if the env var isn't set.
- """
- val = os.environ.get('FLASK_SKIP_DOTENV')
-
- if not val:
- return default
-
- return val.lower() in ('0', 'false', 'no')
-
-
-def _endpoint_from_view_func(view_func):
- """Internal helper that returns the default endpoint for a given
- function. This always is the function name.
- """
- assert view_func is not None, 'expected view func if endpoint ' \
- 'is not provided.'
- return view_func.__name__
-
-
-def stream_with_context(generator_or_function):
- """Request contexts disappear when the response is started on the server.
- This is done for efficiency reasons and to make it less likely to encounter
- memory leaks with badly written WSGI middlewares. The downside is that if
- you are using streamed responses, the generator cannot access request bound
- information any more.
-
- This function however can help you keep the context around for longer::
-
- from flask import stream_with_context, request, Response
-
- @app.route('/stream')
- def streamed_response():
- @stream_with_context
- def generate():
- yield 'Hello '
- yield request.args['name']
- yield '!'
- return Response(generate())
-
- Alternatively it can also be used around a specific generator::
-
- from flask import stream_with_context, request, Response
-
- @app.route('/stream')
- def streamed_response():
- def generate():
- yield 'Hello '
- yield request.args['name']
- yield '!'
- return Response(stream_with_context(generate()))
-
- .. versionadded:: 0.9
- """
- try:
- gen = iter(generator_or_function)
- except TypeError:
- def decorator(*args, **kwargs):
- gen = generator_or_function(*args, **kwargs)
- return stream_with_context(gen)
- return update_wrapper(decorator, generator_or_function)
-
- def generator():
- ctx = _request_ctx_stack.top
- if ctx is None:
- raise RuntimeError('Attempted to stream with context but '
- 'there was no context in the first place to keep around.')
- with ctx:
- # Dummy sentinel. Has to be inside the context block or we're
- # not actually keeping the context around.
- yield None
-
- # The try/finally is here so that if someone passes a WSGI level
- # iterator in we're still running the cleanup logic. Generators
- # don't need that because they are closed on their destruction
- # automatically.
- try:
- for item in gen:
- yield item
- finally:
- if hasattr(gen, 'close'):
- gen.close()
-
- # The trick is to start the generator. Then the code execution runs until
- # the first dummy None is yielded at which point the context was already
- # pushed. This item is discarded. Then when the iteration continues the
- # real generator is executed.
- wrapped_g = generator()
- next(wrapped_g)
- return wrapped_g
-
-
-def make_response(*args):
- """Sometimes it is necessary to set additional headers in a view. Because
- views do not have to return response objects but can return a value that
- is converted into a response object by Flask itself, it becomes tricky to
- add headers to it. This function can be called instead of using a return
- and you will get a response object which you can use to attach headers.
-
- If view looked like this and you want to add a new header::
-
- def index():
- return render_template('index.html', foo=42)
-
- You can now do something like this::
-
- def index():
- response = make_response(render_template('index.html', foo=42))
- response.headers['X-Parachutes'] = 'parachutes are cool'
- return response
-
- This function accepts the very same arguments you can return from a
- view function. This for example creates a response with a 404 error
- code::
-
- response = make_response(render_template('not_found.html'), 404)
-
- The other use case of this function is to force the return value of a
- view function into a response which is helpful with view
- decorators::
-
- response = make_response(view_function())
- response.headers['X-Parachutes'] = 'parachutes are cool'
-
- Internally this function does the following things:
-
- - if no arguments are passed, it creates a new response argument
- - if one argument is passed, :meth:`flask.Flask.make_response`
- is invoked with it.
- - if more than one argument is passed, the arguments are passed
- to the :meth:`flask.Flask.make_response` function as tuple.
-
- .. versionadded:: 0.6
- """
- if not args:
- return current_app.response_class()
- if len(args) == 1:
- args = args[0]
- return current_app.make_response(args)
-
-
-def url_for(endpoint, **values):
- """Generates a URL to the given endpoint with the method provided.
-
- Variable arguments that are unknown to the target endpoint are appended
- to the generated URL as query arguments. If the value of a query argument
- is ``None``, the whole pair is skipped. In case blueprints are active
- you can shortcut references to the same blueprint by prefixing the
- local endpoint with a dot (``.``).
-
- This will reference the index function local to the current blueprint::
-
- url_for('.index')
-
- For more information, head over to the :ref:`Quickstart <url-building>`.
-
- To integrate applications, :class:`Flask` has a hook to intercept URL build
- errors through :attr:`Flask.url_build_error_handlers`. The `url_for`
- function results in a :exc:`~werkzeug.routing.BuildError` when the current
- app does not have a URL for the given endpoint and values. When it does, the
- :data:`~flask.current_app` calls its :attr:`~Flask.url_build_error_handlers` if
- it is not ``None``, which can return a string to use as the result of
- `url_for` (instead of `url_for`'s default to raise the
- :exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.
- An example::
-
- def external_url_handler(error, endpoint, values):
- "Looks up an external URL when `url_for` cannot build a URL."
- # This is an example of hooking the build_error_handler.
- # Here, lookup_url is some utility function you've built
- # which looks up the endpoint in some external URL registry.
- url = lookup_url(endpoint, **values)
- if url is None:
- # External lookup did not have a URL.
- # Re-raise the BuildError, in context of original traceback.
- exc_type, exc_value, tb = sys.exc_info()
- if exc_value is error:
- raise exc_type, exc_value, tb
- else:
- raise error
- # url_for will use this result, instead of raising BuildError.
- return url
-
- app.url_build_error_handlers.append(external_url_handler)
-
- Here, `error` is the instance of :exc:`~werkzeug.routing.BuildError`, and
- `endpoint` and `values` are the arguments passed into `url_for`. Note
- that this is for building URLs outside the current application, and not for
- handling 404 NotFound errors.
-
- .. versionadded:: 0.10
- The `_scheme` parameter was added.
-
- .. versionadded:: 0.9
- The `_anchor` and `_method` parameters were added.
-
- .. versionadded:: 0.9
- Calls :meth:`Flask.handle_build_error` on
- :exc:`~werkzeug.routing.BuildError`.
-
- :param endpoint: the endpoint of the URL (name of the function)
- :param values: the variable arguments of the URL rule
- :param _external: if set to ``True``, an absolute URL is generated. Server
- address can be changed via ``SERVER_NAME`` configuration variable which
- falls back to the `Host` header, then to the IP and port of the request.
- :param _scheme: a string specifying the desired URL scheme. The `_external`
- parameter must be set to ``True`` or a :exc:`ValueError` is raised. The default
- behavior uses the same scheme as the current request, or
- ``PREFERRED_URL_SCHEME`` from the :ref:`app configuration <config>` if no
- request context is available. As of Werkzeug 0.10, this also can be set
- to an empty string to build protocol-relative URLs.
- :param _anchor: if provided this is added as anchor to the URL.
- :param _method: if provided this explicitly specifies an HTTP method.
- """
- appctx = _app_ctx_stack.top
- reqctx = _request_ctx_stack.top
-
- if appctx is None:
- raise RuntimeError(
- 'Attempted to generate a URL without the application context being'
- ' pushed. This has to be executed when application context is'
- ' available.'
- )
-
- # If request specific information is available we have some extra
- # features that support "relative" URLs.
- if reqctx is not None:
- url_adapter = reqctx.url_adapter
- blueprint_name = request.blueprint
-
- if endpoint[:1] == '.':
- if blueprint_name is not None:
- endpoint = blueprint_name + endpoint
- else:
- endpoint = endpoint[1:]
-
- external = values.pop('_external', False)
-
- # Otherwise go with the url adapter from the appctx and make
- # the URLs external by default.
- else:
- url_adapter = appctx.url_adapter
-
- if url_adapter is None:
- raise RuntimeError(
- 'Application was not able to create a URL adapter for request'
- ' independent URL generation. You might be able to fix this by'
- ' setting the SERVER_NAME config variable.'
- )
-
- external = values.pop('_external', True)
-
- anchor = values.pop('_anchor', None)
- method = values.pop('_method', None)
- scheme = values.pop('_scheme', None)
- appctx.app.inject_url_defaults(endpoint, values)
-
- # This is not the best way to deal with this but currently the
- # underlying Werkzeug router does not support overriding the scheme on
- # a per build call basis.
- old_scheme = None
- if scheme is not None:
- if not external:
- raise ValueError('When specifying _scheme, _external must be True')
- old_scheme = url_adapter.url_scheme
- url_adapter.url_scheme = scheme
-
- try:
- try:
- rv = url_adapter.build(endpoint, values, method=method,
- force_external=external)
- finally:
- if old_scheme is not None:
- url_adapter.url_scheme = old_scheme
- except BuildError as error:
- # We need to inject the values again so that the app callback can
- # deal with that sort of stuff.
- values['_external'] = external
- values['_anchor'] = anchor
- values['_method'] = method
- values['_scheme'] = scheme
- return appctx.app.handle_url_build_error(error, endpoint, values)
-
- if anchor is not None:
- rv += '#' + url_quote(anchor)
- return rv
-
-
-def get_template_attribute(template_name, attribute):
- """Loads a macro (or variable) a template exports. This can be used to
- invoke a macro from within Python code. If you for example have a
- template named :file:`_cider.html` with the following contents:
-
- .. sourcecode:: html+jinja
-
- {% macro hello(name) %}Hello {{ name }}!{% endmacro %}
-
- You can access this from Python code like this::
-
- hello = get_template_attribute('_cider.html', 'hello')
- return hello('World')
-
- .. versionadded:: 0.2
-
- :param template_name: the name of the template
- :param attribute: the name of the variable of macro to access
- """
- return getattr(current_app.jinja_env.get_template(template_name).module,
- attribute)
-
-
-def flash(message, category='message'):
- """Flashes a message to the next request. In order to remove the
- flashed message from the session and to display it to the user,
- the template has to call :func:`get_flashed_messages`.
-
- .. versionchanged:: 0.3
- `category` parameter added.
-
- :param message: the message to be flashed.
- :param category: the category for the message. The following values
- are recommended: ``'message'`` for any kind of message,
- ``'error'`` for errors, ``'info'`` for information
- messages and ``'warning'`` for warnings. However any
- kind of string can be used as category.
- """
- # Original implementation:
- #
- # session.setdefault('_flashes', []).append((category, message))
- #
- # This assumed that changes made to mutable structures in the session are
- # always in sync with the session object, which is not true for session
- # implementations that use external storage for keeping their keys/values.
- flashes = session.get('_flashes', [])
- flashes.append((category, message))
- session['_flashes'] = flashes
- message_flashed.send(current_app._get_current_object(),
- message=message, category=category)
-
-
-def get_flashed_messages(with_categories=False, category_filter=[]):
- """Pulls all flashed messages from the session and returns them.
- Further calls in the same request to the function will return
- the same messages. By default just the messages are returned,
- but when `with_categories` is set to ``True``, the return value will
- be a list of tuples in the form ``(category, message)`` instead.
-
- Filter the flashed messages to one or more categories by providing those
- categories in `category_filter`. This allows rendering categories in
- separate html blocks. The `with_categories` and `category_filter`
- arguments are distinct:
-
- * `with_categories` controls whether categories are returned with message
- text (``True`` gives a tuple, where ``False`` gives just the message text).
- * `category_filter` filters the messages down to only those matching the
- provided categories.
-
- See :ref:`message-flashing-pattern` for examples.
-
- .. versionchanged:: 0.3
- `with_categories` parameter added.
-
- .. versionchanged:: 0.9
- `category_filter` parameter added.
-
- :param with_categories: set to ``True`` to also receive categories.
- :param category_filter: whitelist of categories to limit return values
- """
- flashes = _request_ctx_stack.top.flashes
- if flashes is None:
- _request_ctx_stack.top.flashes = flashes = session.pop('_flashes') \
- if '_flashes' in session else []
- if category_filter:
- flashes = list(filter(lambda f: f[0] in category_filter, flashes))
- if not with_categories:
- return [x[1] for x in flashes]
- return flashes
-
-
-def send_file(filename_or_fp, mimetype=None, as_attachment=False,
- attachment_filename=None, add_etags=True,
- cache_timeout=None, conditional=False, last_modified=None):
- """Sends the contents of a file to the client. This will use the
- most efficient method available and configured. By default it will
- try to use the WSGI server's file_wrapper support. Alternatively
- you can set the application's :attr:`~Flask.use_x_sendfile` attribute
- to ``True`` to directly emit an ``X-Sendfile`` header. This however
- requires support of the underlying webserver for ``X-Sendfile``.
-
- By default it will try to guess the mimetype for you, but you can
- also explicitly provide one. For extra security you probably want
- to send certain files as attachment (HTML for instance). The mimetype
- guessing requires a `filename` or an `attachment_filename` to be
- provided.
-
- ETags will also be attached automatically if a `filename` is provided. You
- can turn this off by setting `add_etags=False`.
-
- If `conditional=True` and `filename` is provided, this method will try to
- upgrade the response stream to support range requests. This will allow
- the request to be answered with partial content response.
-
- Please never pass filenames to this function from user sources;
- you should use :func:`send_from_directory` instead.
-
- .. versionadded:: 0.2
-
- .. versionadded:: 0.5
- The `add_etags`, `cache_timeout` and `conditional` parameters were
- added. The default behavior is now to attach etags.
-
- .. versionchanged:: 0.7
- mimetype guessing and etag support for file objects was
- deprecated because it was unreliable. Pass a filename if you are
- able to, otherwise attach an etag yourself. This functionality
- will be removed in Flask 1.0
-
- .. versionchanged:: 0.9
- cache_timeout pulls its default from application config, when None.
-
- .. versionchanged:: 0.12
- The filename is no longer automatically inferred from file objects. If
- you want to use automatic mimetype and etag support, pass a filepath via
- `filename_or_fp` or `attachment_filename`.
-
- .. versionchanged:: 0.12
- The `attachment_filename` is preferred over `filename` for MIME-type
- detection.
-
- .. versionchanged:: 1.0
- UTF-8 filenames, as specified in `RFC 2231`_, are supported.
-
- .. _RFC 2231: https://tools.ietf.org/html/rfc2231#section-4
-
- .. versionchanged:: 1.0.3
- Filenames are encoded with ASCII instead of Latin-1 for broader
- compatibility with WSGI servers.
-
- :param filename_or_fp: the filename of the file to send.
- This is relative to the :attr:`~Flask.root_path`
- if a relative path is specified.
- Alternatively a file object might be provided in
- which case ``X-Sendfile`` might not work and fall
- back to the traditional method. Make sure that the
- file pointer is positioned at the start of data to
- send before calling :func:`send_file`.
- :param mimetype: the mimetype of the file if provided. If a file path is
- given, auto detection happens as fallback, otherwise an
- error will be raised.
- :param as_attachment: set to ``True`` if you want to send this file with
- a ``Content-Disposition: attachment`` header.
- :param attachment_filename: the filename for the attachment if it
- differs from the file's filename.
- :param add_etags: set to ``False`` to disable attaching of etags.
- :param conditional: set to ``True`` to enable conditional responses.
-
- :param cache_timeout: the timeout in seconds for the headers. When ``None``
- (default), this value is set by
- :meth:`~Flask.get_send_file_max_age` of
- :data:`~flask.current_app`.
- :param last_modified: set the ``Last-Modified`` header to this value,
- a :class:`~datetime.datetime` or timestamp.
- If a file was passed, this overrides its mtime.
- """
- mtime = None
- fsize = None
- if isinstance(filename_or_fp, string_types):
- filename = filename_or_fp
- if not os.path.isabs(filename):
- filename = os.path.join(current_app.root_path, filename)
- file = None
- if attachment_filename is None:
- attachment_filename = os.path.basename(filename)
- else:
- file = filename_or_fp
- filename = None
-
- if mimetype is None:
- if attachment_filename is not None:
- mimetype = mimetypes.guess_type(attachment_filename)[0] \
- or 'application/octet-stream'
-
- if mimetype is None:
- raise ValueError(
- 'Unable to infer MIME-type because no filename is available. '
- 'Please set either `attachment_filename`, pass a filepath to '
- '`filename_or_fp` or set your own MIME-type via `mimetype`.'
- )
-
- headers = Headers()
- if as_attachment:
- if attachment_filename is None:
- raise TypeError('filename unavailable, required for '
- 'sending as attachment')
-
- if not isinstance(attachment_filename, text_type):
- attachment_filename = attachment_filename.decode('utf-8')
-
- try:
- attachment_filename = attachment_filename.encode('ascii')
- except UnicodeEncodeError:
- filenames = {
- 'filename': unicodedata.normalize(
- 'NFKD', attachment_filename).encode('ascii', 'ignore'),
- 'filename*': "UTF-8''%s" % url_quote(attachment_filename),
- }
- else:
- filenames = {'filename': attachment_filename}
-
- headers.add('Content-Disposition', 'attachment', **filenames)
-
- if current_app.use_x_sendfile and filename:
- if file is not None:
- file.close()
- headers['X-Sendfile'] = filename
- fsize = os.path.getsize(filename)
- headers['Content-Length'] = fsize
- data = None
- else:
- if file is None:
- file = open(filename, 'rb')
- mtime = os.path.getmtime(filename)
- fsize = os.path.getsize(filename)
- headers['Content-Length'] = fsize
- data = wrap_file(request.environ, file)
-
- rv = current_app.response_class(data, mimetype=mimetype, headers=headers,
- direct_passthrough=True)
-
- if last_modified is not None:
- rv.last_modified = last_modified
- elif mtime is not None:
- rv.last_modified = mtime
-
- rv.cache_control.public = True
- if cache_timeout is None:
- cache_timeout = current_app.get_send_file_max_age(filename)
- if cache_timeout is not None:
- rv.cache_control.max_age = cache_timeout
- rv.expires = int(time() + cache_timeout)
-
- if add_etags and filename is not None:
- from warnings import warn
-
- try:
- rv.set_etag('%s-%s-%s' % (
- os.path.getmtime(filename),
- os.path.getsize(filename),
- adler32(
- filename.encode('utf-8') if isinstance(filename, text_type)
- else filename
- ) & 0xffffffff
- ))
- except OSError:
- warn('Access %s failed, maybe it does not exist, so ignore etags in '
- 'headers' % filename, stacklevel=2)
-
- if conditional:
- try:
- rv = rv.make_conditional(request, accept_ranges=True,
- complete_length=fsize)
- except RequestedRangeNotSatisfiable:
- if file is not None:
- file.close()
- raise
- # make sure we don't send x-sendfile for servers that
- # ignore the 304 status code for x-sendfile.
- if rv.status_code == 304:
- rv.headers.pop('x-sendfile', None)
- return rv
-
-
-def safe_join(directory, *pathnames):
- """Safely join `directory` and zero or more untrusted `pathnames`
- components.
-
- Example usage::
-
- @app.route('/wiki/<path:filename>')
- def wiki_page(filename):
- filename = safe_join(app.config['WIKI_FOLDER'], filename)
- with open(filename, 'rb') as fd:
- content = fd.read() # Read and process the file content...
-
- :param directory: the trusted base directory.
- :param pathnames: the untrusted pathnames relative to that directory.
- :raises: :class:`~werkzeug.exceptions.NotFound` if one or more passed
- paths fall out of its boundaries.
- """
-
- parts = [directory]
-
- for filename in pathnames:
- if filename != '':
- filename = posixpath.normpath(filename)
-
- if (
- any(sep in filename for sep in _os_alt_seps)
- or os.path.isabs(filename)
- or filename == '..'
- or filename.startswith('../')
- ):
- raise NotFound()
-
- parts.append(filename)
-
- return posixpath.join(*parts)
-
-
-def send_from_directory(directory, filename, **options):
- """Send a file from a given directory with :func:`send_file`. This
- is a secure way to quickly expose static files from an upload folder
- or something similar.
-
- Example usage::
-
- @app.route('/uploads/<path:filename>')
- def download_file(filename):
- return send_from_directory(app.config['UPLOAD_FOLDER'],
- filename, as_attachment=True)
-
- .. admonition:: Sending files and Performance
-
- It is strongly recommended to activate either ``X-Sendfile`` support in
- your webserver or (if no authentication happens) to tell the webserver
- to serve files for the given path on its own without calling into the
- web application for improved performance.
-
- .. versionadded:: 0.5
-
- :param directory: the directory where all the files are stored.
- :param filename: the filename relative to that directory to
- download.
- :param options: optional keyword arguments that are directly
- forwarded to :func:`send_file`.
- """
- filename = safe_join(directory, filename)
- if not os.path.isabs(filename):
- filename = os.path.join(current_app.root_path, filename)
- try:
- if not os.path.isfile(filename):
- raise NotFound()
- except (TypeError, ValueError):
- raise BadRequest()
- options.setdefault('conditional', True)
- return send_file(filename, **options)
-
-
-def get_root_path(import_name):
- """Returns the path to a package or cwd if that cannot be found. This
- returns the path of a package or the folder that contains a module.
-
- Not to be confused with the package path returned by :func:`find_package`.
- """
- # Module already imported and has a file attribute. Use that first.
- mod = sys.modules.get(import_name)
- if mod is not None and hasattr(mod, '__file__'):
- return os.path.dirname(os.path.abspath(mod.__file__))
-
- # Next attempt: check the loader.
- loader = pkgutil.get_loader(import_name)
-
- # Loader does not exist or we're referring to an unloaded main module
- # or a main module without path (interactive sessions), go with the
- # current working directory.
- if loader is None or import_name == '__main__':
- return os.getcwd()
-
- # For .egg, zipimporter does not have get_filename until Python 2.7.
- # Some other loaders might exhibit the same behavior.
- if hasattr(loader, 'get_filename'):
- filepath = loader.get_filename(import_name)
- else:
- # Fall back to imports.
- __import__(import_name)
- mod = sys.modules[import_name]
- filepath = getattr(mod, '__file__', None)
-
- # If we don't have a filepath it might be because we are a
- # namespace package. In this case we pick the root path from the
- # first module that is contained in our package.
- if filepath is None:
- raise RuntimeError('No root path can be found for the provided '
- 'module "%s". This can happen because the '
- 'module came from an import hook that does '
- 'not provide file name information or because '
- 'it\'s a namespace package. In this case '
- 'the root path needs to be explicitly '
- 'provided.' % import_name)
-
- # filepath is import_name.py for a module, or __init__.py for a package.
- return os.path.dirname(os.path.abspath(filepath))
-
-
-def _matching_loader_thinks_module_is_package(loader, mod_name):
- """Given the loader that loaded a module and the module this function
- attempts to figure out if the given module is actually a package.
- """
- # If the loader can tell us if something is a package, we can
- # directly ask the loader.
- if hasattr(loader, 'is_package'):
- return loader.is_package(mod_name)
- # importlib's namespace loaders do not have this functionality but
- # all the modules it loads are packages, so we can take advantage of
- # this information.
- elif (loader.__class__.__module__ == '_frozen_importlib' and
- loader.__class__.__name__ == 'NamespaceLoader'):
- return True
- # Otherwise we need to fail with an error that explains what went
- # wrong.
- raise AttributeError(
- ('%s.is_package() method is missing but is required by Flask of '
- 'PEP 302 import hooks. If you do not use import hooks and '
- 'you encounter this error please file a bug against Flask.') %
- loader.__class__.__name__)
-
-
-def find_package(import_name):
- """Finds a package and returns the prefix (or None if the package is
- not installed) as well as the folder that contains the package or
- module as a tuple. The package path returned is the module that would
- have to be added to the pythonpath in order to make it possible to
- import the module. The prefix is the path below which a UNIX like
- folder structure exists (lib, share etc.).
- """
- root_mod_name = import_name.split('.')[0]
- loader = pkgutil.get_loader(root_mod_name)
- if loader is None or import_name == '__main__':
- # import name is not found, or interactive/main module
- package_path = os.getcwd()
- else:
- # For .egg, zipimporter does not have get_filename until Python 2.7.
- if hasattr(loader, 'get_filename'):
- filename = loader.get_filename(root_mod_name)
- elif hasattr(loader, 'archive'):
- # zipimporter's loader.archive points to the .egg or .zip
- # archive filename is dropped in call to dirname below.
- filename = loader.archive
- else:
- # At least one loader is missing both get_filename and archive:
- # Google App Engine's HardenedModulesHook
- #
- # Fall back to imports.
- __import__(import_name)
- filename = sys.modules[import_name].__file__
- package_path = os.path.abspath(os.path.dirname(filename))
-
- # In case the root module is a package we need to chop of the
- # rightmost part. This needs to go through a helper function
- # because of python 3.3 namespace packages.
- if _matching_loader_thinks_module_is_package(
- loader, root_mod_name):
- package_path = os.path.dirname(package_path)
-
- site_parent, site_folder = os.path.split(package_path)
- py_prefix = os.path.abspath(sys.prefix)
- if package_path.startswith(py_prefix):
- return py_prefix, package_path
- elif site_folder.lower() == 'site-packages':
- parent, folder = os.path.split(site_parent)
- # Windows like installations
- if folder.lower() == 'lib':
- base_dir = parent
- # UNIX like installations
- elif os.path.basename(parent).lower() == 'lib':
- base_dir = os.path.dirname(parent)
- else:
- base_dir = site_parent
- return base_dir, package_path
- return None, package_path
-
-
-class locked_cached_property(object):
- """A decorator that converts a function into a lazy property. The
- function wrapped is called the first time to retrieve the result
- and then that calculated result is used the next time you access
- the value. Works like the one in Werkzeug but has a lock for
- thread safety.
- """
-
- def __init__(self, func, name=None, doc=None):
- self.__name__ = name or func.__name__
- self.__module__ = func.__module__
- self.__doc__ = doc or func.__doc__
- self.func = func
- self.lock = RLock()
-
- def __get__(self, obj, type=None):
- if obj is None:
- return self
- with self.lock:
- value = obj.__dict__.get(self.__name__, _missing)
- if value is _missing:
- value = self.func(obj)
- obj.__dict__[self.__name__] = value
- return value
-
-
-class _PackageBoundObject(object):
- #: The name of the package or module that this app belongs to. Do not
- #: change this once it is set by the constructor.
- import_name = None
-
- #: Location of the template files to be added to the template lookup.
- #: ``None`` if templates should not be added.
- template_folder = None
-
- #: Absolute path to the package on the filesystem. Used to look up
- #: resources contained in the package.
- root_path = None
-
- def __init__(self, import_name, template_folder=None, root_path=None):
- self.import_name = import_name
- self.template_folder = template_folder
-
- if root_path is None:
- root_path = get_root_path(self.import_name)
-
- self.root_path = root_path
- self._static_folder = None
- self._static_url_path = None
-
- def _get_static_folder(self):
- if self._static_folder is not None:
- return os.path.join(self.root_path, self._static_folder)
-
- def _set_static_folder(self, value):
- self._static_folder = value
-
- static_folder = property(
- _get_static_folder, _set_static_folder,
- doc='The absolute path to the configured static folder.'
- )
- del _get_static_folder, _set_static_folder
-
- def _get_static_url_path(self):
- if self._static_url_path is not None:
- return self._static_url_path
-
- if self.static_folder is not None:
- return '/' + os.path.basename(self.static_folder)
-
- def _set_static_url_path(self, value):
- self._static_url_path = value
-
- static_url_path = property(
- _get_static_url_path, _set_static_url_path,
- doc='The URL prefix that the static route will be registered for.'
- )
- del _get_static_url_path, _set_static_url_path
-
- @property
- def has_static_folder(self):
- """This is ``True`` if the package bound object's container has a
- folder for static files.
-
- .. versionadded:: 0.5
- """
- return self.static_folder is not None
-
- @locked_cached_property
- def jinja_loader(self):
- """The Jinja loader for this package bound object.
-
- .. versionadded:: 0.5
- """
- if self.template_folder is not None:
- return FileSystemLoader(os.path.join(self.root_path,
- self.template_folder))
-
- def get_send_file_max_age(self, filename):
- """Provides default cache_timeout for the :func:`send_file` functions.
-
- By default, this function returns ``SEND_FILE_MAX_AGE_DEFAULT`` from
- the configuration of :data:`~flask.current_app`.
-
- Static file functions such as :func:`send_from_directory` use this
- function, and :func:`send_file` calls this function on
- :data:`~flask.current_app` when the given cache_timeout is ``None``. If a
- cache_timeout is given in :func:`send_file`, that timeout is used;
- otherwise, this method is called.
-
- This allows subclasses to change the behavior when sending files based
- on the filename. For example, to set the cache timeout for .js files
- to 60 seconds::
-
- class MyFlask(flask.Flask):
- def get_send_file_max_age(self, name):
- if name.lower().endswith('.js'):
- return 60
- return flask.Flask.get_send_file_max_age(self, name)
-
- .. versionadded:: 0.9
- """
- return total_seconds(current_app.send_file_max_age_default)
-
- def send_static_file(self, filename):
- """Function used internally to send static files from the static
- folder to the browser.
-
- .. versionadded:: 0.5
- """
- if not self.has_static_folder:
- raise RuntimeError('No static folder for this object')
- # Ensure get_send_file_max_age is called in all cases.
- # Here, we ensure get_send_file_max_age is called for Blueprints.
- cache_timeout = self.get_send_file_max_age(filename)
- return send_from_directory(self.static_folder, filename,
- cache_timeout=cache_timeout)
-
- def open_resource(self, resource, mode='rb'):
- """Opens a resource from the application's resource folder. To see
- how this works, consider the following folder structure::
-
- /myapplication.py
- /schema.sql
- /static
- /style.css
- /templates
- /layout.html
- /index.html
-
- If you want to open the :file:`schema.sql` file you would do the
- following::
-
- with app.open_resource('schema.sql') as f:
- contents = f.read()
- do_something_with(contents)
-
- :param resource: the name of the resource. To access resources within
- subfolders use forward slashes as separator.
- :param mode: resource file opening mode, default is 'rb'.
- """
- if mode not in ('r', 'rb'):
- raise ValueError('Resources can only be opened for reading')
- return open(os.path.join(self.root_path, resource), mode)
-
-
-def total_seconds(td):
- """Returns the total seconds from a timedelta object.
-
- :param timedelta td: the timedelta to be converted in seconds
-
- :returns: number of seconds
- :rtype: int
- """
- return td.days * 60 * 60 * 24 + td.seconds
-
-
-def is_ip(value):
- """Determine if the given string is an IP address.
-
- Python 2 on Windows doesn't provide ``inet_pton``, so this only
- checks IPv4 addresses in that environment.
-
- :param value: value to check
- :type value: str
-
- :return: True if string is an IP address
- :rtype: bool
- """
- if PY2 and os.name == 'nt':
- try:
- socket.inet_aton(value)
- return True
- except socket.error:
- return False
-
- for family in (socket.AF_INET, socket.AF_INET6):
- try:
- socket.inet_pton(family, value)
- except socket.error:
- pass
- else:
- return True
-
- return False
diff --git a/python/flask/json/__init__.py b/python/flask/json/__init__.py
deleted file mode 100644
index c24286c..0000000
--- a/python/flask/json/__init__.py
+++ /dev/null
@@ -1,357 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-flask.json
-~~~~~~~~~~
-
-:copyright: © 2010 by the Pallets team.
-:license: BSD, see LICENSE for more details.
-"""
-import codecs
-import io
-import uuid
-from datetime import date, datetime
-from flask.globals import current_app, request
-from flask._compat import text_type, PY2
-
-from werkzeug.http import http_date
-from jinja2 import Markup
-
-# Use the same json implementation as itsdangerous on which we
-# depend anyways.
-from itsdangerous import json as _json
-
-
-# Figure out if simplejson escapes slashes. This behavior was changed
-# from one version to another without reason.
-_slash_escape = '\\/' not in _json.dumps('/')
-
-
-__all__ = ['dump', 'dumps', 'load', 'loads', 'htmlsafe_dump',
- 'htmlsafe_dumps', 'JSONDecoder', 'JSONEncoder',
- 'jsonify']
-
-
-def _wrap_reader_for_text(fp, encoding):
- if isinstance(fp.read(0), bytes):
- fp = io.TextIOWrapper(io.BufferedReader(fp), encoding)
- return fp
-
-
-def _wrap_writer_for_text(fp, encoding):
- try:
- fp.write('')
- except TypeError:
- fp = io.TextIOWrapper(fp, encoding)
- return fp
-
-
-class JSONEncoder(_json.JSONEncoder):
- """The default Flask JSON encoder. This one extends the default simplejson
- encoder by also supporting ``datetime`` objects, ``UUID`` as well as
- ``Markup`` objects which are serialized as RFC 822 datetime strings (same
- as the HTTP date format). In order to support more data types override the
- :meth:`default` method.
- """
-
- def default(self, o):
- """Implement this method in a subclass such that it returns a
- serializable object for ``o``, or calls the base implementation (to
- raise a :exc:`TypeError`).
-
- For example, to support arbitrary iterators, you could implement
- default like this::
-
- def default(self, o):
- try:
- iterable = iter(o)
- except TypeError:
- pass
- else:
- return list(iterable)
- return JSONEncoder.default(self, o)
- """
- if isinstance(o, datetime):
- return http_date(o.utctimetuple())
- if isinstance(o, date):
- return http_date(o.timetuple())
- if isinstance(o, uuid.UUID):
- return str(o)
- if hasattr(o, '__html__'):
- return text_type(o.__html__())
- return _json.JSONEncoder.default(self, o)
-
-
-class JSONDecoder(_json.JSONDecoder):
- """The default JSON decoder. This one does not change the behavior from
- the default simplejson decoder. Consult the :mod:`json` documentation
- for more information. This decoder is not only used for the load
- functions of this module but also :attr:`~flask.Request`.
- """
-
-
-def _dump_arg_defaults(kwargs, app=None):
- """Inject default arguments for dump functions."""
- if app is None:
- app = current_app
-
- if app:
- bp = app.blueprints.get(request.blueprint) if request else None
- kwargs.setdefault(
- 'cls', bp.json_encoder if bp and bp.json_encoder else app.json_encoder
- )
-
- if not app.config['JSON_AS_ASCII']:
- kwargs.setdefault('ensure_ascii', False)
-
- kwargs.setdefault('sort_keys', app.config['JSON_SORT_KEYS'])
- else:
- kwargs.setdefault('sort_keys', True)
- kwargs.setdefault('cls', JSONEncoder)
-
-
-def _load_arg_defaults(kwargs, app=None):
- """Inject default arguments for load functions."""
- if app is None:
- app = current_app
-
- if app:
- bp = app.blueprints.get(request.blueprint) if request else None
- kwargs.setdefault(
- 'cls',
- bp.json_decoder if bp and bp.json_decoder
- else app.json_decoder
- )
- else:
- kwargs.setdefault('cls', JSONDecoder)
-
-
-def detect_encoding(data):
- """Detect which UTF codec was used to encode the given bytes.
-
- The latest JSON standard (:rfc:`8259`) suggests that only UTF-8 is
- accepted. Older documents allowed 8, 16, or 32. 16 and 32 can be big
- or little endian. Some editors or libraries may prepend a BOM.
-
- :param data: Bytes in unknown UTF encoding.
- :return: UTF encoding name
- """
- head = data[:4]
-
- if head[:3] == codecs.BOM_UTF8:
- return 'utf-8-sig'
-
- if b'\x00' not in head:
- return 'utf-8'
-
- if head in (codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE):
- return 'utf-32'
-
- if head[:2] in (codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE):
- return 'utf-16'
-
- if len(head) == 4:
- if head[:3] == b'\x00\x00\x00':
- return 'utf-32-be'
-
- if head[::2] == b'\x00\x00':
- return 'utf-16-be'
-
- if head[1:] == b'\x00\x00\x00':
- return 'utf-32-le'
-
- if head[1::2] == b'\x00\x00':
- return 'utf-16-le'
-
- if len(head) == 2:
- return 'utf-16-be' if head.startswith(b'\x00') else 'utf-16-le'
-
- return 'utf-8'
-
-
-def dumps(obj, app=None, **kwargs):
- """Serialize ``obj`` to a JSON-formatted string. If there is an
- app context pushed, use the current app's configured encoder
- (:attr:`~flask.Flask.json_encoder`), or fall back to the default
- :class:`JSONEncoder`.
-
- Takes the same arguments as the built-in :func:`json.dumps`, and
- does some extra configuration based on the application. If the
- simplejson package is installed, it is preferred.
-
- :param obj: Object to serialize to JSON.
- :param app: App instance to use to configure the JSON encoder.
- Uses ``current_app`` if not given, and falls back to the default
- encoder when not in an app context.
- :param kwargs: Extra arguments passed to :func:`json.dumps`.
-
- .. versionchanged:: 1.0.3
-
- ``app`` can be passed directly, rather than requiring an app
- context for configuration.
- """
- _dump_arg_defaults(kwargs, app=app)
- encoding = kwargs.pop('encoding', None)
- rv = _json.dumps(obj, **kwargs)
- if encoding is not None and isinstance(rv, text_type):
- rv = rv.encode(encoding)
- return rv
-
-
-def dump(obj, fp, app=None, **kwargs):
- """Like :func:`dumps` but writes into a file object."""
- _dump_arg_defaults(kwargs, app=app)
- encoding = kwargs.pop('encoding', None)
- if encoding is not None:
- fp = _wrap_writer_for_text(fp, encoding)
- _json.dump(obj, fp, **kwargs)
-
-
-def loads(s, app=None, **kwargs):
- """Deserialize an object from a JSON-formatted string ``s``. If
- there is an app context pushed, use the current app's configured
- decoder (:attr:`~flask.Flask.json_decoder`), or fall back to the
- default :class:`JSONDecoder`.
-
- Takes the same arguments as the built-in :func:`json.loads`, and
- does some extra configuration based on the application. If the
- simplejson package is installed, it is preferred.
-
- :param s: JSON string to deserialize.
- :param app: App instance to use to configure the JSON decoder.
- Uses ``current_app`` if not given, and falls back to the default
- encoder when not in an app context.
- :param kwargs: Extra arguments passed to :func:`json.dumps`.
-
- .. versionchanged:: 1.0.3
-
- ``app`` can be passed directly, rather than requiring an app
- context for configuration.
- """
- _load_arg_defaults(kwargs, app=app)
- if isinstance(s, bytes):
- encoding = kwargs.pop('encoding', None)
- if encoding is None:
- encoding = detect_encoding(s)
- s = s.decode(encoding)
- return _json.loads(s, **kwargs)
-
-
-def load(fp, app=None, **kwargs):
- """Like :func:`loads` but reads from a file object."""
- _load_arg_defaults(kwargs, app=app)
- if not PY2:
- fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
- return _json.load(fp, **kwargs)
-
-
-def htmlsafe_dumps(obj, **kwargs):
- """Works exactly like :func:`dumps` but is safe for use in ``<script>``
- tags. It accepts the same arguments and returns a JSON string. Note that
- this is available in templates through the ``|tojson`` filter which will
- also mark the result as safe. Due to how this function escapes certain
- characters this is safe even if used outside of ``<script>`` tags.
-
- The following characters are escaped in strings:
-
- - ``<``
- - ``>``
- - ``&``
- - ``'``
-
- This makes it safe to embed such strings in any place in HTML with the
- notable exception of double quoted attributes. In that case single
- quote your attributes or HTML escape it in addition.
-
- .. versionchanged:: 0.10
- This function's return value is now always safe for HTML usage, even
- if outside of script tags or if used in XHTML. This rule does not
- hold true when using this function in HTML attributes that are double
- quoted. Always single quote attributes if you use the ``|tojson``
- filter. Alternatively use ``|tojson|forceescape``.
- """
- rv = dumps(obj, **kwargs) \
- .replace(u'<', u'\\u003c') \
- .replace(u'>', u'\\u003e') \
- .replace(u'&', u'\\u0026') \
- .replace(u"'", u'\\u0027')
- if not _slash_escape:
- rv = rv.replace('\\/', '/')
- return rv
-
-
-def htmlsafe_dump(obj, fp, **kwargs):
- """Like :func:`htmlsafe_dumps` but writes into a file object."""
- fp.write(text_type(htmlsafe_dumps(obj, **kwargs)))
-
-
-def jsonify(*args, **kwargs):
- """This function wraps :func:`dumps` to add a few enhancements that make
- life easier. It turns the JSON output into a :class:`~flask.Response`
- object with the :mimetype:`application/json` mimetype. For convenience, it
- also converts multiple arguments into an array or multiple keyword arguments
- into a dict. This means that both ``jsonify(1,2,3)`` and
- ``jsonify([1,2,3])`` serialize to ``[1,2,3]``.
-
- For clarity, the JSON serialization behavior has the following differences
- from :func:`dumps`:
-
- 1. Single argument: Passed straight through to :func:`dumps`.
- 2. Multiple arguments: Converted to an array before being passed to
- :func:`dumps`.
- 3. Multiple keyword arguments: Converted to a dict before being passed to
- :func:`dumps`.
- 4. Both args and kwargs: Behavior undefined and will throw an exception.
-
- Example usage::
-
- from flask import jsonify
-
- @app.route('/_get_current_user')
- def get_current_user():
- return jsonify(username=g.user.username,
- email=g.user.email,
- id=g.user.id)
-
- This will send a JSON response like this to the browser::
-
- {
- "username": "admin",
- "email": "admin@localhost",
- "id": 42
- }
-
-
- .. versionchanged:: 0.11
- Added support for serializing top-level arrays. This introduces a
- security risk in ancient browsers. See :ref:`json-security` for details.
-
- This function's response will be pretty printed if the
- ``JSONIFY_PRETTYPRINT_REGULAR`` config parameter is set to True or the
- Flask app is running in debug mode. Compressed (not pretty) formatting
- currently means no indents and no spaces after separators.
-
- .. versionadded:: 0.2
- """
-
- indent = None
- separators = (',', ':')
-
- if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] or current_app.debug:
- indent = 2
- separators = (', ', ': ')
-
- if args and kwargs:
- raise TypeError('jsonify() behavior undefined when passed both args and kwargs')
- elif len(args) == 1: # single args are passed directly to dumps()
- data = args[0]
- else:
- data = args or kwargs
-
- return current_app.response_class(
- dumps(data, indent=indent, separators=separators) + '\n',
- mimetype=current_app.config['JSONIFY_MIMETYPE']
- )
-
-
-def tojson_filter(obj, **kwargs):
- return Markup(htmlsafe_dumps(obj, **kwargs))
diff --git a/python/flask/json/tag.py b/python/flask/json/tag.py
deleted file mode 100644
index 11c966c..0000000
--- a/python/flask/json/tag.py
+++ /dev/null
@@ -1,300 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tagged JSON
-~~~~~~~~~~~
-
-A compact representation for lossless serialization of non-standard JSON types.
-:class:`~flask.sessions.SecureCookieSessionInterface` uses this to serialize
-the session data, but it may be useful in other places. It can be extended to
-support other types.
-
-.. autoclass:: TaggedJSONSerializer
- :members:
-
-.. autoclass:: JSONTag
- :members:
-
-Let's seen an example that adds support for :class:`~collections.OrderedDict`.
-Dicts don't have an order in Python or JSON, so to handle this we will dump
-the items as a list of ``[key, value]`` pairs. Subclass :class:`JSONTag` and
-give it the new key ``' od'`` to identify the type. The session serializer
-processes dicts first, so insert the new tag at the front of the order since
-``OrderedDict`` must be processed before ``dict``. ::
-
- from flask.json.tag import JSONTag
-
- class TagOrderedDict(JSONTag):
- __slots__ = ('serializer',)
- key = ' od'
-
- def check(self, value):
- return isinstance(value, OrderedDict)
-
- def to_json(self, value):
- return [[k, self.serializer.tag(v)] for k, v in iteritems(value)]
-
- def to_python(self, value):
- return OrderedDict(value)
-
- app.session_interface.serializer.register(TagOrderedDict, index=0)
-
-:copyright: © 2010 by the Pallets team.
-:license: BSD, see LICENSE for more details.
-"""
-
-from base64 import b64decode, b64encode
-from datetime import datetime
-from uuid import UUID
-
-from jinja2 import Markup
-from werkzeug.http import http_date, parse_date
-
-from flask._compat import iteritems, text_type
-from flask.json import dumps, loads
-
-
-class JSONTag(object):
- """Base class for defining type tags for :class:`TaggedJSONSerializer`."""
-
- __slots__ = ('serializer',)
-
- #: The tag to mark the serialized object with. If ``None``, this tag is
- #: only used as an intermediate step during tagging.
- key = None
-
- def __init__(self, serializer):
- """Create a tagger for the given serializer."""
- self.serializer = serializer
-
- def check(self, value):
- """Check if the given value should be tagged by this tag."""
- raise NotImplementedError
-
- def to_json(self, value):
- """Convert the Python object to an object that is a valid JSON type.
- The tag will be added later."""
- raise NotImplementedError
-
- def to_python(self, value):
- """Convert the JSON representation back to the correct type. The tag
- will already be removed."""
- raise NotImplementedError
-
- def tag(self, value):
- """Convert the value to a valid JSON type and add the tag structure
- around it."""
- return {self.key: self.to_json(value)}
-
-
-class TagDict(JSONTag):
- """Tag for 1-item dicts whose only key matches a registered tag.
-
- Internally, the dict key is suffixed with `__`, and the suffix is removed
- when deserializing.
- """
-
- __slots__ = ()
- key = ' di'
-
- def check(self, value):
- return (
- isinstance(value, dict)
- and len(value) == 1
- and next(iter(value)) in self.serializer.tags
- )
-
- def to_json(self, value):
- key = next(iter(value))
- return {key + '__': self.serializer.tag(value[key])}
-
- def to_python(self, value):
- key = next(iter(value))
- return {key[:-2]: value[key]}
-
-
-class PassDict(JSONTag):
- __slots__ = ()
-
- def check(self, value):
- return isinstance(value, dict)
-
- def to_json(self, value):
- # JSON objects may only have string keys, so don't bother tagging the
- # key here.
- return dict((k, self.serializer.tag(v)) for k, v in iteritems(value))
-
- tag = to_json
-
-
-class TagTuple(JSONTag):
- __slots__ = ()
- key = ' t'
-
- def check(self, value):
- return isinstance(value, tuple)
-
- def to_json(self, value):
- return [self.serializer.tag(item) for item in value]
-
- def to_python(self, value):
- return tuple(value)
-
-
-class PassList(JSONTag):
- __slots__ = ()
-
- def check(self, value):
- return isinstance(value, list)
-
- def to_json(self, value):
- return [self.serializer.tag(item) for item in value]
-
- tag = to_json
-
-
-class TagBytes(JSONTag):
- __slots__ = ()
- key = ' b'
-
- def check(self, value):
- return isinstance(value, bytes)
-
- def to_json(self, value):
- return b64encode(value).decode('ascii')
-
- def to_python(self, value):
- return b64decode(value)
-
-
-class TagMarkup(JSONTag):
- """Serialize anything matching the :class:`~flask.Markup` API by
- having a ``__html__`` method to the result of that method. Always
- deserializes to an instance of :class:`~flask.Markup`."""
-
- __slots__ = ()
- key = ' m'
-
- def check(self, value):
- return callable(getattr(value, '__html__', None))
-
- def to_json(self, value):
- return text_type(value.__html__())
-
- def to_python(self, value):
- return Markup(value)
-
-
-class TagUUID(JSONTag):
- __slots__ = ()
- key = ' u'
-
- def check(self, value):
- return isinstance(value, UUID)
-
- def to_json(self, value):
- return value.hex
-
- def to_python(self, value):
- return UUID(value)
-
-
-class TagDateTime(JSONTag):
- __slots__ = ()
- key = ' d'
-
- def check(self, value):
- return isinstance(value, datetime)
-
- def to_json(self, value):
- return http_date(value)
-
- def to_python(self, value):
- return parse_date(value)
-
-
-class TaggedJSONSerializer(object):
- """Serializer that uses a tag system to compactly represent objects that
- are not JSON types. Passed as the intermediate serializer to
- :class:`itsdangerous.Serializer`.
-
- The following extra types are supported:
-
- * :class:`dict`
- * :class:`tuple`
- * :class:`bytes`
- * :class:`~flask.Markup`
- * :class:`~uuid.UUID`
- * :class:`~datetime.datetime`
- """
-
- __slots__ = ('tags', 'order')
-
- #: Tag classes to bind when creating the serializer. Other tags can be
- #: added later using :meth:`~register`.
- default_tags = [
- TagDict, PassDict, TagTuple, PassList, TagBytes, TagMarkup, TagUUID,
- TagDateTime,
- ]
-
- def __init__(self):
- self.tags = {}
- self.order = []
-
- for cls in self.default_tags:
- self.register(cls)
-
- def register(self, tag_class, force=False, index=None):
- """Register a new tag with this serializer.
-
- :param tag_class: tag class to register. Will be instantiated with this
- serializer instance.
- :param force: overwrite an existing tag. If false (default), a
- :exc:`KeyError` is raised.
- :param index: index to insert the new tag in the tag order. Useful when
- the new tag is a special case of an existing tag. If ``None``
- (default), the tag is appended to the end of the order.
-
- :raise KeyError: if the tag key is already registered and ``force`` is
- not true.
- """
- tag = tag_class(self)
- key = tag.key
-
- if key is not None:
- if not force and key in self.tags:
- raise KeyError("Tag '{0}' is already registered.".format(key))
-
- self.tags[key] = tag
-
- if index is None:
- self.order.append(tag)
- else:
- self.order.insert(index, tag)
-
- def tag(self, value):
- """Convert a value to a tagged representation if necessary."""
- for tag in self.order:
- if tag.check(value):
- return tag.tag(value)
-
- return value
-
- def untag(self, value):
- """Convert a tagged representation back to the original type."""
- if len(value) != 1:
- return value
-
- key = next(iter(value))
-
- if key not in self.tags:
- return value
-
- return self.tags[key].to_python(value[key])
-
- def dumps(self, value):
- """Tag the value and dump it to a compact JSON string."""
- return dumps(self.tag(value), separators=(',', ':'))
-
- def loads(self, value):
- """Load data from a JSON string and deserialized any tagged objects."""
- return loads(value, object_hook=self.untag)
diff --git a/python/flask/logging.py b/python/flask/logging.py
deleted file mode 100644
index 389c2c2..0000000
--- a/python/flask/logging.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-flask.logging
-~~~~~~~~~~~~~
-
-:copyright: © 2010 by the Pallets team.
-:license: BSD, see LICENSE for more details.
-"""
-
-from __future__ import absolute_import
-
-import logging
-import sys
-
-from werkzeug.local import LocalProxy
-
-from .globals import request
-
-
-@LocalProxy
-def wsgi_errors_stream():
- """Find the most appropriate error stream for the application. If a request
- is active, log to ``wsgi.errors``, otherwise use ``sys.stderr``.
-
- If you configure your own :class:`logging.StreamHandler`, you may want to
- use this for the stream. If you are using file or dict configuration and
- can't import this directly, you can refer to it as
- ``ext://flask.logging.wsgi_errors_stream``.
- """
- return request.environ['wsgi.errors'] if request else sys.stderr
-
-
-def has_level_handler(logger):
- """Check if there is a handler in the logging chain that will handle the
- given logger's :meth:`effective level <~logging.Logger.getEffectiveLevel>`.
- """
- level = logger.getEffectiveLevel()
- current = logger
-
- while current:
- if any(handler.level <= level for handler in current.handlers):
- return True
-
- if not current.propagate:
- break
-
- current = current.parent
-
- return False
-
-
-#: Log messages to :func:`~flask.logging.wsgi_errors_stream` with the format
-#: ``[%(asctime)s] %(levelname)s in %(module)s: %(message)s``.
-default_handler = logging.StreamHandler(wsgi_errors_stream)
-default_handler.setFormatter(logging.Formatter(
- '[%(asctime)s] %(levelname)s in %(module)s: %(message)s'
-))
-
-
-def create_logger(app):
- """Get the ``'flask.app'`` logger and configure it if needed.
-
- When :attr:`~flask.Flask.debug` is enabled, set the logger level to
- :data:`logging.DEBUG` if it is not set.
-
- If there is no handler for the logger's effective level, add a
- :class:`~logging.StreamHandler` for
- :func:`~flask.logging.wsgi_errors_stream` with a basic format.
- """
- logger = logging.getLogger('flask.app')
-
- if app.debug and logger.level == logging.NOTSET:
- logger.setLevel(logging.DEBUG)
-
- if not has_level_handler(logger):
- logger.addHandler(default_handler)
-
- return logger
diff --git a/python/flask/sessions.py b/python/flask/sessions.py
deleted file mode 100644
index c8b7d4e..0000000
--- a/python/flask/sessions.py
+++ /dev/null
@@ -1,385 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.sessions
- ~~~~~~~~~~~~~~
-
- Implements cookie based sessions based on itsdangerous.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import hashlib
-import warnings
-from datetime import datetime
-
-from itsdangerous import BadSignature, URLSafeTimedSerializer
-from werkzeug.datastructures import CallbackDict
-
-from flask._compat import collections_abc
-from flask.helpers import is_ip, total_seconds
-from flask.json.tag import TaggedJSONSerializer
-
-
-class SessionMixin(collections_abc.MutableMapping):
- """Expands a basic dictionary with session attributes."""
-
- @property
- def permanent(self):
- """This reflects the ``'_permanent'`` key in the dict."""
- return self.get('_permanent', False)
-
- @permanent.setter
- def permanent(self, value):
- self['_permanent'] = bool(value)
-
- #: Some implementations can detect whether a session is newly
- #: created, but that is not guaranteed. Use with caution. The mixin
- # default is hard-coded ``False``.
- new = False
-
- #: Some implementations can detect changes to the session and set
- #: this when that happens. The mixin default is hard coded to
- #: ``True``.
- modified = True
-
- #: Some implementations can detect when session data is read or
- #: written and set this when that happens. The mixin default is hard
- #: coded to ``True``.
- accessed = True
-
-
-class SecureCookieSession(CallbackDict, SessionMixin):
- """Base class for sessions based on signed cookies.
-
- This session backend will set the :attr:`modified` and
- :attr:`accessed` attributes. It cannot reliably track whether a
- session is new (vs. empty), so :attr:`new` remains hard coded to
- ``False``.
- """
-
- #: When data is changed, this is set to ``True``. Only the session
- #: dictionary itself is tracked; if the session contains mutable
- #: data (for example a nested dict) then this must be set to
- #: ``True`` manually when modifying that data. The session cookie
- #: will only be written to the response if this is ``True``.
- modified = False
-
- #: When data is read or written, this is set to ``True``. Used by
- # :class:`.SecureCookieSessionInterface` to add a ``Vary: Cookie``
- #: header, which allows caching proxies to cache different pages for
- #: different users.
- accessed = False
-
- def __init__(self, initial=None):
- def on_update(self):
- self.modified = True
- self.accessed = True
-
- super(SecureCookieSession, self).__init__(initial, on_update)
-
- def __getitem__(self, key):
- self.accessed = True
- return super(SecureCookieSession, self).__getitem__(key)
-
- def get(self, key, default=None):
- self.accessed = True
- return super(SecureCookieSession, self).get(key, default)
-
- def setdefault(self, key, default=None):
- self.accessed = True
- return super(SecureCookieSession, self).setdefault(key, default)
-
-
-class NullSession(SecureCookieSession):
- """Class used to generate nicer error messages if sessions are not
- available. Will still allow read-only access to the empty session
- but fail on setting.
- """
-
- def _fail(self, *args, **kwargs):
- raise RuntimeError('The session is unavailable because no secret '
- 'key was set. Set the secret_key on the '
- 'application to something unique and secret.')
- __setitem__ = __delitem__ = clear = pop = popitem = \
- update = setdefault = _fail
- del _fail
-
-
-class SessionInterface(object):
- """The basic interface you have to implement in order to replace the
- default session interface which uses werkzeug's securecookie
- implementation. The only methods you have to implement are
- :meth:`open_session` and :meth:`save_session`, the others have
- useful defaults which you don't need to change.
-
- The session object returned by the :meth:`open_session` method has to
- provide a dictionary like interface plus the properties and methods
- from the :class:`SessionMixin`. We recommend just subclassing a dict
- and adding that mixin::
-
- class Session(dict, SessionMixin):
- pass
-
- If :meth:`open_session` returns ``None`` Flask will call into
- :meth:`make_null_session` to create a session that acts as replacement
- if the session support cannot work because some requirement is not
- fulfilled. The default :class:`NullSession` class that is created
- will complain that the secret key was not set.
-
- To replace the session interface on an application all you have to do
- is to assign :attr:`flask.Flask.session_interface`::
-
- app = Flask(__name__)
- app.session_interface = MySessionInterface()
-
- .. versionadded:: 0.8
- """
-
- #: :meth:`make_null_session` will look here for the class that should
- #: be created when a null session is requested. Likewise the
- #: :meth:`is_null_session` method will perform a typecheck against
- #: this type.
- null_session_class = NullSession
-
- #: A flag that indicates if the session interface is pickle based.
- #: This can be used by Flask extensions to make a decision in regards
- #: to how to deal with the session object.
- #:
- #: .. versionadded:: 0.10
- pickle_based = False
-
- def make_null_session(self, app):
- """Creates a null session which acts as a replacement object if the
- real session support could not be loaded due to a configuration
- error. This mainly aids the user experience because the job of the
- null session is to still support lookup without complaining but
- modifications are answered with a helpful error message of what
- failed.
-
- This creates an instance of :attr:`null_session_class` by default.
- """
- return self.null_session_class()
-
- def is_null_session(self, obj):
- """Checks if a given object is a null session. Null sessions are
- not asked to be saved.
-
- This checks if the object is an instance of :attr:`null_session_class`
- by default.
- """
- return isinstance(obj, self.null_session_class)
-
- def get_cookie_domain(self, app):
- """Returns the domain that should be set for the session cookie.
-
- Uses ``SESSION_COOKIE_DOMAIN`` if it is configured, otherwise
- falls back to detecting the domain based on ``SERVER_NAME``.
-
- Once detected (or if not set at all), ``SESSION_COOKIE_DOMAIN`` is
- updated to avoid re-running the logic.
- """
-
- rv = app.config['SESSION_COOKIE_DOMAIN']
-
- # set explicitly, or cached from SERVER_NAME detection
- # if False, return None
- if rv is not None:
- return rv if rv else None
-
- rv = app.config['SERVER_NAME']
-
- # server name not set, cache False to return none next time
- if not rv:
- app.config['SESSION_COOKIE_DOMAIN'] = False
- return None
-
- # chop off the port which is usually not supported by browsers
- # remove any leading '.' since we'll add that later
- rv = rv.rsplit(':', 1)[0].lstrip('.')
-
- if '.' not in rv:
- # Chrome doesn't allow names without a '.'
- # this should only come up with localhost
- # hack around this by not setting the name, and show a warning
- warnings.warn(
- '"{rv}" is not a valid cookie domain, it must contain a ".".'
- ' Add an entry to your hosts file, for example'
- ' "{rv}.localdomain", and use that instead.'.format(rv=rv)
- )
- app.config['SESSION_COOKIE_DOMAIN'] = False
- return None
-
- ip = is_ip(rv)
-
- if ip:
- warnings.warn(
- 'The session cookie domain is an IP address. This may not work'
- ' as intended in some browsers. Add an entry to your hosts'
- ' file, for example "localhost.localdomain", and use that'
- ' instead.'
- )
-
- # if this is not an ip and app is mounted at the root, allow subdomain
- # matching by adding a '.' prefix
- if self.get_cookie_path(app) == '/' and not ip:
- rv = '.' + rv
-
- app.config['SESSION_COOKIE_DOMAIN'] = rv
- return rv
-
- def get_cookie_path(self, app):
- """Returns the path for which the cookie should be valid. The
- default implementation uses the value from the ``SESSION_COOKIE_PATH``
- config var if it's set, and falls back to ``APPLICATION_ROOT`` or
- uses ``/`` if it's ``None``.
- """
- return app.config['SESSION_COOKIE_PATH'] \
- or app.config['APPLICATION_ROOT']
-
- def get_cookie_httponly(self, app):
- """Returns True if the session cookie should be httponly. This
- currently just returns the value of the ``SESSION_COOKIE_HTTPONLY``
- config var.
- """
- return app.config['SESSION_COOKIE_HTTPONLY']
-
- def get_cookie_secure(self, app):
- """Returns True if the cookie should be secure. This currently
- just returns the value of the ``SESSION_COOKIE_SECURE`` setting.
- """
- return app.config['SESSION_COOKIE_SECURE']
-
- def get_cookie_samesite(self, app):
- """Return ``'Strict'`` or ``'Lax'`` if the cookie should use the
- ``SameSite`` attribute. This currently just returns the value of
- the :data:`SESSION_COOKIE_SAMESITE` setting.
- """
- return app.config['SESSION_COOKIE_SAMESITE']
-
- def get_expiration_time(self, app, session):
- """A helper method that returns an expiration date for the session
- or ``None`` if the session is linked to the browser session. The
- default implementation returns now + the permanent session
- lifetime configured on the application.
- """
- if session.permanent:
- return datetime.utcnow() + app.permanent_session_lifetime
-
- def should_set_cookie(self, app, session):
- """Used by session backends to determine if a ``Set-Cookie`` header
- should be set for this session cookie for this response. If the session
- has been modified, the cookie is set. If the session is permanent and
- the ``SESSION_REFRESH_EACH_REQUEST`` config is true, the cookie is
- always set.
-
- This check is usually skipped if the session was deleted.
-
- .. versionadded:: 0.11
- """
-
- return session.modified or (
- session.permanent and app.config['SESSION_REFRESH_EACH_REQUEST']
- )
-
- def open_session(self, app, request):
- """This method has to be implemented and must either return ``None``
- in case the loading failed because of a configuration error or an
- instance of a session object which implements a dictionary like
- interface + the methods and attributes on :class:`SessionMixin`.
- """
- raise NotImplementedError()
-
- def save_session(self, app, session, response):
- """This is called for actual sessions returned by :meth:`open_session`
- at the end of the request. This is still called during a request
- context so if you absolutely need access to the request you can do
- that.
- """
- raise NotImplementedError()
-
-
-session_json_serializer = TaggedJSONSerializer()
-
-
-class SecureCookieSessionInterface(SessionInterface):
- """The default session interface that stores sessions in signed cookies
- through the :mod:`itsdangerous` module.
- """
- #: the salt that should be applied on top of the secret key for the
- #: signing of cookie based sessions.
- salt = 'cookie-session'
- #: the hash function to use for the signature. The default is sha1
- digest_method = staticmethod(hashlib.sha1)
- #: the name of the itsdangerous supported key derivation. The default
- #: is hmac.
- key_derivation = 'hmac'
- #: A python serializer for the payload. The default is a compact
- #: JSON derived serializer with support for some extra Python types
- #: such as datetime objects or tuples.
- serializer = session_json_serializer
- session_class = SecureCookieSession
-
- def get_signing_serializer(self, app):
- if not app.secret_key:
- return None
- signer_kwargs = dict(
- key_derivation=self.key_derivation,
- digest_method=self.digest_method
- )
- return URLSafeTimedSerializer(app.secret_key, salt=self.salt,
- serializer=self.serializer,
- signer_kwargs=signer_kwargs)
-
- def open_session(self, app, request):
- s = self.get_signing_serializer(app)
- if s is None:
- return None
- val = request.cookies.get(app.session_cookie_name)
- if not val:
- return self.session_class()
- max_age = total_seconds(app.permanent_session_lifetime)
- try:
- data = s.loads(val, max_age=max_age)
- return self.session_class(data)
- except BadSignature:
- return self.session_class()
-
- def save_session(self, app, session, response):
- domain = self.get_cookie_domain(app)
- path = self.get_cookie_path(app)
-
- # If the session is modified to be empty, remove the cookie.
- # If the session is empty, return without setting the cookie.
- if not session:
- if session.modified:
- response.delete_cookie(
- app.session_cookie_name,
- domain=domain,
- path=path
- )
-
- return
-
- # Add a "Vary: Cookie" header if the session was accessed at all.
- if session.accessed:
- response.vary.add('Cookie')
-
- if not self.should_set_cookie(app, session):
- return
-
- httponly = self.get_cookie_httponly(app)
- secure = self.get_cookie_secure(app)
- samesite = self.get_cookie_samesite(app)
- expires = self.get_expiration_time(app, session)
- val = self.get_signing_serializer(app).dumps(dict(session))
- response.set_cookie(
- app.session_cookie_name,
- val,
- expires=expires,
- httponly=httponly,
- domain=domain,
- path=path,
- secure=secure,
- samesite=samesite
- )
diff --git a/python/flask/signals.py b/python/flask/signals.py
deleted file mode 100644
index 18f2630..0000000
--- a/python/flask/signals.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.signals
- ~~~~~~~~~~~~~
-
- Implements signals based on blinker if available, otherwise
- falls silently back to a noop.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-signals_available = False
-try:
- from blinker import Namespace
- signals_available = True
-except ImportError:
- class Namespace(object):
- def signal(self, name, doc=None):
- return _FakeSignal(name, doc)
-
- class _FakeSignal(object):
- """If blinker is unavailable, create a fake class with the same
- interface that allows sending of signals but will fail with an
- error on anything else. Instead of doing anything on send, it
- will just ignore the arguments and do nothing instead.
- """
-
- def __init__(self, name, doc=None):
- self.name = name
- self.__doc__ = doc
- def _fail(self, *args, **kwargs):
- raise RuntimeError('signalling support is unavailable '
- 'because the blinker library is '
- 'not installed.')
- send = lambda *a, **kw: None
- connect = disconnect = has_receivers_for = receivers_for = \
- temporarily_connected_to = connected_to = _fail
- del _fail
-
-# The namespace for code signals. If you are not Flask code, do
-# not put signals in here. Create your own namespace instead.
-_signals = Namespace()
-
-
-# Core signals. For usage examples grep the source code or consult
-# the API documentation in docs/api.rst as well as docs/signals.rst
-template_rendered = _signals.signal('template-rendered')
-before_render_template = _signals.signal('before-render-template')
-request_started = _signals.signal('request-started')
-request_finished = _signals.signal('request-finished')
-request_tearing_down = _signals.signal('request-tearing-down')
-got_request_exception = _signals.signal('got-request-exception')
-appcontext_tearing_down = _signals.signal('appcontext-tearing-down')
-appcontext_pushed = _signals.signal('appcontext-pushed')
-appcontext_popped = _signals.signal('appcontext-popped')
-message_flashed = _signals.signal('message-flashed')
diff --git a/python/flask/templating.py b/python/flask/templating.py
deleted file mode 100644
index 0240200..0000000
--- a/python/flask/templating.py
+++ /dev/null
@@ -1,150 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.templating
- ~~~~~~~~~~~~~~~~
-
- Implements the bridge to Jinja2.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-from jinja2 import BaseLoader, Environment as BaseEnvironment, \
- TemplateNotFound
-
-from .globals import _request_ctx_stack, _app_ctx_stack
-from .signals import template_rendered, before_render_template
-
-
-def _default_template_ctx_processor():
- """Default template context processor. Injects `request`,
- `session` and `g`.
- """
- reqctx = _request_ctx_stack.top
- appctx = _app_ctx_stack.top
- rv = {}
- if appctx is not None:
- rv['g'] = appctx.g
- if reqctx is not None:
- rv['request'] = reqctx.request
- rv['session'] = reqctx.session
- return rv
-
-
-class Environment(BaseEnvironment):
- """Works like a regular Jinja2 environment but has some additional
- knowledge of how Flask's blueprint works so that it can prepend the
- name of the blueprint to referenced templates if necessary.
- """
-
- def __init__(self, app, **options):
- if 'loader' not in options:
- options['loader'] = app.create_global_jinja_loader()
- BaseEnvironment.__init__(self, **options)
- self.app = app
-
-
-class DispatchingJinjaLoader(BaseLoader):
- """A loader that looks for templates in the application and all
- the blueprint folders.
- """
-
- def __init__(self, app):
- self.app = app
-
- def get_source(self, environment, template):
- if self.app.config['EXPLAIN_TEMPLATE_LOADING']:
- return self._get_source_explained(environment, template)
- return self._get_source_fast(environment, template)
-
- def _get_source_explained(self, environment, template):
- attempts = []
- trv = None
-
- for srcobj, loader in self._iter_loaders(template):
- try:
- rv = loader.get_source(environment, template)
- if trv is None:
- trv = rv
- except TemplateNotFound:
- rv = None
- attempts.append((loader, srcobj, rv))
-
- from .debughelpers import explain_template_loading_attempts
- explain_template_loading_attempts(self.app, template, attempts)
-
- if trv is not None:
- return trv
- raise TemplateNotFound(template)
-
- def _get_source_fast(self, environment, template):
- for srcobj, loader in self._iter_loaders(template):
- try:
- return loader.get_source(environment, template)
- except TemplateNotFound:
- continue
- raise TemplateNotFound(template)
-
- def _iter_loaders(self, template):
- loader = self.app.jinja_loader
- if loader is not None:
- yield self.app, loader
-
- for blueprint in self.app.iter_blueprints():
- loader = blueprint.jinja_loader
- if loader is not None:
- yield blueprint, loader
-
- def list_templates(self):
- result = set()
- loader = self.app.jinja_loader
- if loader is not None:
- result.update(loader.list_templates())
-
- for blueprint in self.app.iter_blueprints():
- loader = blueprint.jinja_loader
- if loader is not None:
- for template in loader.list_templates():
- result.add(template)
-
- return list(result)
-
-
-def _render(template, context, app):
- """Renders the template and fires the signal"""
-
- before_render_template.send(app, template=template, context=context)
- rv = template.render(context)
- template_rendered.send(app, template=template, context=context)
- return rv
-
-
-def render_template(template_name_or_list, **context):
- """Renders a template from the template folder with the given
- context.
-
- :param template_name_or_list: the name of the template to be
- rendered, or an iterable with template names
- the first one existing will be rendered
- :param context: the variables that should be available in the
- context of the template.
- """
- ctx = _app_ctx_stack.top
- ctx.app.update_template_context(context)
- return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
- context, ctx.app)
-
-
-def render_template_string(source, **context):
- """Renders a template from the given template source string
- with the given context. Template variables will be autoescaped.
-
- :param source: the source code of the template to be
- rendered
- :param context: the variables that should be available in the
- context of the template.
- """
- ctx = _app_ctx_stack.top
- ctx.app.update_template_context(context)
- return _render(ctx.app.jinja_env.from_string(source),
- context, ctx.app)
diff --git a/python/flask/testing.py b/python/flask/testing.py
deleted file mode 100644
index 114c5cc..0000000
--- a/python/flask/testing.py
+++ /dev/null
@@ -1,246 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.testing
- ~~~~~~~~~~~~~
-
- Implements test support helpers. This module is lazily imported
- and usually not used in production environments.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-import werkzeug
-from contextlib import contextmanager
-
-from click.testing import CliRunner
-from flask.cli import ScriptInfo
-from werkzeug.test import Client, EnvironBuilder
-from flask import _request_ctx_stack
-from flask.json import dumps as json_dumps
-from werkzeug.urls import url_parse
-
-
-def make_test_environ_builder(
- app, path='/', base_url=None, subdomain=None, url_scheme=None,
- *args, **kwargs
-):
- """Create a :class:`~werkzeug.test.EnvironBuilder`, taking some
- defaults from the application.
-
- :param app: The Flask application to configure the environment from.
- :param path: URL path being requested.
- :param base_url: Base URL where the app is being served, which
- ``path`` is relative to. If not given, built from
- :data:`PREFERRED_URL_SCHEME`, ``subdomain``,
- :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`.
- :param subdomain: Subdomain name to append to :data:`SERVER_NAME`.
- :param url_scheme: Scheme to use instead of
- :data:`PREFERRED_URL_SCHEME`.
- :param json: If given, this is serialized as JSON and passed as
- ``data``. Also defaults ``content_type`` to
- ``application/json``.
- :param args: other positional arguments passed to
- :class:`~werkzeug.test.EnvironBuilder`.
- :param kwargs: other keyword arguments passed to
- :class:`~werkzeug.test.EnvironBuilder`.
- """
-
- assert (
- not (base_url or subdomain or url_scheme)
- or (base_url is not None) != bool(subdomain or url_scheme)
- ), 'Cannot pass "subdomain" or "url_scheme" with "base_url".'
-
- if base_url is None:
- http_host = app.config.get('SERVER_NAME') or 'localhost'
- app_root = app.config['APPLICATION_ROOT']
-
- if subdomain:
- http_host = '{0}.{1}'.format(subdomain, http_host)
-
- if url_scheme is None:
- url_scheme = app.config['PREFERRED_URL_SCHEME']
-
- url = url_parse(path)
- base_url = '{scheme}://{netloc}/{path}'.format(
- scheme=url.scheme or url_scheme,
- netloc=url.netloc or http_host,
- path=app_root.lstrip('/')
- )
- path = url.path
-
- if url.query:
- sep = b'?' if isinstance(url.query, bytes) else '?'
- path += sep + url.query
-
- # TODO use EnvironBuilder.json_dumps once we require Werkzeug 0.15
- if 'json' in kwargs:
- assert 'data' not in kwargs, "Client cannot provide both 'json' and 'data'."
- kwargs['data'] = json_dumps(kwargs.pop('json'), app=app)
-
- if 'content_type' not in kwargs:
- kwargs['content_type'] = 'application/json'
-
- return EnvironBuilder(path, base_url, *args, **kwargs)
-
-
-class FlaskClient(Client):
- """Works like a regular Werkzeug test client but has some knowledge about
- how Flask works to defer the cleanup of the request context stack to the
- end of a ``with`` body when used in a ``with`` statement. For general
- information about how to use this class refer to
- :class:`werkzeug.test.Client`.
-
- .. versionchanged:: 0.12
- `app.test_client()` includes preset default environment, which can be
- set after instantiation of the `app.test_client()` object in
- `client.environ_base`.
-
- Basic usage is outlined in the :ref:`testing` chapter.
- """
-
- preserve_context = False
-
- def __init__(self, *args, **kwargs):
- super(FlaskClient, self).__init__(*args, **kwargs)
- self.environ_base = {
- "REMOTE_ADDR": "127.0.0.1",
- "HTTP_USER_AGENT": "werkzeug/" + werkzeug.__version__
- }
-
- @contextmanager
- def session_transaction(self, *args, **kwargs):
- """When used in combination with a ``with`` statement this opens a
- session transaction. This can be used to modify the session that
- the test client uses. Once the ``with`` block is left the session is
- stored back.
-
- ::
-
- with client.session_transaction() as session:
- session['value'] = 42
-
- Internally this is implemented by going through a temporary test
- request context and since session handling could depend on
- request variables this function accepts the same arguments as
- :meth:`~flask.Flask.test_request_context` which are directly
- passed through.
- """
- if self.cookie_jar is None:
- raise RuntimeError('Session transactions only make sense '
- 'with cookies enabled.')
- app = self.application
- environ_overrides = kwargs.setdefault('environ_overrides', {})
- self.cookie_jar.inject_wsgi(environ_overrides)
- outer_reqctx = _request_ctx_stack.top
- with app.test_request_context(*args, **kwargs) as c:
- session_interface = app.session_interface
- sess = session_interface.open_session(app, c.request)
- if sess is None:
- raise RuntimeError('Session backend did not open a session. '
- 'Check the configuration')
-
- # Since we have to open a new request context for the session
- # handling we want to make sure that we hide out own context
- # from the caller. By pushing the original request context
- # (or None) on top of this and popping it we get exactly that
- # behavior. It's important to not use the push and pop
- # methods of the actual request context object since that would
- # mean that cleanup handlers are called
- _request_ctx_stack.push(outer_reqctx)
- try:
- yield sess
- finally:
- _request_ctx_stack.pop()
-
- resp = app.response_class()
- if not session_interface.is_null_session(sess):
- session_interface.save_session(app, sess, resp)
- headers = resp.get_wsgi_headers(c.request.environ)
- self.cookie_jar.extract_wsgi(c.request.environ, headers)
-
- def open(self, *args, **kwargs):
- as_tuple = kwargs.pop('as_tuple', False)
- buffered = kwargs.pop('buffered', False)
- follow_redirects = kwargs.pop('follow_redirects', False)
-
- if (
- not kwargs and len(args) == 1
- and isinstance(args[0], (EnvironBuilder, dict))
- ):
- environ = self.environ_base.copy()
-
- if isinstance(args[0], EnvironBuilder):
- environ.update(args[0].get_environ())
- else:
- environ.update(args[0])
-
- environ['flask._preserve_context'] = self.preserve_context
- else:
- kwargs.setdefault('environ_overrides', {}) \
- ['flask._preserve_context'] = self.preserve_context
- kwargs.setdefault('environ_base', self.environ_base)
- builder = make_test_environ_builder(
- self.application, *args, **kwargs
- )
-
- try:
- environ = builder.get_environ()
- finally:
- builder.close()
-
- return Client.open(
- self, environ,
- as_tuple=as_tuple,
- buffered=buffered,
- follow_redirects=follow_redirects
- )
-
- def __enter__(self):
- if self.preserve_context:
- raise RuntimeError('Cannot nest client invocations')
- self.preserve_context = True
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.preserve_context = False
-
- # on exit we want to clean up earlier. Normally the request context
- # stays preserved until the next request in the same thread comes
- # in. See RequestGlobals.push() for the general behavior.
- top = _request_ctx_stack.top
- if top is not None and top.preserved:
- top.pop()
-
-
-class FlaskCliRunner(CliRunner):
- """A :class:`~click.testing.CliRunner` for testing a Flask app's
- CLI commands. Typically created using
- :meth:`~flask.Flask.test_cli_runner`. See :ref:`testing-cli`.
- """
- def __init__(self, app, **kwargs):
- self.app = app
- super(FlaskCliRunner, self).__init__(**kwargs)
-
- def invoke(self, cli=None, args=None, **kwargs):
- """Invokes a CLI command in an isolated environment. See
- :meth:`CliRunner.invoke <click.testing.CliRunner.invoke>` for
- full method documentation. See :ref:`testing-cli` for examples.
-
- If the ``obj`` argument is not given, passes an instance of
- :class:`~flask.cli.ScriptInfo` that knows how to load the Flask
- app being tested.
-
- :param cli: Command object to invoke. Default is the app's
- :attr:`~flask.app.Flask.cli` group.
- :param args: List of strings to invoke the command with.
-
- :return: a :class:`~click.testing.Result` object.
- """
- if cli is None:
- cli = self.app.cli
-
- if 'obj' not in kwargs:
- kwargs['obj'] = ScriptInfo(create_app=lambda: self.app)
-
- return super(FlaskCliRunner, self).invoke(cli, args, **kwargs)
diff --git a/python/flask/views.py b/python/flask/views.py
deleted file mode 100644
index 1f2c997..0000000
--- a/python/flask/views.py
+++ /dev/null
@@ -1,158 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.views
- ~~~~~~~~~~~
-
- This module provides class-based views inspired by the ones in Django.
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-from .globals import request
-from ._compat import with_metaclass
-
-
-http_method_funcs = frozenset(['get', 'post', 'head', 'options',
- 'delete', 'put', 'trace', 'patch'])
-
-
-class View(object):
- """Alternative way to use view functions. A subclass has to implement
- :meth:`dispatch_request` which is called with the view arguments from
- the URL routing system. If :attr:`methods` is provided the methods
- do not have to be passed to the :meth:`~flask.Flask.add_url_rule`
- method explicitly::
-
- class MyView(View):
- methods = ['GET']
-
- def dispatch_request(self, name):
- return 'Hello %s!' % name
-
- app.add_url_rule('/hello/<name>', view_func=MyView.as_view('myview'))
-
- When you want to decorate a pluggable view you will have to either do that
- when the view function is created (by wrapping the return value of
- :meth:`as_view`) or you can use the :attr:`decorators` attribute::
-
- class SecretView(View):
- methods = ['GET']
- decorators = [superuser_required]
-
- def dispatch_request(self):
- ...
-
- The decorators stored in the decorators list are applied one after another
- when the view function is created. Note that you can *not* use the class
- based decorators since those would decorate the view class and not the
- generated view function!
- """
-
- #: A list of methods this view can handle.
- methods = None
-
- #: Setting this disables or force-enables the automatic options handling.
- provide_automatic_options = None
-
- #: The canonical way to decorate class-based views is to decorate the
- #: return value of as_view(). However since this moves parts of the
- #: logic from the class declaration to the place where it's hooked
- #: into the routing system.
- #:
- #: You can place one or more decorators in this list and whenever the
- #: view function is created the result is automatically decorated.
- #:
- #: .. versionadded:: 0.8
- decorators = ()
-
- def dispatch_request(self):
- """Subclasses have to override this method to implement the
- actual view function code. This method is called with all
- the arguments from the URL rule.
- """
- raise NotImplementedError()
-
- @classmethod
- def as_view(cls, name, *class_args, **class_kwargs):
- """Converts the class into an actual view function that can be used
- with the routing system. Internally this generates a function on the
- fly which will instantiate the :class:`View` on each request and call
- the :meth:`dispatch_request` method on it.
-
- The arguments passed to :meth:`as_view` are forwarded to the
- constructor of the class.
- """
- def view(*args, **kwargs):
- self = view.view_class(*class_args, **class_kwargs)
- return self.dispatch_request(*args, **kwargs)
-
- if cls.decorators:
- view.__name__ = name
- view.__module__ = cls.__module__
- for decorator in cls.decorators:
- view = decorator(view)
-
- # We attach the view class to the view function for two reasons:
- # first of all it allows us to easily figure out what class-based
- # view this thing came from, secondly it's also used for instantiating
- # the view class so you can actually replace it with something else
- # for testing purposes and debugging.
- view.view_class = cls
- view.__name__ = name
- view.__doc__ = cls.__doc__
- view.__module__ = cls.__module__
- view.methods = cls.methods
- view.provide_automatic_options = cls.provide_automatic_options
- return view
-
-
-class MethodViewType(type):
- """Metaclass for :class:`MethodView` that determines what methods the view
- defines.
- """
-
- def __init__(cls, name, bases, d):
- super(MethodViewType, cls).__init__(name, bases, d)
-
- if 'methods' not in d:
- methods = set()
-
- for key in http_method_funcs:
- if hasattr(cls, key):
- methods.add(key.upper())
-
- # If we have no method at all in there we don't want to add a
- # method list. This is for instance the case for the base class
- # or another subclass of a base method view that does not introduce
- # new methods.
- if methods:
- cls.methods = methods
-
-
-class MethodView(with_metaclass(MethodViewType, View)):
- """A class-based view that dispatches request methods to the corresponding
- class methods. For example, if you implement a ``get`` method, it will be
- used to handle ``GET`` requests. ::
-
- class CounterAPI(MethodView):
- def get(self):
- return session.get('counter', 0)
-
- def post(self):
- session['counter'] = session.get('counter', 0) + 1
- return 'OK'
-
- app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
- """
-
- def dispatch_request(self, *args, **kwargs):
- meth = getattr(self, request.method.lower(), None)
-
- # If the request method is HEAD and we don't have a handler for it
- # retry with GET.
- if meth is None and request.method == 'HEAD':
- meth = getattr(self, 'get', None)
-
- assert meth is not None, 'Unimplemented method %r' % request.method
- return meth(*args, **kwargs)
diff --git a/python/flask/wrappers.py b/python/flask/wrappers.py
deleted file mode 100644
index 12eff2c..0000000
--- a/python/flask/wrappers.py
+++ /dev/null
@@ -1,216 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- flask.wrappers
- ~~~~~~~~~~~~~~
-
- Implements the WSGI wrappers (request and response).
-
- :copyright: © 2010 by the Pallets team.
- :license: BSD, see LICENSE for more details.
-"""
-
-from werkzeug.exceptions import BadRequest
-from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase
-
-from flask import json
-from flask.globals import current_app
-
-
-class JSONMixin(object):
- """Common mixin for both request and response objects to provide JSON
- parsing capabilities.
-
- .. versionadded:: 1.0
- """
-
- _cached_json = (Ellipsis, Ellipsis)
-
- @property
- def is_json(self):
- """Check if the mimetype indicates JSON data, either
- :mimetype:`application/json` or :mimetype:`application/*+json`.
-
- .. versionadded:: 0.11
- """
- mt = self.mimetype
- return (
- mt == 'application/json'
- or (mt.startswith('application/')) and mt.endswith('+json')
- )
-
- @property
- def json(self):
- """This will contain the parsed JSON data if the mimetype indicates
- JSON (:mimetype:`application/json`, see :meth:`is_json`), otherwise it
- will be ``None``.
- """
- return self.get_json()
-
- def _get_data_for_json(self, cache):
- return self.get_data(cache=cache)
-
- def get_json(self, force=False, silent=False, cache=True):
- """Parse and return the data as JSON. If the mimetype does not
- indicate JSON (:mimetype:`application/json`, see
- :meth:`is_json`), this returns ``None`` unless ``force`` is
- true. If parsing fails, :meth:`on_json_loading_failed` is called
- and its return value is used as the return value.
-
- :param force: Ignore the mimetype and always try to parse JSON.
- :param silent: Silence parsing errors and return ``None``
- instead.
- :param cache: Store the parsed JSON to return for subsequent
- calls.
- """
- if cache and self._cached_json[silent] is not Ellipsis:
- return self._cached_json[silent]
-
- if not (force or self.is_json):
- return None
-
- data = self._get_data_for_json(cache=cache)
-
- try:
- rv = json.loads(data)
- except ValueError as e:
- if silent:
- rv = None
- if cache:
- normal_rv, _ = self._cached_json
- self._cached_json = (normal_rv, rv)
- else:
- rv = self.on_json_loading_failed(e)
- if cache:
- _, silent_rv = self._cached_json
- self._cached_json = (rv, silent_rv)
- else:
- if cache:
- self._cached_json = (rv, rv)
-
- return rv
-
- def on_json_loading_failed(self, e):
- """Called if :meth:`get_json` parsing fails and isn't silenced. If
- this method returns a value, it is used as the return value for
- :meth:`get_json`. The default implementation raises a
- :class:`BadRequest` exception.
-
- .. versionchanged:: 0.10
- Raise a :exc:`BadRequest` error instead of returning an error
- message as JSON. If you want that behavior you can add it by
- subclassing.
-
- .. versionadded:: 0.8
- """
- if current_app is not None and current_app.debug:
- raise BadRequest('Failed to decode JSON object: {0}'.format(e))
-
- raise BadRequest()
-
-
-class Request(RequestBase, JSONMixin):
- """The request object used by default in Flask. Remembers the
- matched endpoint and view arguments.
-
- It is what ends up as :class:`~flask.request`. If you want to replace
- the request object used you can subclass this and set
- :attr:`~flask.Flask.request_class` to your subclass.
-
- The request object is a :class:`~werkzeug.wrappers.Request` subclass and
- provides all of the attributes Werkzeug defines plus a few Flask
- specific ones.
- """
-
- #: The internal URL rule that matched the request. This can be
- #: useful to inspect which methods are allowed for the URL from
- #: a before/after handler (``request.url_rule.methods``) etc.
- #: Though if the request's method was invalid for the URL rule,
- #: the valid list is available in ``routing_exception.valid_methods``
- #: instead (an attribute of the Werkzeug exception :exc:`~werkzeug.exceptions.MethodNotAllowed`)
- #: because the request was never internally bound.
- #:
- #: .. versionadded:: 0.6
- url_rule = None
-
- #: A dict of view arguments that matched the request. If an exception
- #: happened when matching, this will be ``None``.
- view_args = None
-
- #: If matching the URL failed, this is the exception that will be
- #: raised / was raised as part of the request handling. This is
- #: usually a :exc:`~werkzeug.exceptions.NotFound` exception or
- #: something similar.
- routing_exception = None
-
- @property
- def max_content_length(self):
- """Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""
- if current_app:
- return current_app.config['MAX_CONTENT_LENGTH']
-
- @property
- def endpoint(self):
- """The endpoint that matched the request. This in combination with
- :attr:`view_args` can be used to reconstruct the same or a
- modified URL. If an exception happened when matching, this will
- be ``None``.
- """
- if self.url_rule is not None:
- return self.url_rule.endpoint
-
- @property
- def blueprint(self):
- """The name of the current blueprint"""
- if self.url_rule and '.' in self.url_rule.endpoint:
- return self.url_rule.endpoint.rsplit('.', 1)[0]
-
- def _load_form_data(self):
- RequestBase._load_form_data(self)
-
- # In debug mode we're replacing the files multidict with an ad-hoc
- # subclass that raises a different error for key errors.
- if (
- current_app
- and current_app.debug
- and self.mimetype != 'multipart/form-data'
- and not self.files
- ):
- from .debughelpers import attach_enctype_error_multidict
- attach_enctype_error_multidict(self)
-
-
-class Response(ResponseBase, JSONMixin):
- """The response object that is used by default in Flask. Works like the
- response object from Werkzeug but is set to have an HTML mimetype by
- default. Quite often you don't have to create this object yourself because
- :meth:`~flask.Flask.make_response` will take care of that for you.
-
- If you want to replace the response object used you can subclass this and
- set :attr:`~flask.Flask.response_class` to your subclass.
-
- .. versionchanged:: 1.0
- JSON support is added to the response, like the request. This is useful
- when testing to get the test client response data as JSON.
-
- .. versionchanged:: 1.0
-
- Added :attr:`max_cookie_size`.
- """
-
- default_mimetype = 'text/html'
-
- def _get_data_for_json(self, cache):
- return self.get_data()
-
- @property
- def max_cookie_size(self):
- """Read-only view of the :data:`MAX_COOKIE_SIZE` config key.
-
- See :attr:`~werkzeug.wrappers.BaseResponse.max_cookie_size` in
- Werkzeug's docs.
- """
- if current_app:
- return current_app.config['MAX_COOKIE_SIZE']
-
- # return Werkzeug's default when not in an app context
- return super(Response, self).max_cookie_size
diff --git a/python/gevent/__greenlet_primitives.cp36-win32.pyd b/python/gevent/__greenlet_primitives.cp36-win32.pyd
deleted file mode 100644
index 1f446b2..0000000
--- a/python/gevent/__greenlet_primitives.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__greenlet_primitives.pxd b/python/gevent/__greenlet_primitives.pxd
deleted file mode 100644
index 18381f1..0000000
--- a/python/gevent/__greenlet_primitives.pxd
+++ /dev/null
@@ -1,44 +0,0 @@
-cimport cython
-
-# This file must not cimport anything from gevent.
-
-cdef wref
-
-cdef BlockingSwitchOutError
-
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- object PyGreenlet_Switch(greenlet self, void* args, void* kwargs)
- void PyGreenlet_Import()
-
-@cython.final
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef bint _greenlet_imported
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-cdef inline object _greenlet_switch(greenlet self):
- return PyGreenlet_Switch(self, NULL, NULL)
-
-cdef class TrackedRawGreenlet(greenlet):
- pass
-
-cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet):
- cdef public loop
-
- cpdef switch(self)
- cpdef switch_out(self)
diff --git a/python/gevent/__hub_local.cp36-win32.pyd b/python/gevent/__hub_local.cp36-win32.pyd
deleted file mode 100644
index f75bd3d..0000000
--- a/python/gevent/__hub_local.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__hub_local.pxd b/python/gevent/__hub_local.pxd
deleted file mode 100644
index e7df56f..0000000
--- a/python/gevent/__hub_local.pxd
+++ /dev/null
@@ -1,17 +0,0 @@
-from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
-
-cdef _threadlocal
-
-cpdef get_hub_class()
-cpdef SwitchOutGreenletWithLoop get_hub_if_exists()
-cpdef set_hub(SwitchOutGreenletWithLoop hub)
-cpdef get_loop()
-cpdef set_loop(loop)
-
-# We can't cdef this, it won't do varargs.
-# cpdef WaitOperationsGreenlet get_hub(*args, **kwargs)
-
-# XXX: TODO: Move the definition of TrackedRawGreenlet
-# into a file that can be cython compiled so get_hub can
-# return that.
-cpdef SwitchOutGreenletWithLoop get_hub_noargs()
diff --git a/python/gevent/__hub_primitives.cp36-win32.pyd b/python/gevent/__hub_primitives.cp36-win32.pyd
deleted file mode 100644
index 649fff9..0000000
--- a/python/gevent/__hub_primitives.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__hub_primitives.pxd b/python/gevent/__hub_primitives.pxd
deleted file mode 100644
index 6d8a115..0000000
--- a/python/gevent/__hub_primitives.pxd
+++ /dev/null
@@ -1,69 +0,0 @@
-cimport cython
-
-from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
-from gevent.__hub_local cimport get_hub_noargs as get_hub
-
-from gevent.__waiter cimport Waiter
-from gevent.__waiter cimport MultipleWaiter
-
-cdef InvalidSwitchError
-cdef _waiter
-cdef _greenlet_primitives
-cdef traceback
-cdef _timeout_error
-cdef Timeout
-
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-@cython.final
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef bint _greenlet_imported
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-
-cdef class WaitOperationsGreenlet(SwitchOutGreenletWithLoop):
-
- cpdef wait(self, watcher)
- cpdef cancel_wait(self, watcher, error, close_watcher=*)
- cpdef _cancel_wait(self, watcher, error, close_watcher)
-
-cdef class _WaitIterator:
- cdef SwitchOutGreenletWithLoop _hub
- cdef MultipleWaiter _waiter
- cdef _switch
- cdef _timeout
- cdef _objects
- cdef _timer
- cdef Py_ssize_t _count
- cdef bint _begun
-
-
-
- cdef _cleanup(self)
-
-cpdef iwait_on_objects(objects, timeout=*, count=*)
-cpdef wait_on_objects(objects=*, timeout=*, count=*)
-
-cdef _primitive_wait(watcher, timeout, timeout_exc, WaitOperationsGreenlet hub)
-cpdef wait_on_watcher(watcher, timeout=*, timeout_exc=*, WaitOperationsGreenlet hub=*)
-cpdef wait_read(fileno, timeout=*, timeout_exc=*)
-cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*)
-cpdef wait_readwrite(fileno, timeout=*, timeout_exc=*, event=*)
-cpdef wait_on_socket(socket, watcher, timeout_exc=*)
diff --git a/python/gevent/__ident.cp36-win32.pyd b/python/gevent/__ident.cp36-win32.pyd
deleted file mode 100644
index 4e219f2..0000000
--- a/python/gevent/__ident.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__ident.pxd b/python/gevent/__ident.pxd
deleted file mode 100644
index 55e4307..0000000
--- a/python/gevent/__ident.pxd
+++ /dev/null
@@ -1,26 +0,0 @@
-cimport cython
-
-cdef extern from "Python.h":
-
- ctypedef class weakref.ref [object PyWeakReference]:
- pass
-
-cdef heappop
-cdef heappush
-cdef object WeakKeyDictionary
-cdef type ref
-
-@cython.internal
-@cython.final
-cdef class ValuedWeakRef(ref):
- cdef object value
-
-@cython.final
-cdef class IdentRegistry:
- cdef object _registry
- cdef list _available_idents
-
- @cython.final
- cpdef object get_ident(self, obj)
- @cython.final
- cpdef _return_ident(self, ValuedWeakRef ref)
diff --git a/python/gevent/__imap.cp36-win32.pyd b/python/gevent/__imap.cp36-win32.pyd
deleted file mode 100644
index 28ecbec..0000000
--- a/python/gevent/__imap.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__imap.pxd b/python/gevent/__imap.pxd
deleted file mode 100644
index 5e3e930..0000000
--- a/python/gevent/__imap.pxd
+++ /dev/null
@@ -1,45 +0,0 @@
-cimport cython
-from gevent._greenlet cimport Greenlet
-from gevent.__semaphore cimport Semaphore
-from gevent._queue cimport UnboundQueue
-
-@cython.freelist(100)
-@cython.internal
-@cython.final
-cdef class Failure:
- cdef readonly exc
- cdef raise_exception
-
-cdef inline _raise_exc(Failure failure)
-
-cdef class IMapUnordered(Greenlet):
- cdef bint _zipped
- cdef func
- cdef iterable
- cdef spawn
- cdef Semaphore _result_semaphore
- cdef int _outstanding_tasks
- cdef int _max_index
-
- cdef readonly UnboundQueue queue
- cdef readonly bint finished
-
- cdef _inext(self)
- cdef _ispawn(self, func, item, int item_index)
-
- # Passed to greenlet.link
- cpdef _on_result(self, greenlet)
- # Called directly
- cdef _on_finish(self, exception)
-
- cdef _iqueue_value_for_success(self, greenlet)
- cdef _iqueue_value_for_failure(self, greenlet)
- cdef _iqueue_value_for_self_finished(self)
- cdef _iqueue_value_for_self_failure(self, exception)
-
-cdef class IMap(IMapUnordered):
- cdef int index
- cdef dict _results
-
- @cython.locals(index=int)
- cdef _inext(self)
diff --git a/python/gevent/__init__.py b/python/gevent/__init__.py
deleted file mode 100644
index c9feb9a..0000000
--- a/python/gevent/__init__.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-"""
-gevent is a coroutine-based Python networking library that uses greenlet
-to provide a high-level synchronous API on top of libev event loop.
-
-See http://www.gevent.org/ for the documentation.
-
-.. versionchanged:: 1.3a2
- Add the `config` object.
-"""
-
-from __future__ import absolute_import
-
-from collections import namedtuple
-
-_version_info = namedtuple('version_info',
- ('major', 'minor', 'micro', 'releaselevel', 'serial'))
-
-#: The programatic version identifier. The fields have (roughly) the
-#: same meaning as :data:`sys.version_info`
-#: .. deprecated:: 1.2
-#: Use ``pkg_resources.parse_version(__version__)`` (or the equivalent
-#: ``packaging.version.Version(__version__)``).
-version_info = _version_info(1, 3, 0, 'dev', 0)
-
-#: The human-readable PEP 440 version identifier.
-#: Use ``pkg_resources.parse_version(__version__)`` or
-#: ``packaging.version.Version(__version__)`` to get a machine-usable
-#: value.
-__version__ = '1.3.6'
-
-
-__all__ = [
- 'get_hub',
- 'Greenlet',
- 'GreenletExit',
- 'spawn',
- 'spawn_later',
- 'spawn_raw',
- 'iwait',
- 'wait',
- 'killall',
- 'Timeout',
- 'with_timeout',
- 'getcurrent',
- 'sleep',
- 'idle',
- 'kill',
- 'signal', # deprecated
- 'signal_handler',
- 'fork',
- 'reinit',
- 'getswitchinterval',
- 'setswitchinterval',
- # Added in 1.3a2
- 'config',
-]
-
-
-import sys
-if sys.platform == 'win32':
- # trigger WSAStartup call
- import socket # pylint:disable=unused-import,useless-suppression
- del socket
-
-try:
- # Floating point number, in number of seconds,
- # like time.time
- getswitchinterval = sys.getswitchinterval
- setswitchinterval = sys.setswitchinterval
-except AttributeError:
- # Running on Python 2
- _switchinterval = 0.005
-
- def getswitchinterval():
- return _switchinterval
-
- def setswitchinterval(interval):
- # Weed out None and non-numbers. This is not
- # exactly exception compatible with the Python 3
- # versions.
- if interval > 0:
- global _switchinterval
- _switchinterval = interval
-
-from gevent._config import config
-from gevent._hub_local import get_hub
-from gevent._hub_primitives import iwait_on_objects as iwait
-from gevent._hub_primitives import wait_on_objects as wait
-
-from gevent.greenlet import Greenlet, joinall, killall
-joinall = joinall # export for pylint
-spawn = Greenlet.spawn
-spawn_later = Greenlet.spawn_later
-#: The singleton configuration object for gevent.
-config = config
-
-from gevent.timeout import Timeout, with_timeout
-from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, reinit
-try:
- from gevent.os import fork
-except ImportError:
- __all__.remove('fork')
-
-# See https://github.com/gevent/gevent/issues/648
-# A temporary backwards compatibility shim to enable users to continue
-# to treat 'from gevent import signal' as a callable, to matter whether
-# the 'gevent.signal' module has been imported first
-from gevent.hub import signal as _signal_class
-signal_handler = _signal_class
-from gevent import signal as _signal_module
-
-# The object 'gevent.signal' must:
-# - be callable, returning a gevent.hub.signal;
-# - answer True to isinstance(gevent.signal(...), gevent.signal);
-# - answer True to isinstance(gevent.signal(...), gevent.hub.signal)
-# - have all the attributes of the module 'gevent.signal';
-# - answer True to isinstance(gevent.signal, types.ModuleType) (optional)
-
-# The only way to do this is to use a metaclass, an instance of which (a class)
-# is put in sys.modules and is substituted for gevent.hub.signal.
-# This handles everything except the last one.
-
-
-class _signal_metaclass(type):
-
- def __getattr__(cls, name):
- return getattr(_signal_module, name)
-
- def __setattr__(cls, name, value):
- setattr(_signal_module, name, value)
-
- def __instancecheck__(cls, instance):
- return isinstance(instance, _signal_class)
-
- def __dir__(cls):
- return dir(_signal_module)
-
-
-class signal(object):
-
- __doc__ = _signal_module.__doc__
-
- def __new__(cls, *args, **kwargs):
- return _signal_class(*args, **kwargs)
-
-
-# The metaclass is applied after the class declaration
-# for Python 2/3 compatibility
-signal = _signal_metaclass(str("signal"),
- (),
- dict(signal.__dict__))
-
-sys.modules['gevent.signal'] = signal
-sys.modules['gevent.hub'].signal = signal
-
-del sys
-
-
-# the following makes hidden imports visible to freezing tools like
-# py2exe. see https://github.com/gevent/gevent/issues/181
-
-def __dependencies_for_freezing():
- # pylint:disable=unused-variable
- from gevent import core
- from gevent import resolver_thread
- from gevent import resolver_ares
- from gevent import socket as _socket
- from gevent import threadpool
- from gevent import thread
- from gevent import threading
- from gevent import select
- from gevent import subprocess
- import pprint
- import traceback
- import signal as _signal
-
-del __dependencies_for_freezing
diff --git a/python/gevent/__semaphore.cp36-win32.pyd b/python/gevent/__semaphore.cp36-win32.pyd
deleted file mode 100644
index 5458372..0000000
--- a/python/gevent/__semaphore.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__semaphore.pxd b/python/gevent/__semaphore.pxd
deleted file mode 100644
index 5c8ecf1..0000000
--- a/python/gevent/__semaphore.pxd
+++ /dev/null
@@ -1,54 +0,0 @@
-cimport cython
-
-from gevent.__hub_local cimport get_hub_noargs as get_hub
-cdef Timeout
-
-cdef bint _greenlet_imported
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-
-cdef void _init()
-
-
-cdef class Semaphore:
- cdef public int counter
- cdef readonly list _links
- cdef readonly object _notifier
- cdef public int _dirty
- cdef object __weakref__
-
- cpdef bint locked(self)
- cpdef int release(self) except -1000
- cpdef rawlink(self, object callback)
- cpdef unlink(self, object callback)
- cpdef _start_notify(self)
- cpdef _notify_links(self)
- cdef _do_wait(self, object timeout)
- cpdef int wait(self, object timeout=*) except -1000
- cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000
- cpdef __enter__(self)
- cpdef __exit__(self, object t, object v, object tb)
-
-cdef class BoundedSemaphore(Semaphore):
- cdef readonly int _initial_value
-
- cpdef int release(self) except -1000
diff --git a/python/gevent/__tracer.cp36-win32.pyd b/python/gevent/__tracer.cp36-win32.pyd
deleted file mode 100644
index a194af6..0000000
--- a/python/gevent/__tracer.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__tracer.pxd b/python/gevent/__tracer.pxd
deleted file mode 100644
index 454147e..0000000
--- a/python/gevent/__tracer.pxd
+++ /dev/null
@@ -1,43 +0,0 @@
-cimport cython
-
-cdef sys
-cdef traceback
-
-cdef settrace
-cdef getcurrent
-
-cdef format_run_info
-
-cdef perf_counter
-cdef gmctime
-
-
-cdef class GreenletTracer:
- cpdef readonly object active_greenlet
- cpdef readonly object previous_trace_function
- cpdef readonly Py_ssize_t greenlet_switch_counter
-
- cdef bint _killed
-
- cpdef _trace(self, str event, tuple args)
-
- @cython.locals(did_switch=bint)
- cpdef did_block_hub(self, hub)
-
- cpdef kill(self)
-
-@cython.internal
-cdef class _HubTracer(GreenletTracer):
- cpdef readonly object hub
- cpdef readonly double max_blocking_time
-
-
-cdef class HubSwitchTracer(_HubTracer):
- cpdef readonly double last_entered_hub
-
-cdef class MaxSwitchTracer(_HubTracer):
- cpdef readonly double max_blocking
- cpdef readonly double last_switch
-
- @cython.locals(switched_at=double)
- cpdef _trace(self, str event, tuple args)
diff --git a/python/gevent/__waiter.cp36-win32.pyd b/python/gevent/__waiter.cp36-win32.pyd
deleted file mode 100644
index f880a61..0000000
--- a/python/gevent/__waiter.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/__waiter.pxd b/python/gevent/__waiter.pxd
deleted file mode 100644
index 0763bae..0000000
--- a/python/gevent/__waiter.pxd
+++ /dev/null
@@ -1,48 +0,0 @@
-cimport cython
-
-from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
-from gevent.__hub_local cimport get_hub_noargs as get_hub
-
-cdef sys
-cdef ConcurrentObjectUseError
-
-
-cdef bint _greenlet_imported
-cdef _NONE
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-cdef class Waiter:
- cdef readonly SwitchOutGreenletWithLoop hub
- cdef readonly greenlet greenlet
- cdef readonly value
- cdef _exception
-
- cpdef get(self)
- cpdef clear(self)
-
- # cpdef of switch leads to parameter errors...
- #cpdef switch(self, value)
-
-@cython.final
-@cython.internal
-cdef class MultipleWaiter(Waiter):
- cdef list _values
diff --git a/python/gevent/_compat.py b/python/gevent/_compat.py
deleted file mode 100644
index 22bad70..0000000
--- a/python/gevent/_compat.py
+++ /dev/null
@@ -1,160 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-internal gevent python 2/python 3 bridges. Not for external use.
-"""
-
-from __future__ import print_function, absolute_import, division
-
-import sys
-import os
-
-
-PY2 = sys.version_info[0] == 2
-PY3 = sys.version_info[0] >= 3
-PYPY = hasattr(sys, 'pypy_version_info')
-WIN = sys.platform.startswith("win")
-LINUX = sys.platform.startswith('linux')
-OSX = sys.platform == 'darwin'
-
-
-PURE_PYTHON = PYPY or os.getenv('PURE_PYTHON')
-
-## Types
-
-if PY3:
- string_types = (str,)
- integer_types = (int,)
- text_type = str
- native_path_types = (str, bytes)
- thread_mod_name = '_thread'
-
-else:
- import __builtin__ # pylint:disable=import-error
- string_types = (__builtin__.basestring,)
- text_type = __builtin__.unicode
- integer_types = (int, __builtin__.long)
- native_path_types = string_types
- thread_mod_name = 'thread'
-
-def NativeStrIO():
- import io
- return io.BytesIO() if str is bytes else io.StringIO()
-
-## Exceptions
-if PY3:
- def reraise(t, value, tb=None): # pylint:disable=unused-argument
- if value.__traceback__ is not tb and tb is not None:
- raise value.with_traceback(tb)
- raise value
- def exc_clear():
- pass
-
-else:
- from gevent._util_py2 import reraise # pylint:disable=import-error,no-name-in-module
- reraise = reraise # export
- exc_clear = sys.exc_clear
-
-## import locks
-try:
- # In Python 3.4 and newer in CPython and PyPy3,
- # imp.acquire_lock and imp.release_lock are delegated to
- # '_imp'. (Which is also used by importlib.) 'imp' itself is
- # deprecated. Avoid that warning.
- import _imp as imp
-except ImportError:
- import imp
-imp_acquire_lock = imp.acquire_lock
-imp_release_lock = imp.release_lock
-
-## Functions
-if PY3:
- iteritems = dict.items
- itervalues = dict.values
- xrange = range
- izip = zip
-
-else:
- iteritems = dict.iteritems # python 3: pylint:disable=no-member
- itervalues = dict.itervalues # python 3: pylint:disable=no-member
- xrange = __builtin__.xrange
- from itertools import izip # python 3: pylint:disable=no-member,no-name-in-module
- izip = izip
-
-# fspath from 3.6 os.py, but modified to raise the same exceptions as the
-# real native implementation.
-# Define for testing
-def _fspath(path):
- """
- Return the path representation of a path-like object.
-
- If str or bytes is passed in, it is returned unchanged. Otherwise the
- os.PathLike interface is used to get the path representation. If the
- path representation is not str or bytes, TypeError is raised. If the
- provided path is not str, bytes, or os.PathLike, TypeError is raised.
- """
- if isinstance(path, native_path_types):
- return path
-
- # Work from the object's type to match method resolution of other magic
- # methods.
- path_type = type(path)
- try:
- path_type_fspath = path_type.__fspath__
- except AttributeError:
- raise TypeError("expected str, bytes or os.PathLike object, "
- "not " + path_type.__name__)
-
- path_repr = path_type_fspath(path)
- if isinstance(path_repr, native_path_types):
- return path_repr
-
- raise TypeError("expected {}.__fspath__() to return str or bytes, "
- "not {}".format(path_type.__name__,
- type(path_repr).__name__))
-try:
- from os import fspath # pylint: disable=unused-import,no-name-in-module
-except ImportError:
- # if not available, use the Python version as transparently as
- # possible
- fspath = _fspath
- fspath.__name__ = 'fspath'
-
-try:
- from os import fsencode # pylint: disable=unused-import,no-name-in-module
-except ImportError:
- encoding = sys.getfilesystemencoding() or ('utf-8' if not WIN else 'mbcs')
- errors = 'strict' if WIN and encoding == 'mbcs' else 'surrogateescape'
-
- # Added in 3.2, so this is for Python 2.7. Note that it doesn't have
- # sys.getfilesystemencodeerrors(), which was added in 3.6
- def fsencode(filename):
- """Encode filename (an os.PathLike, bytes, or str) to the filesystem
- encoding with 'surrogateescape' error handler, return bytes unchanged.
- On Windows, use 'strict' error handler if the file system encoding is
- 'mbcs' (which is the default encoding).
- """
- filename = fspath(filename) # Does type-checking of `filename`.
- if isinstance(filename, bytes):
- return filename
-
- try:
- return filename.encode(encoding, errors)
- except LookupError:
- # Can't encode it, and the error handler doesn't
- # exist. Probably on Python 2 with an astral character.
- # Not sure how to handle this.
- raise UnicodeEncodeError("Can't encode path to filesystem encoding")
-
-
-## Clocks
-try:
- # Python 3.3+ (PEP 418)
- from time import perf_counter
- perf_counter = perf_counter
-except ImportError:
- import time
-
- if sys.platform == "win32":
- perf_counter = time.clock
- else:
- perf_counter = time.time
diff --git a/python/gevent/_config.py b/python/gevent/_config.py
deleted file mode 100644
index aaf74e6..0000000
--- a/python/gevent/_config.py
+++ /dev/null
@@ -1,709 +0,0 @@
-# Copyright (c) 2018 gevent. See LICENSE for details.
-"""
-gevent tunables.
-
-This should be used as ``from gevent import config``. That variable
-is an object of :class:`Config`.
-
-.. versionadded:: 1.3a2
-"""
-
-from __future__ import print_function, absolute_import, division
-
-import importlib
-import os
-import sys
-import textwrap
-
-from gevent._compat import string_types
-from gevent._compat import WIN
-
-__all__ = [
- 'config',
-]
-
-ALL_SETTINGS = []
-
-class SettingType(type):
- # pylint:disable=bad-mcs-classmethod-argument
-
- def __new__(cls, name, bases, cls_dict):
- if name == 'Setting':
- return type.__new__(cls, name, bases, cls_dict)
-
- cls_dict["order"] = len(ALL_SETTINGS)
- if 'name' not in cls_dict:
- cls_dict['name'] = name.lower()
-
- if 'environment_key' not in cls_dict:
- cls_dict['environment_key'] = 'GEVENT_' + cls_dict['name'].upper()
-
-
- new_class = type.__new__(cls, name, bases, cls_dict)
- new_class.fmt_desc(cls_dict.get("desc", ""))
- new_class.__doc__ = new_class.desc
- ALL_SETTINGS.append(new_class)
-
- if new_class.document:
- setting_name = cls_dict['name']
-
- def getter(self):
- return self.settings[setting_name].get()
-
- def setter(self, value): # pragma: no cover
- # The setter should never be hit, Config has a
- # __setattr__ that would override. But for the sake
- # of consistency we provide one.
- self.settings[setting_name].set(value)
-
- prop = property(getter, setter, doc=new_class.__doc__)
-
- setattr(Config, cls_dict['name'], prop)
- return new_class
-
- def fmt_desc(cls, desc):
- desc = textwrap.dedent(desc).strip()
- if hasattr(cls, 'shortname_map'):
- desc += (
- "\n\nThis is an importable value. It can be "
- "given as a string naming an importable object, "
- "or a list of strings in preference order and the first "
- "successfully importable object will be used. (Separate values "
- "in the environment variable with commas.) "
- "It can also be given as the callable object itself (in code). "
- )
- if cls.shortname_map:
- desc += "Shorthand names for default objects are %r" % (list(cls.shortname_map),)
- if getattr(cls.validate, '__doc__'):
- desc += '\n\n' + textwrap.dedent(cls.validate.__doc__).strip()
- if isinstance(cls.default, str) and hasattr(cls, 'shortname_map'):
- default = "`%s`" % (cls.default,)
- else:
- default = "`%r`" % (cls.default,)
- desc += "\n\nThe default value is %s" % (default,)
- desc += ("\n\nThe environment variable ``%s`` "
- "can be used to control this." % (cls.environment_key,))
- setattr(cls, "desc", desc)
- return desc
-
-def validate_invalid(value):
- raise ValueError("Not a valid value: %r" % (value,))
-
-def validate_bool(value):
- """
- This is a boolean value.
-
- In the environment variable, it may be given as ``1``, ``true``,
- ``on`` or ``yes`` for `True`, or ``0``, ``false``, ``off``, or
- ``no`` for `False`.
- """
- if isinstance(value, string_types):
- value = value.lower().strip()
- if value in ('1', 'true', 'on', 'yes'):
- value = True
- elif value in ('0', 'false', 'off', 'no') or not value:
- value = False
- else:
- raise ValueError("Invalid boolean string: %r" % (value,))
- return bool(value)
-
-def validate_anything(value):
- return value
-
-convert_str_value_as_is = validate_anything
-
-class Setting(object):
- name = None
- value = None
- validate = staticmethod(validate_invalid)
- default = None
- environment_key = None
- document = True
-
- desc = """\
-
- A long ReST description.
-
- The first line should be a single sentence.
-
- """
-
- def _convert(self, value):
- if isinstance(value, string_types):
- return value.split(',')
- return value
-
- def _default(self):
- result = os.environ.get(self.environment_key, self.default)
- result = self._convert(result)
- return result
-
- def get(self):
- # If we've been specifically set, return it
- if 'value' in self.__dict__:
- return self.value
- # Otherwise, read from the environment and reify
- # so we return consistent results.
- self.value = self.validate(self._default())
- return self.value
-
- def set(self, val):
- self.value = self.validate(self._convert(val))
-
-
-Setting = SettingType('Setting', (Setting,), dict(Setting.__dict__))
-
-def make_settings():
- """
- Return fresh instances of all classes defined in `ALL_SETTINGS`.
- """
- settings = {}
- for setting_kind in ALL_SETTINGS:
- setting = setting_kind()
- assert setting.name not in settings
- settings[setting.name] = setting
- return settings
-
-
-class Config(object):
- """
- Global configuration for gevent.
-
- There is one instance of this object at ``gevent.config``. If you
- are going to make changes in code, instead of using the documented
- environment variables, you need to make the changes before using
- any parts of gevent that might need those settings. For example::
-
- >>> from gevent import config
- >>> config.fileobject = 'thread'
-
- >>> from gevent import fileobject
- >>> fileobject.FileObject.__name__
- 'FileObjectThread'
-
- .. versionadded:: 1.3a2
-
- """
-
- def __init__(self):
- self.settings = make_settings()
-
- def __getattr__(self, name):
- if name not in self.settings:
- raise AttributeError("No configuration setting for: %r" % name)
- return self.settings[name].get()
-
- def __setattr__(self, name, value):
- if name != "settings" and name in self.settings:
- self.set(name, value)
- else:
- super(Config, self).__setattr__(name, value)
-
- def set(self, name, value):
- if name not in self.settings:
- raise AttributeError("No configuration setting for: %r" % name)
- self.settings[name].set(value)
-
- def __dir__(self):
- return list(self.settings)
-
-
-class ImportableSetting(object):
-
- def _import(self, path, _NONE=object):
- # pylint:disable=too-many-branches
- if isinstance(path, list):
- if not path:
- raise ImportError('Cannot import from empty list: %r' % (path, ))
-
- for item in path[:-1]:
- try:
- return self._import(item)
- except ImportError:
- pass
-
- return self._import(path[-1])
-
- if not isinstance(path, string_types):
- return path
-
- if '.' not in path:
- raise ImportError("Cannot import %r. "
- "Required format: [path/][package.]module.class. "
- "Or choose from %r"
- % (path, list(self.shortname_map)))
-
- if '/' in path:
- # This is dangerous, subject to race conditions, and
- # may not work properly for things like namespace packages
- import warnings
- warnings.warn("Absolute paths are deprecated and will be removed in 1.4."
- "Please put the package on sys.path first",
- DeprecationWarning)
- package_path, path = path.rsplit('/', 1)
- sys.path = [package_path] + sys.path
- else:
- package_path = None
-
- try:
- module, item = path.rsplit('.', 1)
- module = importlib.import_module(module)
- x = getattr(module, item, _NONE)
- if x is _NONE:
- raise ImportError('Cannot import %r from %r' % (item, module))
- return x
- finally:
- if package_path:
- try:
- sys.path.remove(package_path)
- except ValueError: # pragma: no cover
- pass
-
- shortname_map = {}
-
- def validate(self, value):
- if isinstance(value, type):
- return value
- return self._import([self.shortname_map.get(x, x) for x in value])
-
-class BoolSettingMixin(object):
- validate = staticmethod(validate_bool)
- # Don't do string-to-list conversion.
- _convert = staticmethod(convert_str_value_as_is)
-
-class IntSettingMixin(object):
- # Don't do string-to-list conversion.
- def _convert(self, value):
- if value:
- return int(value)
-
- validate = staticmethod(validate_anything)
-
-
-class _PositiveValueMixin(object):
-
- def validate(self, value):
- if value is not None and value <= 0:
- raise ValueError("Must be positive")
- return value
-
-
-class FloatSettingMixin(_PositiveValueMixin):
- def _convert(self, value):
- if value:
- return float(value)
-
-
-class ByteCountSettingMixin(_PositiveValueMixin):
-
- _MULTIPLES = {
- # All keys must be the same size.
- 'kb': 1024,
- 'mb': 1024 * 1024,
- 'gb': 1024 * 1024 * 1024,
- }
-
- _SUFFIX_SIZE = 2
-
- def _convert(self, value):
- if not value or not isinstance(value, str):
- return value
- value = value.lower()
- for s, m in self._MULTIPLES.items():
- if value[-self._SUFFIX_SIZE:] == s:
- return int(value[:-self._SUFFIX_SIZE]) * m
- return int(value)
-
-
-class Resolver(ImportableSetting, Setting):
-
- desc = """\
- The callable that will be used to create
- :attr:`gevent.hub.Hub.resolver`.
-
- See :doc:`dns` for more information.
- """
-
- default = [
- 'thread',
- 'dnspython',
- 'ares',
- 'block',
- ]
-
- shortname_map = {
- 'ares': 'gevent.resolver.ares.Resolver',
- 'thread': 'gevent.resolver.thread.Resolver',
- 'block': 'gevent.resolver.blocking.Resolver',
- 'dnspython': 'gevent.resolver.dnspython.Resolver',
- }
-
-
-
-class Threadpool(ImportableSetting, Setting):
-
- desc = """\
- The kind of threadpool we use.
- """
-
- default = 'gevent.threadpool.ThreadPool'
-
-
-class Loop(ImportableSetting, Setting):
-
- desc = """\
- The kind of the loop we use.
-
- On Windows, this defaults to libuv, while on
- other platforms it defaults to libev.
-
- """
-
- default = [
- 'libev-cext',
- 'libev-cffi',
- 'libuv-cffi',
- ] if not WIN else [
- 'libuv-cffi',
- 'libev-cext',
- 'libev-cffi',
- ]
-
- shortname_map = {
- 'libev-cext': 'gevent.libev.corecext.loop',
- 'libev-cffi': 'gevent.libev.corecffi.loop',
- 'libuv-cffi': 'gevent.libuv.loop.loop',
- }
-
- shortname_map['libuv'] = shortname_map['libuv-cffi']
-
-
-class FormatContext(ImportableSetting, Setting):
- name = 'format_context'
-
- # using pprint.pformat can override custom __repr__ methods on dict/list
- # subclasses, which can be a security concern
- default = 'pprint.saferepr'
-
-
-class LibevBackend(Setting):
- name = 'libev_backend'
- environment_key = 'GEVENT_BACKEND'
-
- desc = """\
- The backend for libev, such as 'select'
- """
-
- default = None
-
- validate = staticmethod(validate_anything)
-
-
-class FileObject(ImportableSetting, Setting):
- desc = """\
- The kind of ``FileObject`` we will use.
-
- See :mod:`gevent.fileobject` for a detailed description.
-
- """
- environment_key = 'GEVENT_FILE'
-
- default = [
- 'posix',
- 'thread',
- ]
-
- shortname_map = {
- 'thread': 'gevent._fileobjectcommon.FileObjectThread',
- 'posix': 'gevent._fileobjectposix.FileObjectPosix',
- 'block': 'gevent._fileobjectcommon.FileObjectBlock'
- }
-
-
-class WatchChildren(BoolSettingMixin, Setting):
- desc = """\
- Should we *not* watch children with the event loop watchers?
-
- This is an advanced setting.
-
- See :mod:`gevent.os` for a detailed description.
- """
- name = 'disable_watch_children'
- environment_key = 'GEVENT_NOWAITPID'
- default = False
-
-
-class TraceMalloc(IntSettingMixin, Setting):
- name = 'trace_malloc'
- environment_key = 'PYTHONTRACEMALLOC'
- default = False
-
- desc = """\
- Should FFI objects track their allocation?
-
- This is only useful for low-level debugging.
-
- On Python 3, this environment variable is built in to the
- interpreter, and it may also be set with the ``-X
- tracemalloc`` command line argument.
-
- On Python 2, gevent interprets this argument and adds extra
- tracking information for FFI objects.
- """
-
-
-class TrackGreenletTree(BoolSettingMixin, Setting):
- name = 'track_greenlet_tree'
- environment_key = 'GEVENT_TRACK_GREENLET_TREE'
- default = True
-
- desc = """\
- Should `Greenlet` objects track their spawning tree?
-
- Setting this to a false value will make spawning `Greenlet`
- objects and using `spawn_raw` faster, but the
- ``spawning_greenlet``, ``spawn_tree_locals`` and ``spawning_stack``
- will not be captured.
-
- .. versionadded:: 1.3b1
- """
-
-
-## Monitoring settings
-# All env keys should begin with GEVENT_MONITOR
-
-class MonitorThread(BoolSettingMixin, Setting):
- name = 'monitor_thread'
- environment_key = 'GEVENT_MONITOR_THREAD_ENABLE'
- default = False
-
- desc = """\
- Should each hub start a native OS thread to monitor
- for problems?
-
- Such a thread will periodically check to see if the event loop
- is blocked for longer than `max_blocking_time`, producing output on
- the hub's exception stream (stderr by default) if it detects this condition.
-
- If this setting is true, then this thread will be created
- the first time the hub is switched to,
- or you can call :meth:`gevent.hub.Hub.start_periodic_monitoring_thread` at any
- time to create it (from the same thread that will run the hub). That function
- will return an instance of :class:`gevent.events.IPeriodicMonitorThread`
- to which you can add your own monitoring functions. That function
- also emits an event of :class:`gevent.events.PeriodicMonitorThreadStartedEvent`.
-
- .. seealso:: `max_blocking_time`
-
- .. versionadded:: 1.3b1
- """
-
-class MaxBlockingTime(FloatSettingMixin, Setting):
- name = 'max_blocking_time'
- # This environment key doesn't follow the convention because it's
- # meant to match a key used by existing projects
- environment_key = 'GEVENT_MAX_BLOCKING_TIME'
- default = 0.1
-
- desc = """\
- If the `monitor_thread` is enabled, this is
- approximately how long (in seconds)
- the event loop will be allowed to block before a warning is issued.
-
- This function depends on using `greenlet.settrace`, so installing
- your own trace function after starting the monitoring thread will
- cause this feature to misbehave unless you call the function
- returned by `greenlet.settrace`. If you install a tracing function *before*
- the monitoring thread is started, it will still be called.
-
- .. note:: In the unlikely event of creating and using multiple different
- gevent hubs in the same native thread in a short period of time,
- especially without destroying the hubs, false positives may be reported.
-
- .. versionadded:: 1.3b1
- """
-
-class MonitorMemoryPeriod(FloatSettingMixin, Setting):
- name = 'memory_monitor_period'
-
- environment_key = 'GEVENT_MONITOR_MEMORY_PERIOD'
- default = 5
-
- desc = """\
- If `monitor_thread` is enabled, this is approximately how long
- (in seconds) we will go between checking the processes memory usage.
-
- Checking the memory usage is relatively expensive on some operating
- systems, so this should not be too low. gevent will place a floor
- value on it.
- """
-
-class MonitorMemoryMaxUsage(ByteCountSettingMixin, Setting):
- name = 'max_memory_usage'
-
- environment_key = 'GEVENT_MONITOR_MEMORY_MAX'
- default = None
-
- desc = """\
- If `monitor_thread` is enabled,
- then if memory usage exceeds this amount (in bytes), events will
- be emitted. See `gevent.events`. In the environment variable, you can use
- a suffix of 'kb', 'mb' or 'gb' to specify the value in kilobytes, megabytes
- or gigibytes.
-
- There is no default value for this setting. If you wish to
- cap memory usage, you must choose a value.
- """
-
-# The ares settings are all interpreted by
-# gevent/resolver/ares.pyx, so we don't do
-# any validation here.
-
-class AresSettingMixin(object):
-
- document = False
-
- @property
- def kwarg_name(self):
- return self.name[5:]
-
- validate = staticmethod(validate_anything)
-
- _convert = staticmethod(convert_str_value_as_is)
-
-class AresFlags(AresSettingMixin, Setting):
- name = 'ares_flags'
- default = None
- environment_key = 'GEVENTARES_FLAGS'
-
-class AresTimeout(AresSettingMixin, Setting):
- document = True
- name = 'ares_timeout'
- default = None
- environment_key = 'GEVENTARES_TIMEOUT'
- desc = """\
-
- .. deprecated:: 1.3a2
- Prefer the :attr:`resolver_timeout` setting. If both are set,
- the results are not defined.
- """
-
-class AresTries(AresSettingMixin, Setting):
- name = 'ares_tries'
- default = None
- environment_key = 'GEVENTARES_TRIES'
-
-class AresNdots(AresSettingMixin, Setting):
- name = 'ares_ndots'
- default = None
- environment_key = 'GEVENTARES_NDOTS'
-
-class AresUDPPort(AresSettingMixin, Setting):
- name = 'ares_udp_port'
- default = None
- environment_key = 'GEVENTARES_UDP_PORT'
-
-class AresTCPPort(AresSettingMixin, Setting):
- name = 'ares_tcp_port'
- default = None
- environment_key = 'GEVENTARES_TCP_PORT'
-
-class AresServers(AresSettingMixin, Setting):
- document = True
- name = 'ares_servers'
- default = None
- environment_key = 'GEVENTARES_SERVERS'
- desc = """\
- A list of strings giving the IP addresses of nameservers for the ares resolver.
-
- In the environment variable, these strings are separated by commas.
-
- .. deprecated:: 1.3a2
- Prefer the :attr:`resolver_nameservers` setting. If both are set,
- the results are not defined.
- """
-
-# Generic nameservers, works for dnspython and ares.
-class ResolverNameservers(AresSettingMixin, Setting):
- document = True
- name = 'resolver_nameservers'
- default = None
- environment_key = 'GEVENT_RESOLVER_NAMESERVERS'
- desc = """\
- A list of strings giving the IP addresses of nameservers for the (non-system) resolver.
-
- In the environment variable, these strings are separated by commas.
-
- .. rubric:: Resolver Behaviour
-
- * blocking
-
- Ignored
-
- * Threaded
-
- Ignored
-
- * dnspython
-
- If this setting is not given, the dnspython resolver will
- load nameservers to use from ``/etc/resolv.conf``
- or the Windows registry. This setting replaces any nameservers read
- from those means. Note that the file and registry are still read
- for other settings.
-
- .. caution:: dnspython does not validate the members of the list.
- An improper address (such as a hostname instead of IP) has
- undefined results, including hanging the process.
-
- * ares
-
- Similar to dnspython, but with more platform and compile-time
- options. ares validates that the members of the list are valid
- addresses.
- """
-
- # Normal string-to-list rules. But still validate_anything.
- _convert = Setting._convert
-
- # TODO: In the future, support reading a resolv.conf file
- # *other* than /etc/resolv.conf, and do that both on Windows
- # and other platforms. Also offer the option to disable the system
- # configuration entirely.
-
- @property
- def kwarg_name(self):
- return 'servers'
-
-# Generic timeout, works for dnspython and ares
-class ResolverTimeout(FloatSettingMixin, AresSettingMixin, Setting):
- document = True
- name = 'resolver_timeout'
- environment_key = 'GEVENT_RESOLVER_TIMEOUT'
- desc = """\
- The total amount of time that the DNS resolver will spend making queries.
-
- Only the ares and dnspython resolvers support this.
-
- .. versionadded:: 1.3a2
- """
-
- @property
- def kwarg_name(self):
- return 'timeout'
-
-config = Config()
-
-# Go ahead and attempt to import the loop when this class is
-# instantiated. The hub won't work if the loop can't be found. This
-# can solve problems with the class being imported from multiple
-# threads at once, leading to one of the imports failing.
-# factories are themselves handled lazily. See #687.
-
-# Don't cache it though, in case the user re-configures through the
-# API.
-
-try:
- Loop().get()
-except ImportError: # pragma: no cover
- pass
diff --git a/python/gevent/_event.cp36-win32.pyd b/python/gevent/_event.cp36-win32.pyd
deleted file mode 100644
index e594296..0000000
--- a/python/gevent/_event.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/_event.pxd b/python/gevent/_event.pxd
deleted file mode 100644
index e92e05e..0000000
--- a/python/gevent/_event.pxd
+++ /dev/null
@@ -1,77 +0,0 @@
-cimport cython
-
-from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
-from gevent.__hub_local cimport get_hub_noargs as get_hub
-
-cdef _None
-cdef reraise
-cdef dump_traceback
-cdef load_traceback
-
-
-cdef InvalidSwitchError
-cdef Timeout
-cdef bint _greenlet_imported
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-cdef void _init()
-
-cdef class _AbstractLinkable:
- # We declare the __weakref__ here in the base (even though
- # that's not really what we want) as a workaround for a Cython
- # issue we see reliably on 3.7b4 and sometimes on 3.6. See
- # https://github.com/cython/cython/issues/2270
- cdef object __weakref__
- cdef _notifier
- cdef set _links
- cdef readonly SwitchOutGreenletWithLoop hub
-
- cpdef rawlink(self, callback)
- cpdef bint ready(self)
- cpdef unlink(self, callback)
-
- cdef _check_and_notify(self)
- @cython.locals(todo=set)
- cpdef _notify_links(self)
- cdef _wait_core(self, timeout, catch=*)
- cdef _wait_return_value(self, waited, wait_success)
- cdef _wait(self, timeout=*)
-
-
-cdef class Event(_AbstractLinkable):
- cdef bint _flag
-
-cdef class AsyncResult(_AbstractLinkable):
- cdef readonly _value
- cdef readonly tuple _exc_info
-
- # For the use of _imap.py
- cdef public int _imap_task_index
-
- cpdef get(self, block=*, timeout=*)
- cpdef bint successful(self)
-
- cpdef wait(self, timeout=*)
- cpdef bint done(self)
-
- cpdef bint cancel(self)
- cpdef bint cancelled(self)
diff --git a/python/gevent/_ffi/__init__.py b/python/gevent/_ffi/__init__.py
deleted file mode 100644
index 56f1e96..0000000
--- a/python/gevent/_ffi/__init__.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-Internal helpers for FFI implementations.
-"""
-from __future__ import print_function, absolute_import
-
-import os
-import sys
-
-def _dbg(*args, **kwargs):
- # pylint:disable=unused-argument
- pass
-
-#_dbg = print
-
-def _pid_dbg(*args, **kwargs):
- kwargs['file'] = sys.stderr
- print(os.getpid(), *args, **kwargs)
-
-CRITICAL = 1
-ERROR = 3
-DEBUG = 5
-TRACE = 9
-
-GEVENT_DEBUG_LEVEL = vars()[os.getenv("GEVENT_DEBUG", 'CRITICAL').upper()]
-
-if GEVENT_DEBUG_LEVEL >= TRACE:
- _dbg = _pid_dbg
diff --git a/python/gevent/_ffi/callback.py b/python/gevent/_ffi/callback.py
deleted file mode 100644
index df59a9f..0000000
--- a/python/gevent/_ffi/callback.py
+++ /dev/null
@@ -1,58 +0,0 @@
-from __future__ import absolute_import, print_function
-
-__all__ = [
- 'callback',
-]
-
-
-# For times when *args is captured but often not passed (empty),
-# we can avoid keeping the new tuple that was created for *args
-# around by using a constant.
-_NOARGS = ()
-
-
-class callback(object):
-
- __slots__ = ('callback', 'args')
-
- def __init__(self, cb, args):
- self.callback = cb
- self.args = args or _NOARGS
-
- def stop(self):
- self.callback = None
- self.args = None
-
- close = stop
-
- # Note that __nonzero__ and pending are different
- # bool() is used in contexts where we need to know whether to schedule another callback,
- # so it's true if it's pending or currently running
- # 'pending' has the same meaning as libev watchers: it is cleared before actually
- # running the callback
-
- def __nonzero__(self):
- # it's nonzero if it's pending or currently executing
- # NOTE: This depends on loop._run_callbacks setting the args property
- # to None.
- return self.args is not None
- __bool__ = __nonzero__
-
- @property
- def pending(self):
- return self.callback is not None
-
- def _format(self):
- return ''
-
- def __repr__(self):
- result = "<%s at 0x%x" % (self.__class__.__name__, id(self))
- if self.pending:
- result += " pending"
- if self.callback is not None:
- result += " callback=%r" % (self.callback, )
- if self.args is not None:
- result += " args=%r" % (self.args, )
- if self.callback is None and self.args is None:
- result += " stopped"
- return result + ">"
diff --git a/python/gevent/_ffi/loop.py b/python/gevent/_ffi/loop.py
deleted file mode 100644
index efe4462..0000000
--- a/python/gevent/_ffi/loop.py
+++ /dev/null
@@ -1,709 +0,0 @@
-"""
-Basic loop implementation for ffi-based cores.
-"""
-# pylint: disable=too-many-lines, protected-access, redefined-outer-name, not-callable
-from __future__ import absolute_import, print_function
-
-from collections import deque
-import sys
-import os
-import traceback
-
-from gevent._ffi import _dbg
-from gevent._ffi import GEVENT_DEBUG_LEVEL
-from gevent._ffi import TRACE
-from gevent._ffi.callback import callback
-from gevent._compat import PYPY
-
-from gevent import getswitchinterval
-
-__all__ = [
- 'AbstractLoop',
- 'assign_standard_callbacks',
-]
-
-
-class _EVENTSType(object):
- def __repr__(self):
- return 'gevent.core.EVENTS'
-
-EVENTS = GEVENT_CORE_EVENTS = _EVENTSType()
-
-
-#####
-## Note on CFFI objects, callbacks and the lifecycle of watcher objects
-#
-# Each subclass of `watcher` allocates a C structure of the
-# appropriate type e.g., struct gevent_ev_io and holds this pointer in
-# its `_gwatcher` attribute. When that watcher instance is garbage
-# collected, then the C structure is also freed. The C structure is
-# passed to libev from the watcher's start() method and then to the
-# appropriate C callback function, e.g., _gevent_ev_io_callback, which
-# passes it back to python's _python_callback where we need the
-# watcher instance. Therefore, as long as that callback is active (the
-# watcher is started), the watcher instance must not be allowed to get
-# GC'd---any access at the C level or even the FFI level to the freed
-# memory could crash the process.
-#
-# However, the typical idiom calls for writing something like this:
-# loop.io(fd, python_cb).start()
-# thus forgetting the newly created watcher subclass and allowing it to be immediately
-# GC'd. To combat this, when the watcher is started, it places itself into the loop's
-# `_keepaliveset`, and it only removes itself when the watcher's `stop()` method is called.
-# Often, this is the *only* reference keeping the watcher object, and hence its C structure,
-# alive.
-#
-# This is slightly complicated by the fact that the python-level
-# callback, called from the C callback, could choose to manually stop
-# the watcher. When we return to the C level callback, we now have an
-# invalid pointer, and attempting to pass it back to Python (e.g., to
-# handle an error) could crash. Hence, _python_callback,
-# _gevent_io_callback, and _python_handle_error cooperate to make sure
-# that the watcher instance stays in the loops `_keepaliveset` while
-# the C code could be running---and if it gets removed, to not call back
-# to Python again.
-# See also https://github.com/gevent/gevent/issues/676
-####
-class AbstractCallbacks(object):
-
-
- def __init__(self, ffi):
- self.ffi = ffi
- self.callbacks = []
- if GEVENT_DEBUG_LEVEL < TRACE:
- self.from_handle = ffi.from_handle
-
- def from_handle(self, handle): # pylint:disable=method-hidden
- x = self.ffi.from_handle(handle)
- return x
-
- def python_callback(self, handle, revents):
- """
- Returns an integer having one of three values:
-
- - -1
- An exception occurred during the callback and you must call
- :func:`_python_handle_error` to deal with it. The Python watcher
- object will have the exception tuple saved in ``_exc_info``.
- - 1
- Everything went according to plan. You should check to see if the libev
- watcher is still active, and call :func:`python_stop` if it is not. This will
- clean up the memory. Finding the watcher still active at the event loop level,
- but not having stopped itself at the gevent level is a buggy scenario and
- shouldn't happen.
- - 2
- Everything went according to plan, but the watcher has already
- been stopped. Its memory may no longer be valid.
-
- This function should never return 0, as that's the default value that
- Python exceptions will produce.
- """
- #print("Running callback", handle)
- orig_ffi_watcher = None
- try:
- # Even dereferencing the handle needs to be inside the try/except;
- # if we don't return normally (e.g., a signal) then we wind up going
- # to the 'onerror' handler (unhandled_onerror), which
- # is not what we want; that can permanently wedge the loop depending
- # on which callback was executing.
- # XXX: See comments in that function. We may be able to restart and do better?
- if not handle:
- # Hmm, a NULL handle. That's not supposed to happen.
- # We can easily get into a loop if we deref it and allow that
- # to raise.
- _dbg("python_callback got null handle")
- return 1
- the_watcher = self.from_handle(handle)
- orig_ffi_watcher = the_watcher._watcher
- args = the_watcher.args
- if args is None:
- # Legacy behaviour from corecext: convert None into ()
- # See test__core_watcher.py
- args = _NOARGS
- if args and args[0] == GEVENT_CORE_EVENTS:
- args = (revents, ) + args[1:]
- #print("Calling function", the_watcher.callback, args)
- the_watcher.callback(*args)
- except: # pylint:disable=bare-except
- _dbg("Got exception servicing watcher with handle", handle, sys.exc_info())
- # It's possible for ``the_watcher`` to be undefined (UnboundLocalError)
- # if we threw an exception (signal) on the line that created that variable.
- # This is typically the case with a signal under libuv
- try:
- the_watcher
- except UnboundLocalError:
- the_watcher = self.from_handle(handle)
- the_watcher._exc_info = sys.exc_info()
- # Depending on when the exception happened, the watcher
- # may or may not have been stopped. We need to make sure its
- # memory stays valid so we can stop it at the ev level if needed.
- the_watcher.loop._keepaliveset.add(the_watcher)
- return -1
- else:
- if (the_watcher.loop is not None
- and the_watcher in the_watcher.loop._keepaliveset
- and the_watcher._watcher is orig_ffi_watcher):
- # It didn't stop itself, *and* it didn't stop itself, reset
- # its watcher, and start itself again. libuv's io watchers MAY
- # do that.
- # The normal, expected scenario when we find the watcher still
- # in the keepaliveset is that it is still active at the event loop
- # level, so we don't expect that python_stop gets called.
- #_dbg("The watcher has not stopped itself, possibly still active", the_watcher)
- return 1
- return 2 # it stopped itself
-
- def python_handle_error(self, handle, _revents):
- _dbg("Handling error for handle", handle)
- if not handle:
- return
- try:
- watcher = self.from_handle(handle)
- exc_info = watcher._exc_info
- del watcher._exc_info
- # In the past, we passed the ``watcher`` itself as the context,
- # which typically meant that the Hub would just print
- # the exception. This is a problem because sometimes we can't
- # detect signals until late in ``python_callback``; specifically,
- # test_selectors.py:DefaultSelectorTest.test_select_interrupt_exc
- # installs a SIGALRM handler that raises an exception. That exception can happen
- # before we enter ``python_callback`` or at any point within it because of the way
- # libuv swallows signals. By passing None, we get the exception prapagated into
- # the main greenlet (which is probably *also* not what we always want, but
- # I see no way to distinguish the cases).
- watcher.loop.handle_error(None, *exc_info)
- finally:
- # XXX Since we're here on an error condition, and we
- # made sure that the watcher object was put in loop._keepaliveset,
- # what about not stopping the watcher? Looks like a possible
- # memory leak?
- # XXX: This used to do "if revents & (libev.EV_READ | libev.EV_WRITE)"
- # before stopping. Why?
- try:
- watcher.stop()
- except: # pylint:disable=bare-except
- watcher.loop.handle_error(watcher, *sys.exc_info())
- return # pylint:disable=lost-exception
-
- def unhandled_onerror(self, t, v, tb):
- # This is supposed to be called for signals, etc.
- # This is the onerror= value for CFFI.
- # If we return None, C will get a value of 0/NULL;
- # if we raise, CFFI will print the exception and then
- # return 0/NULL; (unless error= was configured)
- # If things go as planned, we return the value that asks
- # C to call back and check on if the watcher needs to be closed or
- # not.
-
- # XXX: TODO: Could this cause events to be lost? Maybe we need to return
- # a value that causes the C loop to try the callback again?
- # at least for signals under libuv, which are delivered at very odd times.
- # Hopefully the event still shows up when we poll the next time.
- watcher = None
- handle = tb.tb_frame.f_locals['handle'] if tb is not None else None
- if handle: # handle could be NULL
- watcher = self.from_handle(handle)
- if watcher is not None:
- watcher.loop.handle_error(None, t, v, tb)
- return 1
-
- # Raising it causes a lot of noise from CFFI
- print("WARNING: gevent: Unhandled error with no watcher",
- file=sys.stderr)
- traceback.print_exception(t, v, tb)
-
- def python_stop(self, handle):
- if not handle: # pragma: no cover
- print(
- "WARNING: gevent: Unable to dereference handle; not stopping watcher. "
- "Native resources may leak. This is most likely a bug in gevent.",
- file=sys.stderr)
- # The alternative is to crash with no helpful information
- # NOTE: Raising exceptions here does nothing, they're swallowed by CFFI.
- # Since the C level passed in a null pointer, even dereferencing the handle
- # will just produce some exceptions.
- return
- watcher = self.from_handle(handle)
- watcher.stop()
-
- if not PYPY:
- def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
- # If we have the onerror callback, this is a no-op; all the real
- # work to rethrow the exception is done by the onerror callback
-
- # NOTE: Unlike the rest of the functions, this is called with a pointer
- # to the C level structure, *not* a pointer to the void* that represents a
- # <cdata> for the Python Watcher object.
- pass
- else: # PyPy
- # On PyPy, we need the function to have some sort of body, otherwise
- # the signal exceptions don't always get caught, *especially* with
- # libuv (however, there's no reason to expect this to only be a libuv
- # issue; it's just that we don't depend on the periodic signal timer
- # under libev, so the issue is much more pronounced under libuv)
- # test_socket's test_sendall_interrupted can hang.
- # See https://github.com/gevent/gevent/issues/1112
-
- def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
- # Things we've tried that *don't* work:
- # greenlet.getcurrent()
- # 1 + 1
- try:
- raise MemoryError()
- except MemoryError:
- pass
-
- def python_prepare_callback(self, watcher_ptr):
- loop = self._find_loop_from_c_watcher(watcher_ptr)
- if loop is None: # pragma: no cover
- print("WARNING: gevent: running prepare callbacks from a destroyed handle: ",
- watcher_ptr)
- return
- loop._run_callbacks()
-
- def check_callback_onerror(self, t, v, tb):
- watcher_ptr = tb.tb_frame.f_locals['watcher_ptr'] if tb is not None else None
- if watcher_ptr:
- loop = self._find_loop_from_c_watcher(watcher_ptr)
- if loop is not None:
- # None as the context argument causes the exception to be raised
- # in the main greenlet.
- loop.handle_error(None, t, v, tb)
- return None
- raise v # Let CFFI print
-
- def _find_loop_from_c_watcher(self, watcher_ptr):
- raise NotImplementedError()
-
-
-
-def assign_standard_callbacks(ffi, lib, callbacks_class, extras=()): # pylint:disable=unused-argument
- # callbacks keeps these cdata objects alive at the python level
- callbacks = callbacks_class(ffi)
- extras = tuple([(getattr(callbacks, name), error) for name, error in extras])
- for (func, error_func) in ((callbacks.python_callback, None),
- (callbacks.python_handle_error, None),
- (callbacks.python_stop, None),
- (callbacks.python_check_callback,
- callbacks.check_callback_onerror),
- (callbacks.python_prepare_callback,
- callbacks.check_callback_onerror)) + extras:
- # The name of the callback function matches the 'extern Python' declaration.
- error_func = error_func or callbacks.unhandled_onerror
- callback = ffi.def_extern(onerror=error_func)(func)
- # keep alive the cdata
- # (def_extern returns the original function, and it requests that
- # the function be "global", so maybe it keeps a hard reference to it somewhere now
- # unlike ffi.callback(), and we don't need to do this?)
- callbacks.callbacks.append(callback)
-
- # At this point, the library C variable (static function, actually)
- # is filled in.
-
- return callbacks
-
-
-if sys.version_info[0] >= 3:
- basestring = (bytes, str)
- integer_types = (int,)
-else:
- import __builtin__ # pylint:disable=import-error
- basestring = (__builtin__.basestring,)
- integer_types = (int, __builtin__.long)
-
-
-
-
-_NOARGS = ()
-
-CALLBACK_CHECK_COUNT = 50
-
-class AbstractLoop(object):
- # pylint:disable=too-many-public-methods,too-many-instance-attributes
-
- error_handler = None
-
- _CHECK_POINTER = None
-
- _TIMER_POINTER = None
- _TIMER_CALLBACK_SIG = None
-
- _PREPARE_POINTER = None
-
- starting_timer_may_update_loop_time = False
-
- # Subclasses should set this in __init__ to reflect
- # whether they were the default loop.
- _default = None
-
- def __init__(self, ffi, lib, watchers, flags=None, default=None):
- self._ffi = ffi
- self._lib = lib
- self._ptr = None
- self._handle_to_self = self._ffi.new_handle(self) # XXX: Reference cycle?
- self._watchers = watchers
- self._in_callback = False
- self._callbacks = deque()
- # Stores python watcher objects while they are started
- self._keepaliveset = set()
- self._init_loop_and_aux_watchers(flags, default)
-
-
- def _init_loop_and_aux_watchers(self, flags=None, default=None):
-
- self._ptr = self._init_loop(flags, default)
-
-
- # self._check is a watcher that runs in each iteration of the
- # mainloop, just after the blocking call. It's point is to handle
- # signals. It doesn't run watchers or callbacks, it just exists to give
- # CFFI a chance to raise signal exceptions so we can handle them.
- self._check = self._ffi.new(self._CHECK_POINTER)
- self._check.data = self._handle_to_self
- self._init_and_start_check()
-
- # self._prepare is a watcher that runs in each iteration of the mainloop,
- # just before the blocking call. It's where we run deferred callbacks
- # from self.run_callback. This cooperates with _setup_for_run_callback()
- # to schedule self._timer0 if needed.
- self._prepare = self._ffi.new(self._PREPARE_POINTER)
- self._prepare.data = self._handle_to_self
- self._init_and_start_prepare()
-
- # A timer we start and stop on demand. If we have callbacks,
- # too many to run in one iteration of _run_callbacks, we turn this
- # on so as to have the next iteration of the run loop return to us
- # as quickly as possible.
- # TODO: There may be a more efficient way to do this using ev_timer_again;
- # see the "ev_timer" section of the ev manpage (http://linux.die.net/man/3/ev)
- # Alternatively, setting the ev maximum block time may also work.
- self._timer0 = self._ffi.new(self._TIMER_POINTER)
- self._timer0.data = self._handle_to_self
- self._init_callback_timer()
-
- # TODO: We may be able to do something nicer and use the existing python_callback
- # combined with onerror and the class check/timer/prepare to simplify things
- # and unify our handling
-
- def _init_loop(self, flags, default):
- """
- Called by __init__ to create or find the loop. The return value
- is assigned to self._ptr.
- """
- raise NotImplementedError()
-
- def _init_and_start_check(self):
- raise NotImplementedError()
-
- def _init_and_start_prepare(self):
- raise NotImplementedError()
-
- def _init_callback_timer(self):
- raise NotImplementedError()
-
- def _stop_callback_timer(self):
- raise NotImplementedError()
-
- def _start_callback_timer(self):
- raise NotImplementedError()
-
- def _check_callback_handle_error(self, t, v, tb):
- self.handle_error(None, t, v, tb)
-
- def _run_callbacks(self): # pylint:disable=too-many-branches
- # When we're running callbacks, its safe for timers to
- # update the notion of the current time (because if we're here,
- # we're not running in a timer callback that may let other timers
- # run; this is mostly an issue for libuv).
-
- # That's actually a bit of a lie: on libev, self._timer0 really is
- # a timer, and so sometimes this is running in a timer callback, not
- # a prepare callback. But that's OK, libev doesn't suffer from cascading
- # timer expiration and its safe to update the loop time at any
- # moment there.
- self.starting_timer_may_update_loop_time = True
- try:
- count = CALLBACK_CHECK_COUNT
- now = self.now()
- expiration = now + getswitchinterval()
- self._stop_callback_timer()
- while self._callbacks:
- cb = self._callbacks.popleft() # pylint:disable=assignment-from-no-return
- count -= 1
- self.unref() # XXX: libuv doesn't have a global ref count!
- callback = cb.callback
- cb.callback = None
- args = cb.args
- if callback is None or args is None:
- # it's been stopped
- continue
-
- try:
- callback(*args)
- except: # pylint:disable=bare-except
- # If we allow an exception to escape this method (while we are running the ev callback),
- # then CFFI will print the error and libev will continue executing.
- # There are two problems with this. The first is that the code after
- # the loop won't run. The second is that any remaining callbacks scheduled
- # for this loop iteration will be silently dropped; they won't run, but they'll
- # also not be *stopped* (which is not a huge deal unless you're looking for
- # consistency or checking the boolean/pending status; the loop doesn't keep
- # a reference to them like it does to watchers...*UNLESS* the callback itself had
- # a reference to a watcher; then I don't know what would happen, it depends on
- # the state of the watcher---a leak or crash is not totally inconceivable).
- # The Cython implementation in core.ppyx uses gevent_call from callbacks.c
- # to run the callback, which uses gevent_handle_error to handle any errors the
- # Python callback raises...it unconditionally simply prints any error raised
- # by loop.handle_error and clears it, so callback handling continues.
- # We take a similar approach (but are extra careful about printing)
- try:
- self.handle_error(cb, *sys.exc_info())
- except: # pylint:disable=bare-except
- try:
- print("Exception while handling another error", file=sys.stderr)
- traceback.print_exc()
- except: # pylint:disable=bare-except
- pass # Nothing we can do here
- finally:
- # NOTE: this must be reset here, because cb.args is used as a flag in
- # the callback class so that bool(cb) of a callback that has been run
- # becomes False
- cb.args = None
-
- # We've finished running one group of callbacks
- # but we may have more, so before looping check our
- # switch interval.
- if count == 0 and self._callbacks:
- count = CALLBACK_CHECK_COUNT
- self.update_now()
- if self.now() >= expiration:
- now = 0
- break
-
- # Update the time before we start going again, if we didn't
- # just do so.
- if now != 0:
- self.update_now()
-
- if self._callbacks:
- self._start_callback_timer()
- finally:
- self.starting_timer_may_update_loop_time = False
-
- def _stop_aux_watchers(self):
- raise NotImplementedError()
-
- def destroy(self):
- if self._ptr:
- try:
- if not self._can_destroy_loop(self._ptr):
- return False
- self._stop_aux_watchers()
- self._destroy_loop(self._ptr)
- finally:
- # not ffi.NULL, we don't want something that can be
- # passed to C and crash later. This will create nice friendly
- # TypeError from CFFI.
- self._ptr = None
- del self._handle_to_self
- del self._callbacks
- del self._keepaliveset
-
- return True
-
- def _can_destroy_loop(self, ptr):
- raise NotImplementedError()
-
- def _destroy_loop(self, ptr):
- raise NotImplementedError()
-
- @property
- def ptr(self):
- return self._ptr
-
- @property
- def WatcherType(self):
- return self._watchers.watcher
-
- @property
- def MAXPRI(self):
- return 1
-
- @property
- def MINPRI(self):
- return 1
-
- def _handle_syserr(self, message, errno):
- try:
- errno = os.strerror(errno)
- except: # pylint:disable=bare-except
- traceback.print_exc()
- try:
- message = '%s: %s' % (message, errno)
- except: # pylint:disable=bare-except
- traceback.print_exc()
- self.handle_error(None, SystemError, SystemError(message), None)
-
- def handle_error(self, context, type, value, tb):
- handle_error = None
- error_handler = self.error_handler
- if error_handler is not None:
- # we do want to do getattr every time so that setting Hub.handle_error property just works
- handle_error = getattr(error_handler, 'handle_error', error_handler)
- handle_error(context, type, value, tb)
- else:
- self._default_handle_error(context, type, value, tb)
-
- def _default_handle_error(self, context, type, value, tb): # pylint:disable=unused-argument
- # note: Hub sets its own error handler so this is not used by gevent
- # this is here to make core.loop usable without the rest of gevent
- # Should cause the loop to stop running.
- traceback.print_exception(type, value, tb)
-
-
- def run(self, nowait=False, once=False):
- raise NotImplementedError()
-
- def reinit(self):
- raise NotImplementedError()
-
- def ref(self):
- # XXX: libuv doesn't do it this way
- raise NotImplementedError()
-
- def unref(self):
- raise NotImplementedError()
-
- def break_(self, how=None):
- raise NotImplementedError()
-
- def verify(self):
- pass
-
- def now(self):
- raise NotImplementedError()
-
- def update_now(self):
- raise NotImplementedError()
-
- def update(self):
- import warnings
- warnings.warn("'update' is deprecated; use 'update_now'",
- DeprecationWarning,
- stacklevel=2)
- self.update_now()
-
- def __repr__(self):
- return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format())
-
- @property
- def default(self):
- return self._default if self._ptr else False
-
- @property
- def iteration(self):
- return -1
-
- @property
- def depth(self):
- return -1
-
- @property
- def backend_int(self):
- return 0
-
- @property
- def backend(self):
- return "default"
-
- @property
- def pendingcnt(self):
- return 0
-
- def io(self, fd, events, ref=True, priority=None):
- return self._watchers.io(self, fd, events, ref, priority)
-
- def timer(self, after, repeat=0.0, ref=True, priority=None):
- return self._watchers.timer(self, after, repeat, ref, priority)
-
- def signal(self, signum, ref=True, priority=None):
- return self._watchers.signal(self, signum, ref, priority)
-
- def idle(self, ref=True, priority=None):
- return self._watchers.idle(self, ref, priority)
-
- def prepare(self, ref=True, priority=None):
- return self._watchers.prepare(self, ref, priority)
-
- def check(self, ref=True, priority=None):
- return self._watchers.check(self, ref, priority)
-
- def fork(self, ref=True, priority=None):
- return self._watchers.fork(self, ref, priority)
-
- def async_(self, ref=True, priority=None):
- return self._watchers.async_(self, ref, priority)
-
- # Provide BWC for those that can use 'async' as is
- locals()['async'] = async_
-
- if sys.platform != "win32":
-
- def child(self, pid, trace=0, ref=True):
- return self._watchers.child(self, pid, trace, ref)
-
- def install_sigchld(self):
- pass
-
- def stat(self, path, interval=0.0, ref=True, priority=None):
- return self._watchers.stat(self, path, interval, ref, priority)
-
- def callback(self, priority=None):
- return callback(self, priority)
-
- def _setup_for_run_callback(self):
- raise NotImplementedError()
-
- def run_callback(self, func, *args):
- # If we happen to already be running callbacks (inside
- # _run_callbacks), this could happen almost immediately,
- # without the loop cycling.
- cb = callback(func, args)
- self._callbacks.append(cb)
- self._setup_for_run_callback()
-
- return cb
-
- def _format(self):
- if not self._ptr:
- return 'destroyed'
- msg = self.backend
- if self.default:
- msg += ' default'
- msg += ' pending=%s' % self.pendingcnt
- msg += self._format_details()
- return msg
-
- def _format_details(self):
- msg = ''
- fileno = self.fileno() # pylint:disable=assignment-from-none
- try:
- activecnt = self.activecnt
- except AttributeError:
- activecnt = None
- if activecnt is not None:
- msg += ' ref=' + repr(activecnt)
- if fileno is not None:
- msg += ' fileno=' + repr(fileno)
- #if sigfd is not None and sigfd != -1:
- # msg += ' sigfd=' + repr(sigfd)
- return msg
-
- def fileno(self):
- return None
-
- @property
- def activecnt(self):
- if not self._ptr:
- raise ValueError('operation on destroyed loop')
- return 0
diff --git a/python/gevent/_ffi/watcher.py b/python/gevent/_ffi/watcher.py
deleted file mode 100644
index 3f880ce..0000000
--- a/python/gevent/_ffi/watcher.py
+++ /dev/null
@@ -1,641 +0,0 @@
-"""
-Useful base classes for watchers. The available
-watchers will depend on the specific event loop.
-"""
-# pylint:disable=not-callable
-from __future__ import absolute_import, print_function
-
-import signal as signalmodule
-import functools
-import warnings
-
-from gevent._config import config
-
-try:
- from tracemalloc import get_object_traceback
-
- def tracemalloc(init):
- # PYTHONTRACEMALLOC env var controls this on Python 3.
- return init
-except ImportError: # Python < 3.4
-
- if config.trace_malloc:
- # Use the same env var to turn this on for Python 2
- import traceback
-
- class _TB(object):
- __slots__ = ('lines',)
-
- def __init__(self, lines):
- # These end in newlines, which we don't want for consistency
- self.lines = [x.rstrip() for x in lines]
-
- def format(self):
- return self.lines
-
- def tracemalloc(init):
- @functools.wraps(init)
- def traces(self, *args, **kwargs):
- init(self, *args, **kwargs)
- self._captured_malloc = _TB(traceback.format_stack())
- return traces
-
- def get_object_traceback(obj):
- return obj._captured_malloc
-
- else:
- def get_object_traceback(_obj):
- return None
-
- def tracemalloc(init):
- return init
-
-from gevent._compat import fsencode
-
-from gevent._ffi import _dbg # pylint:disable=unused-import
-from gevent._ffi import GEVENT_DEBUG_LEVEL
-from gevent._ffi import DEBUG
-from gevent._ffi.loop import GEVENT_CORE_EVENTS
-from gevent._ffi.loop import _NOARGS
-
-ALLOW_WATCHER_DEL = GEVENT_DEBUG_LEVEL >= DEBUG
-
-__all__ = [
-
-]
-
-try:
- ResourceWarning
-except NameError:
- class ResourceWarning(Warning):
- "Python 2 fallback"
-
-class _NoWatcherResult(int):
-
- def __repr__(self):
- return "<NoWatcher>"
-
-_NoWatcherResult = _NoWatcherResult(0)
-
-def events_to_str(event_field, all_events):
- result = []
- for (flag, string) in all_events:
- c_flag = flag
- if event_field & c_flag:
- result.append(string)
- event_field = event_field & (~c_flag)
- if not event_field:
- break
- if event_field:
- result.append(hex(event_field))
- return '|'.join(result)
-
-
-def not_while_active(func):
- @functools.wraps(func)
- def nw(self, *args, **kwargs):
- if self.active:
- raise ValueError("not while active")
- func(self, *args, **kwargs)
- return nw
-
-def only_if_watcher(func):
- @functools.wraps(func)
- def if_w(self):
- if self._watcher:
- return func(self)
- return _NoWatcherResult
- return if_w
-
-
-class LazyOnClass(object):
-
- @classmethod
- def lazy(cls, cls_dict, func):
- "Put a LazyOnClass object in *cls_dict* with the same name as *func*"
- cls_dict[func.__name__] = cls(func)
-
- def __init__(self, func, name=None):
- self.name = name or func.__name__
- self.func = func
-
- def __get__(self, inst, klass):
- if inst is None: # pragma: no cover
- return self
-
- val = self.func(inst)
- setattr(klass, self.name, val)
- return val
-
-
-class AbstractWatcherType(type):
- """
- Base metaclass for watchers.
-
- To use, you will:
-
- - subclass the watcher class defined from this type.
- - optionally subclass this type
- """
- # pylint:disable=bad-mcs-classmethod-argument
-
- _FFI = None
- _LIB = None
-
- def __new__(cls, name, bases, cls_dict):
- if name != 'watcher' and not cls_dict.get('_watcher_skip_ffi'):
- cls._fill_watcher(name, bases, cls_dict)
- if '__del__' in cls_dict and not ALLOW_WATCHER_DEL: # pragma: no cover
- raise TypeError("CFFI watchers are not allowed to have __del__")
- return type.__new__(cls, name, bases, cls_dict)
-
- @classmethod
- def _fill_watcher(cls, name, bases, cls_dict):
- # TODO: refactor smaller
- # pylint:disable=too-many-locals
- if name.endswith('_'):
- # Strip trailing _ added to avoid keyword duplications
- # e.g., async_
- name = name[:-1]
-
- def _mro_get(attr, bases, error=True):
- for b in bases:
- try:
- return getattr(b, attr)
- except AttributeError:
- continue
- if error: # pragma: no cover
- raise AttributeError(attr)
- _watcher_prefix = cls_dict.get('_watcher_prefix') or _mro_get('_watcher_prefix', bases)
-
- if '_watcher_type' not in cls_dict:
- watcher_type = _watcher_prefix + '_' + name
- cls_dict['_watcher_type'] = watcher_type
- elif not cls_dict['_watcher_type'].startswith(_watcher_prefix):
- watcher_type = _watcher_prefix + '_' + cls_dict['_watcher_type']
- cls_dict['_watcher_type'] = watcher_type
-
- active_name = _watcher_prefix + '_is_active'
-
- def _watcher_is_active(self):
- return getattr(self._LIB, active_name)
-
- LazyOnClass.lazy(cls_dict, _watcher_is_active)
-
- watcher_struct_name = cls_dict.get('_watcher_struct_name')
- if not watcher_struct_name:
- watcher_struct_pattern = (cls_dict.get('_watcher_struct_pattern')
- or _mro_get('_watcher_struct_pattern', bases, False)
- or 'struct %s')
- watcher_struct_name = watcher_struct_pattern % (watcher_type,)
-
- def _watcher_struct_pointer_type(self):
- return self._FFI.typeof(watcher_struct_name + ' *')
-
- LazyOnClass.lazy(cls_dict, _watcher_struct_pointer_type)
-
- callback_name = (cls_dict.get('_watcher_callback_name')
- or _mro_get('_watcher_callback_name', bases, False)
- or '_gevent_generic_callback')
-
- def _watcher_callback(self):
- return self._FFI.addressof(self._LIB, callback_name)
-
- LazyOnClass.lazy(cls_dict, _watcher_callback)
-
- def _make_meth(name, watcher_name):
- def meth(self):
- lib_name = self._watcher_type + '_' + name
- return getattr(self._LIB, lib_name)
- meth.__name__ = watcher_name
- return meth
-
- for meth_name in 'start', 'stop', 'init':
- watcher_name = '_watcher' + '_' + meth_name
- if watcher_name not in cls_dict:
- LazyOnClass.lazy(cls_dict, _make_meth(meth_name, watcher_name))
-
- def new_handle(cls, obj):
- return cls._FFI.new_handle(obj)
-
- def new(cls, kind):
- return cls._FFI.new(kind)
-
-class watcher(object):
-
- _callback = None
- _args = None
- _watcher = None
- # self._handle has a reference to self, keeping it alive.
- # We must keep self._handle alive for ffi.from_handle() to be
- # able to work. We only fill this in when we are started,
- # and when we are stopped we destroy it.
- # NOTE: This is a GC cycle, so we keep it around for as short
- # as possible.
- _handle = None
-
- @tracemalloc
- def __init__(self, _loop, ref=True, priority=None, args=_NOARGS):
- self.loop = _loop
- self.__init_priority = priority
- self.__init_args = args
- self.__init_ref = ref
- self._watcher_full_init()
-
-
- def _watcher_full_init(self):
- priority = self.__init_priority
- ref = self.__init_ref
- args = self.__init_args
-
- self._watcher_create(ref)
-
- if priority is not None:
- self._watcher_ffi_set_priority(priority)
-
- try:
- self._watcher_ffi_init(args)
- except:
- # Let these be GC'd immediately.
- # If we keep them around to when *we* are gc'd,
- # they're probably invalid, meaning any native calls
- # we do then to close() them are likely to fail
- self._watcher = None
- raise
- self._watcher_ffi_set_init_ref(ref)
-
- @classmethod
- def _watcher_ffi_close(cls, ffi_watcher):
- pass
-
- def _watcher_create(self, ref): # pylint:disable=unused-argument
- self._watcher = self._watcher_new()
-
- def _watcher_new(self):
- return type(self).new(self._watcher_struct_pointer_type) # pylint:disable=no-member
-
- def _watcher_ffi_set_init_ref(self, ref):
- pass
-
- def _watcher_ffi_set_priority(self, priority):
- pass
-
- def _watcher_ffi_init(self, args):
- raise NotImplementedError()
-
- def _watcher_ffi_start(self):
- raise NotImplementedError()
-
- def _watcher_ffi_stop(self):
- self._watcher_stop(self.loop._ptr, self._watcher)
-
- def _watcher_ffi_ref(self):
- raise NotImplementedError()
-
- def _watcher_ffi_unref(self):
- raise NotImplementedError()
-
- def _watcher_ffi_start_unref(self):
- # While a watcher is active, we don't keep it
- # referenced. This allows a timer, for example, to be started,
- # and still allow the loop to end if there is nothing
- # else to do. see test__order.TestSleep0 for one example.
- self._watcher_ffi_unref()
-
- def _watcher_ffi_stop_ref(self):
- self._watcher_ffi_ref()
-
- # A string identifying the type of libev object we watch, e.g., 'ev_io'
- # This should be a class attribute.
- _watcher_type = None
- # A class attribute that is the callback on the libev object that init's the C struct,
- # e.g., libev.ev_io_init. If None, will be set by _init_subclasses.
- _watcher_init = None
- # A class attribute that is the callback on the libev object that starts the C watcher,
- # e.g., libev.ev_io_start. If None, will be set by _init_subclasses.
- _watcher_start = None
- # A class attribute that is the callback on the libev object that stops the C watcher,
- # e.g., libev.ev_io_stop. If None, will be set by _init_subclasses.
- _watcher_stop = None
- # A cffi ctype object identifying the struct pointer we create.
- # This is a class attribute set based on the _watcher_type
- _watcher_struct_pointer_type = None
- # The attribute of the libev object identifying the custom
- # callback function for this type of watcher. This is a class
- # attribute set based on the _watcher_type in _init_subclasses.
- _watcher_callback = None
- _watcher_is_active = None
-
- def close(self):
- if self._watcher is None:
- return
-
- self.stop()
- _watcher = self._watcher
- self._watcher = None
- self._watcher_set_data(_watcher, self._FFI.NULL) # pylint: disable=no-member
- self._watcher_ffi_close(_watcher)
- self.loop = None
-
- def _watcher_set_data(self, the_watcher, data):
- # This abstraction exists for the sole benefit of
- # libuv.watcher.stat, which "subclasses" uv_handle_t.
- # Can we do something to avoid this extra function call?
- the_watcher.data = data
- return data
-
- def __enter__(self):
- return self
-
- def __exit__(self, t, v, tb):
- self.close()
-
- if ALLOW_WATCHER_DEL:
- def __del__(self):
- if self._watcher:
- tb = get_object_traceback(self)
- tb_msg = ''
- if tb is not None:
- tb_msg = '\n'.join(tb.format())
- tb_msg = '\nTraceback:\n' + tb_msg
- warnings.warn("Failed to close watcher %r%s" % (self, tb_msg),
- ResourceWarning)
-
- # may fail if __init__ did; will be harmlessly printed
- self.close()
-
-
- def __repr__(self):
- formats = self._format()
- result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), formats)
- if self.pending:
- result += " pending"
- if self.callback is not None:
- fself = getattr(self.callback, '__self__', None)
- if fself is self:
- result += " callback=<bound method %s of self>" % (self.callback.__name__)
- else:
- result += " callback=%r" % (self.callback, )
- if self.args is not None:
- result += " args=%r" % (self.args, )
- if self.callback is None and self.args is None:
- result += " stopped"
- result += " watcher=%s" % (self._watcher)
- result += " handle=%s" % (self._watcher_handle)
- result += " ref=%s" % (self.ref)
- return result + ">"
-
- @property
- def _watcher_handle(self):
- if self._watcher:
- return self._watcher.data
-
- def _format(self):
- return ''
-
- @property
- def ref(self):
- raise NotImplementedError()
-
- def _get_callback(self):
- return self._callback
-
- def _set_callback(self, cb):
- if not callable(cb) and cb is not None:
- raise TypeError("Expected callable, not %r" % (cb, ))
- if cb is None:
- if '_callback' in self.__dict__:
- del self._callback
- else:
- self._callback = cb
- callback = property(_get_callback, _set_callback)
-
- def _get_args(self):
- return self._args
-
- def _set_args(self, args):
- if not isinstance(args, tuple) and args is not None:
- raise TypeError("args must be a tuple or None")
- if args is None:
- if '_args' in self.__dict__:
- del self._args
- else:
- self._args = args
-
- args = property(_get_args, _set_args)
-
- def start(self, callback, *args):
- if callback is None:
- raise TypeError('callback must be callable, not None')
- self.callback = callback
- self.args = args or _NOARGS
- self.loop._keepaliveset.add(self)
- self._handle = self._watcher_set_data(self._watcher, type(self).new_handle(self)) # pylint:disable=no-member
- self._watcher_ffi_start()
- self._watcher_ffi_start_unref()
-
- def stop(self):
- if self._callback is None:
- assert self.loop is None or self not in self.loop._keepaliveset
- return
- self._watcher_ffi_stop_ref()
- self._watcher_ffi_stop()
- self.loop._keepaliveset.discard(self)
- self._handle = None
- self._watcher_set_data(self._watcher, self._FFI.NULL) # pylint:disable=no-member
- self.callback = None
- self.args = None
-
- def _get_priority(self):
- return None
-
- @not_while_active
- def _set_priority(self, priority):
- pass
-
- priority = property(_get_priority, _set_priority)
-
-
- @property
- def active(self):
- if self._watcher is not None and self._watcher_is_active(self._watcher):
- return True
- return False
-
- @property
- def pending(self):
- return False
-
-watcher = AbstractWatcherType('watcher', (object,), dict(watcher.__dict__))
-
-class IoMixin(object):
-
- EVENT_MASK = 0
-
- def __init__(self, loop, fd, events, ref=True, priority=None, _args=None):
- # Win32 only works with sockets, and only when we use libuv, because
- # we don't use _open_osfhandle. See libuv/watchers.py:io for a description.
- if fd < 0:
- raise ValueError('fd must be non-negative: %r' % fd)
- if events & ~self.EVENT_MASK:
- raise ValueError('illegal event mask: %r' % events)
- self._fd = fd
- super(IoMixin, self).__init__(loop, ref=ref, priority=priority,
- args=_args or (fd, events))
-
- def start(self, callback, *args, **kwargs):
- args = args or _NOARGS
- if kwargs.get('pass_events'):
- args = (GEVENT_CORE_EVENTS, ) + args
- super(IoMixin, self).start(callback, *args)
-
- def _format(self):
- return ' fd=%d' % self._fd
-
-class TimerMixin(object):
- _watcher_type = 'timer'
-
- def __init__(self, loop, after=0.0, repeat=0.0, ref=True, priority=None):
- if repeat < 0.0:
- raise ValueError("repeat must be positive or zero: %r" % repeat)
- self._after = after
- self._repeat = repeat
- super(TimerMixin, self).__init__(loop, ref=ref, priority=priority, args=(after, repeat))
-
- def start(self, callback, *args, **kw):
- update = kw.get("update", self.loop.starting_timer_may_update_loop_time)
- if update:
- # Quoth the libev doc: "This is a costly operation and is
- # usually done automatically within ev_run(). This
- # function is rarely useful, but when some event callback
- # runs for a very long time without entering the event
- # loop, updating libev's idea of the current time is a
- # good idea."
-
- # 1.3 changed the default for this to False *unless* the loop is
- # running a callback; see libuv for details. Note that
- # starting Timeout objects still sets this to true.
-
- self.loop.update_now()
- super(TimerMixin, self).start(callback, *args)
-
- def again(self, callback, *args, **kw):
- raise NotImplementedError()
-
-
-class SignalMixin(object):
- _watcher_type = 'signal'
-
- def __init__(self, loop, signalnum, ref=True, priority=None):
- if signalnum < 1 or signalnum >= signalmodule.NSIG:
- raise ValueError('illegal signal number: %r' % signalnum)
- # still possible to crash on one of libev's asserts:
- # 1) "libev: ev_signal_start called with illegal signal number"
- # EV_NSIG might be different from signal.NSIG on some platforms
- # 2) "libev: a signal must not be attached to two different loops"
- # we probably could check that in LIBEV_EMBED mode, but not in general
- self._signalnum = signalnum
- super(SignalMixin, self).__init__(loop, ref=ref, priority=priority, args=(signalnum, ))
-
-
-class IdleMixin(object):
- _watcher_type = 'idle'
-
-
-class PrepareMixin(object):
- _watcher_type = 'prepare'
-
-
-class CheckMixin(object):
- _watcher_type = 'check'
-
-
-class ForkMixin(object):
- _watcher_type = 'fork'
-
-
-class AsyncMixin(object):
- _watcher_type = 'async'
-
- def send(self):
- raise NotImplementedError()
-
- @property
- def pending(self):
- raise NotImplementedError()
-
-
-class ChildMixin(object):
-
- # hack for libuv which doesn't extend watcher
- _CALL_SUPER_INIT = True
-
- def __init__(self, loop, pid, trace=0, ref=True):
- if not loop.default:
- raise TypeError('child watchers are only available on the default loop')
- loop.install_sigchld()
- self._pid = pid
- if self._CALL_SUPER_INIT:
- super(ChildMixin, self).__init__(loop, ref=ref, args=(pid, trace))
-
- def _format(self):
- return ' pid=%r rstatus=%r' % (self.pid, self.rstatus)
-
- @property
- def pid(self):
- return self._pid
-
- @property
- def rpid(self):
- # The received pid, the result of the waitpid() call.
- return self._rpid
-
- _rpid = None
- _rstatus = 0
-
- @property
- def rstatus(self):
- return self._rstatus
-
-class StatMixin(object):
-
- @staticmethod
- def _encode_path(path):
- return fsencode(path)
-
- def __init__(self, _loop, path, interval=0.0, ref=True, priority=None):
- # Store the encoded path in the same attribute that corecext does
- self._paths = self._encode_path(path)
-
- # Keep the original path to avoid re-encoding, especially on Python 3
- self._path = path
-
- # Although CFFI would automatically convert a bytes object into a char* when
- # calling ev_stat_init(..., char*, ...), on PyPy the char* pointer is not
- # guaranteed to live past the function call. On CPython, only with a constant/interned
- # bytes object is the pointer guaranteed to last path the function call. (And since
- # Python 3 is pretty much guaranteed to produce a newly-encoded bytes object above, thats
- # rarely the case). Therefore, we must keep a reference to the produced cdata object
- # so that the struct ev_stat_watcher's `path` pointer doesn't become invalid/deallocated
- self._cpath = self._FFI.new('char[]', self._paths)
-
- self._interval = interval
- super(StatMixin, self).__init__(_loop, ref=ref, priority=priority,
- args=(self._cpath,
- interval))
-
- @property
- def path(self):
- return self._path
-
- @property
- def attr(self):
- raise NotImplementedError
-
- @property
- def prev(self):
- raise NotImplementedError
-
- @property
- def interval(self):
- return self._interval
diff --git a/python/gevent/_fileobjectcommon.py b/python/gevent/_fileobjectcommon.py
deleted file mode 100644
index 38b1da7..0000000
--- a/python/gevent/_fileobjectcommon.py
+++ /dev/null
@@ -1,275 +0,0 @@
-from __future__ import absolute_import, print_function, division
-
-try:
- from errno import EBADF
-except ImportError:
- EBADF = 9
-
-import os
-from io import TextIOWrapper
-import functools
-import sys
-
-
-from gevent.hub import _get_hub_noargs as get_hub
-from gevent._compat import integer_types
-from gevent._compat import reraise
-from gevent.lock import Semaphore, DummySemaphore
-
-class cancel_wait_ex(IOError):
-
- def __init__(self):
- super(cancel_wait_ex, self).__init__(
- EBADF, 'File descriptor was closed in another greenlet')
-
-
-class FileObjectClosed(IOError):
-
- def __init__(self):
- super(FileObjectClosed, self).__init__(
- EBADF, 'Bad file descriptor (FileObject was closed)')
-
-class FileObjectBase(object):
- """
- Internal base class to ensure a level of consistency
- between FileObjectPosix and FileObjectThread
- """
-
- # List of methods we delegate to the wrapping IO object, if they
- # implement them and we do not.
- _delegate_methods = (
- # General methods
- 'flush',
- 'fileno',
- 'writable',
- 'readable',
- 'seek',
- 'seekable',
- 'tell',
-
- # Read
- 'read',
- 'readline',
- 'readlines',
- 'read1',
-
- # Write
- 'write',
- 'writelines',
- 'truncate',
- )
-
-
- # Whether we are translating universal newlines or not.
- _translate = False
-
- _translate_encoding = None
- _translate_errors = None
-
- def __init__(self, io, closefd):
- """
- :param io: An io.IOBase-like object.
- """
- self._io = io
- # We don't actually use this property ourself, but we save it (and
- # pass it along) for compatibility.
- self._close = closefd
-
- if self._translate:
- # This automatically handles delegation by assigning to
- # self.io
- self.translate_newlines(None, self._translate_encoding, self._translate_errors)
- else:
- self._do_delegate_methods()
-
-
- io = property(lambda s: s._io,
- # Historically we either hand-wrote all the delegation methods
- # to use self.io, or we simply used __getattr__ to look them up at
- # runtime. This meant people could change the io attribute on the fly
- # and it would mostly work (subprocess.py used to do that). We don't recommend
- # that, but we still support it.
- lambda s, nv: setattr(s, '_io', nv) or s._do_delegate_methods())
-
- def _do_delegate_methods(self):
- for meth_name in self._delegate_methods:
- meth = getattr(self._io, meth_name, None)
- implemented_by_class = hasattr(type(self), meth_name)
- if meth and not implemented_by_class:
- setattr(self, meth_name, self._wrap_method(meth))
- elif hasattr(self, meth_name) and not implemented_by_class:
- delattr(self, meth_name)
-
- def _wrap_method(self, method):
- """
- Wrap a method we're copying into our dictionary from the underlying
- io object to do something special or different, if necessary.
- """
- return method
-
- def translate_newlines(self, mode, *text_args, **text_kwargs):
- wrapper = TextIOWrapper(self._io, *text_args, **text_kwargs)
- if mode:
- wrapper.mode = mode
- self.io = wrapper
- self._translate = True
-
- @property
- def closed(self):
- """True if the file is closed"""
- return self._io is None
-
- def close(self):
- if self._io is None:
- return
-
- io = self._io
- self._io = None
- self._do_close(io, self._close)
-
- def _do_close(self, fobj, closefd):
- raise NotImplementedError()
-
- def __getattr__(self, name):
- if self._io is None:
- raise FileObjectClosed()
- return getattr(self._io, name)
-
- def __repr__(self):
- return '<%s _fobj=%r%s>' % (self.__class__.__name__, self.io, self._extra_repr())
-
- def _extra_repr(self):
- return ''
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args):
- self.close()
-
-class FileObjectBlock(FileObjectBase):
-
- def __init__(self, fobj, *args, **kwargs):
- closefd = kwargs.pop('close', True)
- if kwargs:
- raise TypeError('Unexpected arguments: %r' % kwargs.keys())
- if isinstance(fobj, integer_types):
- if not closefd:
- # we cannot do this, since fdopen object will close the descriptor
- raise TypeError('FileObjectBlock does not support close=False on an fd.')
- fobj = os.fdopen(fobj, *args)
- super(FileObjectBlock, self).__init__(fobj, closefd)
-
- def _do_close(self, fobj, closefd):
- fobj.close()
-
-class FileObjectThread(FileObjectBase):
- """
- A file-like object wrapping another file-like object, performing all blocking
- operations on that object in a background thread.
-
- .. caution::
- Attempting to change the threadpool or lock of an existing FileObjectThread
- has undefined consequences.
-
- .. versionchanged:: 1.1b1
- The file object is closed using the threadpool. Note that whether or
- not this action is synchronous or asynchronous is not documented.
-
- """
-
- def __init__(self, fobj, mode=None, bufsize=-1, close=True, threadpool=None, lock=True):
- """
- :param fobj: The underlying file-like object to wrap, or an integer fileno
- that will be pass to :func:`os.fdopen` along with *mode* and *bufsize*.
- :keyword bool lock: If True (the default) then all operations will
- be performed one-by-one. Note that this does not guarantee that, if using
- this file object from multiple threads/greenlets, operations will be performed
- in any particular order, only that no two operations will be attempted at the
- same time. You can also pass your own :class:`gevent.lock.Semaphore` to synchronize
- file operations with an external resource.
- :keyword bool close: If True (the default) then when this object is closed,
- the underlying object is closed as well.
- """
- closefd = close
- self.threadpool = threadpool or get_hub().threadpool
- self.lock = lock
- if self.lock is True:
- self.lock = Semaphore()
- elif not self.lock:
- self.lock = DummySemaphore()
- if not hasattr(self.lock, '__enter__'):
- raise TypeError('Expected a Semaphore or boolean, got %r' % type(self.lock))
- if isinstance(fobj, integer_types):
- if not closefd:
- # we cannot do this, since fdopen object will close the descriptor
- raise TypeError('FileObjectThread does not support close=False on an fd.')
- if mode is None:
- assert bufsize == -1, "If you use the default mode, you can't choose a bufsize"
- fobj = os.fdopen(fobj)
- else:
- fobj = os.fdopen(fobj, mode, bufsize)
-
- self.__io_holder = [fobj] # signal for _wrap_method
- super(FileObjectThread, self).__init__(fobj, closefd)
-
- def _do_close(self, fobj, closefd):
- self.__io_holder[0] = None # for _wrap_method
- try:
- with self.lock:
- self.threadpool.apply(fobj.flush)
- finally:
- if closefd:
- # Note that we're not taking the lock; older code
- # did fobj.close() without going through the threadpool at all,
- # so acquiring the lock could potentially introduce deadlocks
- # that weren't present before. Avoiding the lock doesn't make
- # the existing race condition any worse.
- # We wrap the close in an exception handler and re-raise directly
- # to avoid the (common, expected) IOError from being logged by the pool
- def close():
- try:
- fobj.close()
- except: # pylint:disable=bare-except
- return sys.exc_info()
- exc_info = self.threadpool.apply(close)
- if exc_info:
- reraise(*exc_info)
-
- def _do_delegate_methods(self):
- super(FileObjectThread, self)._do_delegate_methods()
- if not hasattr(self, 'read1') and 'r' in getattr(self._io, 'mode', ''):
- self.read1 = self.read
- self.__io_holder[0] = self._io
-
- def _extra_repr(self):
- return ' threadpool=%r' % (self.threadpool,)
-
- def __iter__(self):
- return self
-
- def next(self):
- line = self.readline()
- if line:
- return line
- raise StopIteration
- __next__ = next
-
- def _wrap_method(self, method):
- # NOTE: We are careful to avoid introducing a refcycle
- # within self. Our wrapper cannot refer to self.
- io_holder = self.__io_holder
- lock = self.lock
- threadpool = self.threadpool
-
- @functools.wraps(method)
- def thread_method(*args, **kwargs):
- if io_holder[0] is None:
- # This is different than FileObjectPosix, etc,
- # because we want to save the expensive trip through
- # the threadpool.
- raise FileObjectClosed()
- with lock:
- return threadpool.apply(method, args, kwargs)
-
- return thread_method
diff --git a/python/gevent/_fileobjectposix.py b/python/gevent/_fileobjectposix.py
deleted file mode 100644
index 93dd65f..0000000
--- a/python/gevent/_fileobjectposix.py
+++ /dev/null
@@ -1,320 +0,0 @@
-from __future__ import absolute_import
-import os
-import io
-from io import BufferedReader
-from io import BufferedWriter
-from io import BytesIO
-from io import DEFAULT_BUFFER_SIZE
-from io import RawIOBase
-from io import UnsupportedOperation
-
-from gevent._fileobjectcommon import cancel_wait_ex
-from gevent._fileobjectcommon import FileObjectBase
-from gevent.hub import get_hub
-from gevent.os import _read
-from gevent.os import _write
-from gevent.os import ignored_errors
-from gevent.os import make_nonblocking
-
-
-class GreenFileDescriptorIO(RawIOBase):
-
- # Note that RawIOBase has a __del__ method that calls
- # self.close(). (In C implementations like CPython, this is
- # the type's tp_dealloc slot; prior to Python 3, the object doesn't
- # appear to have a __del__ method, even though it functionally does)
-
- _read_event = None
- _write_event = None
- _closed = False
- _seekable = None
-
- def __init__(self, fileno, mode='r', closefd=True):
- RawIOBase.__init__(self) # Python 2: pylint:disable=no-member,non-parent-init-called
- self._closefd = closefd
- self._fileno = fileno
- make_nonblocking(fileno)
- readable = 'r' in mode
- writable = 'w' in mode
- self.hub = get_hub()
-
- io_watcher = self.hub.loop.io
- if readable:
- self._read_event = io_watcher(fileno, 1)
-
- if writable:
- self._write_event = io_watcher(fileno, 2)
-
- def readable(self):
- return self._read_event is not None
-
- def writable(self):
- return self._write_event is not None
-
- def seekable(self):
- if self._seekable is None:
- try:
- os.lseek(self._fileno, 0, os.SEEK_CUR)
- except OSError:
- self._seekable = False
- else:
- self._seekable = True
- return self._seekable
-
- def fileno(self):
- return self._fileno
-
- @property
- def closed(self):
- return self._closed
-
- def close(self):
- if self._closed:
- return
- self.flush()
- # TODO: Can we use 'read_event is not None and write_event is
- # not None' to mean _closed?
- self._closed = True
- read_event = self._read_event
- write_event = self._write_event
- self._read_event = self._write_event = None
-
- if read_event is not None:
- self.hub.cancel_wait(read_event, cancel_wait_ex, True)
- if write_event is not None:
- self.hub.cancel_wait(write_event, cancel_wait_ex, True)
-
- fileno = self._fileno
- if self._closefd:
- self._fileno = None
- os.close(fileno)
-
- # RawIOBase provides a 'read' method that will call readall() if
- # the `size` was missing or -1 and otherwise call readinto(). We
- # want to take advantage of this to avoid single byte reads when
- # possible. This is highlighted by a bug in BufferedIOReader that
- # calls read() in a loop when its readall() method is invoked;
- # this was fixed in Python 3.3, but we still need our workaround for 2.7. See
- # https://github.com/gevent/gevent/issues/675)
- def __read(self, n):
- if self._read_event is None:
- raise UnsupportedOperation('read')
- while True:
- try:
- return _read(self._fileno, n)
- except (IOError, OSError) as ex:
- if ex.args[0] not in ignored_errors:
- raise
- self.hub.wait(self._read_event)
-
- def readall(self):
- ret = BytesIO()
- while True:
- data = self.__read(DEFAULT_BUFFER_SIZE)
- if not data:
- break
- ret.write(data)
- return ret.getvalue()
-
- def readinto(self, b):
- data = self.__read(len(b))
- n = len(data)
- try:
- b[:n] = data
- except TypeError as err:
- import array
- if not isinstance(b, array.array):
- raise err
- b[:n] = array.array(b'b', data)
- return n
-
- def write(self, b):
- if self._write_event is None:
- raise UnsupportedOperation('write')
- while True:
- try:
- return _write(self._fileno, b)
- except (IOError, OSError) as ex:
- if ex.args[0] not in ignored_errors:
- raise
- self.hub.wait(self._write_event)
-
- def seek(self, offset, whence=0):
- return os.lseek(self._fileno, offset, whence)
-
-class FlushingBufferedWriter(BufferedWriter):
-
- def write(self, b):
- ret = BufferedWriter.write(self, b)
- self.flush()
- return ret
-
-class FileObjectPosix(FileObjectBase):
- """
- A file-like object that operates on non-blocking files but
- provides a synchronous, cooperative interface.
-
- .. caution::
- This object is only effective wrapping files that can be used meaningfully
- with :func:`select.select` such as sockets and pipes.
-
- In general, on most platforms, operations on regular files
- (e.g., ``open('a_file.txt')``) are considered non-blocking
- already, even though they can take some time to complete as
- data is copied to the kernel and flushed to disk: this time
- is relatively bounded compared to sockets or pipes, though.
- A :func:`~os.read` or :func:`~os.write` call on such a file
- will still effectively block for some small period of time.
- Therefore, wrapping this class around a regular file is
- unlikely to make IO gevent-friendly: reading or writing large
- amounts of data could still block the event loop.
-
- If you'll be working with regular files and doing IO in large
- chunks, you may consider using
- :class:`~gevent.fileobject.FileObjectThread` or
- :func:`~gevent.os.tp_read` and :func:`~gevent.os.tp_write` to bypass this
- concern.
-
- .. note::
- Random read/write (e.g., ``mode='rwb'``) is not supported.
- For that, use :class:`io.BufferedRWPair` around two instance of this
- class.
-
- .. tip::
- Although this object provides a :meth:`fileno` method and so
- can itself be passed to :func:`fcntl.fcntl`, setting the
- :data:`os.O_NONBLOCK` flag will have no effect (reads will
- still block the greenlet, although other greenlets can run).
- However, removing that flag *will cause this object to no
- longer be cooperative* (other greenlets will no longer run).
-
- You can use the internal ``fileio`` attribute of this object
- (a :class:`io.RawIOBase`) to perform non-blocking byte reads.
- Note, however, that once you begin directly using this
- attribute, the results from using methods of *this* object
- are undefined, especially in text mode. (See :issue:`222`.)
-
- .. versionchanged:: 1.1
- Now uses the :mod:`io` package internally. Under Python 2, previously
- used the undocumented class :class:`socket._fileobject`. This provides
- better file-like semantics (and portability to Python 3).
- .. versionchanged:: 1.2a1
- Document the ``fileio`` attribute for non-blocking reads.
- """
-
- #: platform specific default for the *bufsize* parameter
- default_bufsize = io.DEFAULT_BUFFER_SIZE
-
- def __init__(self, fobj, mode='rb', bufsize=-1, close=True):
- """
- :param fobj: Either an integer fileno, or an object supporting the
- usual :meth:`socket.fileno` method. The file *will* be
- put in non-blocking mode using :func:`gevent.os.make_nonblocking`.
- :keyword str mode: The manner of access to the file, one of "rb", "rU" or "wb"
- (where the "b" or "U" can be omitted).
- If "U" is part of the mode, universal newlines will be used. On Python 2,
- if 't' is not in the mode, this will result in returning byte (native) strings;
- putting 't' in the mode will return text strings. This may cause
- :exc:`UnicodeDecodeError` to be raised.
- :keyword int bufsize: If given, the size of the buffer to use. The default
- value means to use a platform-specific default
- Other values are interpreted as for the :mod:`io` package.
- Buffering is ignored in text mode.
-
- .. versionchanged:: 1.3a1
-
- On Python 2, enabling universal newlines no longer forces unicode
- IO.
-
- .. versionchanged:: 1.2a1
-
- A bufsize of 0 in write mode is no longer forced to be 1.
- Instead, the underlying buffer is flushed after every write
- operation to simulate a bufsize of 0. In gevent 1.0, a
- bufsize of 0 was flushed when a newline was written, while
- in gevent 1.1 it was flushed when more than one byte was
- written. Note that this may have performance impacts.
- """
-
- if isinstance(fobj, int):
- fileno = fobj
- fobj = None
- else:
- fileno = fobj.fileno()
- if not isinstance(fileno, int):
- raise TypeError('fileno must be int: %r' % fileno)
-
- orig_mode = mode
- mode = (mode or 'rb').replace('b', '')
- if 'U' in mode:
- self._translate = True
- if bytes is str and 't' not in mode:
- # We're going to be producing unicode objects, but
- # universal newlines doesn't do that in the stdlib,
- # so fix that to return str objects. The fix is two parts:
- # first, set an encoding on the stream that can round-trip
- # all bytes, and second, decode all bytes once they've been read.
- self._translate_encoding = 'latin-1'
- import functools
-
- def wrap_method(m):
- if m.__name__.startswith("read"):
- @functools.wraps(m)
- def wrapped(*args, **kwargs):
- result = m(*args, **kwargs)
- assert isinstance(result, unicode) # pylint:disable=undefined-variable
- return result.encode('latin-1')
- return wrapped
- return m
- self._wrap_method = wrap_method
- mode = mode.replace('U', '')
- else:
- self._translate = False
-
- mode = mode.replace('t', '')
-
- if len(mode) != 1 and mode not in 'rw': # pragma: no cover
- # Python 3 builtin `open` raises a ValueError for invalid modes;
- # Python 2 ignores it. In the past, we raised an AssertionError, if __debug__ was
- # enabled (which it usually was). Match Python 3 because it makes more sense
- # and because __debug__ may not be enabled.
- # NOTE: This is preventing a mode like 'rwb' for binary random access;
- # that code was never tested and was explicitly marked as "not used"
- raise ValueError('mode can only be [rb, rU, wb], not %r' % (orig_mode,))
-
- self._fobj = fobj
-
- # This attribute is documented as available for non-blocking reads.
- self.fileio = GreenFileDescriptorIO(fileno, mode, closefd=close)
-
- self._orig_bufsize = bufsize
- if bufsize < 0 or bufsize == 1:
- bufsize = self.default_bufsize
- elif bufsize == 0:
- bufsize = 1
-
- if mode == 'r':
- IOFamily = BufferedReader
- else:
- assert mode == 'w'
- IOFamily = BufferedWriter
- if self._orig_bufsize == 0:
- # We could also simply pass self.fileio as *io*, but this way
- # we at least consistently expose a BufferedWriter in our *io*
- # attribute.
- IOFamily = FlushingBufferedWriter
-
- super(FileObjectPosix, self).__init__(IOFamily(self.fileio, bufsize), close)
-
- def _do_close(self, fobj, closefd):
- try:
- fobj.close()
- # self.fileio already knows whether or not to close the
- # file descriptor
- self.fileio.close()
- finally:
- self._fobj = None
- self.fileio = None
-
- def __iter__(self):
- return self._io
diff --git a/python/gevent/_greenlet.cp36-win32.pyd b/python/gevent/_greenlet.cp36-win32.pyd
deleted file mode 100644
index bad32d6..0000000
--- a/python/gevent/_greenlet.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/_greenlet.pxd b/python/gevent/_greenlet.pxd
deleted file mode 100644
index 230b049..0000000
--- a/python/gevent/_greenlet.pxd
+++ /dev/null
@@ -1,174 +0,0 @@
-# cython: auto_pickle=False
-
-cimport cython
-from gevent.__ident cimport IdentRegistry
-from gevent.__hub_local cimport get_hub_noargs as get_hub
-from gevent.__waiter cimport Waiter
-
-cdef bint _PYPY
-cdef sys_getframe
-cdef sys_exc_info
-cdef Timeout
-cdef GreenletExit
-cdef InvalidSwitchError
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-@cython.final
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef bint _greenlet_imported
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-cdef extern from "Python.h":
-
- ctypedef class types.CodeType [object PyCodeObject]:
- pass
-
-cdef extern from "frameobject.h":
-
- ctypedef class types.FrameType [object PyFrameObject]:
- cdef CodeType f_code
- cdef int f_lineno
- # We can't declare this in the object, because it's
- # allowed to be NULL, and Cython can't handle that.
- # We have to go through the python machinery to get a
- # proper None instead.
- # cdef FrameType f_back
-
-cdef void _init()
-
-cdef class SpawnedLink:
- cdef public object callback
-
-
-@cython.final
-cdef class SuccessSpawnedLink(SpawnedLink):
- pass
-
-@cython.final
-cdef class FailureSpawnedLink(SpawnedLink):
- pass
-
-@cython.final
-@cython.internal
-@cython.freelist(1000)
-cdef class _Frame:
- cdef readonly CodeType f_code
- cdef readonly int f_lineno
- cdef readonly _Frame f_back
-
-
-@cython.final
-@cython.locals(frames=list,frame=FrameType)
-cdef inline list _extract_stack(int limit)
-
-@cython.final
-@cython.locals(previous=_Frame, frame=tuple, f=_Frame)
-cdef _Frame _Frame_from_list(list frames)
-
-
-cdef class Greenlet(greenlet):
- cdef readonly object value
- cdef readonly tuple args
- cdef readonly dict kwargs
- cdef readonly object spawning_greenlet
- cdef public dict spawn_tree_locals
-
- # This is accessed with getattr() dynamically so it
- # must be visible to Python
- cdef readonly list _spawning_stack_frames
-
- cdef list _links
- cdef tuple _exc_info
- cdef object _notifier
- cdef object _start_event
- cdef str _formatted_info
- cdef object _ident
-
- cpdef bint has_links(self)
- cpdef join(self, timeout=*)
- cpdef bint ready(self)
- cpdef bint successful(self)
- cpdef rawlink(self, object callback)
- cpdef str _formatinfo(self)
-
- @cython.locals(reg=IdentRegistry)
- cdef _get_minimal_ident(self)
-
-
- cdef bint __started_but_aborted(self)
- cdef bint __start_cancelled_by_kill(self)
- cdef bint __start_pending(self)
- cdef bint __never_started_or_killed(self)
- cdef bint __start_completed(self)
- cdef __handle_death_before_start(self, tuple args)
-
- cdef __cancel_start(self)
-
- cdef _report_result(self, object result)
- cdef _report_error(self, tuple exc_info)
- # This is used as the target of a callback
- # from the loop, and so needs to be a cpdef
- cpdef _notify_links(self)
-
- # Hmm, declaring _raise_exception causes issues when _imap
- # is also compiled.
- # TypeError: wrap() takes exactly one argument (0 given)
- # cpdef _raise_exception(self)
-
-
-
-# Declare a bunch of imports as cdefs so they can
-# be accessed directly as static vars without
-# doing a module global lookup. This is especially important
-# for spawning greenlets.
-cdef _greenlet__init__
-cdef _threadlocal
-cdef get_hub_class
-cdef wref
-
-cdef dump_traceback
-cdef load_traceback
-cdef Waiter
-cdef wait
-cdef iwait
-cdef reraise
-cpdef GEVENT_CONFIG
-
-
-@cython.final
-@cython.internal
-cdef class _dummy_event:
- cdef readonly bint pending
- cdef readonly bint active
-
- cpdef stop(self)
- cpdef start(self, cb)
- cpdef close(self)
-
-cdef _dummy_event _cancelled_start_event
-cdef _dummy_event _start_completed_event
-
-
-@cython.locals(diehards=list)
-cdef _killall3(list greenlets, object exception, object waiter)
-cdef _killall(list greenlets, object exception)
-
-@cython.locals(done=list)
-cpdef joinall(greenlets, timeout=*, raise_error=*, count=*)
diff --git a/python/gevent/_greenlet_primitives.c b/python/gevent/_greenlet_primitives.c
deleted file mode 100644
index 4ea63cc..0000000
--- a/python/gevent/_greenlet_primitives.c
+++ /dev/null
@@ -1,6042 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__greenlet_primitives.pxd",
- "src\\gevent\\__greenlet_primitives.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__greenlet_primitives",
- "sources": [
- "src/gevent/_greenlet_primitives.py"
- ]
- },
- "module_name": "gevent.__greenlet_primitives"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____greenlet_primitives
-#define __PYX_HAVE_API__gevent____greenlet_primitives
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_greenlet_primitives.py",
- "src\\gevent\\__greenlet_primitives.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-
-/* "src/gevent/_greenlet_primitives.py":52
- *
- *
- * class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * # Subclasses must define:
- * # - self.loop
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch_out(CYTHON_UNUSED struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject *__pyx_v_6gevent_21__greenlet_primitives_wref = 0;
-static PyObject *__pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-static int __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void); /*proto*/
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__greenlet_primitives"
-extern int __pyx_module_is_main_gevent____greenlet_primitives;
-int __pyx_module_is_main_gevent____greenlet_primitives = 0;
-
-/* Implementation of 'gevent.__greenlet_primitives' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_AttributeError;
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_ref[] = "ref";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wref[] = "wref";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_init_2[] = "_init";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_parent[] = "parent";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_weakref[] = "weakref";
-static const char __pyx_k_function[] = "function";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_switch_out[] = "switch_out";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_AttributeError[] = "AttributeError";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_greenlet_switch[] = "_greenlet_switch";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_spawn_tree_locals[] = "spawn_tree_locals";
-static const char __pyx_k_spawning_greenlet[] = "spawning_greenlet";
-static const char __pyx_k_TrackedRawGreenlet[] = "TrackedRawGreenlet";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_BlockingSwitchOutError[] = "BlockingSwitchOutError";
-static const char __pyx_k_SwitchOutGreenletWithLoop[] = "SwitchOutGreenletWithLoop";
-static const char __pyx_k_gevent___greenlet_primitives[] = "gevent.__greenlet_primitives";
-static const char __pyx_k_A_collection_of_primitives_used[] = "\nA collection of primitives used by the hub, and suitable for\ncompilation with Cython because of their frequency of use.\n\n";
-static const char __pyx_k_src_gevent__greenlet_primitives[] = "src\\gevent\\_greenlet_primitives.py";
-static const char __pyx_k_Impossible_to_call_blocking_func[] = "Impossible to call blocking function in the event loop callback";
-static const char __pyx_k_SwitchOutGreenletWithLoop_switch[] = "SwitchOutGreenletWithLoop.switch";
-static const char __pyx_k_SwitchOutGreenletWithLoop_switch_2[] = "SwitchOutGreenletWithLoop.switch_out";
-static PyObject *__pyx_n_s_AttributeError;
-static PyObject *__pyx_n_s_BlockingSwitchOutError;
-static PyObject *__pyx_kp_s_Impossible_to_call_blocking_func;
-static PyObject *__pyx_n_s_SwitchOutGreenletWithLoop;
-static PyObject *__pyx_n_s_SwitchOutGreenletWithLoop_switch;
-static PyObject *__pyx_n_s_SwitchOutGreenletWithLoop_switch_2;
-static PyObject *__pyx_n_s_TrackedRawGreenlet;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_function;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent___greenlet_primitives;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_greenlet_switch;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_init_2;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_parent;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_ref;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_spawn_tree_locals;
-static PyObject *__pyx_n_s_spawning_greenlet;
-static PyObject *__pyx_kp_s_src_gevent__greenlet_primitives;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_switch_out;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_weakref;
-static PyObject *__pyx_n_s_wref;
-static PyObject *__pyx_lambda_funcdef_6gevent_21__greenlet_primitives_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_21__greenlet_primitives_18TrackedRawGreenlet___init__(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet *__pyx_v_self, PyObject *__pyx_v_function, PyObject *__pyx_v_parent); /* proto */
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_2switch_out(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop___get__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_2__set__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_4__del__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives__init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_21__greenlet_primitives_TrackedRawGreenlet(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_codeobj__4;
-static PyObject *__pyx_codeobj__6;
-static PyObject *__pyx_codeobj__7;
-/* Late includes */
-
-/* "src/gevent/_greenlet_primitives.py":25
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['_greenlet_switch'] = greenlet.switch
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_2lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_21__greenlet_primitives_2lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_2lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_2lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_21__greenlet_primitives_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_21__greenlet_primitives_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_greenlet_primitives.py":35
- * class TrackedRawGreenlet(greenlet):
- *
- * def __init__(self, function, parent): # <<<<<<<<<<<<<<
- * greenlet.__init__(self, function, parent)
- * # See greenlet.py's Greenlet class. We capture the cheap
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_21__greenlet_primitives_18TrackedRawGreenlet_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_21__greenlet_primitives_18TrackedRawGreenlet_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_function = 0;
- PyObject *__pyx_v_parent = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_function,&__pyx_n_s_parent,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_function)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parent)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 35, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 35, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_function = values[0];
- __pyx_v_parent = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 35, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__greenlet_primitives.TrackedRawGreenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_18TrackedRawGreenlet___init__(((struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet *)__pyx_v_self), __pyx_v_function, __pyx_v_parent);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_21__greenlet_primitives_18TrackedRawGreenlet___init__(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet *__pyx_v_self, PyObject *__pyx_v_function, PyObject *__pyx_v_parent) {
- PyGreenlet *__pyx_v_current = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_greenlet_primitives.py":36
- *
- * def __init__(self, function, parent):
- * greenlet.__init__(self, function, parent) # <<<<<<<<<<<<<<
- * # See greenlet.py's Greenlet class. We capture the cheap
- * # parts to maintain the tree structure, but we do not capture
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_21__greenlet_primitives_greenlet), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_function, __pyx_v_parent};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_function, __pyx_v_parent};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_function);
- __Pyx_GIVEREF(__pyx_v_function);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_function);
- __Pyx_INCREF(__pyx_v_parent);
- __Pyx_GIVEREF(__pyx_v_parent);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_parent);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":41
- * # the stack because that's too expensive for 'spawn_raw'.
- *
- * current = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.spawning_greenlet = wref(current)
- * # See Greenlet for how trees are maintained.
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_21__greenlet_primitives_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_current = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":42
- *
- * current = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(current) # <<<<<<<<<<<<<<
- * # See Greenlet for how trees are maintained.
- * try:
- */
- __Pyx_INCREF(__pyx_v_6gevent_21__greenlet_primitives_wref);
- __pyx_t_2 = __pyx_v_6gevent_21__greenlet_primitives_wref; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_current)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_current)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_current)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_current));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_current));
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_current));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_spawning_greenlet, __pyx_t_1) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":44
- * self.spawning_greenlet = wref(current)
- * # See Greenlet for how trees are maintained.
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = current.spawn_tree_locals
- * except AttributeError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/_greenlet_primitives.py":45
- * # See Greenlet for how trees are maintained.
- * try:
- * self.spawn_tree_locals = current.spawn_tree_locals # <<<<<<<<<<<<<<
- * except AttributeError:
- * self.spawn_tree_locals = {}
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_current), __pyx_n_s_spawn_tree_locals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_spawn_tree_locals, __pyx_t_1) < 0) __PYX_ERR(0, 45, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":44
- * self.spawning_greenlet = wref(current)
- * # See Greenlet for how trees are maintained.
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = current.spawn_tree_locals
- * except AttributeError:
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":46
- * try:
- * self.spawn_tree_locals = current.spawn_tree_locals
- * except AttributeError: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = {}
- * if current.parent:
- */
- __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_4) {
- __Pyx_AddTraceback("gevent.__greenlet_primitives.TrackedRawGreenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "src/gevent/_greenlet_primitives.py":47
- * self.spawn_tree_locals = current.spawn_tree_locals
- * except AttributeError:
- * self.spawn_tree_locals = {} # <<<<<<<<<<<<<<
- * if current.parent:
- * current.spawn_tree_locals = self.spawn_tree_locals
- */
- __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 47, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_spawn_tree_locals, __pyx_t_5) < 0) __PYX_ERR(0, 47, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":48
- * except AttributeError:
- * self.spawn_tree_locals = {}
- * if current.parent: # <<<<<<<<<<<<<<
- * current.spawn_tree_locals = self.spawn_tree_locals
- *
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_current), __pyx_n_s_parent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 48, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 48, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (__pyx_t_9) {
-
- /* "src/gevent/_greenlet_primitives.py":49
- * self.spawn_tree_locals = {}
- * if current.parent:
- * current.spawn_tree_locals = self.spawn_tree_locals # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_spawn_tree_locals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 49, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_current), __pyx_n_s_spawn_tree_locals, __pyx_t_5) < 0) __PYX_ERR(0, 49, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":48
- * except AttributeError:
- * self.spawn_tree_locals = {}
- * if current.parent: # <<<<<<<<<<<<<<
- * current.spawn_tree_locals = self.spawn_tree_locals
- *
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/_greenlet_primitives.py":44
- * self.spawning_greenlet = wref(current)
- * # See Greenlet for how trees are maintained.
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = current.spawn_tree_locals
- * except AttributeError:
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/_greenlet_primitives.py":35
- * class TrackedRawGreenlet(greenlet):
- *
- * def __init__(self, function, parent): # <<<<<<<<<<<<<<
- * greenlet.__init__(self, function, parent)
- * # See greenlet.py's Greenlet class. We capture the cheap
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.TrackedRawGreenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_current);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_greenlet_primitives.py":59
- * # circular dependencies with the hub.
- *
- * def switch(self): # <<<<<<<<<<<<<<
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None:
- */
-
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_switch_out = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("switch", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_greenlet_primitives.py":60
- *
- * def switch(self):
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * if switch_out is not None:
- * switch_out()
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_21__greenlet_primitives_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_GetAttr3(__pyx_t_1, __pyx_n_s_switch_out, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_switch_out = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":61
- * def switch(self):
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None: # <<<<<<<<<<<<<<
- * switch_out()
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- */
- __pyx_t_5 = (__pyx_v_switch_out != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_greenlet_primitives.py":62
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None:
- * switch_out() # <<<<<<<<<<<<<<
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- *
- */
- __Pyx_INCREF(__pyx_v_switch_out);
- __pyx_t_1 = __pyx_v_switch_out; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":61
- * def switch(self):
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None: # <<<<<<<<<<<<<<
- * switch_out()
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- */
- }
-
- /* "src/gevent/_greenlet_primitives.py":63
- * if switch_out is not None:
- * switch_out()
- * return _greenlet_switch(self) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * def switch_out(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(((PyGreenlet *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_greenlet_primitives.py":59
- * # circular dependencies with the hub.
- *
- * def switch(self): # <<<<<<<<<<<<<<
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_switch_out);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch[] = "SwitchOutGreenletWithLoop.switch(self)";
-static PyMethodDef __pyx_mdef_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch = {"switch", (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch, METH_NOARGS, __pyx_doc_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch};
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("switch (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("switch", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_greenlet_primitives.py":65
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- *
- * def switch_out(self): # <<<<<<<<<<<<<<
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- */
-
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch_out(CYTHON_UNUSED struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("switch_out", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch_out); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_greenlet_primitives.py":66
- *
- * def switch_out(self):
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback') # <<<<<<<<<<<<<<
- *
- * def _init():
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 66, __pyx_L1_error)
-
- /* "src/gevent/_greenlet_primitives.py":65
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- *
- * def switch_out(self): # <<<<<<<<<<<<<<
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_2switch_out[] = "SwitchOutGreenletWithLoop.switch_out(self)";
-static PyMethodDef __pyx_mdef_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out = {"switch_out", (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out, METH_NOARGS, __pyx_doc_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_2switch_out};
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("switch_out (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_2switch_out(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_2switch_out(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("switch_out", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch_out(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch_out", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":41
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet):
- * cdef public loop # <<<<<<<<<<<<<<
- *
- * cpdef switch(self)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop___get__(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop___get__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->loop);
- __pyx_r = __pyx_v_self->loop;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_2__set__(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_2__set__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_4__del__(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_4__del__(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_greenlet_primitives.py":68
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_1_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_21__greenlet_primitives__init[] = "_init()";
-static PyMethodDef __pyx_mdef_6gevent_21__greenlet_primitives_1_init = {"_init", (PyCFunction)__pyx_pw_6gevent_21__greenlet_primitives_1_init, METH_NOARGS, __pyx_doc_6gevent_21__greenlet_primitives__init};
-static PyObject *__pyx_pw_6gevent_21__greenlet_primitives_1_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_21__greenlet_primitives__init(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_21__greenlet_primitives__init(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/_greenlet_primitives.py":69
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_21__greenlet_primitives_greenlet_init();
-
- /* "src/gevent/_greenlet_primitives.py":68
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_tp_new_6gevent_21__greenlet_primitives_TrackedRawGreenlet(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_ptype_6gevent_21__greenlet_primitives_greenlet->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_21__greenlet_primitives_TrackedRawGreenlet[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__greenlet_primitives.TrackedRawGreenlet", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "TrackedRawGreenlet(function, parent)", /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_21__greenlet_primitives_TrackedRawGreenlet, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_21__greenlet_primitives_18TrackedRawGreenlet_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_21__greenlet_primitives_TrackedRawGreenlet, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop __pyx_vtable_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-static PyObject *__pyx_tp_new_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *p;
- PyObject *o = __pyx_tp_new_6gevent_21__greenlet_primitives_TrackedRawGreenlet(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
- p->loop = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop(PyObject *o) {
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *p = (struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->loop);
- #if CYTHON_USE_TYPE_SLOTS
- if (PyType_IS_GC(Py_TYPE(o)->tp_base))
- #endif
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop);
-}
-
-static int __pyx_tp_traverse_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *p = (struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)o;
- e = ((likely(__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) ? ((__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet->tp_traverse) ? __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)); if (e) return e;
- if (p->loop) {
- e = (*v)(p->loop, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *p = (struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)o;
- if (likely(__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) { if (__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet->tp_clear) __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop);
- tmp = ((PyObject*)p->loop);
- p->loop = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_loop(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_4loop_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop[] = {
- {(char *)"loop", __pyx_getprop_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_loop, __pyx_setprop_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_loop, (char *)"loop: object", 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__greenlet_primitives.SwitchOutGreenletWithLoop", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_traverse*/
- __pyx_tp_clear_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_21__greenlet_primitives_18TrackedRawGreenlet_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___greenlet_primitives(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___greenlet_primitives},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__greenlet_primitives",
- __pyx_k_A_collection_of_primitives_used, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
- {&__pyx_n_s_BlockingSwitchOutError, __pyx_k_BlockingSwitchOutError, sizeof(__pyx_k_BlockingSwitchOutError), 0, 0, 1, 1},
- {&__pyx_kp_s_Impossible_to_call_blocking_func, __pyx_k_Impossible_to_call_blocking_func, sizeof(__pyx_k_Impossible_to_call_blocking_func), 0, 0, 1, 0},
- {&__pyx_n_s_SwitchOutGreenletWithLoop, __pyx_k_SwitchOutGreenletWithLoop, sizeof(__pyx_k_SwitchOutGreenletWithLoop), 0, 0, 1, 1},
- {&__pyx_n_s_SwitchOutGreenletWithLoop_switch, __pyx_k_SwitchOutGreenletWithLoop_switch, sizeof(__pyx_k_SwitchOutGreenletWithLoop_switch), 0, 0, 1, 1},
- {&__pyx_n_s_SwitchOutGreenletWithLoop_switch_2, __pyx_k_SwitchOutGreenletWithLoop_switch_2, sizeof(__pyx_k_SwitchOutGreenletWithLoop_switch_2), 0, 0, 1, 1},
- {&__pyx_n_s_TrackedRawGreenlet, __pyx_k_TrackedRawGreenlet, sizeof(__pyx_k_TrackedRawGreenlet), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_function, __pyx_k_function, sizeof(__pyx_k_function), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___greenlet_primitives, __pyx_k_gevent___greenlet_primitives, sizeof(__pyx_k_gevent___greenlet_primitives), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_switch, __pyx_k_greenlet_switch, sizeof(__pyx_k_greenlet_switch), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_init_2, __pyx_k_init_2, sizeof(__pyx_k_init_2), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_spawn_tree_locals, __pyx_k_spawn_tree_locals, sizeof(__pyx_k_spawn_tree_locals), 0, 0, 1, 1},
- {&__pyx_n_s_spawning_greenlet, __pyx_k_spawning_greenlet, sizeof(__pyx_k_spawning_greenlet), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__greenlet_primitives, __pyx_k_src_gevent__greenlet_primitives, sizeof(__pyx_k_src_gevent__greenlet_primitives), 0, 0, 1, 0},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_switch_out, __pyx_k_switch_out, sizeof(__pyx_k_switch_out), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {&__pyx_n_s_wref, __pyx_k_wref, sizeof(__pyx_k_wref), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 24, __pyx_L1_error)
- __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 46, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_greenlet_primitives.py":66
- *
- * def switch_out(self):
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback') # <<<<<<<<<<<<<<
- *
- * def _init():
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Impossible_to_call_blocking_func); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_greenlet_primitives.py":24
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['_greenlet_switch'] = greenlet.switch
- */
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "src/gevent/_greenlet_primitives.py":59
- * # circular dependencies with the hub.
- *
- * def switch(self): # <<<<<<<<<<<<<<
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None:
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
- __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__greenlet_primitives, __pyx_n_s_switch, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 59, __pyx_L1_error)
-
- /* "src/gevent/_greenlet_primitives.py":65
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- *
- * def switch_out(self): # <<<<<<<<<<<<<<
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- */
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
- __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__greenlet_primitives, __pyx_n_s_switch_out, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 65, __pyx_L1_error)
-
- /* "src/gevent/_greenlet_primitives.py":68
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__greenlet_primitives, __pyx_n_s_init_2, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_21__greenlet_primitives_wref = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_wref, (void *)&__pyx_v_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_BlockingSwitchOutError, (void *)&__pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(1, 12, __pyx_L1_error)
- __pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet.tp_base = __pyx_ptype_6gevent_21__greenlet_primitives_greenlet;
- if (PyType_Ready(&__pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
- __pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet.tp_dictoffset && __pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "TrackedRawGreenlet", (PyObject *)&__pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = &__pyx_type_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = &__pyx_vtable_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
- __pyx_vtable_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.__pyx_switch = (PyObject *(*)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch))__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch;
- __pyx_vtable_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.switch_out = (PyObject *(*)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch))__pyx_f_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_switch_out;
- __pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_base = __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
- if (PyType_Ready(&__pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- __pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_dictoffset && __pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop.tp_dict, __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "SwitchOutGreenletWithLoop", (PyObject *)&__pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = &__pyx_type_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__greenlet_primitives(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__greenlet_primitives(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___greenlet_primitives(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___greenlet_primitives(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___greenlet_primitives(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___greenlet_primitives(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__greenlet_primitives", __pyx_methods, __pyx_k_A_collection_of_primitives_used, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____greenlet_primitives) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__greenlet_primitives")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__greenlet_primitives", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_type_import_code();
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_greenlet_primitives.py":13
- * from __future__ import print_function
- *
- * from weakref import ref as wref # <<<<<<<<<<<<<<
- *
- * from greenlet import greenlet
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_ref);
- __Pyx_GIVEREF(__pyx_n_s_ref);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ref);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_21__greenlet_primitives_wref);
- __Pyx_DECREF_SET(__pyx_v_6gevent_21__greenlet_primitives_wref, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":15
- * from weakref import ref as wref
- *
- * from greenlet import greenlet # <<<<<<<<<<<<<<
- *
- * from gevent.exceptions import BlockingSwitchOutError
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_greenlet);
- __Pyx_GIVEREF(__pyx_n_s_greenlet);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_greenlet);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":17
- * from greenlet import greenlet
- *
- * from gevent.exceptions import BlockingSwitchOutError # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_BlockingSwitchOutError);
- __Pyx_GIVEREF(__pyx_n_s_BlockingSwitchOutError);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_BlockingSwitchOutError);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_BlockingSwitchOutError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError);
- __Pyx_DECREF_SET(__pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":24
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['_greenlet_switch'] = greenlet.switch
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_getcurrent, __pyx_t_1) < 0)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":25
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['_greenlet_switch'] = greenlet.switch
- *
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_21__greenlet_primitives_2lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent___greenlet_primitives, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_greenlet_init, __pyx_t_1) < 0)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":26
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None
- * locals()['_greenlet_switch'] = greenlet.switch # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_21__greenlet_primitives_greenlet), __pyx_n_s_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_greenlet_switch, __pyx_t_1) < 0)) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":28
- * locals()['_greenlet_switch'] = greenlet.switch
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'TrackedRawGreenlet',
- * 'SwitchOutGreenletWithLoop',
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_TrackedRawGreenlet);
- __Pyx_GIVEREF(__pyx_n_s_TrackedRawGreenlet);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_TrackedRawGreenlet);
- __Pyx_INCREF(__pyx_n_s_SwitchOutGreenletWithLoop);
- __Pyx_GIVEREF(__pyx_n_s_SwitchOutGreenletWithLoop);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_SwitchOutGreenletWithLoop);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":59
- * # circular dependencies with the hub.
- *
- * def switch(self): # <<<<<<<<<<<<<<
- * switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- * if switch_out is not None:
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_1switch, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_SwitchOutGreenletWithLoop_switch, NULL, __pyx_n_s_gevent___greenlet_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict, __pyx_n_s_switch, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop);
-
- /* "src/gevent/_greenlet_primitives.py":65
- * return _greenlet_switch(self) # pylint:disable=undefined-variable
- *
- * def switch_out(self): # <<<<<<<<<<<<<<
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_21__greenlet_primitives_25SwitchOutGreenletWithLoop_3switch_out, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_SwitchOutGreenletWithLoop_switch_2, NULL, __pyx_n_s_gevent___greenlet_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict, __pyx_n_s_switch_out, __pyx_t_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop);
-
- /* "src/gevent/_greenlet_primitives.py":68
- * raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_21__greenlet_primitives_1_init, 0, __pyx_n_s_init_2, NULL, __pyx_n_s_gevent___greenlet_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_2, __pyx_t_1) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":71
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":73
- * _init()
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__greenlet_primitives')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":74
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__greenlet_primitives') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___greenlet_primitives);
- __Pyx_GIVEREF(__pyx_n_s_gevent___greenlet_primitives);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___greenlet_primitives);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_greenlet_primitives.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # copyright (c) 2018 gevent. See LICENSE.
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__greenlet_primitives", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__greenlet_primitives");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectSetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* SaveResetException */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetException */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* PyObjectCallNoArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_greenlet_primitives.py b/python/gevent/_greenlet_primitives.py
deleted file mode 100644
index 706f71b..0000000
--- a/python/gevent/_greenlet_primitives.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright (c) 2018 gevent. See LICENSE.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-"""
-A collection of primitives used by the hub, and suitable for
-compilation with Cython because of their frequency of use.
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-from weakref import ref as wref
-
-from greenlet import greenlet
-
-from gevent.exceptions import BlockingSwitchOutError
-
-
-# In Cython, we define these as 'cdef inline' functions. The
-# compilation unit cannot have a direct assignment to them (import
-# is assignment) without generating a 'lvalue is not valid target'
-# error.
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-locals()['_greenlet_switch'] = greenlet.switch
-
-__all__ = [
- 'TrackedRawGreenlet',
- 'SwitchOutGreenletWithLoop',
-]
-
-class TrackedRawGreenlet(greenlet):
-
- def __init__(self, function, parent):
- greenlet.__init__(self, function, parent)
- # See greenlet.py's Greenlet class. We capture the cheap
- # parts to maintain the tree structure, but we do not capture
- # the stack because that's too expensive for 'spawn_raw'.
-
- current = getcurrent() # pylint:disable=undefined-variable
- self.spawning_greenlet = wref(current)
- # See Greenlet for how trees are maintained.
- try:
- self.spawn_tree_locals = current.spawn_tree_locals
- except AttributeError:
- self.spawn_tree_locals = {}
- if current.parent:
- current.spawn_tree_locals = self.spawn_tree_locals
-
-
-class SwitchOutGreenletWithLoop(TrackedRawGreenlet):
- # Subclasses must define:
- # - self.loop
-
- # This class defines loop in its .pxd for Cython. This lets us avoid
- # circular dependencies with the hub.
-
- def switch(self):
- switch_out = getattr(getcurrent(), 'switch_out', None) # pylint:disable=undefined-variable
- if switch_out is not None:
- switch_out()
- return _greenlet_switch(self) # pylint:disable=undefined-variable
-
- def switch_out(self):
- raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback')
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__greenlet_primitives')
diff --git a/python/gevent/_hub_local.c b/python/gevent/_hub_local.c
deleted file mode 100644
index 40bec7c..0000000
--- a/python/gevent/_hub_local.c
+++ /dev/null
@@ -1,5720 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__hub_local.pxd",
- "src\\gevent\\__hub_local.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__hub_local",
- "sources": [
- "src/gevent/_hub_local.py"
- ]
- },
- "module_name": "gevent.__hub_local"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____hub_local
-#define __PYX_HAVE_API__gevent____hub_local
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_hub_local.py",
- "src\\gevent\\__greenlet_primitives.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* CalculateMetaclass.proto */
-static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* SetNameInClass.proto */
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
-#elif CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
-#else
-#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
-#endif
-
-/* Py3ClassCreate.proto */
-static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
- PyObject *mkw, PyObject *modname, PyObject *doc);
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
- PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject *__pyx_v_6gevent_11__hub_local__threadlocal = 0;
-static PyObject *__pyx_f_6gevent_11__hub_local_get_hub_class(int __pyx_skip_dispatch); /*proto*/
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_11__hub_local_get_hub_if_exists(int __pyx_skip_dispatch); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_set_hub(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_get_loop(int __pyx_skip_dispatch); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_set_loop(PyObject *, int __pyx_skip_dispatch); /*proto*/
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_11__hub_local_get_hub_noargs(int __pyx_skip_dispatch); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__hub_local"
-extern int __pyx_module_is_main_gevent____hub_local;
-int __pyx_module_is_main_gevent____hub_local = 0;
-
-/* Implementation of 'gevent.__hub_local' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_super;
-static const char __pyx_k_Hub[] = "Hub";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_doc[] = "__doc__";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_loop[] = "loop";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_local[] = "_local";
-static const char __pyx_k_super[] = "super";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_kwargs[] = "kwargs";
-static const char __pyx_k_module[] = "__module__";
-static const char __pyx_k_get_hub[] = "get_hub";
-static const char __pyx_k_hubtype[] = "hubtype";
-static const char __pyx_k_prepare[] = "__prepare__";
-static const char __pyx_k_set_hub[] = "set_hub";
-static const char __pyx_k_get_loop[] = "get_loop";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_qualname[] = "__qualname__";
-static const char __pyx_k_set_loop[] = "set_loop";
-static const char __pyx_k_metaclass[] = "__metaclass__";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_Threadlocal[] = "_Threadlocal";
-static const char __pyx_k_threadlocal[] = "_threadlocal";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_get_hub_class[] = "get_hub_class";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_gevent__compat[] = "gevent._compat";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_thread_mod_name[] = "thread_mod_name";
-static const char __pyx_k_get_hub_if_exists[] = "get_hub_if_exists";
-static const char __pyx_k_Threadlocal___init[] = "_Threadlocal.__init__";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_gevent___hub_local[] = "gevent.__hub_local";
-static const char __pyx_k_set_default_hub_class[] = "set_default_hub_class";
-static const char __pyx_k_src_gevent__hub_local_py[] = "src\\gevent\\_hub_local.py";
-static const char __pyx_k_Maintains_the_thread_local_hub[] = "\nMaintains the thread local hub.\n\n";
-static PyObject *__pyx_n_s_Hub;
-static PyObject *__pyx_n_s_Threadlocal;
-static PyObject *__pyx_n_s_Threadlocal___init;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_doc;
-static PyObject *__pyx_n_s_get_hub;
-static PyObject *__pyx_n_s_get_hub_class;
-static PyObject *__pyx_n_s_get_hub_if_exists;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_get_loop;
-static PyObject *__pyx_n_s_gevent___hub_local;
-static PyObject *__pyx_n_s_gevent__compat;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_n_s_hubtype;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_kwargs;
-static PyObject *__pyx_n_s_local;
-static PyObject *__pyx_n_s_loop;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_metaclass;
-static PyObject *__pyx_n_s_module;
-static PyObject *__pyx_n_s_prepare;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_qualname;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_set_default_hub_class;
-static PyObject *__pyx_n_s_set_hub;
-static PyObject *__pyx_n_s_set_loop;
-static PyObject *__pyx_kp_s_src_gevent__hub_local_py;
-static PyObject *__pyx_n_s_super;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_thread_mod_name;
-static PyObject *__pyx_n_s_threadlocal;
-static PyObject *__pyx_pf_6gevent_11__hub_local_12_Threadlocal___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_get_hub_class(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_2set_default_hub_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_hubtype); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_4get_hub(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_6get_hub_noargs(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_8get_hub_if_exists(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_10set_hub(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_12get_loop(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__hub_local_14set_loop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_loop); /* proto */
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_codeobj__2;
-static PyObject *__pyx_codeobj__3;
-static PyObject *__pyx_codeobj__5;
-static PyObject *__pyx_codeobj__7;
-static PyObject *__pyx_codeobj__8;
-static PyObject *__pyx_codeobj__9;
-static PyObject *__pyx_codeobj__11;
-static PyObject *__pyx_codeobj__12;
-static PyObject *__pyx_codeobj__14;
-/* Late includes */
-
-/* "src/gevent/_hub_local.py":26
- * class _Threadlocal(__import__(thread_mod_name)._local):
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Use a class with an initializer so that we can test
- * # for 'is None' instead of catching AttributeError, making
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_12_Threadlocal_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_12_Threadlocal_1__init__ = {"__init__", (PyCFunction)__pyx_pw_6gevent_11__hub_local_12_Threadlocal_1__init__, METH_O, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_12_Threadlocal_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_12_Threadlocal___init__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_12_Threadlocal___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_hub_local.py":31
- * # the code cleaner and possibly solving some corner cases
- * # (like #687)
- * super(_Threadlocal, self).__init__() # <<<<<<<<<<<<<<
- * self.Hub = None
- * self.loop = None
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Threadlocal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_self);
- __Pyx_GIVEREF(__pyx_v_self);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":32
- * # (like #687)
- * super(_Threadlocal, self).__init__()
- * self.Hub = None # <<<<<<<<<<<<<<
- * self.loop = None
- * self.hub = None
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_Hub, Py_None) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":33
- * super(_Threadlocal, self).__init__()
- * self.Hub = None
- * self.loop = None # <<<<<<<<<<<<<<
- * self.hub = None
- *
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_loop, Py_None) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":34
- * self.Hub = None
- * self.loop = None
- * self.hub = None # <<<<<<<<<<<<<<
- *
- * _threadlocal = _Threadlocal()
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_hub, Py_None) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":26
- * class _Threadlocal(__import__(thread_mod_name)._local):
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Use a class with an initializer so that we can test
- * # for 'is None' instead of catching AttributeError, making
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__hub_local._Threadlocal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":40
- * Hub = None # Set when gevent.hub is imported
- *
- * def get_hub_class(): # <<<<<<<<<<<<<<
- * """Return the type of hub to use for the current thread.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_get_hub_class(CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_hubtype = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("get_hub_class", 0);
-
- /* "src/gevent/_hub_local.py":45
- * If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used.
- * """
- * hubtype = _threadlocal.Hub # <<<<<<<<<<<<<<
- * if hubtype is None:
- * hubtype = _threadlocal.Hub = Hub
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_Hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hubtype = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":46
- * """
- * hubtype = _threadlocal.Hub
- * if hubtype is None: # <<<<<<<<<<<<<<
- * hubtype = _threadlocal.Hub = Hub
- * return hubtype
- */
- __pyx_t_2 = (__pyx_v_hubtype == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_local.py":47
- * hubtype = _threadlocal.Hub
- * if hubtype is None:
- * hubtype = _threadlocal.Hub = Hub # <<<<<<<<<<<<<<
- * return hubtype
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_hubtype, __pyx_t_1);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_Hub, __pyx_t_1) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":46
- * """
- * hubtype = _threadlocal.Hub
- * if hubtype is None: # <<<<<<<<<<<<<<
- * hubtype = _threadlocal.Hub = Hub
- * return hubtype
- */
- }
-
- /* "src/gevent/_hub_local.py":48
- * if hubtype is None:
- * hubtype = _threadlocal.Hub = Hub
- * return hubtype # <<<<<<<<<<<<<<
- *
- * def set_default_hub_class(hubtype):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_hubtype);
- __pyx_r = __pyx_v_hubtype;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_local.py":40
- * Hub = None # Set when gevent.hub is imported
- *
- * def get_hub_class(): # <<<<<<<<<<<<<<
- * """Return the type of hub to use for the current thread.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_hubtype);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__hub_local_get_hub_class[] = "Return the type of hub to use for the current thread.\n\n If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_1get_hub_class = {"get_hub_class", (PyCFunction)__pyx_pw_6gevent_11__hub_local_1get_hub_class, METH_NOARGS, __pyx_doc_6gevent_11__hub_local_get_hub_class};
-static PyObject *__pyx_pw_6gevent_11__hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_hub_class (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_get_hub_class(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_get_hub_class(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_hub_class", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_get_hub_class(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":50
- * return hubtype
- *
- * def set_default_hub_class(hubtype): # <<<<<<<<<<<<<<
- * global Hub
- * Hub = hubtype
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_3set_default_hub_class(PyObject *__pyx_self, PyObject *__pyx_v_hubtype); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_3set_default_hub_class = {"set_default_hub_class", (PyCFunction)__pyx_pw_6gevent_11__hub_local_3set_default_hub_class, METH_O, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_3set_default_hub_class(PyObject *__pyx_self, PyObject *__pyx_v_hubtype) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_default_hub_class (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_2set_default_hub_class(__pyx_self, ((PyObject *)__pyx_v_hubtype));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_2set_default_hub_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_hubtype) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_default_hub_class", 0);
-
- /* "src/gevent/_hub_local.py":52
- * def set_default_hub_class(hubtype):
- * global Hub
- * Hub = hubtype # <<<<<<<<<<<<<<
- *
- * def get_hub(*args, **kwargs):
- */
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Hub, __pyx_v_hubtype) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":50
- * return hubtype
- *
- * def set_default_hub_class(hubtype): # <<<<<<<<<<<<<<
- * global Hub
- * Hub = hubtype
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.__hub_local.set_default_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":54
- * Hub = hubtype
- *
- * def get_hub(*args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * Return the hub for the current thread.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_5get_hub(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_11__hub_local_4get_hub[] = "\n Return the hub for the current thread.\n\n If a hub does not exist in the current thread, a new one is\n created of the type returned by :func:`get_hub_class`.\n\n .. deprecated:: 1.3b1\n The ``*args`` and ``**kwargs`` arguments are deprecated. They were\n only used when the hub was created, and so were non-deterministic---to be\n sure they were used, *all* callers had to pass them, or they were order-dependent.\n Use ``set_hub`` instead.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_5get_hub = {"get_hub", (PyCFunction)__pyx_pw_6gevent_11__hub_local_5get_hub, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__hub_local_4get_hub};
-static PyObject *__pyx_pw_6gevent_11__hub_local_5get_hub(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_hub (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "get_hub", 1))) return NULL;
- if (unlikely(__pyx_kwds)) {
- __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
- __Pyx_GOTREF(__pyx_v_kwargs);
- } else {
- __pyx_v_kwargs = NULL;
- }
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_11__hub_local_4get_hub(__pyx_self, __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_4get_hub(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- PyObject *__pyx_v_hub = NULL;
- PyObject *__pyx_v_hubtype = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("get_hub", 0);
-
- /* "src/gevent/_hub_local.py":67
- * Use ``set_hub`` instead.
- * """
- * hub = _threadlocal.hub # <<<<<<<<<<<<<<
- * if hub is None:
- * hubtype = get_hub_class()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":68
- * """
- * hub = _threadlocal.hub
- * if hub is None: # <<<<<<<<<<<<<<
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype(*args, **kwargs)
- */
- __pyx_t_2 = (__pyx_v_hub == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_local.py":69
- * hub = _threadlocal.hub
- * if hub is None:
- * hubtype = get_hub_class() # <<<<<<<<<<<<<<
- * hub = _threadlocal.hub = hubtype(*args, **kwargs)
- * return hub
- */
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_get_hub_class(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hubtype = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":70
- * if hub is None:
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype(*args, **kwargs) # <<<<<<<<<<<<<<
- * return hub
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_hubtype, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_hub, __pyx_t_1);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub, __pyx_t_1) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":68
- * """
- * hub = _threadlocal.hub
- * if hub is None: # <<<<<<<<<<<<<<
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype(*args, **kwargs)
- */
- }
-
- /* "src/gevent/_hub_local.py":71
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype(*args, **kwargs)
- * return hub # <<<<<<<<<<<<<<
- *
- * def get_hub_noargs():
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_hub);
- __pyx_r = __pyx_v_hub;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_local.py":54
- * Hub = hubtype
- *
- * def get_hub(*args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * Return the hub for the current thread.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_hub);
- __Pyx_XDECREF(__pyx_v_hubtype);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":73
- * return hub
- *
- * def get_hub_noargs(): # <<<<<<<<<<<<<<
- * # Just like get_hub, but cheaper to call because it
- * # takes no arguments or kwargs. See also a copy in
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_11__hub_local_get_hub_noargs(CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_hub = NULL;
- PyObject *__pyx_v_hubtype = NULL;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("get_hub_noargs", 0);
-
- /* "src/gevent/_hub_local.py":77
- * # takes no arguments or kwargs. See also a copy in
- * # gevent/greenlet.py
- * hub = _threadlocal.hub # <<<<<<<<<<<<<<
- * if hub is None:
- * hubtype = get_hub_class()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":78
- * # gevent/greenlet.py
- * hub = _threadlocal.hub
- * if hub is None: # <<<<<<<<<<<<<<
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype()
- */
- __pyx_t_2 = (__pyx_v_hub == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_local.py":79
- * hub = _threadlocal.hub
- * if hub is None:
- * hubtype = get_hub_class() # <<<<<<<<<<<<<<
- * hub = _threadlocal.hub = hubtype()
- * return hub
- */
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_get_hub_class(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hubtype = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":80
- * if hub is None:
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype() # <<<<<<<<<<<<<<
- * return hub
- *
- */
- __Pyx_INCREF(__pyx_v_hubtype);
- __pyx_t_4 = __pyx_v_hubtype; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_hub, __pyx_t_1);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub, __pyx_t_1) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":78
- * # gevent/greenlet.py
- * hub = _threadlocal.hub
- * if hub is None: # <<<<<<<<<<<<<<
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype()
- */
- }
-
- /* "src/gevent/_hub_local.py":81
- * hubtype = get_hub_class()
- * hub = _threadlocal.hub = hubtype()
- * return hub # <<<<<<<<<<<<<<
- *
- * def get_hub_if_exists():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_hub);
- __pyx_r = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_hub);
- goto __pyx_L0;
-
- /* "src/gevent/_hub_local.py":73
- * return hub
- *
- * def get_hub_noargs(): # <<<<<<<<<<<<<<
- * # Just like get_hub, but cheaper to call because it
- * # takes no arguments or kwargs. See also a copy in
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_noargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_hub);
- __Pyx_XDECREF(__pyx_v_hubtype);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_7get_hub_noargs = {"get_hub_noargs", (PyCFunction)__pyx_pw_6gevent_11__hub_local_7get_hub_noargs, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_hub_noargs (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_6get_hub_noargs(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_6get_hub_noargs(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_hub_noargs", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_noargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":83
- * return hub
- *
- * def get_hub_if_exists(): # <<<<<<<<<<<<<<
- * """Return the hub for the current thread.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_11__hub_local_get_hub_if_exists(CYTHON_UNUSED int __pyx_skip_dispatch) {
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_hub_if_exists", 0);
-
- /* "src/gevent/_hub_local.py":88
- * Return ``None`` if no hub has been created yet.
- * """
- * return _threadlocal.hub # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 88, __pyx_L1_error)
- __pyx_r = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_local.py":83
- * return hub
- *
- * def get_hub_if_exists(): # <<<<<<<<<<<<<<
- * """Return the hub for the current thread.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_if_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__hub_local_8get_hub_if_exists[] = "Return the hub for the current thread.\n\n Return ``None`` if no hub has been created yet.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_9get_hub_if_exists = {"get_hub_if_exists", (PyCFunction)__pyx_pw_6gevent_11__hub_local_9get_hub_if_exists, METH_NOARGS, __pyx_doc_6gevent_11__hub_local_8get_hub_if_exists};
-static PyObject *__pyx_pw_6gevent_11__hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_hub_if_exists (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_8get_hub_if_exists(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_8get_hub_if_exists(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_hub_if_exists", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_if_exists(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_hub_if_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":91
- *
- *
- * def set_hub(hub): # <<<<<<<<<<<<<<
- * _threadlocal.hub = hub
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_set_hub(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_hub", 0);
-
- /* "src/gevent/_hub_local.py":92
- *
- * def set_hub(hub):
- * _threadlocal.hub = hub # <<<<<<<<<<<<<<
- *
- * def get_loop():
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_hub, ((PyObject *)__pyx_v_hub)) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":91
- *
- *
- * def set_hub(hub): # <<<<<<<<<<<<<<
- * _threadlocal.hub = hub
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.__hub_local.set_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_11set_hub = {"set_hub", (PyCFunction)__pyx_pw_6gevent_11__hub_local_11set_hub, METH_O, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_hub (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hub), __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop, 1, "hub", 0))) __PYX_ERR(0, 91, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_11__hub_local_10set_hub(__pyx_self, ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_hub));
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_10set_hub(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("set_hub", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_set_hub(__pyx_v_hub, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.set_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":94
- * _threadlocal.hub = hub
- *
- * def get_loop(): # <<<<<<<<<<<<<<
- * return _threadlocal.loop
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_get_loop(CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_loop", 0);
-
- /* "src/gevent/_hub_local.py":95
- *
- * def get_loop():
- * return _threadlocal.loop # <<<<<<<<<<<<<<
- *
- * def set_loop(loop):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_loop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_local.py":94
- * _threadlocal.hub = hub
- *
- * def get_loop(): # <<<<<<<<<<<<<<
- * return _threadlocal.loop
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_13get_loop = {"get_loop", (PyCFunction)__pyx_pw_6gevent_11__hub_local_13get_loop, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_loop (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_12get_loop(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_12get_loop(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_loop", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_get_loop(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.get_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_local.py":97
- * return _threadlocal.loop
- *
- * def set_loop(loop): # <<<<<<<<<<<<<<
- * _threadlocal.loop = loop
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop); /*proto*/
-static PyObject *__pyx_f_6gevent_11__hub_local_set_loop(PyObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_loop", 0);
-
- /* "src/gevent/_hub_local.py":98
- *
- * def set_loop(loop):
- * _threadlocal.loop = loop # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_n_s_loop, __pyx_v_loop) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":97
- * return _threadlocal.loop
- *
- * def set_loop(loop): # <<<<<<<<<<<<<<
- * _threadlocal.loop = loop
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.__hub_local.set_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__hub_local_15set_loop = {"set_loop", (PyCFunction)__pyx_pw_6gevent_11__hub_local_15set_loop, METH_O, 0};
-static PyObject *__pyx_pw_6gevent_11__hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_loop (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__hub_local_14set_loop(__pyx_self, ((PyObject *)__pyx_v_loop));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__hub_local_14set_loop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_loop) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("set_loop", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__hub_local_set_loop(__pyx_v_loop, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_local.set_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___hub_local(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___hub_local},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__hub_local",
- __pyx_k_Maintains_the_thread_local_hub, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_Hub, __pyx_k_Hub, sizeof(__pyx_k_Hub), 0, 0, 1, 1},
- {&__pyx_n_s_Threadlocal, __pyx_k_Threadlocal, sizeof(__pyx_k_Threadlocal), 0, 0, 1, 1},
- {&__pyx_n_s_Threadlocal___init, __pyx_k_Threadlocal___init, sizeof(__pyx_k_Threadlocal___init), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub, __pyx_k_get_hub, sizeof(__pyx_k_get_hub), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_class, __pyx_k_get_hub_class, sizeof(__pyx_k_get_hub_class), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_if_exists, __pyx_k_get_hub_if_exists, sizeof(__pyx_k_get_hub_if_exists), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_get_loop, __pyx_k_get_loop, sizeof(__pyx_k_get_loop), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___hub_local, __pyx_k_gevent___hub_local, sizeof(__pyx_k_gevent___hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__compat, __pyx_k_gevent__compat, sizeof(__pyx_k_gevent__compat), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_n_s_hubtype, __pyx_k_hubtype, sizeof(__pyx_k_hubtype), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
- {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1},
- {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
- {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
- {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_set_default_hub_class, __pyx_k_set_default_hub_class, sizeof(__pyx_k_set_default_hub_class), 0, 0, 1, 1},
- {&__pyx_n_s_set_hub, __pyx_k_set_hub, sizeof(__pyx_k_set_hub), 0, 0, 1, 1},
- {&__pyx_n_s_set_loop, __pyx_k_set_loop, sizeof(__pyx_k_set_loop), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__hub_local_py, __pyx_k_src_gevent__hub_local_py, sizeof(__pyx_k_src_gevent__hub_local_py), 0, 0, 1, 0},
- {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_thread_mod_name, __pyx_k_thread_mod_name, sizeof(__pyx_k_thread_mod_name), 0, 0, 1, 1},
- {&__pyx_n_s_threadlocal, __pyx_k_threadlocal, sizeof(__pyx_k_threadlocal), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 24, __pyx_L1_error)
- __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 31, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_hub_local.py":26
- * class _Threadlocal(__import__(thread_mod_name)._local):
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Use a class with an initializer so that we can test
- * # for 'is None' instead of catching AttributeError, making
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
- __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_init, 26, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 26, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":40
- * Hub = None # Set when gevent.hub is imported
- *
- * def get_hub_class(): # <<<<<<<<<<<<<<
- * """Return the type of hub to use for the current thread.
- *
- */
- __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_get_hub_class, 40, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 40, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":50
- * return hubtype
- *
- * def set_default_hub_class(hubtype): # <<<<<<<<<<<<<<
- * global Hub
- * Hub = hubtype
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_hubtype); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
- __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_set_default_hub_class, 50, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 50, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":54
- * Hub = hubtype
- *
- * def get_hub(*args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * Return the hub for the current thread.
- */
- __pyx_tuple__6 = PyTuple_Pack(4, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_hub, __pyx_n_s_hubtype); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 54, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
- __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_get_hub, 54, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 54, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":73
- * return hub
- *
- * def get_hub_noargs(): # <<<<<<<<<<<<<<
- * # Just like get_hub, but cheaper to call because it
- * # takes no arguments or kwargs. See also a copy in
- */
- __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_get_hub_noargs, 73, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 73, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":83
- * return hub
- *
- * def get_hub_if_exists(): # <<<<<<<<<<<<<<
- * """Return the hub for the current thread.
- *
- */
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_get_hub_if_exists, 83, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 83, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":91
- *
- *
- * def set_hub(hub): # <<<<<<<<<<<<<<
- * _threadlocal.hub = hub
- *
- */
- __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
- __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_set_hub, 91, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 91, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":94
- * _threadlocal.hub = hub
- *
- * def get_loop(): # <<<<<<<<<<<<<<
- * return _threadlocal.loop
- *
- */
- __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_get_loop, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 94, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":97
- * return _threadlocal.loop
- *
- * def set_loop(loop): # <<<<<<<<<<<<<<
- * _threadlocal.loop = loop
- *
- */
- __pyx_tuple__13 = PyTuple_Pack(1, __pyx_n_s_loop); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
- __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_local_py, __pyx_n_s_set_loop, 97, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_11__hub_local__threadlocal = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_threadlocal, (void *)&__pyx_v_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("get_hub_class", (void (*)(void))__pyx_f_6gevent_11__hub_local_get_hub_class, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("get_hub_if_exists", (void (*)(void))__pyx_f_6gevent_11__hub_local_get_hub_if_exists, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("set_hub", (void (*)(void))__pyx_f_6gevent_11__hub_local_set_hub, "PyObject *(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("get_loop", (void (*)(void))__pyx_f_6gevent_11__hub_local_get_loop, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("set_loop", (void (*)(void))__pyx_f_6gevent_11__hub_local_set_loop, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("get_hub_noargs", (void (*)(void))__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(1, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(1, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__hub_local(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__hub_local(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___hub_local(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___hub_local(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___hub_local(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___hub_local(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__hub_local", __pyx_methods, __pyx_k_Maintains_the_thread_local_hub, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____hub_local) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__hub_local")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__hub_local", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_type_init_code();
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_hub_local.py":12
- *
- *
- * from gevent._compat import thread_mod_name # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_thread_mod_name);
- __Pyx_GIVEREF(__pyx_n_s_thread_mod_name);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_thread_mod_name);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_thread_mod_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread_mod_name, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":14
- * from gevent._compat import thread_mod_name
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'get_hub',
- * 'get_hub_noargs',
- */
- __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_get_hub);
- __Pyx_GIVEREF(__pyx_n_s_get_hub);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_hub);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_get_hub_noargs);
- __Pyx_INCREF(__pyx_n_s_get_hub_if_exists);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_if_exists);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_get_hub_if_exists);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":24
- * # We are imported early enough (by gevent/__init__) that
- * # we can rely on not being monkey-patched in any way yet.
- * class _Threadlocal(__import__(thread_mod_name)._local): # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_thread_mod_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin___import__, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_local); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_Threadlocal, __pyx_n_s_Threadlocal, (PyObject *) NULL, __pyx_n_s_gevent___hub_local, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "src/gevent/_hub_local.py":26
- * class _Threadlocal(__import__(thread_mod_name)._local):
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Use a class with an initializer so that we can test
- * # for 'is None' instead of catching AttributeError, making
- */
- __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_12_Threadlocal_1__init__, 0, __pyx_n_s_Threadlocal___init, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_hub_local.py":24
- * # We are imported early enough (by gevent/__init__) that
- * # we can rely on not being monkey-patched in any way yet.
- * class _Threadlocal(__import__(thread_mod_name)._local): # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Threadlocal, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Threadlocal, __pyx_t_4) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":36
- * self.hub = None
- *
- * _threadlocal = _Threadlocal() # <<<<<<<<<<<<<<
- *
- * Hub = None # Set when gevent.hub is imported
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Threadlocal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XGOTREF(__pyx_v_6gevent_11__hub_local__threadlocal);
- __Pyx_DECREF_SET(__pyx_v_6gevent_11__hub_local__threadlocal, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":38
- * _threadlocal = _Threadlocal()
- *
- * Hub = None # Set when gevent.hub is imported # <<<<<<<<<<<<<<
- *
- * def get_hub_class():
- */
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Hub, Py_None) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
-
- /* "src/gevent/_hub_local.py":40
- * Hub = None # Set when gevent.hub is imported
- *
- * def get_hub_class(): # <<<<<<<<<<<<<<
- * """Return the type of hub to use for the current thread.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_1get_hub_class, 0, __pyx_n_s_get_hub_class, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_class, __pyx_t_2) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":50
- * return hubtype
- *
- * def set_default_hub_class(hubtype): # <<<<<<<<<<<<<<
- * global Hub
- * Hub = hubtype
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_3set_default_hub_class, 0, __pyx_n_s_set_default_hub_class, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_default_hub_class, __pyx_t_2) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":54
- * Hub = hubtype
- *
- * def get_hub(*args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * Return the hub for the current thread.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_5get_hub, 0, __pyx_n_s_get_hub, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub, __pyx_t_2) < 0) __PYX_ERR(0, 54, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":73
- * return hub
- *
- * def get_hub_noargs(): # <<<<<<<<<<<<<<
- * # Just like get_hub, but cheaper to call because it
- * # takes no arguments or kwargs. See also a copy in
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_7get_hub_noargs, 0, __pyx_n_s_get_hub_noargs, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":83
- * return hub
- *
- * def get_hub_if_exists(): # <<<<<<<<<<<<<<
- * """Return the hub for the current thread.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_9get_hub_if_exists, 0, __pyx_n_s_get_hub_if_exists, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_if_exists, __pyx_t_2) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":91
- *
- *
- * def set_hub(hub): # <<<<<<<<<<<<<<
- * _threadlocal.hub = hub
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_11set_hub, 0, __pyx_n_s_set_hub, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_hub, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":94
- * _threadlocal.hub = hub
- *
- * def get_loop(): # <<<<<<<<<<<<<<
- * return _threadlocal.loop
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_13get_loop, 0, __pyx_n_s_get_loop, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_loop, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":97
- * return _threadlocal.loop
- *
- * def set_loop(loop): # <<<<<<<<<<<<<<
- * _threadlocal.loop = loop
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__hub_local_15set_loop, 0, __pyx_n_s_set_loop, NULL, __pyx_n_s_gevent___hub_local, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_loop, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":100
- * _threadlocal.loop = loop
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__hub_local')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_local.py":101
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__hub_local') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___hub_local);
- __Pyx_GIVEREF(__pyx_n_s_gevent___hub_local);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___hub_local);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_local.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # copyright 2018 gevent. See LICENSE
- * """
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__hub_local", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__hub_local");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* GetModuleGlobalName */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* PyObjectCall */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyCFunctionFastCall */
- #if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
- #if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCallMethO */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* CalculateMetaclass */
- static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
- Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
- for (i=0; i < nbases; i++) {
- PyTypeObject *tmptype;
- PyObject *tmp = PyTuple_GET_ITEM(bases, i);
- tmptype = Py_TYPE(tmp);
-#if PY_MAJOR_VERSION < 3
- if (tmptype == &PyClass_Type)
- continue;
-#endif
- if (!metaclass) {
- metaclass = tmptype;
- continue;
- }
- if (PyType_IsSubtype(metaclass, tmptype))
- continue;
- if (PyType_IsSubtype(tmptype, metaclass)) {
- metaclass = tmptype;
- continue;
- }
- PyErr_SetString(PyExc_TypeError,
- "metaclass conflict: "
- "the metaclass of a derived class "
- "must be a (non-strict) subclass "
- "of the metaclasses of all its bases");
- return NULL;
- }
- if (!metaclass) {
-#if PY_MAJOR_VERSION < 3
- metaclass = &PyClass_Type;
-#else
- metaclass = &PyType_Type;
-#endif
- }
- Py_INCREF((PyObject*) metaclass);
- return (PyObject*) metaclass;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* Py3ClassCreate */
- static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
- PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
- PyObject *ns;
- if (metaclass) {
- PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
- if (prep) {
- PyObject *pargs = PyTuple_Pack(2, name, bases);
- if (unlikely(!pargs)) {
- Py_DECREF(prep);
- return NULL;
- }
- ns = PyObject_Call(prep, pargs, mkw);
- Py_DECREF(prep);
- Py_DECREF(pargs);
- } else {
- if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- PyErr_Clear();
- ns = PyDict_New();
- }
- } else {
- ns = PyDict_New();
- }
- if (unlikely(!ns))
- return NULL;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
- if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
- return ns;
-bad:
- Py_DECREF(ns);
- return NULL;
-}
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
- PyObject *dict, PyObject *mkw,
- int calculate_metaclass, int allow_py2_metaclass) {
- PyObject *result, *margs;
- PyObject *owned_metaclass = NULL;
- if (allow_py2_metaclass) {
- owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
- if (owned_metaclass) {
- metaclass = owned_metaclass;
- } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
- PyErr_Clear();
- } else {
- return NULL;
- }
- }
- if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
- metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
- Py_XDECREF(owned_metaclass);
- if (unlikely(!metaclass))
- return NULL;
- owned_metaclass = metaclass;
- }
- margs = PyTuple_Pack(3, name, bases, dict);
- if (unlikely(!margs)) {
- result = NULL;
- } else {
- result = PyObject_Call(metaclass, margs, mkw);
- Py_DECREF(margs);
- }
- Py_XDECREF(owned_metaclass);
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_hub_local.py b/python/gevent/_hub_local.py
deleted file mode 100644
index 622062a..0000000
--- a/python/gevent/_hub_local.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright 2018 gevent. See LICENSE
-"""
-Maintains the thread local hub.
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-from gevent._compat import thread_mod_name
-
-__all__ = [
- 'get_hub',
- 'get_hub_noargs',
- 'get_hub_if_exists',
-]
-
-# These must be the "real" native thread versions,
-# not monkey-patched.
-# We are imported early enough (by gevent/__init__) that
-# we can rely on not being monkey-patched in any way yet.
-class _Threadlocal(__import__(thread_mod_name)._local):
-
- def __init__(self):
- # Use a class with an initializer so that we can test
- # for 'is None' instead of catching AttributeError, making
- # the code cleaner and possibly solving some corner cases
- # (like #687)
- super(_Threadlocal, self).__init__()
- self.Hub = None
- self.loop = None
- self.hub = None
-
-_threadlocal = _Threadlocal()
-
-Hub = None # Set when gevent.hub is imported
-
-def get_hub_class():
- """Return the type of hub to use for the current thread.
-
- If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used.
- """
- hubtype = _threadlocal.Hub
- if hubtype is None:
- hubtype = _threadlocal.Hub = Hub
- return hubtype
-
-def set_default_hub_class(hubtype):
- global Hub
- Hub = hubtype
-
-def get_hub(*args, **kwargs):
- """
- Return the hub for the current thread.
-
- If a hub does not exist in the current thread, a new one is
- created of the type returned by :func:`get_hub_class`.
-
- .. deprecated:: 1.3b1
- The ``*args`` and ``**kwargs`` arguments are deprecated. They were
- only used when the hub was created, and so were non-deterministic---to be
- sure they were used, *all* callers had to pass them, or they were order-dependent.
- Use ``set_hub`` instead.
- """
- hub = _threadlocal.hub
- if hub is None:
- hubtype = get_hub_class()
- hub = _threadlocal.hub = hubtype(*args, **kwargs)
- return hub
-
-def get_hub_noargs():
- # Just like get_hub, but cheaper to call because it
- # takes no arguments or kwargs. See also a copy in
- # gevent/greenlet.py
- hub = _threadlocal.hub
- if hub is None:
- hubtype = get_hub_class()
- hub = _threadlocal.hub = hubtype()
- return hub
-
-def get_hub_if_exists():
- """Return the hub for the current thread.
-
- Return ``None`` if no hub has been created yet.
- """
- return _threadlocal.hub
-
-
-def set_hub(hub):
- _threadlocal.hub = hub
-
-def get_loop():
- return _threadlocal.loop
-
-def set_loop(loop):
- _threadlocal.loop = loop
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__hub_local')
diff --git a/python/gevent/_hub_primitives.c b/python/gevent/_hub_primitives.c
deleted file mode 100644
index 583bb93..0000000
--- a/python/gevent/_hub_primitives.c
+++ /dev/null
@@ -1,11875 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__hub_primitives.pxd",
- "src\\gevent\\__hub_primitives.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__hub_primitives",
- "sources": [
- "src/gevent/_hub_primitives.py"
- ]
- },
- "module_name": "gevent.__hub_primitives"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____hub_primitives
-#define __PYX_HAVE_API__gevent____hub_primitives
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_hub_primitives.py",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
- "src\\gevent\\__hub_primitives.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet;
-struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator;
-struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait;
-struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite;
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket;
-
-/* "gevent/__hub_primitives.pxd":44
- *
- * cpdef wait(self, watcher)
- * cpdef cancel_wait(self, watcher, error, close_watcher=*) # <<<<<<<<<<<<<<
- * cpdef _cancel_wait(self, watcher, error, close_watcher)
- *
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait {
- int __pyx_n;
- PyObject *close_watcher;
-};
-
-/* "gevent/__hub_primitives.pxd":61
- * cdef _cleanup(self)
- *
- * cpdef iwait_on_objects(objects, timeout=*, count=*) # <<<<<<<<<<<<<<
- * cpdef wait_on_objects(objects=*, timeout=*, count=*)
- *
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects {
- int __pyx_n;
- PyObject *timeout;
- PyObject *count;
-};
-
-/* "gevent/__hub_primitives.pxd":62
- *
- * cpdef iwait_on_objects(objects, timeout=*, count=*)
- * cpdef wait_on_objects(objects=*, timeout=*, count=*) # <<<<<<<<<<<<<<
- *
- * cdef _primitive_wait(watcher, timeout, timeout_exc, WaitOperationsGreenlet hub)
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects {
- int __pyx_n;
- PyObject *objects;
- PyObject *timeout;
- PyObject *count;
-};
-
-/* "gevent/__hub_primitives.pxd":65
- *
- * cdef _primitive_wait(watcher, timeout, timeout_exc, WaitOperationsGreenlet hub)
- * cpdef wait_on_watcher(watcher, timeout=*, timeout_exc=*, WaitOperationsGreenlet hub=*) # <<<<<<<<<<<<<<
- * cpdef wait_read(fileno, timeout=*, timeout_exc=*)
- * cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*)
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher {
- int __pyx_n;
- PyObject *timeout;
- PyObject *timeout_exc;
- struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *hub;
-};
-
-/* "gevent/__hub_primitives.pxd":66
- * cdef _primitive_wait(watcher, timeout, timeout_exc, WaitOperationsGreenlet hub)
- * cpdef wait_on_watcher(watcher, timeout=*, timeout_exc=*, WaitOperationsGreenlet hub=*)
- * cpdef wait_read(fileno, timeout=*, timeout_exc=*) # <<<<<<<<<<<<<<
- * cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*)
- * cpdef wait_readwrite(fileno, timeout=*, timeout_exc=*, event=*)
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read {
- int __pyx_n;
- PyObject *timeout;
- PyObject *timeout_exc;
-};
-
-/* "gevent/__hub_primitives.pxd":67
- * cpdef wait_on_watcher(watcher, timeout=*, timeout_exc=*, WaitOperationsGreenlet hub=*)
- * cpdef wait_read(fileno, timeout=*, timeout_exc=*)
- * cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*) # <<<<<<<<<<<<<<
- * cpdef wait_readwrite(fileno, timeout=*, timeout_exc=*, event=*)
- * cpdef wait_on_socket(socket, watcher, timeout_exc=*)
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write {
- int __pyx_n;
- PyObject *timeout;
- PyObject *timeout_exc;
- PyObject *event;
-};
-
-/* "gevent/__hub_primitives.pxd":68
- * cpdef wait_read(fileno, timeout=*, timeout_exc=*)
- * cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*)
- * cpdef wait_readwrite(fileno, timeout=*, timeout_exc=*, event=*) # <<<<<<<<<<<<<<
- * cpdef wait_on_socket(socket, watcher, timeout_exc=*)
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite {
- int __pyx_n;
- PyObject *timeout;
- PyObject *timeout_exc;
- PyObject *event;
-};
-
-/* "gevent/__hub_primitives.pxd":69
- * cpdef wait_write(fileno, timeout=*, timeout_exc=*, event=*)
- * cpdef wait_readwrite(fileno, timeout=*, timeout_exc=*, event=*)
- * cpdef wait_on_socket(socket, watcher, timeout_exc=*) # <<<<<<<<<<<<<<
- */
-struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket {
- int __pyx_n;
- PyObject *timeout_exc;
-};
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-/* "gevent/__hub_primitives.pxd":41
- *
- *
- * cdef class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # <<<<<<<<<<<<<<
- *
- * cpdef wait(self, watcher)
- */
-struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet {
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop __pyx_base;
-};
-
-
-/* "gevent/__hub_primitives.pxd":47
- * cpdef _cancel_wait(self, watcher, error, close_watcher)
- *
- * cdef class _WaitIterator: # <<<<<<<<<<<<<<
- * cdef SwitchOutGreenletWithLoop _hub
- * cdef MultipleWaiter _waiter
- */
-struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *_hub;
- struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *_waiter;
- PyObject *_switch;
- PyObject *_timeout;
- PyObject *_objects;
- PyObject *_timer;
- Py_ssize_t _count;
- int _begun;
-};
-
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-
-/* "src/gevent/_hub_primitives.py":44
- * ]
- *
- * class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * def wait(self, watcher):
- */
-
-struct __pyx_vtabstruct_6gevent_16__hub_primitives_WaitOperationsGreenlet {
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop __pyx_base;
- PyObject *(*wait)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*cancel_wait)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait *__pyx_optional_args);
- PyObject *(*_cancel_wait)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_vtabptr_6gevent_16__hub_primitives_WaitOperationsGreenlet;
-
-
-/* "src/gevent/_hub_primitives.py":98
- *
- *
- * class _WaitIterator(object): # <<<<<<<<<<<<<<
- *
- * def __init__(self, objects, hub, timeout, count):
- */
-
-struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator {
- PyObject *(*_cleanup)(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *);
-};
-static struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator *__pyx_vtabptr_6gevent_16__hub_primitives__WaitIterator;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* PyObjectLookupSpecial.proto */
-#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
- PyObject *res;
- PyTypeObject *tp = Py_TYPE(obj);
-#if PY_MAJOR_VERSION < 3
- if (unlikely(PyInstance_Check(obj)))
- return __Pyx_PyObject_GetAttrStr(obj, attr_name);
-#endif
- res = _PyType_Lookup(tp, attr_name);
- if (likely(res)) {
- descrgetfunc f = Py_TYPE(res)->tp_descr_get;
- if (!f) {
- Py_INCREF(res);
- } else {
- res = f(res, obj, (PyObject *)tp);
- }
- } else {
- PyErr_SetObject(PyExc_AttributeError, attr_name);
- }
- return res;
-}
-#else
-#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
-#endif
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet__cancel_wait(CYTHON_UNUSED struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_13_WaitIterator__cleanup(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject **__pyx_vp_6gevent_8__waiter_sys = 0;
-#define __pyx_v_6gevent_8__waiter_sys (*__pyx_vp_6gevent_8__waiter_sys)
-static PyObject **__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-#define __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError (*__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError)
-static int *__pyx_vp_6gevent_8__waiter__greenlet_imported = 0;
-#define __pyx_v_6gevent_8__waiter__greenlet_imported (*__pyx_vp_6gevent_8__waiter__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_8__waiter__NONE = 0;
-#define __pyx_v_6gevent_8__waiter__NONE (*__pyx_vp_6gevent_8__waiter__NONE)
-
-/* Module declarations from 'gevent.__hub_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_16__hub_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_16__hub_primitives__WaitIterator = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives_InvalidSwitchError = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives__waiter = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives__greenlet_primitives = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives_traceback = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives__timeout_error = 0;
-static PyObject *__pyx_v_6gevent_16__hub_primitives_Timeout = 0;
-static int __pyx_v_6gevent_16__hub_primitives__greenlet_imported;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_16__hub_primitives_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_16__hub_primitives_greenlet_init(void); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_iwait_on_objects(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_objects(int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives__primitive_wait(PyObject *, PyObject *, PyObject *, struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_watcher(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_read(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_write(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_readwrite(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_socket(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket *__pyx_optional_args); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__hub_primitives"
-extern int __pyx_module_is_main_gevent____hub_primitives;
-int __pyx_module_is_main_gevent____hub_primitives = 0;
-
-/* Implementation of 'gevent.__hub_primitives' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_StopIteration;
-static const char __pyx_k_e[] = "e";
-static const char __pyx_k_io[] = "io";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_NONE[] = "_NONE";
-static const char __pyx_k_exit[] = "__exit__";
-static const char __pyx_k_init[] = "_init";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_next[] = "__next__";
-static const char __pyx_k_self[] = "__self__";
-static const char __pyx_k_stop[] = "stop";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wait[] = "wait";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_count[] = "count";
-static const char __pyx_k_enter[] = "__enter__";
-static const char __pyx_k_error[] = "error";
-static const char __pyx_k_event[] = "event";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_timer[] = "timer";
-static const char __pyx_k_Waiter[] = "Waiter";
-static const char __pyx_k_active[] = "active";
-static const char __pyx_k_fileno[] = "fileno";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_next_2[] = "next";
-static const char __pyx_k_self_2[] = "self";
-static const char __pyx_k_socket[] = "socket";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_unlink[] = "unlink";
-static const char __pyx_k_waiter[] = "_waiter";
-static const char __pyx_k_Timeout[] = "Timeout";
-static const char __pyx_k_objects[] = "objects";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_watcher[] = "watcher";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_priority[] = "priority";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_print_exc[] = "print_exc";
-static const char __pyx_k_timed_out[] = "timed out";
-static const char __pyx_k_traceback[] = "traceback";
-static const char __pyx_k_wait_read[] = "wait_read";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_wait_write[] = "wait_write";
-static const char __pyx_k_cancel_wait[] = "cancel_wait";
-static const char __pyx_k_timeout_exc[] = "timeout_exc";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_run_callback[] = "run_callback";
-static const char __pyx_k_StopIteration[] = "StopIteration";
-static const char __pyx_k_cancel_wait_2[] = "_cancel_wait";
-static const char __pyx_k_close_watcher[] = "close_watcher";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_timeout_error[] = "_timeout_error";
-static const char __pyx_k_MultipleWaiter[] = "MultipleWaiter";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_gevent_timeout[] = "gevent.timeout";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_wait_on_socket[] = "wait_on_socket";
-static const char __pyx_k_wait_readwrite[] = "wait_readwrite";
-static const char __pyx_k_wait_on_objects[] = "wait_on_objects";
-static const char __pyx_k_wait_on_watcher[] = "wait_on_watcher";
-static const char __pyx_k_iwait_on_objects[] = "iwait_on_objects";
-static const char __pyx_k_gevent__hub_local[] = "gevent._hub_local";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_InvalidSwitchError[] = "InvalidSwitchError";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy";
-static const char __pyx_k_greenlet_primitives[] = "_greenlet_primitives";
-static const char __pyx_k_WaitOperationsGreenlet[] = "WaitOperationsGreenlet";
-static const char __pyx_k_gevent___hub_primitives[] = "gevent.__hub_primitives";
-static const char __pyx_k_ConcurrentObjectUseError[] = "ConcurrentObjectUseError";
-static const char __pyx_k_SwitchOutGreenletWithLoop[] = "SwitchOutGreenletWithLoop";
-static const char __pyx_k_set_default_timeout_error[] = "set_default_timeout_error";
-static const char __pyx_k_WaitOperationsGreenlet_wait[] = "WaitOperationsGreenlet.wait";
-static const char __pyx_k_src_gevent__hub_primitives_py[] = "src\\gevent\\_hub_primitives.py";
-static const char __pyx_k_A_collection_of_primitives_used[] = "\nA collection of primitives used by the hub, and suitable for\ncompilation with Cython because of their frequency of use.\n\n\n";
-static const char __pyx_k_Invalid_switch_into_s_r_expected[] = "Invalid switch into %s: %r (expected %r)";
-static const char __pyx_k_This_socket_is_already_used_by_a[] = "This socket is already used by another greenlet: %r";
-static const char __pyx_k_WaitOperationsGreenlet__cancel_w[] = "WaitOperationsGreenlet._cancel_wait";
-static const char __pyx_k_WaitOperationsGreenlet_cancel_wa[] = "WaitOperationsGreenlet.cancel_wait";
-static PyObject *__pyx_n_s_ConcurrentObjectUseError;
-static PyObject *__pyx_n_s_InvalidSwitchError;
-static PyObject *__pyx_kp_s_Invalid_switch_into_s_r_expected;
-static PyObject *__pyx_n_s_MultipleWaiter;
-static PyObject *__pyx_n_s_NONE;
-static PyObject *__pyx_n_s_StopIteration;
-static PyObject *__pyx_n_s_SwitchOutGreenletWithLoop;
-static PyObject *__pyx_kp_s_This_socket_is_already_used_by_a;
-static PyObject *__pyx_n_s_Timeout;
-static PyObject *__pyx_n_s_WaitOperationsGreenlet;
-static PyObject *__pyx_n_s_WaitOperationsGreenlet__cancel_w;
-static PyObject *__pyx_n_s_WaitOperationsGreenlet_cancel_wa;
-static PyObject *__pyx_n_s_WaitOperationsGreenlet_wait;
-static PyObject *__pyx_n_s_Waiter;
-static PyObject *__pyx_n_s_active;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_n_s_cancel_wait;
-static PyObject *__pyx_n_s_cancel_wait_2;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_close_watcher;
-static PyObject *__pyx_n_s_count;
-static PyObject *__pyx_n_s_e;
-static PyObject *__pyx_n_s_enter;
-static PyObject *__pyx_n_s_error;
-static PyObject *__pyx_n_s_event;
-static PyObject *__pyx_n_s_exit;
-static PyObject *__pyx_n_s_fileno;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_n_s_gevent___hub_primitives;
-static PyObject *__pyx_n_s_gevent__hub_local;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_gevent_timeout;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_greenlet_primitives;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_io;
-static PyObject *__pyx_n_s_iwait_on_objects;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_next;
-static PyObject *__pyx_n_s_next_2;
-static PyObject *__pyx_n_s_objects;
-static PyObject *__pyx_n_s_print_exc;
-static PyObject *__pyx_n_s_priority;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_run_callback;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_self_2;
-static PyObject *__pyx_n_s_set_default_timeout_error;
-static PyObject *__pyx_n_s_socket;
-static PyObject *__pyx_kp_s_src_gevent__hub_primitives_py;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_start_new_or_dummy;
-static PyObject *__pyx_n_s_stop;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_kp_s_timed_out;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_timeout_error;
-static PyObject *__pyx_n_s_timeout_exc;
-static PyObject *__pyx_n_s_timer;
-static PyObject *__pyx_n_s_traceback;
-static PyObject *__pyx_n_s_unlink;
-static PyObject *__pyx_n_s_wait;
-static PyObject *__pyx_n_s_wait_on_objects;
-static PyObject *__pyx_n_s_wait_on_socket;
-static PyObject *__pyx_n_s_wait_on_watcher;
-static PyObject *__pyx_n_s_wait_read;
-static PyObject *__pyx_n_s_wait_readwrite;
-static PyObject *__pyx_n_s_wait_write;
-static PyObject *__pyx_n_s_waiter;
-static PyObject *__pyx_n_s_watcher;
-static PyObject *__pyx_lambda_funcdef_6gevent_16__hub_primitives_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_2cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_4_cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher); /* proto */
-static int __pyx_pf_6gevent_16__hub_primitives_13_WaitIterator___init__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_hub, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_2__iter__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_4__next__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_iwait_on_objects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_2wait_on_objects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_4set_default_timeout_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_e); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_6wait_on_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_socket, PyObject *__pyx_v_watcher, PyObject *__pyx_v_timeout_exc); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_8wait_on_watcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_10wait_read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_12wait_write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, PyObject *__pyx_v_event); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_14wait_readwrite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, PyObject *__pyx_v_event); /* proto */
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_16_init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_16__hub_primitives_WaitOperationsGreenlet(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_16__hub_primitives__WaitIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_int_2;
-static PyObject *__pyx_int_3;
-static PyObject *__pyx_int_neg_1;
-static PyObject *__pyx_k__3;
-static PyObject *__pyx_k__4;
-static PyObject *__pyx_k__5;
-static PyObject *__pyx_k__6;
-static PyObject *__pyx_k__7;
-static PyObject *__pyx_k__8;
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__12;
-static PyObject *__pyx_tuple__14;
-static PyObject *__pyx_tuple__16;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__20;
-static PyObject *__pyx_tuple__22;
-static PyObject *__pyx_tuple__24;
-static PyObject *__pyx_tuple__26;
-static PyObject *__pyx_tuple__28;
-static PyObject *__pyx_tuple__30;
-static PyObject *__pyx_codeobj__11;
-static PyObject *__pyx_codeobj__13;
-static PyObject *__pyx_codeobj__15;
-static PyObject *__pyx_codeobj__17;
-static PyObject *__pyx_codeobj__19;
-static PyObject *__pyx_codeobj__21;
-static PyObject *__pyx_codeobj__23;
-static PyObject *__pyx_codeobj__25;
-static PyObject *__pyx_codeobj__27;
-static PyObject *__pyx_codeobj__29;
-static PyObject *__pyx_codeobj__31;
-static PyObject *__pyx_codeobj__32;
-/* Late includes */
-
-/* "src/gevent/_hub_primitives.py":30
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['Waiter'] = _waiter.Waiter
- * locals()['MultipleWaiter'] = _waiter.MultipleWaiter
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_18lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_18lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_18lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_18lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_16__hub_primitives_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_16__hub_primitives_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":46
- * class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable
- *
- * def wait(self, watcher): # <<<<<<<<<<<<<<
- * """
- * Wait until the *watcher* (which must not be started) is ready.
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait(PyObject *__pyx_v_self, PyObject *__pyx_v_watcher); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, int __pyx_skip_dispatch) {
- struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- char const *__pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- __Pyx_RefNannySetupContext("wait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_watcher); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_watcher};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_watcher};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_watcher);
- __Pyx_GIVEREF(__pyx_v_watcher);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_watcher);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_hub_primitives.py":52
- * The current greenlet will be unscheduled during this time.
- * """
- * waiter = Waiter(self) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * watcher.start(waiter.switch, waiter)
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":53
- * """
- * waiter = Waiter(self) # pylint:disable=undefined-variable
- * watcher.start(waiter.switch, waiter) # <<<<<<<<<<<<<<
- * try:
- * result = waiter.get()
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_waiter), __pyx_n_s_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_waiter));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_waiter));
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, ((PyObject *)__pyx_v_waiter));
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":54
- * waiter = Waiter(self) # pylint:disable=undefined-variable
- * watcher.start(waiter.switch, waiter)
- * try: # <<<<<<<<<<<<<<
- * result = waiter.get()
- * if result is not waiter:
- */
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":55
- * watcher.start(waiter.switch, waiter)
- * try:
- * result = waiter.get() # <<<<<<<<<<<<<<
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *)__pyx_v_waiter->__pyx_vtab)->get(__pyx_v_waiter, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":56
- * try:
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- * getcurrent(), # pylint:disable=undefined-variable
- */
- __pyx_t_7 = (__pyx_v_result != ((PyObject *)__pyx_v_waiter));
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (unlikely(__pyx_t_8)) {
-
- /* "src/gevent/_hub_primitives.py":58
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- * getcurrent(), # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * result, waiter))
- * finally:
- */
- __pyx_t_2 = ((PyObject *)__pyx_f_6gevent_16__hub_primitives_getcurrent()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "src/gevent/_hub_primitives.py":59
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- * getcurrent(), # pylint:disable=undefined-variable
- * result, waiter)) # <<<<<<<<<<<<<<
- * finally:
- * watcher.stop()
- */
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_result);
- __Pyx_INCREF(((PyObject *)__pyx_v_waiter));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_waiter));
- PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_waiter));
- __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":57
- * result = waiter.get()
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % ( # <<<<<<<<<<<<<<
- * getcurrent(), # pylint:disable=undefined-variable
- * result, waiter))
- */
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_s_r_expected, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_16__hub_primitives_InvalidSwitchError);
- __pyx_t_4 = __pyx_v_6gevent_16__hub_primitives_InvalidSwitchError; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 57, __pyx_L4_error)
-
- /* "src/gevent/_hub_primitives.py":56
- * try:
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- * getcurrent(), # pylint:disable=undefined-variable
- */
- }
- }
-
- /* "src/gevent/_hub_primitives.py":61
- * result, waiter))
- * finally:
- * watcher.stop() # <<<<<<<<<<<<<<
- *
- * def cancel_wait(self, watcher, error, close_watcher=False):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __pyx_t_6 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
- {
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L8_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L8_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
- goto __pyx_L1_error;
- __pyx_L8_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/_hub_primitives.py":46
- * class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable
- *
- * def wait(self, watcher): # <<<<<<<<<<<<<<
- * """
- * Wait until the *watcher* (which must not be started) is ready.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait(PyObject *__pyx_v_self, PyObject *__pyx_v_watcher); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait[] = "WaitOperationsGreenlet.wait(self, watcher)\n\n Wait until the *watcher* (which must not be started) is ready.\n\n The current greenlet will be unscheduled during this time.\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait = {"wait", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait, METH_O, __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait(PyObject *__pyx_v_self, PyObject *__pyx_v_watcher) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_self), ((PyObject *)__pyx_v_watcher));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("wait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait(__pyx_v_self, __pyx_v_watcher, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":63
- * watcher.stop()
- *
- * def cancel_wait(self, watcher, error, close_watcher=False): # <<<<<<<<<<<<<<
- * """
- * Cancel an in-progress call to :meth:`wait` by throwing the given *error*
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait *__pyx_optional_args) {
- PyObject *__pyx_v_close_watcher = ((PyObject *)Py_False);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("cancel_wait", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_close_watcher = __pyx_optional_args->close_watcher;
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cancel_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_watcher);
- __Pyx_GIVEREF(__pyx_v_watcher);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_watcher);
- __Pyx_INCREF(__pyx_v_error);
- __Pyx_GIVEREF(__pyx_v_error);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_error);
- __Pyx_INCREF(__pyx_v_close_watcher);
- __Pyx_GIVEREF(__pyx_v_close_watcher);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_close_watcher);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_hub_primitives.py":75
- * Allow the *watcher* to be ``None``. No action is taken in that case.
- * """
- * if watcher is None: # <<<<<<<<<<<<<<
- * # Presumably already closed.
- * # See https://github.com/gevent/gevent/issues/1089
- */
- __pyx_t_7 = (__pyx_v_watcher == Py_None);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_hub_primitives.py":78
- * # Presumably already closed.
- * # See https://github.com/gevent/gevent/issues/1089
- * return # <<<<<<<<<<<<<<
- * if watcher.callback is not None:
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":75
- * Allow the *watcher* to be ``None``. No action is taken in that case.
- * """
- * if watcher is None: # <<<<<<<<<<<<<<
- * # Presumably already closed.
- * # See https://github.com/gevent/gevent/issues/1089
- */
- }
-
- /* "src/gevent/_hub_primitives.py":79
- * # See https://github.com/gevent/gevent/issues/1089
- * return
- * if watcher.callback is not None: # <<<<<<<<<<<<<<
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- * elif close_watcher:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = (__pyx_t_1 != Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_7 = (__pyx_t_8 != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/_hub_primitives.py":80
- * return
- * if watcher.callback is not None:
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher) # <<<<<<<<<<<<<<
- * elif close_watcher:
- * watcher.close()
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cancel_wait_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_watcher);
- __Pyx_GIVEREF(__pyx_v_watcher);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_watcher);
- __Pyx_INCREF(__pyx_v_error);
- __Pyx_GIVEREF(__pyx_v_error);
- PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_error);
- __Pyx_INCREF(__pyx_v_close_watcher);
- __Pyx_GIVEREF(__pyx_v_close_watcher);
- PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_5, __pyx_v_close_watcher);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":79
- * # See https://github.com/gevent/gevent/issues/1089
- * return
- * if watcher.callback is not None: # <<<<<<<<<<<<<<
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- * elif close_watcher:
- */
- goto __pyx_L4;
- }
-
- /* "src/gevent/_hub_primitives.py":81
- * if watcher.callback is not None:
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- * elif close_watcher: # <<<<<<<<<<<<<<
- * watcher.close()
- *
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_close_watcher); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 81, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/_hub_primitives.py":82
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- * elif close_watcher:
- * watcher.close() # <<<<<<<<<<<<<<
- *
- * def _cancel_wait(self, watcher, error, close_watcher):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":81
- * if watcher.callback is not None:
- * self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- * elif close_watcher: # <<<<<<<<<<<<<<
- * watcher.close()
- *
- */
- }
- __pyx_L4:;
-
- /* "src/gevent/_hub_primitives.py":63
- * watcher.stop()
- *
- * def cancel_wait(self, watcher, error, close_watcher=False): # <<<<<<<<<<<<<<
- * """
- * Cancel an in-progress call to :meth:`wait` by throwing the given *error*
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet.cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_2cancel_wait[] = "WaitOperationsGreenlet.cancel_wait(self, watcher, error, close_watcher=False)\n\n Cancel an in-progress call to :meth:`wait` by throwing the given *error*\n in the waiting greenlet.\n\n .. versionchanged:: 1.3a1\n Added the *close_watcher* parameter. If true, the watcher\n will be closed after the exception is thrown. The watcher should then\n be discarded. Closing the watcher is important to release native resources.\n .. versionchanged:: 1.3a2\n Allow the *watcher* to be ``None``. No action is taken in that case.\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait = {"cancel_wait", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_2cancel_wait};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_watcher = 0;
- PyObject *__pyx_v_error = 0;
- PyObject *__pyx_v_close_watcher = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("cancel_wait (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_watcher,&__pyx_n_s_error,&__pyx_n_s_close_watcher,0};
- PyObject* values[3] = {0,0,0};
- values[2] = ((PyObject *)Py_False);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_error)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("cancel_wait", 0, 2, 3, 1); __PYX_ERR(0, 63, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_close_watcher);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cancel_wait") < 0)) __PYX_ERR(0, 63, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_watcher = values[0];
- __pyx_v_error = values[1];
- __pyx_v_close_watcher = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("cancel_wait", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 63, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet.cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_2cancel_wait(((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_self), __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_2cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait __pyx_t_2;
- __Pyx_RefNannySetupContext("cancel_wait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.close_watcher = __pyx_v_close_watcher;
- __pyx_t_1 = __pyx_vtabptr_6gevent_16__hub_primitives_WaitOperationsGreenlet->cancel_wait(__pyx_v_self, __pyx_v_watcher, __pyx_v_error, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet.cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":84
- * watcher.close()
- *
- * def _cancel_wait(self, watcher, error, close_watcher): # <<<<<<<<<<<<<<
- * # We have to check again to see if it was still active by the time
- * # our callback actually runs.
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet__cancel_wait(CYTHON_UNUSED struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_active = NULL;
- PyObject *__pyx_v_cb = NULL;
- PyObject *__pyx_v_glet = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("_cancel_wait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cancel_wait_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_watcher);
- __Pyx_GIVEREF(__pyx_v_watcher);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_watcher);
- __Pyx_INCREF(__pyx_v_error);
- __Pyx_GIVEREF(__pyx_v_error);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_error);
- __Pyx_INCREF(__pyx_v_close_watcher);
- __Pyx_GIVEREF(__pyx_v_close_watcher);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_close_watcher);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_hub_primitives.py":87
- * # We have to check again to see if it was still active by the time
- * # our callback actually runs.
- * active = watcher.active # <<<<<<<<<<<<<<
- * cb = watcher.callback
- * if close_watcher:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_active); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_active = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":88
- * # our callback actually runs.
- * active = watcher.active
- * cb = watcher.callback # <<<<<<<<<<<<<<
- * if close_watcher:
- * watcher.close()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_cb = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":89
- * active = watcher.active
- * cb = watcher.callback
- * if close_watcher: # <<<<<<<<<<<<<<
- * watcher.close()
- * if active:
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_close_watcher); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 89, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/_hub_primitives.py":90
- * cb = watcher.callback
- * if close_watcher:
- * watcher.close() # <<<<<<<<<<<<<<
- * if active:
- * # The callback should be greenlet.switch(). It may or may not be None.
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":89
- * active = watcher.active
- * cb = watcher.callback
- * if close_watcher: # <<<<<<<<<<<<<<
- * watcher.close()
- * if active:
- */
- }
-
- /* "src/gevent/_hub_primitives.py":91
- * if close_watcher:
- * watcher.close()
- * if active: # <<<<<<<<<<<<<<
- * # The callback should be greenlet.switch(). It may or may not be None.
- * glet = getattr(cb, '__self__', None)
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_active); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 91, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/_hub_primitives.py":93
- * if active:
- * # The callback should be greenlet.switch(). It may or may not be None.
- * glet = getattr(cb, '__self__', None) # <<<<<<<<<<<<<<
- * if glet is not None:
- * glet.throw(error)
- */
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_cb, __pyx_n_s_self, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_glet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":94
- * # The callback should be greenlet.switch(). It may or may not be None.
- * glet = getattr(cb, '__self__', None)
- * if glet is not None: # <<<<<<<<<<<<<<
- * glet.throw(error)
- *
- */
- __pyx_t_7 = (__pyx_v_glet != Py_None);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_hub_primitives.py":95
- * glet = getattr(cb, '__self__', None)
- * if glet is not None:
- * glet.throw(error) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_throw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_error};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_error};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_error);
- __Pyx_GIVEREF(__pyx_v_error);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_error);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":94
- * # The callback should be greenlet.switch(). It may or may not be None.
- * glet = getattr(cb, '__self__', None)
- * if glet is not None: # <<<<<<<<<<<<<<
- * glet.throw(error)
- *
- */
- }
-
- /* "src/gevent/_hub_primitives.py":91
- * if close_watcher:
- * watcher.close()
- * if active: # <<<<<<<<<<<<<<
- * # The callback should be greenlet.switch(). It may or may not be None.
- * glet = getattr(cb, '__self__', None)
- */
- }
-
- /* "src/gevent/_hub_primitives.py":84
- * watcher.close()
- *
- * def _cancel_wait(self, watcher, error, close_watcher): # <<<<<<<<<<<<<<
- * # We have to check again to see if it was still active by the time
- * # our callback actually runs.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet._cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_active);
- __Pyx_XDECREF(__pyx_v_cb);
- __Pyx_XDECREF(__pyx_v_glet);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_4_cancel_wait[] = "WaitOperationsGreenlet._cancel_wait(self, watcher, error, close_watcher)";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait = {"_cancel_wait", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_22WaitOperationsGreenlet_4_cancel_wait};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_watcher = 0;
- PyObject *__pyx_v_error = 0;
- PyObject *__pyx_v_close_watcher = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_cancel_wait (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_watcher,&__pyx_n_s_error,&__pyx_n_s_close_watcher,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_error)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_cancel_wait", 1, 3, 3, 1); __PYX_ERR(0, 84, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_close_watcher)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_cancel_wait", 1, 3, 3, 2); __PYX_ERR(0, 84, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cancel_wait") < 0)) __PYX_ERR(0, 84, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_watcher = values[0];
- __pyx_v_error = values[1];
- __pyx_v_close_watcher = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_cancel_wait", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 84, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet._cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_4_cancel_wait(((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_self), __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_22WaitOperationsGreenlet_4_cancel_wait(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_error, PyObject *__pyx_v_close_watcher) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_cancel_wait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet__cancel_wait(__pyx_v_self, __pyx_v_watcher, __pyx_v_error, __pyx_v_close_watcher, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.WaitOperationsGreenlet._cancel_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":100
- * class _WaitIterator(object):
- *
- * def __init__(self, objects, hub, timeout, count): # <<<<<<<<<<<<<<
- * self._hub = hub
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_objects = 0;
- PyObject *__pyx_v_hub = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_count = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_objects,&__pyx_n_s_hub,&__pyx_n_s_timeout,&__pyx_n_s_count,0};
- PyObject* values[4] = {0,0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_objects)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); __PYX_ERR(0, 100, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(0, 100, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_count)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); __PYX_ERR(0, 100, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 100, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- }
- __pyx_v_objects = values[0];
- __pyx_v_hub = values[1];
- __pyx_v_timeout = values[2];
- __pyx_v_count = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 100, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_13_WaitIterator___init__(((struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self), __pyx_v_objects, __pyx_v_hub, __pyx_v_timeout, __pyx_v_count);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_16__hub_primitives_13_WaitIterator___init__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_hub, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- int __pyx_t_3;
- Py_ssize_t __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_hub_primitives.py":101
- *
- * def __init__(self, objects, hub, timeout, count):
- * self._hub = hub # <<<<<<<<<<<<<<
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- * self._switch = self._waiter.switch
- */
- if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 101, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_hub;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_hub);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_hub));
- __pyx_v_self->_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":102
- * def __init__(self, objects, hub, timeout, count):
- * self._hub = hub
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self._switch = self._waiter.switch
- * self._timeout = timeout
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_MultipleWaiter), __pyx_v_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_waiter);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_waiter));
- __pyx_v_self->_waiter = ((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":103
- * self._hub = hub
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- * self._switch = self._waiter.switch # <<<<<<<<<<<<<<
- * self._timeout = timeout
- * self._objects = objects
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_waiter), __pyx_n_s_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_switch);
- __Pyx_DECREF(__pyx_v_self->_switch);
- __pyx_v_self->_switch = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":104
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- * self._switch = self._waiter.switch
- * self._timeout = timeout # <<<<<<<<<<<<<<
- * self._objects = objects
- *
- */
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- __Pyx_GOTREF(__pyx_v_self->_timeout);
- __Pyx_DECREF(__pyx_v_self->_timeout);
- __pyx_v_self->_timeout = __pyx_v_timeout;
-
- /* "src/gevent/_hub_primitives.py":105
- * self._switch = self._waiter.switch
- * self._timeout = timeout
- * self._objects = objects # <<<<<<<<<<<<<<
- *
- * self._timer = None
- */
- __Pyx_INCREF(__pyx_v_objects);
- __Pyx_GIVEREF(__pyx_v_objects);
- __Pyx_GOTREF(__pyx_v_self->_objects);
- __Pyx_DECREF(__pyx_v_self->_objects);
- __pyx_v_self->_objects = __pyx_v_objects;
-
- /* "src/gevent/_hub_primitives.py":107
- * self._objects = objects
- *
- * self._timer = None # <<<<<<<<<<<<<<
- * self._begun = False
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = Py_None;
-
- /* "src/gevent/_hub_primitives.py":108
- *
- * self._timer = None
- * self._begun = False # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_self->_begun = 0;
-
- /* "src/gevent/_hub_primitives.py":114
- * # we must still rawlink() *all* of them, so that no
- * # matter which one finishes first we find it.
- * self._count = len(objects) if count is None else min(count, len(objects)) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = (__pyx_v_count == Py_None);
- if ((__pyx_t_3 != 0)) {
- __pyx_t_4 = PyObject_Length(__pyx_v_objects); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 114, __pyx_L1_error)
- __pyx_t_2 = __pyx_t_4;
- } else {
- __pyx_t_4 = PyObject_Length(__pyx_v_objects); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_count);
- __pyx_t_1 = __pyx_v_count;
- __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (__pyx_t_8) {
- __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_5 = __pyx_t_7;
- __pyx_t_7 = 0;
- } else {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_5 = __pyx_t_1;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_2 = __pyx_t_4;
- }
- __pyx_v_self->_count = __pyx_t_2;
-
- /* "src/gevent/_hub_primitives.py":100
- * class _WaitIterator(object):
- *
- * def __init__(self, objects, hub, timeout, count): # <<<<<<<<<<<<<<
- * self._hub = hub
- * self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":117
- *
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * # When we begin iterating, we begin the timer.
- * # XXX: If iteration doesn't actually happen, we
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_3__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_3__iter__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_2__iter__(((struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_2__iter__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self) {
- PyObject *__pyx_v_obj = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- int __pyx_t_10;
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "src/gevent/_hub_primitives.py":121
- * # XXX: If iteration doesn't actually happen, we
- * # could leave these links around!
- * if not self._begun: # <<<<<<<<<<<<<<
- * self._begun = True
- *
- */
- __pyx_t_1 = ((!(__pyx_v_self->_begun != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/_hub_primitives.py":122
- * # could leave these links around!
- * if not self._begun:
- * self._begun = True # <<<<<<<<<<<<<<
- *
- * for obj in self._objects:
- */
- __pyx_v_self->_begun = 1;
-
- /* "src/gevent/_hub_primitives.py":124
- * self._begun = True
- *
- * for obj in self._objects: # <<<<<<<<<<<<<<
- * obj.rawlink(self._switch)
- *
- */
- if (likely(PyList_CheckExact(__pyx_v_self->_objects)) || PyTuple_CheckExact(__pyx_v_self->_objects)) {
- __pyx_t_2 = __pyx_v_self->_objects; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_self->_objects); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
- }
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L1_error)
- #else
- __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L1_error)
- #else
- __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- }
- } else {
- __pyx_t_5 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_5)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 124, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_5);
- }
- __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/_hub_primitives.py":125
- *
- * for obj in self._objects:
- * obj.rawlink(self._switch) # <<<<<<<<<<<<<<
- *
- * if self._timeout is not None:
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_rawlink); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self->_switch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->_switch};
- __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_self->_switch};
- __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_INCREF(__pyx_v_self->_switch);
- __Pyx_GIVEREF(__pyx_v_self->_switch);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_self->_switch);
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_hub_primitives.py":124
- * self._begun = True
- *
- * for obj in self._objects: # <<<<<<<<<<<<<<
- * obj.rawlink(self._switch)
- *
- */
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":127
- * obj.rawlink(self._switch)
- *
- * if self._timeout is not None: # <<<<<<<<<<<<<<
- * self._timer = self._hub.loop.timer(self._timeout, priority=-1)
- * self._timer.start(self._switch, self)
- */
- __pyx_t_1 = (__pyx_v_self->_timeout != Py_None);
- __pyx_t_9 = (__pyx_t_1 != 0);
- if (__pyx_t_9) {
-
- /* "src/gevent/_hub_primitives.py":128
- *
- * if self._timeout is not None:
- * self._timer = self._hub.loop.timer(self._timeout, priority=-1) # <<<<<<<<<<<<<<
- * self._timer.start(self._switch, self)
- * return self
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_hub->loop, __pyx_n_s_timer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_self->_timeout);
- __Pyx_GIVEREF(__pyx_v_self->_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->_timeout);
- __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_priority, __pyx_int_neg_1) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GIVEREF(__pyx_t_8);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = __pyx_t_8;
- __pyx_t_8 = 0;
-
- /* "src/gevent/_hub_primitives.py":129
- * if self._timeout is not None:
- * self._timer = self._hub.loop.timer(self._timeout, priority=-1)
- * self._timer.start(self._switch, self) # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_5 = NULL;
- __pyx_t_10 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- __pyx_t_10 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->_switch, ((PyObject *)__pyx_v_self)};
- __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_8);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->_switch, ((PyObject *)__pyx_v_self)};
- __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_8);
- } else
- #endif
- {
- __pyx_t_2 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(__pyx_v_self->_switch);
- __Pyx_GIVEREF(__pyx_v_self->_switch);
- PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_10, __pyx_v_self->_switch);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_10, ((PyObject *)__pyx_v_self));
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "src/gevent/_hub_primitives.py":127
- * obj.rawlink(self._switch)
- *
- * if self._timeout is not None: # <<<<<<<<<<<<<<
- * self._timer = self._hub.loop.timer(self._timeout, priority=-1)
- * self._timer.start(self._switch, self)
- */
- }
-
- /* "src/gevent/_hub_primitives.py":121
- * # XXX: If iteration doesn't actually happen, we
- * # could leave these links around!
- * if not self._begun: # <<<<<<<<<<<<<<
- * self._begun = True
- *
- */
- }
-
- /* "src/gevent/_hub_primitives.py":130
- * self._timer = self._hub.loop.timer(self._timeout, priority=-1)
- * self._timer.start(self._switch, self)
- * return self # <<<<<<<<<<<<<<
- *
- * def __next__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":117
- *
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * # When we begin iterating, we begin the timer.
- * # XXX: If iteration doesn't actually happen, we
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_obj);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":132
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * if self._count == 0:
- * # Exhausted
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_5__next__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_5__next__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_4__next__(((struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_13_WaitIterator_4__next__(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self) {
- PyObject *__pyx_v_item = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "src/gevent/_hub_primitives.py":133
- *
- * def __next__(self):
- * if self._count == 0: # <<<<<<<<<<<<<<
- * # Exhausted
- * self._cleanup()
- */
- __pyx_t_1 = ((__pyx_v_self->_count == 0) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/_hub_primitives.py":135
- * if self._count == 0:
- * # Exhausted
- * self._cleanup() # <<<<<<<<<<<<<<
- * raise StopIteration()
- *
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self->__pyx_vtab)->_cleanup(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":136
- * # Exhausted
- * self._cleanup()
- * raise StopIteration() # <<<<<<<<<<<<<<
- *
- * self._count -= 1
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_StopIteration); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 136, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":133
- *
- * def __next__(self):
- * if self._count == 0: # <<<<<<<<<<<<<<
- * # Exhausted
- * self._cleanup()
- */
- }
-
- /* "src/gevent/_hub_primitives.py":138
- * raise StopIteration()
- *
- * self._count -= 1 # <<<<<<<<<<<<<<
- * try:
- * item = self._waiter.get()
- */
- __pyx_v_self->_count = (__pyx_v_self->_count - 1);
-
- /* "src/gevent/_hub_primitives.py":139
- *
- * self._count -= 1
- * try: # <<<<<<<<<<<<<<
- * item = self._waiter.get()
- * self._waiter.clear()
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":140
- * self._count -= 1
- * try:
- * item = self._waiter.get() # <<<<<<<<<<<<<<
- * self._waiter.clear()
- * if item is self:
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *)__pyx_v_self->_waiter->__pyx_base.__pyx_vtab)->__pyx_base.get(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self->_waiter), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_item = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":141
- * try:
- * item = self._waiter.get()
- * self._waiter.clear() # <<<<<<<<<<<<<<
- * if item is self:
- * # Timer expired, no more
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *)__pyx_v_self->_waiter->__pyx_base.__pyx_vtab)->__pyx_base.clear(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self->_waiter), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":142
- * item = self._waiter.get()
- * self._waiter.clear()
- * if item is self: # <<<<<<<<<<<<<<
- * # Timer expired, no more
- * self._cleanup()
- */
- __pyx_t_1 = (__pyx_v_item == ((PyObject *)__pyx_v_self));
- __pyx_t_6 = (__pyx_t_1 != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "src/gevent/_hub_primitives.py":144
- * if item is self:
- * # Timer expired, no more
- * self._cleanup() # <<<<<<<<<<<<<<
- * raise StopIteration()
- * return item
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self->__pyx_vtab)->_cleanup(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":145
- * # Timer expired, no more
- * self._cleanup()
- * raise StopIteration() # <<<<<<<<<<<<<<
- * return item
- * except:
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_StopIteration); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 145, __pyx_L4_error)
-
- /* "src/gevent/_hub_primitives.py":142
- * item = self._waiter.get()
- * self._waiter.clear()
- * if item is self: # <<<<<<<<<<<<<<
- * # Timer expired, no more
- * self._cleanup()
- */
- }
-
- /* "src/gevent/_hub_primitives.py":146
- * self._cleanup()
- * raise StopIteration()
- * return item # <<<<<<<<<<<<<<
- * except:
- * self._cleanup()
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_item);
- __pyx_r = __pyx_v_item;
- goto __pyx_L8_try_return;
-
- /* "src/gevent/_hub_primitives.py":139
- *
- * self._count -= 1
- * try: # <<<<<<<<<<<<<<
- * item = self._waiter.get()
- * self._waiter.clear()
- */
- }
- __pyx_L4_error:;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":147
- * raise StopIteration()
- * return item
- * except: # <<<<<<<<<<<<<<
- * self._cleanup()
- * raise
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 147, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_8);
-
- /* "src/gevent/_hub_primitives.py":148
- * return item
- * except:
- * self._cleanup() # <<<<<<<<<<<<<<
- * raise
- *
- */
- __pyx_t_9 = ((struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator *)__pyx_v_self->__pyx_vtab)->_cleanup(__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "src/gevent/_hub_primitives.py":149
- * except:
- * self._cleanup()
- * raise # <<<<<<<<<<<<<<
- *
- * next = __next__
- */
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_7, __pyx_t_8);
- __pyx_t_2 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
- __PYX_ERR(0, 149, __pyx_L6_except_error)
- }
- __pyx_L6_except_error:;
-
- /* "src/gevent/_hub_primitives.py":139
- *
- * self._count -= 1
- * try: # <<<<<<<<<<<<<<
- * item = self._waiter.get()
- * self._waiter.clear()
- */
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L1_error;
- __pyx_L8_try_return:;
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L0;
- }
-
- /* "src/gevent/_hub_primitives.py":132
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * if self._count == 0:
- * # Exhausted
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":153
- * next = __next__
- *
- * def _cleanup(self): # <<<<<<<<<<<<<<
- * if self._timer is not None:
- * self._timer.close()
- */
-
-static PyObject *__pyx_f_6gevent_16__hub_primitives_13_WaitIterator__cleanup(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *__pyx_v_self) {
- PyObject *__pyx_v_objs = NULL;
- PyObject *__pyx_v_aobj = NULL;
- PyObject *__pyx_v_unlink = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- Py_ssize_t __pyx_t_6;
- PyObject *(*__pyx_t_7)(PyObject *);
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("_cleanup", 0);
-
- /* "src/gevent/_hub_primitives.py":154
- *
- * def _cleanup(self):
- * if self._timer is not None: # <<<<<<<<<<<<<<
- * self._timer.close()
- * self._timer = None
- */
- __pyx_t_1 = (__pyx_v_self->_timer != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_hub_primitives.py":155
- * def _cleanup(self):
- * if self._timer is not None:
- * self._timer.close() # <<<<<<<<<<<<<<
- * self._timer = None
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_hub_primitives.py":156
- * if self._timer is not None:
- * self._timer.close()
- * self._timer = None # <<<<<<<<<<<<<<
- *
- * objs = self._objects
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = Py_None;
-
- /* "src/gevent/_hub_primitives.py":154
- *
- * def _cleanup(self):
- * if self._timer is not None: # <<<<<<<<<<<<<<
- * self._timer.close()
- * self._timer = None
- */
- }
-
- /* "src/gevent/_hub_primitives.py":158
- * self._timer = None
- *
- * objs = self._objects # <<<<<<<<<<<<<<
- * self._objects = ()
- * for aobj in objs:
- */
- __pyx_t_3 = __pyx_v_self->_objects;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_v_objs = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/_hub_primitives.py":159
- *
- * objs = self._objects
- * self._objects = () # <<<<<<<<<<<<<<
- * for aobj in objs:
- * unlink = getattr(aobj, 'unlink', None)
- */
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
- __Pyx_GOTREF(__pyx_v_self->_objects);
- __Pyx_DECREF(__pyx_v_self->_objects);
- __pyx_v_self->_objects = __pyx_empty_tuple;
-
- /* "src/gevent/_hub_primitives.py":160
- * objs = self._objects
- * self._objects = ()
- * for aobj in objs: # <<<<<<<<<<<<<<
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None:
- */
- if (likely(PyList_CheckExact(__pyx_v_objs)) || PyTuple_CheckExact(__pyx_v_objs)) {
- __pyx_t_3 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
- __pyx_t_7 = NULL;
- } else {
- __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_objs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
- }
- for (;;) {
- if (likely(!__pyx_t_7)) {
- if (likely(PyList_CheckExact(__pyx_t_3))) {
- if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- #else
- __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- #endif
- } else {
- if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- #else
- __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- #endif
- }
- } else {
- __pyx_t_4 = __pyx_t_7(__pyx_t_3);
- if (unlikely(!__pyx_t_4)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 160, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_4);
- }
- __Pyx_XDECREF_SET(__pyx_v_aobj, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/_hub_primitives.py":161
- * self._objects = ()
- * for aobj in objs:
- * unlink = getattr(aobj, 'unlink', None) # <<<<<<<<<<<<<<
- * if unlink is not None:
- * try:
- */
- __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_aobj, __pyx_n_s_unlink, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_XDECREF_SET(__pyx_v_unlink, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/_hub_primitives.py":162
- * for aobj in objs:
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None: # <<<<<<<<<<<<<<
- * try:
- * unlink(self._switch)
- */
- __pyx_t_2 = (__pyx_v_unlink != Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/_hub_primitives.py":163
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink(self._switch)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":164
- * if unlink is not None:
- * try:
- * unlink(self._switch) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * traceback.print_exc()
- */
- __Pyx_INCREF(__pyx_v_unlink);
- __pyx_t_5 = __pyx_v_unlink; __pyx_t_11 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_11) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->_switch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_self->_switch};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L7_error)
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_self->_switch};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L7_error)
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 164, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
- __Pyx_INCREF(__pyx_v_self->_switch);
- __Pyx_GIVEREF(__pyx_v_self->_switch);
- PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_self->_switch);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_hub_primitives.py":163
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink(self._switch)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L14_try_end;
- __pyx_L7_error:;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_hub_primitives.py":165
- * try:
- * unlink(self._switch)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * traceback.print_exc()
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator._cleanup", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_12) < 0) __PYX_ERR(0, 165, __pyx_L9_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_12);
-
- /* "src/gevent/_hub_primitives.py":166
- * unlink(self._switch)
- * except: # pylint:disable=bare-except
- * traceback.print_exc() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16__hub_primitives_traceback, __pyx_n_s_print_exc); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 166, __pyx_L9_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __pyx_t_14 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
- __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
- if (likely(__pyx_t_14)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
- __Pyx_INCREF(__pyx_t_14);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_13, function);
- }
- }
- if (__pyx_t_14) {
- __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L9_except_error)
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- } else {
- __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L9_except_error)
- }
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- goto __pyx_L8_exception_handled;
- }
- __pyx_L9_except_error:;
-
- /* "src/gevent/_hub_primitives.py":163
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink(self._switch)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
- goto __pyx_L1_error;
- __pyx_L8_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
- __pyx_L14_try_end:;
- }
-
- /* "src/gevent/_hub_primitives.py":162
- * for aobj in objs:
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None: # <<<<<<<<<<<<<<
- * try:
- * unlink(self._switch)
- */
- }
-
- /* "src/gevent/_hub_primitives.py":160
- * objs = self._objects
- * self._objects = ()
- * for aobj in objs: # <<<<<<<<<<<<<<
- * unlink = getattr(aobj, 'unlink', None)
- * if unlink is not None:
- */
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_hub_primitives.py":153
- * next = __next__
- *
- * def _cleanup(self): # <<<<<<<<<<<<<<
- * if self._timer is not None:
- * self._timer.close()
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_AddTraceback("gevent.__hub_primitives._WaitIterator._cleanup", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_objs);
- __Pyx_XDECREF(__pyx_v_aobj);
- __Pyx_XDECREF(__pyx_v_unlink);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":169
- *
- *
- * def iwait_on_objects(objects, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Iteratively yield *objects* as they are ready, until all (or *count*) are ready
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_1iwait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_iwait_on_objects(PyObject *__pyx_v_objects, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_count = ((PyObject *)Py_None);
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("iwait_on_objects", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_count = __pyx_optional_args->count;
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":192
- * """
- * # QQQ would be nice to support iterable here that can be generated slowly (why?)
- * hub = get_hub() # <<<<<<<<<<<<<<
- * if objects is None:
- * return [hub.join(timeout=timeout)]
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":193
- * # QQQ would be nice to support iterable here that can be generated slowly (why?)
- * hub = get_hub()
- * if objects is None: # <<<<<<<<<<<<<<
- * return [hub.join(timeout=timeout)]
- * return _WaitIterator(objects, hub, timeout, count)
- */
- __pyx_t_2 = (__pyx_v_objects == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_primitives.py":194
- * hub = get_hub()
- * if objects is None:
- * return [hub.join(timeout=timeout)] # <<<<<<<<<<<<<<
- * return _WaitIterator(objects, hub, timeout, count)
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hub), __pyx_n_s_join); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":193
- * # QQQ would be nice to support iterable here that can be generated slowly (why?)
- * hub = get_hub()
- * if objects is None: # <<<<<<<<<<<<<<
- * return [hub.join(timeout=timeout)]
- * return _WaitIterator(objects, hub, timeout, count)
- */
- }
-
- /* "src/gevent/_hub_primitives.py":195
- * if objects is None:
- * return [hub.join(timeout=timeout)]
- * return _WaitIterator(objects, hub, timeout, count) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_objects);
- __Pyx_GIVEREF(__pyx_v_objects);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_objects);
- __Pyx_INCREF(((PyObject *)__pyx_v_hub));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_hub));
- PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_hub));
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_timeout);
- __Pyx_INCREF(__pyx_v_count);
- __Pyx_GIVEREF(__pyx_v_count);
- PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_count);
- __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_16__hub_primitives__WaitIterator), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":169
- *
- *
- * def iwait_on_objects(objects, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Iteratively yield *objects* as they are ready, until all (or *count*) are ready
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.iwait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_1iwait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_iwait_on_objects[] = "iwait_on_objects(objects, timeout=None, count=None)\n\n Iteratively yield *objects* as they are ready, until all (or *count*) are ready\n or *timeout* expired.\n\n :param objects: A sequence (supporting :func:`len`) containing objects\n implementing the wait protocol (rawlink() and unlink()).\n :keyword int count: If not `None`, then a number specifying the maximum number\n of objects to wait for. If ``None`` (the default), all objects\n are waited for.\n :keyword float timeout: If given, specifies a maximum number of seconds\n to wait. If the timeout expires before the desired waited-for objects\n are available, then this method returns immediately.\n\n .. seealso:: :func:`wait`\n\n .. versionchanged:: 1.1a1\n Add the *count* parameter.\n .. versionchanged:: 1.1a2\n No longer raise :exc:`LoopExit` if our caller switches greenlets\n in between items yielded by this function.\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_1iwait_on_objects = {"iwait_on_objects", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_1iwait_on_objects, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_iwait_on_objects};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_1iwait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_objects = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_count = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("iwait_on_objects (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_objects,&__pyx_n_s_timeout,&__pyx_n_s_count,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_objects)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_count);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iwait_on_objects") < 0)) __PYX_ERR(0, 169, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_objects = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_count = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("iwait_on_objects", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 169, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.iwait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_iwait_on_objects(__pyx_self, __pyx_v_objects, __pyx_v_timeout, __pyx_v_count);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_iwait_on_objects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects __pyx_t_2;
- __Pyx_RefNannySetupContext("iwait_on_objects", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.count = __pyx_v_count;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_iwait_on_objects(__pyx_v_objects, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.iwait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":198
- *
- *
- * def wait_on_objects(objects=None, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for ``objects`` to become ready or for event loop to finish.
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_3wait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_objects(CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects *__pyx_optional_args) {
- PyObject *__pyx_v_objects = ((PyObject *)Py_None);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_count = ((PyObject *)Py_None);
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects __pyx_t_6;
- __Pyx_RefNannySetupContext("wait_on_objects", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_objects = __pyx_optional_args->objects;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 2) {
- __pyx_v_count = __pyx_optional_args->count;
- }
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":232
- * .. seealso:: :func:`iwait`
- * """
- * if objects is None: # <<<<<<<<<<<<<<
- * hub = get_hub()
- * return hub.join(timeout=timeout) # pylint:disable=
- */
- __pyx_t_1 = (__pyx_v_objects == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_hub_primitives.py":233
- * """
- * if objects is None:
- * hub = get_hub() # <<<<<<<<<<<<<<
- * return hub.join(timeout=timeout) # pylint:disable=
- * return list(iwait_on_objects(objects, timeout, count))
- */
- __pyx_t_3 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/_hub_primitives.py":234
- * if objects is None:
- * hub = get_hub()
- * return hub.join(timeout=timeout) # pylint:disable= # <<<<<<<<<<<<<<
- * return list(iwait_on_objects(objects, timeout, count))
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hub), __pyx_n_s_join); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 234, __pyx_L1_error)
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":232
- * .. seealso:: :func:`iwait`
- * """
- * if objects is None: # <<<<<<<<<<<<<<
- * hub = get_hub()
- * return hub.join(timeout=timeout) # pylint:disable=
- */
- }
-
- /* "src/gevent/_hub_primitives.py":235
- * hub = get_hub()
- * return hub.join(timeout=timeout) # pylint:disable=
- * return list(iwait_on_objects(objects, timeout, count)) # <<<<<<<<<<<<<<
- *
- * _timeout_error = Exception
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_6.__pyx_n = 2;
- __pyx_t_6.timeout = __pyx_v_timeout;
- __pyx_t_6.count = __pyx_v_count;
- __pyx_t_5 = __pyx_f_6gevent_16__hub_primitives_iwait_on_objects(__pyx_v_objects, 0, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = PySequence_List(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":198
- *
- *
- * def wait_on_objects(objects=None, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for ``objects`` to become ready or for event loop to finish.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_3wait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_2wait_on_objects[] = "wait_on_objects(objects=None, timeout=None, count=None)\n\n Wait for ``objects`` to become ready or for event loop to finish.\n\n If ``objects`` is provided, it must be a list containing objects\n implementing the wait protocol (rawlink() and unlink() methods):\n\n - :class:`gevent.Greenlet` instance\n - :class:`gevent.event.Event` instance\n - :class:`gevent.lock.Semaphore` instance\n - :class:`gevent.subprocess.Popen` instance\n\n If ``objects`` is ``None`` (the default), ``wait()`` blocks until\n the current event loop has nothing to do (or until ``timeout`` passes):\n\n - all greenlets have finished\n - all servers were stopped\n - all event loop watchers were stopped.\n\n If ``count`` is ``None`` (the default), wait for all ``objects``\n to become ready.\n\n If ``count`` is a number, wait for (up to) ``count`` objects to become\n ready. (For example, if count is ``1`` then the function exits\n when any object in the list is ready).\n\n If ``timeout`` is provided, it specifies the maximum number of\n seconds ``wait()`` will block.\n\n Returns the list of ready objects, in the order in which they were\n ready.\n\n .. seealso:: :func:`iwait`\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_3wait_on_objects = {"wait_on_objects", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_3wait_on_objects, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_2wait_on_objects};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_3wait_on_objects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_objects = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_count = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_on_objects (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_objects,&__pyx_n_s_timeout,&__pyx_n_s_count,0};
- PyObject* values[3] = {0,0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)Py_None);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_objects);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_count);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_on_objects") < 0)) __PYX_ERR(0, 198, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_objects = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_count = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_on_objects", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 198, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_2wait_on_objects(__pyx_self, __pyx_v_objects, __pyx_v_timeout, __pyx_v_count);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_2wait_on_objects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects, PyObject *__pyx_v_timeout, PyObject *__pyx_v_count) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_on_objects", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 3;
- __pyx_t_2.objects = __pyx_v_objects;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.count = __pyx_v_count;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_objects(0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_objects", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":239
- * _timeout_error = Exception
- *
- * def set_default_timeout_error(e): # <<<<<<<<<<<<<<
- * global _timeout_error
- * _timeout_error = e
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_5set_default_timeout_error(PyObject *__pyx_self, PyObject *__pyx_v_e); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_4set_default_timeout_error[] = "set_default_timeout_error(e)";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_5set_default_timeout_error = {"set_default_timeout_error", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_5set_default_timeout_error, METH_O, __pyx_doc_6gevent_16__hub_primitives_4set_default_timeout_error};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_5set_default_timeout_error(PyObject *__pyx_self, PyObject *__pyx_v_e) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_default_timeout_error (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_4set_default_timeout_error(__pyx_self, ((PyObject *)__pyx_v_e));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_4set_default_timeout_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_e) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_default_timeout_error", 0);
-
- /* "src/gevent/_hub_primitives.py":241
- * def set_default_timeout_error(e):
- * global _timeout_error
- * _timeout_error = e # <<<<<<<<<<<<<<
- *
- * def _primitive_wait(watcher, timeout, timeout_exc, hub):
- */
- __Pyx_INCREF(__pyx_v_e);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives__timeout_error);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives__timeout_error, __pyx_v_e);
- __Pyx_GIVEREF(__pyx_v_e);
-
- /* "src/gevent/_hub_primitives.py":239
- * _timeout_error = Exception
- *
- * def set_default_timeout_error(e): # <<<<<<<<<<<<<<
- * global _timeout_error
- * _timeout_error = e
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":243
- * _timeout_error = e
- *
- * def _primitive_wait(watcher, timeout, timeout_exc, hub): # <<<<<<<<<<<<<<
- * if watcher.callback is not None:
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- */
-
-static PyObject *__pyx_f_6gevent_16__hub_primitives__primitive_wait(PyObject *__pyx_v_watcher, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("_primitive_wait", 0);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_INCREF((PyObject *)__pyx_v_hub);
-
- /* "src/gevent/_hub_primitives.py":244
- *
- * def _primitive_wait(watcher, timeout, timeout_exc, hub):
- * if watcher.callback is not None: # <<<<<<<<<<<<<<
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- * % (watcher.callback, ))
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = (__pyx_t_1 != Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (unlikely(__pyx_t_3)) {
-
- /* "src/gevent/_hub_primitives.py":245
- * def _primitive_wait(watcher, timeout, timeout_exc, hub):
- * if watcher.callback is not None:
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r' # <<<<<<<<<<<<<<
- * % (watcher.callback, ))
- *
- */
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConcurrentObjectUseError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "src/gevent/_hub_primitives.py":246
- * if watcher.callback is not None:
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- * % (watcher.callback, )) # <<<<<<<<<<<<<<
- *
- * if hub is None:
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_This_socket_is_already_used_by_a, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 245, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":244
- *
- * def _primitive_wait(watcher, timeout, timeout_exc, hub):
- * if watcher.callback is not None: # <<<<<<<<<<<<<<
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- * % (watcher.callback, ))
- */
- }
-
- /* "src/gevent/_hub_primitives.py":248
- * % (watcher.callback, ))
- *
- * if hub is None: # <<<<<<<<<<<<<<
- * hub = get_hub()
- *
- */
- __pyx_t_3 = (((PyObject *)__pyx_v_hub) == Py_None);
- __pyx_t_2 = (__pyx_t_3 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_hub_primitives.py":249
- *
- * if hub is None:
- * hub = get_hub() # <<<<<<<<<<<<<<
- *
- * if timeout is None:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet))))) __PYX_ERR(0, 249, __pyx_L1_error)
- __Pyx_DECREF_SET(__pyx_v_hub, ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":248
- * % (watcher.callback, ))
- *
- * if hub is None: # <<<<<<<<<<<<<<
- * hub = get_hub()
- *
- */
- }
-
- /* "src/gevent/_hub_primitives.py":251
- * hub = get_hub()
- *
- * if timeout is None: # <<<<<<<<<<<<<<
- * hub.wait(watcher)
- * return
- */
- __pyx_t_2 = (__pyx_v_timeout == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_primitives.py":252
- *
- * if timeout is None:
- * hub.wait(watcher) # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_hub->__pyx_base.__pyx_vtab)->wait(__pyx_v_hub, __pyx_v_watcher, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":253
- * if timeout is None:
- * hub.wait(watcher)
- * return # <<<<<<<<<<<<<<
- *
- * timeout = Timeout._start_new_or_dummy(
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/_hub_primitives.py":251
- * hub = get_hub()
- *
- * if timeout is None: # <<<<<<<<<<<<<<
- * hub.wait(watcher)
- * return
- */
- }
-
- /* "src/gevent/_hub_primitives.py":255
- * return
- *
- * timeout = Timeout._start_new_or_dummy( # <<<<<<<<<<<<<<
- * timeout,
- * (timeout_exc
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16__hub_primitives_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "src/gevent/_hub_primitives.py":258
- * timeout,
- * (timeout_exc
- * if timeout_exc is not _NONE or timeout is None # <<<<<<<<<<<<<<
- * else _timeout_error('timed out')))
- *
- */
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_2 = (__pyx_v_timeout_exc != __pyx_t_5);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_8 = (__pyx_t_2 != 0);
- if (!__pyx_t_8) {
- } else {
- __pyx_t_3 = __pyx_t_8;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_8 = (__pyx_v_timeout == Py_None);
- __pyx_t_2 = (__pyx_t_8 != 0);
- __pyx_t_3 = __pyx_t_2;
- __pyx_L6_bool_binop_done:;
- if (__pyx_t_3) {
-
- /* "src/gevent/_hub_primitives.py":257
- * timeout = Timeout._start_new_or_dummy(
- * timeout,
- * (timeout_exc # <<<<<<<<<<<<<<
- * if timeout_exc is not _NONE or timeout is None
- * else _timeout_error('timed out')))
- */
- __Pyx_INCREF(__pyx_v_timeout_exc);
- __pyx_t_7 = __pyx_v_timeout_exc;
- } else {
-
- /* "src/gevent/_hub_primitives.py":259
- * (timeout_exc
- * if timeout_exc is not _NONE or timeout is None
- * else _timeout_error('timed out'))) # <<<<<<<<<<<<<<
- *
- * with timeout:
- */
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_6gevent_16__hub_primitives__timeout_error, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_7 = __pyx_t_5;
- __pyx_t_5 = 0;
- }
- __pyx_t_5 = NULL;
- __pyx_t_9 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_9 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_timeout, __pyx_t_7};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_timeout, __pyx_t_7};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_7);
- __pyx_t_7 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":261
- * else _timeout_error('timed out')))
- *
- * with timeout: # <<<<<<<<<<<<<<
- * hub.wait(watcher)
- *
- */
- /*with:*/ {
- __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_v_timeout, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_v_timeout, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L8_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L8_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /*try:*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":262
- *
- * with timeout:
- * hub.wait(watcher) # <<<<<<<<<<<<<<
- *
- * # Suitable to be bound as an instance method
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_hub->__pyx_base.__pyx_vtab)->wait(__pyx_v_hub, __pyx_v_watcher, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":261
- * else _timeout_error('timed out')))
- *
- * with timeout: # <<<<<<<<<<<<<<
- * hub.wait(watcher)
- *
- */
- }
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- goto __pyx_L17_try_end;
- __pyx_L12_error:;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__hub_primitives._primitive_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 261, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 261, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 261, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- if (__pyx_t_3 < 0) __PYX_ERR(0, 261, __pyx_L14_except_error)
- __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
- if (__pyx_t_2) {
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_6);
- __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0;
- __PYX_ERR(0, 261, __pyx_L14_except_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L13_exception_handled;
- }
- __pyx_L14_except_error:;
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- goto __pyx_L1_error;
- __pyx_L13_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_L17_try_end:;
- }
- }
- /*finally:*/ {
- /*normal exit:*/{
- if (__pyx_t_10) {
- __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__2, NULL);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- }
- goto __pyx_L11;
- }
- __pyx_L11:;
- }
- goto __pyx_L21;
- __pyx_L8_error:;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L1_error;
- __pyx_L21:;
- }
-
- /* "src/gevent/_hub_primitives.py":243
- * _timeout_error = e
- *
- * def _primitive_wait(watcher, timeout, timeout_exc, hub): # <<<<<<<<<<<<<<
- * if watcher.callback is not None:
- * raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__hub_primitives._primitive_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":265
- *
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None): # <<<<<<<<<<<<<<
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE,
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_7wait_on_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_socket(PyObject *__pyx_v_socket, PyObject *__pyx_v_watcher, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket *__pyx_optional_args) {
- PyObject *__pyx_v_timeout_exc = ((PyObject *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("wait_on_socket", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout_exc = __pyx_optional_args->timeout_exc;
- }
- }
-
- /* "src/gevent/_hub_primitives.py":266
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None):
- * _primitive_wait(watcher, socket.timeout, # <<<<<<<<<<<<<<
- * timeout_exc if timeout_exc is not None else _NONE,
- * socket.hub)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_socket, __pyx_n_s_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
-
- /* "src/gevent/_hub_primitives.py":267
- * def wait_on_socket(socket, watcher, timeout_exc=None):
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE, # <<<<<<<<<<<<<<
- * socket.hub)
- *
- */
- __pyx_t_3 = (__pyx_v_timeout_exc != Py_None);
- if ((__pyx_t_3 != 0)) {
- __Pyx_INCREF(__pyx_v_timeout_exc);
- __pyx_t_2 = __pyx_v_timeout_exc;
- } else {
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __pyx_t_4;
- __pyx_t_4 = 0;
- }
-
- /* "src/gevent/_hub_primitives.py":268
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE,
- * socket.hub) # <<<<<<<<<<<<<<
- *
- * def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_socket, __pyx_n_s_hub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet))))) __PYX_ERR(0, 268, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":266
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None):
- * _primitive_wait(watcher, socket.timeout, # <<<<<<<<<<<<<<
- * timeout_exc if timeout_exc is not None else _NONE,
- * socket.hub)
- */
- __pyx_t_5 = __pyx_f_6gevent_16__hub_primitives__primitive_wait(__pyx_v_watcher, __pyx_t_1, __pyx_t_2, ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_hub_primitives.py":265
- *
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None): # <<<<<<<<<<<<<<
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE,
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_7wait_on_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_6wait_on_socket[] = "wait_on_socket(socket, watcher, timeout_exc=None)";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_7wait_on_socket = {"wait_on_socket", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_7wait_on_socket, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_6wait_on_socket};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_7wait_on_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_socket = 0;
- PyObject *__pyx_v_watcher = 0;
- PyObject *__pyx_v_timeout_exc = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_on_socket (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_socket,&__pyx_n_s_watcher,&__pyx_n_s_timeout_exc,0};
- PyObject* values[3] = {0,0,0};
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_socket)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("wait_on_socket", 0, 2, 3, 1); __PYX_ERR(0, 265, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout_exc);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_on_socket") < 0)) __PYX_ERR(0, 265, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_socket = values[0];
- __pyx_v_watcher = values[1];
- __pyx_v_timeout_exc = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_on_socket", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 265, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_6wait_on_socket(__pyx_self, __pyx_v_socket, __pyx_v_watcher, __pyx_v_timeout_exc);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_6wait_on_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_socket, PyObject *__pyx_v_watcher, PyObject *__pyx_v_timeout_exc) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_on_socket", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_socket(__pyx_v_socket, __pyx_v_watcher, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":270
- * socket.hub)
- *
- * def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None): # <<<<<<<<<<<<<<
- * """
- * wait(watcher, timeout=None, [timeout_exc=None]) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_9wait_on_watcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_on_watcher(PyObject *__pyx_v_watcher, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_timeout_exc = __pyx_k__3;
- struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_hub = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("wait_on_watcher", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout_exc = __pyx_optional_args->timeout_exc;
- if (__pyx_optional_args->__pyx_n > 2) {
- __pyx_v_hub = __pyx_optional_args->hub;
- }
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":294
- * already started.
- * """
- * _primitive_wait(watcher, timeout, timeout_exc, hub) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives__primitive_wait(__pyx_v_watcher, __pyx_v_timeout, __pyx_v_timeout_exc, __pyx_v_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":270
- * socket.hub)
- *
- * def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None): # <<<<<<<<<<<<<<
- * """
- * wait(watcher, timeout=None, [timeout_exc=None]) -> None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_watcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_9wait_on_watcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_8wait_on_watcher[] = "wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, WaitOperationsGreenlet hub=None)\n\n wait(watcher, timeout=None, [timeout_exc=None]) -> None\n\n Block the current greenlet until *watcher* is ready.\n\n If *timeout* is non-negative, then *timeout_exc* is raised after\n *timeout* second has passed.\n\n If :func:`cancel_wait` is called on *io* by another greenlet,\n raise an exception in this blocking greenlet\n (``socket.error(EBADF, 'File descriptor was closed in another\n greenlet')`` by default).\n\n :param io: An event loop watcher, most commonly an IO watcher obtained from\n :meth:`gevent.core.loop.io`\n :keyword timeout_exc: The exception to raise if the timeout expires.\n By default, a :class:`socket.timeout` exception is raised.\n If you pass a value for this keyword, it is interpreted as for\n :class:`gevent.timeout.Timeout`.\n\n :raises ~gevent.hub.ConcurrentObjectUseError: If the *watcher* is\n already started.\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_9wait_on_watcher = {"wait_on_watcher", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_9wait_on_watcher, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_8wait_on_watcher};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_9wait_on_watcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_watcher = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_timeout_exc = 0;
- struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_hub = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_on_watcher (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_watcher,&__pyx_n_s_timeout,&__pyx_n_s_timeout_exc,&__pyx_n_s_hub,0};
- PyObject* values[4] = {0,0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = __pyx_k__3;
- values[3] = (PyObject *)((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout_exc);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_on_watcher") < 0)) __PYX_ERR(0, 270, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_watcher = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_timeout_exc = values[2];
- __pyx_v_hub = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)values[3]);
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_on_watcher", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 270, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_watcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hub), __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet, 1, "hub", 0))) __PYX_ERR(0, 270, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_8wait_on_watcher(__pyx_self, __pyx_v_watcher, __pyx_v_timeout, __pyx_v_timeout_exc, __pyx_v_hub);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_8wait_on_watcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_watcher, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_on_watcher", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 3;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_2.hub = __pyx_v_hub;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_watcher(__pyx_v_watcher, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_on_watcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":297
- *
- *
- * def wait_read(fileno, timeout=None, timeout_exc=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_read(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_11wait_read(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_read(PyObject *__pyx_v_fileno, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_timeout_exc = __pyx_k__4;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_v_io = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher __pyx_t_6;
- int __pyx_t_7;
- char const *__pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("wait_read", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout_exc = __pyx_optional_args->timeout_exc;
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":308
- * .. seealso:: :func:`cancel_wait`
- * """
- * hub = get_hub() # <<<<<<<<<<<<<<
- * io = hub.loop.io(fileno, 1)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":309
- * """
- * hub = get_hub()
- * io = hub.loop.io(fileno, 1) # <<<<<<<<<<<<<<
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_1};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_1};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_fileno);
- __Pyx_GIVEREF(__pyx_v_fileno);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_fileno);
- __Pyx_INCREF(__pyx_int_1);
- __Pyx_GIVEREF(__pyx_int_1);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_int_1);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_io = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":310
- * hub = get_hub()
- * io = hub.loop.io(fileno, 1)
- * try: # <<<<<<<<<<<<<<
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- */
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":311
- * io = hub.loop.io(fileno, 1)
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub) # <<<<<<<<<<<<<<
- * finally:
- * io.close()
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(((((PyObject *)__pyx_v_hub)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_hub), __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet))))) __PYX_ERR(0, 311, __pyx_L4_error)
- __pyx_t_6.__pyx_n = 3;
- __pyx_t_6.timeout = __pyx_v_timeout;
- __pyx_t_6.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_6.hub = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_hub);
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_watcher(__pyx_v_io, 0, &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L3_return;
- }
-
- /* "src/gevent/_hub_primitives.py":313
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- * io.close() # <<<<<<<<<<<<<<
- *
- *
- */
- /*finally:*/ {
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
- {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L7_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L7_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
- goto __pyx_L1_error;
- __pyx_L7_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_14 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_14;
- __pyx_t_14 = 0;
- goto __pyx_L0;
- }
- }
-
- /* "src/gevent/_hub_primitives.py":297
- *
- *
- * def wait_read(fileno, timeout=None, timeout_exc=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_read(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_read", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XDECREF(__pyx_v_io);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_11wait_read(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_10wait_read[] = "wait_read(fileno, timeout=None, timeout_exc=_NONE)\n\n wait_read(fileno, timeout=None, [timeout_exc=None]) -> None\n\n Block the current greenlet until *fileno* is ready to read.\n\n For the meaning of the other parameters and possible exceptions,\n see :func:`wait`.\n\n .. seealso:: :func:`cancel_wait`\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_11wait_read = {"wait_read", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_11wait_read, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_10wait_read};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_11wait_read(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_fileno = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_timeout_exc = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_read (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fileno,&__pyx_n_s_timeout,&__pyx_n_s_timeout_exc,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = __pyx_k__4;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fileno)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout_exc);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_read") < 0)) __PYX_ERR(0, 297, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_fileno = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_timeout_exc = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_read", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 297, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_read", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_10wait_read(__pyx_self, __pyx_v_fileno, __pyx_v_timeout, __pyx_v_timeout_exc);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_10wait_read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_read", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_read(__pyx_v_fileno, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_read", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":316
- *
- *
- * def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_write(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13wait_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_write(PyObject *__pyx_v_fileno, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_timeout_exc = __pyx_k__5;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_v_io = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher __pyx_t_6;
- int __pyx_t_7;
- char const *__pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("wait_write", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout_exc = __pyx_optional_args->timeout_exc;
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":332
- * """
- * # pylint:disable=unused-argument
- * hub = get_hub() # <<<<<<<<<<<<<<
- * io = hub.loop.io(fileno, 2)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":333
- * # pylint:disable=unused-argument
- * hub = get_hub()
- * io = hub.loop.io(fileno, 2) # <<<<<<<<<<<<<<
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_fileno);
- __Pyx_GIVEREF(__pyx_v_fileno);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_fileno);
- __Pyx_INCREF(__pyx_int_2);
- __Pyx_GIVEREF(__pyx_int_2);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_int_2);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_io = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":334
- * hub = get_hub()
- * io = hub.loop.io(fileno, 2)
- * try: # <<<<<<<<<<<<<<
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- */
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":335
- * io = hub.loop.io(fileno, 2)
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub) # <<<<<<<<<<<<<<
- * finally:
- * io.close()
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(((((PyObject *)__pyx_v_hub)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_hub), __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet))))) __PYX_ERR(0, 335, __pyx_L4_error)
- __pyx_t_6.__pyx_n = 3;
- __pyx_t_6.timeout = __pyx_v_timeout;
- __pyx_t_6.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_6.hub = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_hub);
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_watcher(__pyx_v_io, 0, &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L3_return;
- }
-
- /* "src/gevent/_hub_primitives.py":337
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- * io.close() # <<<<<<<<<<<<<<
- *
- *
- */
- /*finally:*/ {
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
- {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L7_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L7_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
- goto __pyx_L1_error;
- __pyx_L7_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_14 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_14;
- __pyx_t_14 = 0;
- goto __pyx_L0;
- }
- }
-
- /* "src/gevent/_hub_primitives.py":316
- *
- *
- * def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_write(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XDECREF(__pyx_v_io);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13wait_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_12wait_write[] = "wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE)\n\n wait_write(fileno, timeout=None, [timeout_exc=None]) -> None\n\n Block the current greenlet until *fileno* is ready to write.\n\n For the meaning of the other parameters and possible exceptions,\n see :func:`wait`.\n\n .. deprecated:: 1.1\n The keyword argument *event* is ignored. Applications should not pass this parameter.\n In the future, doing so will become an error.\n\n .. seealso:: :func:`cancel_wait`\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_13wait_write = {"wait_write", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_13wait_write, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_12wait_write};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_13wait_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_fileno = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_timeout_exc = 0;
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_write (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fileno,&__pyx_n_s_timeout,&__pyx_n_s_timeout_exc,&__pyx_n_s_event,0};
- PyObject* values[4] = {0,0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = __pyx_k__5;
- values[3] = __pyx_k__6;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fileno)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout_exc);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_write") < 0)) __PYX_ERR(0, 316, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_fileno = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_timeout_exc = values[2];
- __pyx_v_event = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_write", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 316, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_12wait_write(__pyx_self, __pyx_v_fileno, __pyx_v_timeout, __pyx_v_timeout_exc, __pyx_v_event);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_12wait_write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, PyObject *__pyx_v_event) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_write", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 3;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_2.event = __pyx_v_event;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_write(__pyx_v_fileno, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":340
- *
- *
- * def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_15wait_readwrite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_16__hub_primitives_wait_readwrite(PyObject *__pyx_v_fileno, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_timeout_exc = __pyx_k__7;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_v_io = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher __pyx_t_6;
- int __pyx_t_7;
- char const *__pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("wait_readwrite", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout_exc = __pyx_optional_args->timeout_exc;
- }
- }
- }
-
- /* "src/gevent/_hub_primitives.py":357
- * """
- * # pylint:disable=unused-argument
- * hub = get_hub() # <<<<<<<<<<<<<<
- * io = hub.loop.io(fileno, 3)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":358
- * # pylint:disable=unused-argument
- * hub = get_hub()
- * io = hub.loop.io(fileno, 3) # <<<<<<<<<<<<<<
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_fileno, __pyx_int_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_fileno);
- __Pyx_GIVEREF(__pyx_v_fileno);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_fileno);
- __Pyx_INCREF(__pyx_int_3);
- __Pyx_GIVEREF(__pyx_int_3);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_int_3);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_io = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":359
- * hub = get_hub()
- * io = hub.loop.io(fileno, 3)
- * try: # <<<<<<<<<<<<<<
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- */
- /*try:*/ {
-
- /* "src/gevent/_hub_primitives.py":360
- * io = hub.loop.io(fileno, 3)
- * try:
- * return wait_on_watcher(io, timeout, timeout_exc, hub) # <<<<<<<<<<<<<<
- * finally:
- * io.close()
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(((((PyObject *)__pyx_v_hub)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_hub), __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet))))) __PYX_ERR(0, 360, __pyx_L4_error)
- __pyx_t_6.__pyx_n = 3;
- __pyx_t_6.timeout = __pyx_v_timeout;
- __pyx_t_6.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_6.hub = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)__pyx_v_hub);
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_on_watcher(__pyx_v_io, 0, &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L3_return;
- }
-
- /* "src/gevent/_hub_primitives.py":362
- * return wait_on_watcher(io, timeout, timeout_exc, hub)
- * finally:
- * io.close() # <<<<<<<<<<<<<<
- *
- *
- */
- /*finally:*/ {
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
- {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L7_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L7_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
- goto __pyx_L1_error;
- __pyx_L7_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_14 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_io, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_14;
- __pyx_t_14 = 0;
- goto __pyx_L0;
- }
- }
-
- /* "src/gevent/_hub_primitives.py":340
- *
- *
- * def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_readwrite", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XDECREF(__pyx_v_io);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_15wait_readwrite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_14wait_readwrite[] = "wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE)\n\n wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None\n\n Block the current greenlet until *fileno* is ready to read or\n write.\n\n For the meaning of the other parameters and possible exceptions,\n see :func:`wait`.\n\n .. deprecated:: 1.1\n The keyword argument *event* is ignored. Applications should not pass this parameter.\n In the future, doing so will become an error.\n\n .. seealso:: :func:`cancel_wait`\n ";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_15wait_readwrite = {"wait_readwrite", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_15wait_readwrite, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_16__hub_primitives_14wait_readwrite};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_15wait_readwrite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_fileno = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_timeout_exc = 0;
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait_readwrite (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fileno,&__pyx_n_s_timeout,&__pyx_n_s_timeout_exc,&__pyx_n_s_event,0};
- PyObject* values[4] = {0,0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = __pyx_k__7;
- values[3] = __pyx_k__8;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fileno)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout_exc);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_readwrite") < 0)) __PYX_ERR(0, 340, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_fileno = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_timeout_exc = values[2];
- __pyx_v_event = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait_readwrite", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 340, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_readwrite", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_14wait_readwrite(__pyx_self, __pyx_v_fileno, __pyx_v_timeout, __pyx_v_timeout_exc, __pyx_v_event);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_14wait_readwrite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fileno, PyObject *__pyx_v_timeout, PyObject *__pyx_v_timeout_exc, PyObject *__pyx_v_event) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite __pyx_t_2;
- __Pyx_RefNannySetupContext("wait_readwrite", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 3;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.timeout_exc = __pyx_v_timeout_exc;
- __pyx_t_2.event = __pyx_v_event;
- __pyx_t_1 = __pyx_f_6gevent_16__hub_primitives_wait_readwrite(__pyx_v_fileno, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.wait_readwrite", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_hub_primitives.py":365
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_17_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_16__hub_primitives_16_init[] = "_init()";
-static PyMethodDef __pyx_mdef_6gevent_16__hub_primitives_17_init = {"_init", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_17_init, METH_NOARGS, __pyx_doc_6gevent_16__hub_primitives_16_init};
-static PyObject *__pyx_pw_6gevent_16__hub_primitives_17_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_16__hub_primitives_16_init(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_16__hub_primitives_16_init(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/_hub_primitives.py":366
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_16__hub_primitives_greenlet_init();
-
- /* "src/gevent/_hub_primitives.py":365
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__hub_primitives.pxd":29
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_16__hub_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__hub_primitives.pxd":30
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__hub_primitives.pxd":29
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__hub_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__hub_primitives.pxd":34
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_16__hub_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__hub_primitives.pxd":36
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_16__hub_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__hub_primitives.pxd":37
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__hub_primitives.pxd":38
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_6gevent_16__hub_primitives__greenlet_imported = 1;
-
- /* "gevent/__hub_primitives.pxd":36
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__hub_primitives.pxd":34
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-static struct __pyx_vtabstruct_6gevent_16__hub_primitives_WaitOperationsGreenlet __pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet;
-
-static PyObject *__pyx_tp_new_6gevent_16__hub_primitives_WaitOperationsGreenlet(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *p;
- PyObject *o = __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__pyx_vtabptr_6gevent_16__hub_primitives_WaitOperationsGreenlet;
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_16__hub_primitives_WaitOperationsGreenlet(PyObject *o) {
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_16__hub_primitives_WaitOperationsGreenlet);
-}
-
-static int __pyx_tp_traverse_6gevent_16__hub_primitives_WaitOperationsGreenlet(PyObject *o, visitproc v, void *a) {
- int e;
- e = ((likely(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) ? ((__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_traverse) ? __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_16__hub_primitives_WaitOperationsGreenlet)); if (e) return e;
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_16__hub_primitives_WaitOperationsGreenlet(PyObject *o) {
- if (likely(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) { if (__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_clear) __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_16__hub_primitives_WaitOperationsGreenlet);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_16__hub_primitives_WaitOperationsGreenlet[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__hub_primitives.WaitOperationsGreenlet", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_16__hub_primitives_WaitOperationsGreenlet, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_16__hub_primitives_WaitOperationsGreenlet, /*tp_traverse*/
- __pyx_tp_clear_6gevent_16__hub_primitives_WaitOperationsGreenlet, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_16__hub_primitives_WaitOperationsGreenlet, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_16__hub_primitives_WaitOperationsGreenlet, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_16__hub_primitives__WaitIterator __pyx_vtable_6gevent_16__hub_primitives__WaitIterator;
-
-static PyObject *__pyx_tp_new_6gevent_16__hub_primitives__WaitIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_16__hub_primitives__WaitIterator;
- p->_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- p->_waiter = ((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)Py_None); Py_INCREF(Py_None);
- p->_switch = Py_None; Py_INCREF(Py_None);
- p->_timeout = Py_None; Py_INCREF(Py_None);
- p->_objects = Py_None; Py_INCREF(Py_None);
- p->_timer = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_16__hub_primitives__WaitIterator(PyObject *o) {
- struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *p = (struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_hub);
- Py_CLEAR(p->_waiter);
- Py_CLEAR(p->_switch);
- Py_CLEAR(p->_timeout);
- Py_CLEAR(p->_objects);
- Py_CLEAR(p->_timer);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_16__hub_primitives__WaitIterator(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *p = (struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)o;
- if (p->_hub) {
- e = (*v)(((PyObject *)p->_hub), a); if (e) return e;
- }
- if (p->_waiter) {
- e = (*v)(((PyObject *)p->_waiter), a); if (e) return e;
- }
- if (p->_switch) {
- e = (*v)(p->_switch, a); if (e) return e;
- }
- if (p->_timeout) {
- e = (*v)(p->_timeout, a); if (e) return e;
- }
- if (p->_objects) {
- e = (*v)(p->_objects, a); if (e) return e;
- }
- if (p->_timer) {
- e = (*v)(p->_timer, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_16__hub_primitives__WaitIterator(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *p = (struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *)o;
- tmp = ((PyObject*)p->_hub);
- p->_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_waiter);
- p->_waiter = ((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_switch);
- p->_switch = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_timeout);
- p->_timeout = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_objects);
- p->_objects = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_timer);
- p->_timer = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_16__hub_primitives__WaitIterator[] = {
- {"__next__", (PyCFunction)__pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_5__next__, METH_NOARGS|METH_COEXIST, 0},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_16__hub_primitives__WaitIterator = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__hub_primitives._WaitIterator", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_16__hub_primitives__WaitIterator, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_WaitIterator(objects, hub, timeout, count)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_16__hub_primitives__WaitIterator, /*tp_traverse*/
- __pyx_tp_clear_6gevent_16__hub_primitives__WaitIterator, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- __pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_3__iter__, /*tp_iter*/
- __pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_5__next__, /*tp_iternext*/
- __pyx_methods_6gevent_16__hub_primitives__WaitIterator, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_16__hub_primitives_13_WaitIterator_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_16__hub_primitives__WaitIterator, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___hub_primitives(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___hub_primitives},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__hub_primitives",
- __pyx_k_A_collection_of_primitives_used, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_ConcurrentObjectUseError, __pyx_k_ConcurrentObjectUseError, sizeof(__pyx_k_ConcurrentObjectUseError), 0, 0, 1, 1},
- {&__pyx_n_s_InvalidSwitchError, __pyx_k_InvalidSwitchError, sizeof(__pyx_k_InvalidSwitchError), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_switch_into_s_r_expected, __pyx_k_Invalid_switch_into_s_r_expected, sizeof(__pyx_k_Invalid_switch_into_s_r_expected), 0, 0, 1, 0},
- {&__pyx_n_s_MultipleWaiter, __pyx_k_MultipleWaiter, sizeof(__pyx_k_MultipleWaiter), 0, 0, 1, 1},
- {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1},
- {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
- {&__pyx_n_s_SwitchOutGreenletWithLoop, __pyx_k_SwitchOutGreenletWithLoop, sizeof(__pyx_k_SwitchOutGreenletWithLoop), 0, 0, 1, 1},
- {&__pyx_kp_s_This_socket_is_already_used_by_a, __pyx_k_This_socket_is_already_used_by_a, sizeof(__pyx_k_This_socket_is_already_used_by_a), 0, 0, 1, 0},
- {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1},
- {&__pyx_n_s_WaitOperationsGreenlet, __pyx_k_WaitOperationsGreenlet, sizeof(__pyx_k_WaitOperationsGreenlet), 0, 0, 1, 1},
- {&__pyx_n_s_WaitOperationsGreenlet__cancel_w, __pyx_k_WaitOperationsGreenlet__cancel_w, sizeof(__pyx_k_WaitOperationsGreenlet__cancel_w), 0, 0, 1, 1},
- {&__pyx_n_s_WaitOperationsGreenlet_cancel_wa, __pyx_k_WaitOperationsGreenlet_cancel_wa, sizeof(__pyx_k_WaitOperationsGreenlet_cancel_wa), 0, 0, 1, 1},
- {&__pyx_n_s_WaitOperationsGreenlet_wait, __pyx_k_WaitOperationsGreenlet_wait, sizeof(__pyx_k_WaitOperationsGreenlet_wait), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter, __pyx_k_Waiter, sizeof(__pyx_k_Waiter), 0, 0, 1, 1},
- {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_n_s_cancel_wait, __pyx_k_cancel_wait, sizeof(__pyx_k_cancel_wait), 0, 0, 1, 1},
- {&__pyx_n_s_cancel_wait_2, __pyx_k_cancel_wait_2, sizeof(__pyx_k_cancel_wait_2), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_close_watcher, __pyx_k_close_watcher, sizeof(__pyx_k_close_watcher), 0, 0, 1, 1},
- {&__pyx_n_s_count, __pyx_k_count, sizeof(__pyx_k_count), 0, 0, 1, 1},
- {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
- {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
- {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
- {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1},
- {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
- {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___hub_primitives, __pyx_k_gevent___hub_primitives, sizeof(__pyx_k_gevent___hub_primitives), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_local, __pyx_k_gevent__hub_local, sizeof(__pyx_k_gevent__hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_primitives, __pyx_k_greenlet_primitives, sizeof(__pyx_k_greenlet_primitives), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1},
- {&__pyx_n_s_iwait_on_objects, __pyx_k_iwait_on_objects, sizeof(__pyx_k_iwait_on_objects), 0, 0, 1, 1},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
- {&__pyx_n_s_next_2, __pyx_k_next_2, sizeof(__pyx_k_next_2), 0, 0, 1, 1},
- {&__pyx_n_s_objects, __pyx_k_objects, sizeof(__pyx_k_objects), 0, 0, 1, 1},
- {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1},
- {&__pyx_n_s_priority, __pyx_k_priority, sizeof(__pyx_k_priority), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_self_2, __pyx_k_self_2, sizeof(__pyx_k_self_2), 0, 0, 1, 1},
- {&__pyx_n_s_set_default_timeout_error, __pyx_k_set_default_timeout_error, sizeof(__pyx_k_set_default_timeout_error), 0, 0, 1, 1},
- {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__hub_primitives_py, __pyx_k_src_gevent__hub_primitives_py, sizeof(__pyx_k_src_gevent__hub_primitives_py), 0, 0, 1, 0},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1},
- {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_kp_s_timed_out, __pyx_k_timed_out, sizeof(__pyx_k_timed_out), 0, 0, 1, 0},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_timeout_error, __pyx_k_timeout_error, sizeof(__pyx_k_timeout_error), 0, 0, 1, 1},
- {&__pyx_n_s_timeout_exc, __pyx_k_timeout_exc, sizeof(__pyx_k_timeout_exc), 0, 0, 1, 1},
- {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1},
- {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
- {&__pyx_n_s_wait_on_objects, __pyx_k_wait_on_objects, sizeof(__pyx_k_wait_on_objects), 0, 0, 1, 1},
- {&__pyx_n_s_wait_on_socket, __pyx_k_wait_on_socket, sizeof(__pyx_k_wait_on_socket), 0, 0, 1, 1},
- {&__pyx_n_s_wait_on_watcher, __pyx_k_wait_on_watcher, sizeof(__pyx_k_wait_on_watcher), 0, 0, 1, 1},
- {&__pyx_n_s_wait_read, __pyx_k_wait_read, sizeof(__pyx_k_wait_read), 0, 0, 1, 1},
- {&__pyx_n_s_wait_readwrite, __pyx_k_wait_readwrite, sizeof(__pyx_k_wait_readwrite), 0, 0, 1, 1},
- {&__pyx_n_s_wait_write, __pyx_k_wait_write, sizeof(__pyx_k_wait_write), 0, 0, 1, 1},
- {&__pyx_n_s_waiter, __pyx_k_waiter, sizeof(__pyx_k_waiter), 0, 0, 1, 1},
- {&__pyx_n_s_watcher, __pyx_k_watcher, sizeof(__pyx_k_watcher), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 29, __pyx_L1_error)
- __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 136, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_hub_primitives.py":259
- * (timeout_exc
- * if timeout_exc is not _NONE or timeout is None
- * else _timeout_error('timed out'))) # <<<<<<<<<<<<<<
- *
- * with timeout:
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_timed_out); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_hub_primitives.py":261
- * else _timeout_error('timed out')))
- *
- * with timeout: # <<<<<<<<<<<<<<
- * hub.wait(watcher)
- *
- */
- __pyx_tuple__2 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "src/gevent/_hub_primitives.py":29
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter
- */
- __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
-
- /* "src/gevent/_hub_primitives.py":46
- * class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable
- *
- * def wait(self, watcher): # <<<<<<<<<<<<<<
- * """
- * Wait until the *watcher* (which must not be started) is ready.
- */
- __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_watcher); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
- __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 46, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":63
- * watcher.stop()
- *
- * def cancel_wait(self, watcher, error, close_watcher=False): # <<<<<<<<<<<<<<
- * """
- * Cancel an in-progress call to :meth:`wait` by throwing the given *error*
- */
- __pyx_tuple__12 = PyTuple_Pack(4, __pyx_n_s_self_2, __pyx_n_s_watcher, __pyx_n_s_error, __pyx_n_s_close_watcher); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__12);
- __Pyx_GIVEREF(__pyx_tuple__12);
- __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_cancel_wait, 63, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 63, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":84
- * watcher.close()
- *
- * def _cancel_wait(self, watcher, error, close_watcher): # <<<<<<<<<<<<<<
- * # We have to check again to see if it was still active by the time
- * # our callback actually runs.
- */
- __pyx_tuple__14 = PyTuple_Pack(4, __pyx_n_s_self_2, __pyx_n_s_watcher, __pyx_n_s_error, __pyx_n_s_close_watcher); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__14);
- __Pyx_GIVEREF(__pyx_tuple__14);
- __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_cancel_wait_2, 84, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 84, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":169
- *
- *
- * def iwait_on_objects(objects, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Iteratively yield *objects* as they are ready, until all (or *count*) are ready
- */
- __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_objects, __pyx_n_s_timeout, __pyx_n_s_count); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__16);
- __Pyx_GIVEREF(__pyx_tuple__16);
- __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_iwait_on_objects, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 169, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":198
- *
- *
- * def wait_on_objects(objects=None, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for ``objects`` to become ready or for event loop to finish.
- */
- __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_objects, __pyx_n_s_timeout, __pyx_n_s_count); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
- __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_on_objects, 198, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 198, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":239
- * _timeout_error = Exception
- *
- * def set_default_timeout_error(e): # <<<<<<<<<<<<<<
- * global _timeout_error
- * _timeout_error = e
- */
- __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_e); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__20);
- __Pyx_GIVEREF(__pyx_tuple__20);
- __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_set_default_timeout_error, 239, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 239, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":265
- *
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None): # <<<<<<<<<<<<<<
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE,
- */
- __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_socket, __pyx_n_s_watcher, __pyx_n_s_timeout_exc); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 265, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__22);
- __Pyx_GIVEREF(__pyx_tuple__22);
- __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_on_socket, 265, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 265, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":270
- * socket.hub)
- *
- * def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None): # <<<<<<<<<<<<<<
- * """
- * wait(watcher, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_tuple__24 = PyTuple_Pack(4, __pyx_n_s_watcher, __pyx_n_s_timeout, __pyx_n_s_timeout_exc, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__24);
- __Pyx_GIVEREF(__pyx_tuple__24);
- __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_on_watcher, 270, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 270, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":297
- *
- *
- * def wait_read(fileno, timeout=None, timeout_exc=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_read(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_tuple__26 = PyTuple_Pack(3, __pyx_n_s_fileno, __pyx_n_s_timeout, __pyx_n_s_timeout_exc); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__26);
- __Pyx_GIVEREF(__pyx_tuple__26);
- __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_read, 297, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 297, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":316
- *
- *
- * def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_write(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_tuple__28 = PyTuple_Pack(4, __pyx_n_s_fileno, __pyx_n_s_timeout, __pyx_n_s_timeout_exc, __pyx_n_s_event); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__28);
- __Pyx_GIVEREF(__pyx_tuple__28);
- __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_write, 316, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 316, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":340
- *
- *
- * def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_tuple__30 = PyTuple_Pack(4, __pyx_n_s_fileno, __pyx_n_s_timeout, __pyx_n_s_timeout_exc, __pyx_n_s_event); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__30);
- __Pyx_GIVEREF(__pyx_tuple__30);
- __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_wait_readwrite, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 340, __pyx_L1_error)
-
- /* "src/gevent/_hub_primitives.py":365
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__hub_primitives_py, __pyx_n_s_init, 365, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_16__hub_primitives_InvalidSwitchError = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_16__hub_primitives__waiter = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_16__hub_primitives__greenlet_primitives = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_16__hub_primitives_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_16__hub_primitives__timeout_error = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_16__hub_primitives_Timeout = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_InvalidSwitchError, (void *)&__pyx_v_6gevent_16__hub_primitives_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_waiter, (void *)&__pyx_v_6gevent_16__hub_primitives__waiter, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_primitives, (void *)&__pyx_v_6gevent_16__hub_primitives__greenlet_primitives, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_traceback, (void *)&__pyx_v_6gevent_16__hub_primitives_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_timeout_error, (void *)&__pyx_v_6gevent_16__hub_primitives__timeout_error, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_Timeout, (void *)&__pyx_v_6gevent_16__hub_primitives_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_16__hub_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("iwait_on_objects", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_iwait_on_objects, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_iwait_on_objects *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_on_objects", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_on_objects, "PyObject *(int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_objects *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_primitive_wait", (void (*)(void))__pyx_f_6gevent_16__hub_primitives__primitive_wait, "PyObject *(PyObject *, PyObject *, PyObject *, struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_on_watcher", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_on_watcher, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_watcher *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_read", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_read, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_read *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_write", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_write, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_write *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_readwrite", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_readwrite, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_readwrite *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("wait_on_socket", (void (*)(void))__pyx_f_6gevent_16__hub_primitives_wait_on_socket, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_wait_on_socket *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_16__hub_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_16__hub_primitives_greenlet)) __PYX_ERR(3, 19, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_16__hub_primitives_WaitOperationsGreenlet = &__pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet;
- __pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet.__pyx_base = *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
- __pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet.wait = (PyObject *(*)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_wait;
- __pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet.cancel_wait = (PyObject *(*)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait *__pyx_optional_args))__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet_cancel_wait;
- __pyx_vtable_6gevent_16__hub_primitives_WaitOperationsGreenlet._cancel_wait = (PyObject *(*)(struct __pyx_obj_6gevent_16__hub_primitives_WaitOperationsGreenlet *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_16__hub_primitives_22WaitOperationsGreenlet__cancel_wait;
- __pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_base = __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
- if (PyType_Ready(&__pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
- __pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_dictoffset && __pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet.tp_dict, __pyx_vtabptr_6gevent_16__hub_primitives_WaitOperationsGreenlet) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "WaitOperationsGreenlet", (PyObject *)&__pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
- __pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet = &__pyx_type_6gevent_16__hub_primitives_WaitOperationsGreenlet;
- __pyx_vtabptr_6gevent_16__hub_primitives__WaitIterator = &__pyx_vtable_6gevent_16__hub_primitives__WaitIterator;
- __pyx_vtable_6gevent_16__hub_primitives__WaitIterator._cleanup = (PyObject *(*)(struct __pyx_obj_6gevent_16__hub_primitives__WaitIterator *))__pyx_f_6gevent_16__hub_primitives_13_WaitIterator__cleanup;
- if (PyType_Ready(&__pyx_type_6gevent_16__hub_primitives__WaitIterator) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- __pyx_type_6gevent_16__hub_primitives__WaitIterator.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_16__hub_primitives__WaitIterator.tp_dictoffset && __pyx_type_6gevent_16__hub_primitives__WaitIterator.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_16__hub_primitives__WaitIterator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_16__hub_primitives__WaitIterator.tp_dict, __pyx_vtabptr_6gevent_16__hub_primitives__WaitIterator) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "_WaitIterator", (PyObject *)&__pyx_type_6gevent_16__hub_primitives__WaitIterator) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- __pyx_ptype_6gevent_16__hub_primitives__WaitIterator = &__pyx_type_6gevent_16__hub_primitives__WaitIterator;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(1, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(1, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(2, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_Waiter = __Pyx_ImportType("gevent.__waiter", "Waiter", sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_Waiter)) __PYX_ERR(2, 33, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_Waiter)) __PYX_ERR(2, 33, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = __Pyx_ImportType("gevent.__waiter", "MultipleWaiter", sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(2, 47, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = (struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(2, 47, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_ImportModule("gevent.__waiter"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "sys", (void **)&__pyx_vp_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "ConcurrentObjectUseError", (void **)&__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_greenlet_imported", (void **)&__pyx_vp_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_NONE", (void **)&__pyx_vp_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__hub_primitives(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__hub_primitives(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___hub_primitives(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___hub_primitives(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___hub_primitives(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___hub_primitives(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__hub_primitives", __pyx_methods, __pyx_k_A_collection_of_primitives_used, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____hub_primitives) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__hub_primitives")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__hub_primitives", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_hub_primitives.py":14
- * from __future__ import print_function
- *
- * import traceback # <<<<<<<<<<<<<<
- *
- * from gevent.exceptions import InvalidSwitchError
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_traceback, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives_traceback, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":16
- * import traceback
- *
- * from gevent.exceptions import InvalidSwitchError # <<<<<<<<<<<<<<
- * from gevent.exceptions import ConcurrentObjectUseError
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_InvalidSwitchError);
- __Pyx_GIVEREF(__pyx_n_s_InvalidSwitchError);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_InvalidSwitchError);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives_InvalidSwitchError);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives_InvalidSwitchError, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":17
- *
- * from gevent.exceptions import InvalidSwitchError
- * from gevent.exceptions import ConcurrentObjectUseError # <<<<<<<<<<<<<<
- *
- * from gevent import _greenlet_primitives
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ConcurrentObjectUseError);
- __Pyx_GIVEREF(__pyx_n_s_ConcurrentObjectUseError);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ConcurrentObjectUseError);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ConcurrentObjectUseError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConcurrentObjectUseError, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":19
- * from gevent.exceptions import ConcurrentObjectUseError
- *
- * from gevent import _greenlet_primitives # <<<<<<<<<<<<<<
- * from gevent import _waiter
- * from gevent._util import _NONE
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_greenlet_primitives);
- __Pyx_GIVEREF(__pyx_n_s_greenlet_primitives);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_greenlet_primitives);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_greenlet_primitives); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives__greenlet_primitives);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives__greenlet_primitives, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":20
- *
- * from gevent import _greenlet_primitives
- * from gevent import _waiter # <<<<<<<<<<<<<<
- * from gevent._util import _NONE
- * from gevent._hub_local import get_hub_noargs as get_hub
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_waiter);
- __Pyx_GIVEREF(__pyx_n_s_waiter);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_waiter);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_waiter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives__waiter);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives__waiter, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":21
- * from gevent import _greenlet_primitives
- * from gevent import _waiter
- * from gevent._util import _NONE # <<<<<<<<<<<<<<
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from gevent.timeout import Timeout
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_NONE);
- __Pyx_GIVEREF(__pyx_n_s_NONE);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_NONE);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONE, __pyx_t_1) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":22
- * from gevent import _waiter
- * from gevent._util import _NONE
- * from gevent._hub_local import get_hub_noargs as get_hub # <<<<<<<<<<<<<<
- * from gevent.timeout import Timeout
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_hub_noargs);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":23
- * from gevent._util import _NONE
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from gevent.timeout import Timeout # <<<<<<<<<<<<<<
- *
- * # In Cython, we define these as 'cdef inline' functions. The
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Timeout);
- __Pyx_GIVEREF(__pyx_n_s_Timeout);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Timeout);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives_Timeout);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives_Timeout, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":29
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_getcurrent, __pyx_t_1) < 0)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":30
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['Waiter'] = _waiter.Waiter
- * locals()['MultipleWaiter'] = _waiter.MultipleWaiter
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_18lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_greenlet_init, __pyx_t_1) < 0)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":31
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter # <<<<<<<<<<<<<<
- * locals()['MultipleWaiter'] = _waiter.MultipleWaiter
- * locals()['SwitchOutGreenletWithLoop'] = _greenlet_primitives.SwitchOutGreenletWithLoop
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16__hub_primitives__waiter, __pyx_n_s_Waiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_Waiter, __pyx_t_1) < 0)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":32
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter
- * locals()['MultipleWaiter'] = _waiter.MultipleWaiter # <<<<<<<<<<<<<<
- * locals()['SwitchOutGreenletWithLoop'] = _greenlet_primitives.SwitchOutGreenletWithLoop
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16__hub_primitives__waiter, __pyx_n_s_MultipleWaiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_MultipleWaiter, __pyx_t_1) < 0)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":33
- * locals()['Waiter'] = _waiter.Waiter
- * locals()['MultipleWaiter'] = _waiter.MultipleWaiter
- * locals()['SwitchOutGreenletWithLoop'] = _greenlet_primitives.SwitchOutGreenletWithLoop # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16__hub_primitives__greenlet_primitives, __pyx_n_s_SwitchOutGreenletWithLoop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_SwitchOutGreenletWithLoop, __pyx_t_1) < 0)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":35
- * locals()['SwitchOutGreenletWithLoop'] = _greenlet_primitives.SwitchOutGreenletWithLoop
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'WaitOperationsGreenlet',
- * 'iwait_on_objects',
- */
- __pyx_t_1 = PyList_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_WaitOperationsGreenlet);
- __Pyx_GIVEREF(__pyx_n_s_WaitOperationsGreenlet);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WaitOperationsGreenlet);
- __Pyx_INCREF(__pyx_n_s_iwait_on_objects);
- __Pyx_GIVEREF(__pyx_n_s_iwait_on_objects);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_iwait_on_objects);
- __Pyx_INCREF(__pyx_n_s_wait_on_objects);
- __Pyx_GIVEREF(__pyx_n_s_wait_on_objects);
- PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_wait_on_objects);
- __Pyx_INCREF(__pyx_n_s_wait_read);
- __Pyx_GIVEREF(__pyx_n_s_wait_read);
- PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_wait_read);
- __Pyx_INCREF(__pyx_n_s_wait_write);
- __Pyx_GIVEREF(__pyx_n_s_wait_write);
- PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_wait_write);
- __Pyx_INCREF(__pyx_n_s_wait_readwrite);
- __Pyx_GIVEREF(__pyx_n_s_wait_readwrite);
- PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_wait_readwrite);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":46
- * class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable
- *
- * def wait(self, watcher): # <<<<<<<<<<<<<<
- * """
- * Wait until the *watcher* (which must not be started) is ready.
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_1wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_WaitOperationsGreenlet_wait, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet->tp_dict, __pyx_n_s_wait, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet);
-
- /* "src/gevent/_hub_primitives.py":63
- * watcher.stop()
- *
- * def cancel_wait(self, watcher, error, close_watcher=False): # <<<<<<<<<<<<<<
- * """
- * Cancel an in-progress call to :meth:`wait` by throwing the given *error*
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_3cancel_wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_WaitOperationsGreenlet_cancel_wa, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet->tp_dict, __pyx_n_s_cancel_wait, __pyx_t_1) < 0) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet);
-
- /* "src/gevent/_hub_primitives.py":84
- * watcher.close()
- *
- * def _cancel_wait(self, watcher, error, close_watcher): # <<<<<<<<<<<<<<
- * # We have to check again to see if it was still active by the time
- * # our callback actually runs.
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_22WaitOperationsGreenlet_5_cancel_wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_WaitOperationsGreenlet__cancel_w, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet->tp_dict, __pyx_n_s_cancel_wait_2, __pyx_t_1) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_16__hub_primitives_WaitOperationsGreenlet);
-
- /* "src/gevent/_hub_primitives.py":151
- * raise
- *
- * next = __next__ # <<<<<<<<<<<<<<
- *
- * def _cleanup(self):
- */
- __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_16__hub_primitives__WaitIterator, __pyx_n_s_next); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16__hub_primitives__WaitIterator->tp_dict, __pyx_n_s_next_2, __pyx_t_1) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_16__hub_primitives__WaitIterator);
-
- /* "src/gevent/_hub_primitives.py":169
- *
- *
- * def iwait_on_objects(objects, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Iteratively yield *objects* as they are ready, until all (or *count*) are ready
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_1iwait_on_objects, 0, __pyx_n_s_iwait_on_objects, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_iwait_on_objects, __pyx_t_1) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":198
- *
- *
- * def wait_on_objects(objects=None, timeout=None, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for ``objects`` to become ready or for event loop to finish.
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_3wait_on_objects, 0, __pyx_n_s_wait_on_objects, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_on_objects, __pyx_t_1) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":237
- * return list(iwait_on_objects(objects, timeout, count))
- *
- * _timeout_error = Exception # <<<<<<<<<<<<<<
- *
- * def set_default_timeout_error(e):
- */
- __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
- __Pyx_XGOTREF(__pyx_v_6gevent_16__hub_primitives__timeout_error);
- __Pyx_DECREF_SET(__pyx_v_6gevent_16__hub_primitives__timeout_error, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
- __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
-
- /* "src/gevent/_hub_primitives.py":239
- * _timeout_error = Exception
- *
- * def set_default_timeout_error(e): # <<<<<<<<<<<<<<
- * global _timeout_error
- * _timeout_error = e
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_5set_default_timeout_error, 0, __pyx_n_s_set_default_timeout_error, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_default_timeout_error, __pyx_t_1) < 0) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":265
- *
- * # Suitable to be bound as an instance method
- * def wait_on_socket(socket, watcher, timeout_exc=None): # <<<<<<<<<<<<<<
- * _primitive_wait(watcher, socket.timeout,
- * timeout_exc if timeout_exc is not None else _NONE,
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_7wait_on_socket, 0, __pyx_n_s_wait_on_socket, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_on_socket, __pyx_t_1) < 0) __PYX_ERR(0, 265, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":270
- * socket.hub)
- *
- * def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None): # <<<<<<<<<<<<<<
- * """
- * wait(watcher, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__3 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__3 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_9wait_on_watcher, 0, __pyx_n_s_wait_on_watcher, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_on_watcher, __pyx_t_1) < 0) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":297
- *
- *
- * def wait_read(fileno, timeout=None, timeout_exc=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_read(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__4 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__4 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_11wait_read, 0, __pyx_n_s_wait_read, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_read, __pyx_t_1) < 0) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":316
- *
- *
- * def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_write(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__5 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__6 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__5 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__6 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_13wait_write, 0, __pyx_n_s_wait_write, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_write, __pyx_t_1) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":340
- *
- *
- * def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): # <<<<<<<<<<<<<<
- * """
- * wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__7 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__8 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__7 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_k__8 = __pyx_t_1;
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_15wait_readwrite, 0, __pyx_n_s_wait_readwrite, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_readwrite, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":365
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_16__hub_primitives_17_init, 0, __pyx_n_s_init, NULL, __pyx_n_s_gevent___hub_primitives, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_init, __pyx_t_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":368
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":370
- * _init()
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__hub_primitives')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_hub_primitives.py":371
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__hub_primitives') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___hub_primitives);
- __Pyx_GIVEREF(__pyx_n_s_gevent___hub_primitives);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___hub_primitives);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_hub_primitives.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # copyright (c) 2018 gevent. See LICENSE.
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,binding=True
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/__hub_primitives.pxd":34
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__hub_primitives", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__hub_primitives");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* RaiseArgTupleInvalid */
- static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_hub_primitives.py b/python/gevent/_hub_primitives.py
deleted file mode 100644
index d8ed031..0000000
--- a/python/gevent/_hub_primitives.py
+++ /dev/null
@@ -1,371 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright (c) 2018 gevent. See LICENSE.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,binding=True
-"""
-A collection of primitives used by the hub, and suitable for
-compilation with Cython because of their frequency of use.
-
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-import traceback
-
-from gevent.exceptions import InvalidSwitchError
-from gevent.exceptions import ConcurrentObjectUseError
-
-from gevent import _greenlet_primitives
-from gevent import _waiter
-from gevent._util import _NONE
-from gevent._hub_local import get_hub_noargs as get_hub
-from gevent.timeout import Timeout
-
-# In Cython, we define these as 'cdef inline' functions. The
-# compilation unit cannot have a direct assignment to them (import
-# is assignment) without generating a 'lvalue is not valid target'
-# error.
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-locals()['Waiter'] = _waiter.Waiter
-locals()['MultipleWaiter'] = _waiter.MultipleWaiter
-locals()['SwitchOutGreenletWithLoop'] = _greenlet_primitives.SwitchOutGreenletWithLoop
-
-__all__ = [
- 'WaitOperationsGreenlet',
- 'iwait_on_objects',
- 'wait_on_objects',
- 'wait_read',
- 'wait_write',
- 'wait_readwrite',
-]
-
-class WaitOperationsGreenlet(SwitchOutGreenletWithLoop): # pylint:disable=undefined-variable
-
- def wait(self, watcher):
- """
- Wait until the *watcher* (which must not be started) is ready.
-
- The current greenlet will be unscheduled during this time.
- """
- waiter = Waiter(self) # pylint:disable=undefined-variable
- watcher.start(waiter.switch, waiter)
- try:
- result = waiter.get()
- if result is not waiter:
- raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (
- getcurrent(), # pylint:disable=undefined-variable
- result, waiter))
- finally:
- watcher.stop()
-
- def cancel_wait(self, watcher, error, close_watcher=False):
- """
- Cancel an in-progress call to :meth:`wait` by throwing the given *error*
- in the waiting greenlet.
-
- .. versionchanged:: 1.3a1
- Added the *close_watcher* parameter. If true, the watcher
- will be closed after the exception is thrown. The watcher should then
- be discarded. Closing the watcher is important to release native resources.
- .. versionchanged:: 1.3a2
- Allow the *watcher* to be ``None``. No action is taken in that case.
- """
- if watcher is None:
- # Presumably already closed.
- # See https://github.com/gevent/gevent/issues/1089
- return
- if watcher.callback is not None:
- self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
- elif close_watcher:
- watcher.close()
-
- def _cancel_wait(self, watcher, error, close_watcher):
- # We have to check again to see if it was still active by the time
- # our callback actually runs.
- active = watcher.active
- cb = watcher.callback
- if close_watcher:
- watcher.close()
- if active:
- # The callback should be greenlet.switch(). It may or may not be None.
- glet = getattr(cb, '__self__', None)
- if glet is not None:
- glet.throw(error)
-
-
-class _WaitIterator(object):
-
- def __init__(self, objects, hub, timeout, count):
- self._hub = hub
- self._waiter = MultipleWaiter(hub) # pylint:disable=undefined-variable
- self._switch = self._waiter.switch
- self._timeout = timeout
- self._objects = objects
-
- self._timer = None
- self._begun = False
-
-
- # Even if we're only going to return 1 object,
- # we must still rawlink() *all* of them, so that no
- # matter which one finishes first we find it.
- self._count = len(objects) if count is None else min(count, len(objects))
-
-
- def __iter__(self):
- # When we begin iterating, we begin the timer.
- # XXX: If iteration doesn't actually happen, we
- # could leave these links around!
- if not self._begun:
- self._begun = True
-
- for obj in self._objects:
- obj.rawlink(self._switch)
-
- if self._timeout is not None:
- self._timer = self._hub.loop.timer(self._timeout, priority=-1)
- self._timer.start(self._switch, self)
- return self
-
- def __next__(self):
- if self._count == 0:
- # Exhausted
- self._cleanup()
- raise StopIteration()
-
- self._count -= 1
- try:
- item = self._waiter.get()
- self._waiter.clear()
- if item is self:
- # Timer expired, no more
- self._cleanup()
- raise StopIteration()
- return item
- except:
- self._cleanup()
- raise
-
- next = __next__
-
- def _cleanup(self):
- if self._timer is not None:
- self._timer.close()
- self._timer = None
-
- objs = self._objects
- self._objects = ()
- for aobj in objs:
- unlink = getattr(aobj, 'unlink', None)
- if unlink is not None:
- try:
- unlink(self._switch)
- except: # pylint:disable=bare-except
- traceback.print_exc()
-
-
-def iwait_on_objects(objects, timeout=None, count=None):
- """
- Iteratively yield *objects* as they are ready, until all (or *count*) are ready
- or *timeout* expired.
-
- :param objects: A sequence (supporting :func:`len`) containing objects
- implementing the wait protocol (rawlink() and unlink()).
- :keyword int count: If not `None`, then a number specifying the maximum number
- of objects to wait for. If ``None`` (the default), all objects
- are waited for.
- :keyword float timeout: If given, specifies a maximum number of seconds
- to wait. If the timeout expires before the desired waited-for objects
- are available, then this method returns immediately.
-
- .. seealso:: :func:`wait`
-
- .. versionchanged:: 1.1a1
- Add the *count* parameter.
- .. versionchanged:: 1.1a2
- No longer raise :exc:`LoopExit` if our caller switches greenlets
- in between items yielded by this function.
- """
- # QQQ would be nice to support iterable here that can be generated slowly (why?)
- hub = get_hub()
- if objects is None:
- return [hub.join(timeout=timeout)]
- return _WaitIterator(objects, hub, timeout, count)
-
-
-def wait_on_objects(objects=None, timeout=None, count=None):
- """
- Wait for ``objects`` to become ready or for event loop to finish.
-
- If ``objects`` is provided, it must be a list containing objects
- implementing the wait protocol (rawlink() and unlink() methods):
-
- - :class:`gevent.Greenlet` instance
- - :class:`gevent.event.Event` instance
- - :class:`gevent.lock.Semaphore` instance
- - :class:`gevent.subprocess.Popen` instance
-
- If ``objects`` is ``None`` (the default), ``wait()`` blocks until
- the current event loop has nothing to do (or until ``timeout`` passes):
-
- - all greenlets have finished
- - all servers were stopped
- - all event loop watchers were stopped.
-
- If ``count`` is ``None`` (the default), wait for all ``objects``
- to become ready.
-
- If ``count`` is a number, wait for (up to) ``count`` objects to become
- ready. (For example, if count is ``1`` then the function exits
- when any object in the list is ready).
-
- If ``timeout`` is provided, it specifies the maximum number of
- seconds ``wait()`` will block.
-
- Returns the list of ready objects, in the order in which they were
- ready.
-
- .. seealso:: :func:`iwait`
- """
- if objects is None:
- hub = get_hub()
- return hub.join(timeout=timeout) # pylint:disable=
- return list(iwait_on_objects(objects, timeout, count))
-
-_timeout_error = Exception
-
-def set_default_timeout_error(e):
- global _timeout_error
- _timeout_error = e
-
-def _primitive_wait(watcher, timeout, timeout_exc, hub):
- if watcher.callback is not None:
- raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r'
- % (watcher.callback, ))
-
- if hub is None:
- hub = get_hub()
-
- if timeout is None:
- hub.wait(watcher)
- return
-
- timeout = Timeout._start_new_or_dummy(
- timeout,
- (timeout_exc
- if timeout_exc is not _NONE or timeout is None
- else _timeout_error('timed out')))
-
- with timeout:
- hub.wait(watcher)
-
-# Suitable to be bound as an instance method
-def wait_on_socket(socket, watcher, timeout_exc=None):
- _primitive_wait(watcher, socket.timeout,
- timeout_exc if timeout_exc is not None else _NONE,
- socket.hub)
-
-def wait_on_watcher(watcher, timeout=None, timeout_exc=_NONE, hub=None):
- """
- wait(watcher, timeout=None, [timeout_exc=None]) -> None
-
- Block the current greenlet until *watcher* is ready.
-
- If *timeout* is non-negative, then *timeout_exc* is raised after
- *timeout* second has passed.
-
- If :func:`cancel_wait` is called on *io* by another greenlet,
- raise an exception in this blocking greenlet
- (``socket.error(EBADF, 'File descriptor was closed in another
- greenlet')`` by default).
-
- :param io: An event loop watcher, most commonly an IO watcher obtained from
- :meth:`gevent.core.loop.io`
- :keyword timeout_exc: The exception to raise if the timeout expires.
- By default, a :class:`socket.timeout` exception is raised.
- If you pass a value for this keyword, it is interpreted as for
- :class:`gevent.timeout.Timeout`.
-
- :raises ~gevent.hub.ConcurrentObjectUseError: If the *watcher* is
- already started.
- """
- _primitive_wait(watcher, timeout, timeout_exc, hub)
-
-
-def wait_read(fileno, timeout=None, timeout_exc=_NONE):
- """
- wait_read(fileno, timeout=None, [timeout_exc=None]) -> None
-
- Block the current greenlet until *fileno* is ready to read.
-
- For the meaning of the other parameters and possible exceptions,
- see :func:`wait`.
-
- .. seealso:: :func:`cancel_wait`
- """
- hub = get_hub()
- io = hub.loop.io(fileno, 1)
- try:
- return wait_on_watcher(io, timeout, timeout_exc, hub)
- finally:
- io.close()
-
-
-def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE):
- """
- wait_write(fileno, timeout=None, [timeout_exc=None]) -> None
-
- Block the current greenlet until *fileno* is ready to write.
-
- For the meaning of the other parameters and possible exceptions,
- see :func:`wait`.
-
- .. deprecated:: 1.1
- The keyword argument *event* is ignored. Applications should not pass this parameter.
- In the future, doing so will become an error.
-
- .. seealso:: :func:`cancel_wait`
- """
- # pylint:disable=unused-argument
- hub = get_hub()
- io = hub.loop.io(fileno, 2)
- try:
- return wait_on_watcher(io, timeout, timeout_exc, hub)
- finally:
- io.close()
-
-
-def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE):
- """
- wait_readwrite(fileno, timeout=None, [timeout_exc=None]) -> None
-
- Block the current greenlet until *fileno* is ready to read or
- write.
-
- For the meaning of the other parameters and possible exceptions,
- see :func:`wait`.
-
- .. deprecated:: 1.1
- The keyword argument *event* is ignored. Applications should not pass this parameter.
- In the future, doing so will become an error.
-
- .. seealso:: :func:`cancel_wait`
- """
- # pylint:disable=unused-argument
- hub = get_hub()
- io = hub.loop.io(fileno, 3)
- try:
- return wait_on_watcher(io, timeout, timeout_exc, hub)
- finally:
- io.close()
-
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__hub_primitives')
diff --git a/python/gevent/_ident.c b/python/gevent/_ident.c
deleted file mode 100644
index 57bcf82..0000000
--- a/python/gevent/_ident.c
+++ /dev/null
@@ -1,5407 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__ident.pxd",
- "src\\gevent\\__ident.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__ident",
- "sources": [
- "src/gevent/_ident.py"
- ]
- },
- "module_name": "gevent.__ident"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____ident
-#define __PYX_HAVE_API__gevent____ident
-/* Early includes */
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_ident.py",
- "src\\gevent\\__ident.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef;
-struct __pyx_obj_6gevent_7__ident_IdentRegistry;
-
-/* "gevent/__ident.pxd":15
- * @cython.internal
- * @cython.final
- * cdef class ValuedWeakRef(ref): # <<<<<<<<<<<<<<
- * cdef object value
- *
- */
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef {
- PyWeakReference __pyx_base;
- PyObject *value;
-};
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-struct __pyx_obj_6gevent_7__ident_IdentRegistry {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtab;
- PyObject *_registry;
- PyObject *_available_idents;
-};
-
-
-
-/* "src/gevent/_ident.py":30
- *
- *
- * class IdentRegistry(object): # <<<<<<<<<<<<<<
- * """
- * Maintains a unique mapping of (small) positive integer identifiers
- */
-
-struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry {
- PyObject *(*get_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_return_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtabptr_6gevent_7__ident_IdentRegistry;
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry_get_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry__return_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch);
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry_get_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry__return_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *__pyx_v_vref, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'weakref' */
-
-/* Module declarations from 'gevent.__ident' */
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ref = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ValuedWeakRef = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_IdentRegistry = 0;
-static PyObject *__pyx_v_6gevent_7__ident_heappop = 0;
-static PyObject *__pyx_v_6gevent_7__ident_heappush = 0;
-static PyObject *__pyx_v_6gevent_7__ident_WeakKeyDictionary = 0;
-#define __Pyx_MODULE_NAME "gevent.__ident"
-extern int __pyx_module_is_main_gevent____ident;
-int __pyx_module_is_main_gevent____ident = 0;
-
-/* Implementation of 'gevent.__ident' */
-static PyObject *__pyx_builtin_KeyError;
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_obj[] = "obj";
-static const char __pyx_k_ref[] = "ref";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_vref[] = "vref";
-static const char __pyx_k_heapq[] = "heapq";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_heappop[] = "heappop";
-static const char __pyx_k_weakref[] = "weakref";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_heappush[] = "heappush";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_get_ident[] = "get_ident";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_return_ident[] = "_return_ident";
-static const char __pyx_k_IdentRegistry[] = "IdentRegistry";
-static const char __pyx_k_gevent___ident[] = "gevent.__ident";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_WeakKeyDictionary[] = "WeakKeyDictionary";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_src_gevent__ident_py[] = "src\\gevent\\_ident.py";
-static const char __pyx_k_IdentRegistry_get_ident[] = "IdentRegistry.get_ident";
-static const char __pyx_k_IdentRegistry__return_ident[] = "IdentRegistry._return_ident";
-static PyObject *__pyx_n_s_IdentRegistry;
-static PyObject *__pyx_n_s_IdentRegistry__return_ident;
-static PyObject *__pyx_n_s_IdentRegistry_get_ident;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_WeakKeyDictionary;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_get_ident;
-static PyObject *__pyx_n_s_gevent___ident;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_heappop;
-static PyObject *__pyx_n_s_heappush;
-static PyObject *__pyx_n_s_heapq;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_obj;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_ref;
-static PyObject *__pyx_n_s_return_ident;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_kp_s_src_gevent__ident_py;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_vref;
-static PyObject *__pyx_n_s_weakref;
-static int __pyx_pf_6gevent_7__ident_13IdentRegistry___init__(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_7__ident_13IdentRegistry_2get_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj); /* proto */
-static PyObject *__pyx_pf_6gevent_7__ident_13IdentRegistry_4_return_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *__pyx_v_vref); /* proto */
-static Py_ssize_t __pyx_pf_6gevent_7__ident_13IdentRegistry_6__len__(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_7__ident_ValuedWeakRef(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_7__ident_IdentRegistry(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_codeobj__3;
-static PyObject *__pyx_codeobj__5;
-/* Late includes */
-
-/* "src/gevent/_ident.py":40
- * """
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # {obj -> (ident, wref(obj))}
- * self._registry = WeakKeyDictionary()
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_7__ident_13IdentRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_7__ident_13IdentRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_7__ident_13IdentRegistry___init__(((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_7__ident_13IdentRegistry___init__(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_ident.py":42
- * def __init__(self):
- * # {obj -> (ident, wref(obj))}
- * self._registry = WeakKeyDictionary() # <<<<<<<<<<<<<<
- *
- * # A heap of numbers that have been used and returned
- */
- __Pyx_INCREF(__pyx_v_6gevent_7__ident_WeakKeyDictionary);
- __pyx_t_2 = __pyx_v_6gevent_7__ident_WeakKeyDictionary; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_registry);
- __Pyx_DECREF(__pyx_v_self->_registry);
- __pyx_v_self->_registry = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":45
- *
- * # A heap of numbers that have been used and returned
- * self._available_idents = [] # <<<<<<<<<<<<<<
- *
- * def get_ident(self, obj):
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_available_idents);
- __Pyx_DECREF(__pyx_v_self->_available_idents);
- __pyx_v_self->_available_idents = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":40
- * """
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # {obj -> (ident, wref(obj))}
- * self._registry = WeakKeyDictionary()
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_ident.py":47
- * self._available_idents = []
- *
- * def get_ident(self, obj): # <<<<<<<<<<<<<<
- * """
- * Retrieve the identifier for *obj*, creating one
- */
-
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry_get_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_ident = NULL;
- struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *__pyx_v_vref = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- Py_ssize_t __pyx_t_10;
- __Pyx_RefNannySetupContext("get_ident", 0);
-
- /* "src/gevent/_ident.py":53
- * """
- *
- * try: # <<<<<<<<<<<<<<
- * return self._registry[obj][0]
- * except KeyError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/_ident.py":54
- *
- * try:
- * return self._registry[obj][0] # <<<<<<<<<<<<<<
- * except KeyError:
- * pass
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_self->_registry, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 54, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L7_try_return;
-
- /* "src/gevent/_ident.py":53
- * """
- *
- * try: # <<<<<<<<<<<<<<
- * return self._registry[obj][0]
- * except KeyError:
- */
- }
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_ident.py":55
- * try:
- * return self._registry[obj][0]
- * except KeyError: # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_6) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/_ident.py":53
- * """
- *
- * try: # <<<<<<<<<<<<<<
- * return self._registry[obj][0]
- * except KeyError:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L7_try_return:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L0;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- }
-
- /* "src/gevent/_ident.py":58
- * pass
- *
- * if self._available_idents: # <<<<<<<<<<<<<<
- * # Take the smallest free number
- * ident = heappop(self._available_idents)
- */
- __pyx_t_7 = (__pyx_v_self->_available_idents != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_available_idents) != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/_ident.py":60
- * if self._available_idents:
- * # Take the smallest free number
- * ident = heappop(self._available_idents) # <<<<<<<<<<<<<<
- * else:
- * # Allocate a bigger one
- */
- __Pyx_INCREF(__pyx_v_6gevent_7__ident_heappop);
- __pyx_t_4 = __pyx_v_6gevent_7__ident_heappop; __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->_available_idents); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->_available_idents};
- __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->_available_idents};
- __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_INCREF(__pyx_v_self->_available_idents);
- __Pyx_GIVEREF(__pyx_v_self->_available_idents);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_self->_available_idents);
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_ident = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "src/gevent/_ident.py":58
- * pass
- *
- * if self._available_idents: # <<<<<<<<<<<<<<
- * # Take the smallest free number
- * ident = heappop(self._available_idents)
- */
- goto __pyx_L9;
- }
-
- /* "src/gevent/_ident.py":63
- * else:
- * # Allocate a bigger one
- * ident = len(self._registry) # <<<<<<<<<<<<<<
- *
- * vref = ValuedWeakRef(obj, self._return_ident)
- */
- /*else*/ {
- __pyx_t_5 = __pyx_v_self->_registry;
- __Pyx_INCREF(__pyx_t_5);
- __pyx_t_10 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_v_ident = __pyx_t_5;
- __pyx_t_5 = 0;
- }
- __pyx_L9:;
-
- /* "src/gevent/_ident.py":65
- * ident = len(self._registry)
- *
- * vref = ValuedWeakRef(obj, self._return_ident) # <<<<<<<<<<<<<<
- * vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
- * self._registry[obj] = (ident, vref)
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_return_ident); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_obj);
- __Pyx_GIVEREF(__pyx_v_obj);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_7__ident_ValuedWeakRef), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_vref = ((struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/_ident.py":66
- *
- * vref = ValuedWeakRef(obj, self._return_ident)
- * vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init # <<<<<<<<<<<<<<
- * self._registry[obj] = (ident, vref)
- * return ident
- */
- __Pyx_INCREF(__pyx_v_ident);
- __Pyx_GIVEREF(__pyx_v_ident);
- __Pyx_GOTREF(__pyx_v_vref->value);
- __Pyx_DECREF(__pyx_v_vref->value);
- __pyx_v_vref->value = __pyx_v_ident;
-
- /* "src/gevent/_ident.py":67
- * vref = ValuedWeakRef(obj, self._return_ident)
- * vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
- * self._registry[obj] = (ident, vref) # <<<<<<<<<<<<<<
- * return ident
- *
- */
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 67, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_ident);
- __Pyx_GIVEREF(__pyx_v_ident);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_ident);
- __Pyx_INCREF(((PyObject *)__pyx_v_vref));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_vref));
- PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_vref));
- if (unlikely(PyObject_SetItem(__pyx_v_self->_registry, __pyx_v_obj, __pyx_t_5) < 0)) __PYX_ERR(0, 67, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_ident.py":68
- * vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
- * self._registry[obj] = (ident, vref)
- * return ident # <<<<<<<<<<<<<<
- *
- * def _return_ident(self, vref):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_ident);
- __pyx_r = __pyx_v_ident;
- goto __pyx_L0;
-
- /* "src/gevent/_ident.py":47
- * self._available_idents = []
- *
- * def get_ident(self, obj): # <<<<<<<<<<<<<<
- * """
- * Retrieve the identifier for *obj*, creating one
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry.get_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_ident);
- __Pyx_XDECREF((PyObject *)__pyx_v_vref);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
-static char __pyx_doc_6gevent_7__ident_13IdentRegistry_2get_ident[] = "IdentRegistry.get_ident(self, obj)\n\n Retrieve the identifier for *obj*, creating one\n if necessary.\n ";
-static PyMethodDef __pyx_mdef_6gevent_7__ident_13IdentRegistry_3get_ident = {"get_ident", (PyCFunction)__pyx_pw_6gevent_7__ident_13IdentRegistry_3get_ident, METH_O, __pyx_doc_6gevent_7__ident_13IdentRegistry_2get_ident};
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_ident (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_7__ident_13IdentRegistry_2get_ident(((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)__pyx_v_self), ((PyObject *)__pyx_v_obj));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_7__ident_13IdentRegistry_2get_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_ident", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_7__ident_13IdentRegistry_get_ident(__pyx_v_self, __pyx_v_obj, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry.get_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_ident.py":70
- * return ident
- *
- * def _return_ident(self, vref): # <<<<<<<<<<<<<<
- * # By the time this is called, self._registry has been
- * # updated
- */
-
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref); /*proto*/
-static PyObject *__pyx_f_6gevent_7__ident_13IdentRegistry__return_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *__pyx_v_vref, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("_return_ident", 0);
-
- /* "src/gevent/_ident.py":73
- * # By the time this is called, self._registry has been
- * # updated
- * if heappush is not None: # <<<<<<<<<<<<<<
- * # Under some circumstances we can get called
- * # when the interpreter is shutting down, and globals
- */
- __pyx_t_1 = (__pyx_v_6gevent_7__ident_heappush != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_ident.py":77
- * # when the interpreter is shutting down, and globals
- * # aren't available any more.
- * heappush(self._available_idents, vref.value) # <<<<<<<<<<<<<<
- *
- * def __len__(self):
- */
- __Pyx_INCREF(__pyx_v_6gevent_7__ident_heappush);
- __pyx_t_4 = __pyx_v_6gevent_7__ident_heappush; __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->_available_idents, __pyx_v_vref->value};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->_available_idents, __pyx_v_vref->value};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(__pyx_v_self->_available_idents);
- __Pyx_GIVEREF(__pyx_v_self->_available_idents);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_self->_available_idents);
- __Pyx_INCREF(__pyx_v_vref->value);
- __Pyx_GIVEREF(__pyx_v_vref->value);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_vref->value);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_ident.py":73
- * # By the time this is called, self._registry has been
- * # updated
- * if heappush is not None: # <<<<<<<<<<<<<<
- * # Under some circumstances we can get called
- * # when the interpreter is shutting down, and globals
- */
- }
-
- /* "src/gevent/_ident.py":70
- * return ident
- *
- * def _return_ident(self, vref): # <<<<<<<<<<<<<<
- * # By the time this is called, self._registry has been
- * # updated
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry._return_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref); /*proto*/
-static char __pyx_doc_6gevent_7__ident_13IdentRegistry_4_return_ident[] = "IdentRegistry._return_ident(self, ValuedWeakRef vref)";
-static PyMethodDef __pyx_mdef_6gevent_7__ident_13IdentRegistry_5_return_ident = {"_return_ident", (PyCFunction)__pyx_pw_6gevent_7__ident_13IdentRegistry_5_return_ident, METH_O, __pyx_doc_6gevent_7__ident_13IdentRegistry_4_return_ident};
-static PyObject *__pyx_pw_6gevent_7__ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_return_ident (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vref), __pyx_ptype_6gevent_7__ident_ValuedWeakRef, 1, "vref", 0))) __PYX_ERR(0, 70, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_7__ident_13IdentRegistry_4_return_ident(((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)__pyx_v_self), ((struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)__pyx_v_vref));
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_7__ident_13IdentRegistry_4_return_ident(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *__pyx_v_vref) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_return_ident", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_7__ident_13IdentRegistry__return_ident(__pyx_v_self, __pyx_v_vref, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry._return_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_ident.py":79
- * heappush(self._available_idents, vref.value)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * return len(self._registry)
- *
- */
-
-/* Python wrapper */
-static Py_ssize_t __pyx_pw_6gevent_7__ident_13IdentRegistry_7__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pw_6gevent_7__ident_13IdentRegistry_7__len__(PyObject *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_7__ident_13IdentRegistry_6__len__(((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_ssize_t __pyx_pf_6gevent_7__ident_13IdentRegistry_6__len__(struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- __Pyx_RefNannySetupContext("__len__", 0);
-
- /* "src/gevent/_ident.py":80
- *
- * def __len__(self):
- * return len(self._registry) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __pyx_v_self->_registry;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- goto __pyx_L0;
-
- /* "src/gevent/_ident.py":79
- * heappush(self._available_idents, vref.value)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * return len(self._registry)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__ident.IdentRegistry.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_tp_new_6gevent_7__ident_ValuedWeakRef(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *p;
- PyObject *o = __pyx_ptype_6gevent_7__ident_ref->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)o);
- p->value = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_7__ident_ValuedWeakRef(PyObject *o) {
- struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *p = (struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->value);
- #if CYTHON_USE_TYPE_SLOTS
- if (PyType_IS_GC(Py_TYPE(o)->tp_base))
- #endif
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_7__ident_ref)) __pyx_ptype_6gevent_7__ident_ref->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_7__ident_ValuedWeakRef);
-}
-
-static int __pyx_tp_traverse_6gevent_7__ident_ValuedWeakRef(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *p = (struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)o;
- e = ((likely(__pyx_ptype_6gevent_7__ident_ref)) ? ((__pyx_ptype_6gevent_7__ident_ref->tp_traverse) ? __pyx_ptype_6gevent_7__ident_ref->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_7__ident_ValuedWeakRef)); if (e) return e;
- if (p->value) {
- e = (*v)(p->value, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_7__ident_ValuedWeakRef(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *p = (struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *)o;
- if (likely(__pyx_ptype_6gevent_7__ident_ref)) { if (__pyx_ptype_6gevent_7__ident_ref->tp_clear) __pyx_ptype_6gevent_7__ident_ref->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_7__ident_ValuedWeakRef);
- tmp = ((PyObject*)p->value);
- p->value = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyTypeObject __pyx_type_6gevent_7__ident_ValuedWeakRef = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__ident.ValuedWeakRef", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_7__ident_ValuedWeakRef), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_7__ident_ValuedWeakRef, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "\n A weak ref with an associated value.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_7__ident_ValuedWeakRef, /*tp_traverse*/
- __pyx_tp_clear_6gevent_7__ident_ValuedWeakRef, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_7__ident_ValuedWeakRef, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry __pyx_vtable_6gevent_7__ident_IdentRegistry;
-
-static PyObject *__pyx_tp_new_6gevent_7__ident_IdentRegistry(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_7__ident_IdentRegistry *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_7__ident_IdentRegistry;
- p->_registry = Py_None; Py_INCREF(Py_None);
- p->_available_idents = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_7__ident_IdentRegistry(PyObject *o) {
- struct __pyx_obj_6gevent_7__ident_IdentRegistry *p = (struct __pyx_obj_6gevent_7__ident_IdentRegistry *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_registry);
- Py_CLEAR(p->_available_idents);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_7__ident_IdentRegistry(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_7__ident_IdentRegistry *p = (struct __pyx_obj_6gevent_7__ident_IdentRegistry *)o;
- if (p->_registry) {
- e = (*v)(p->_registry, a); if (e) return e;
- }
- if (p->_available_idents) {
- e = (*v)(p->_available_idents, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_7__ident_IdentRegistry(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_7__ident_IdentRegistry *p = (struct __pyx_obj_6gevent_7__ident_IdentRegistry *)o;
- tmp = ((PyObject*)p->_registry);
- p->_registry = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_available_idents);
- p->_available_idents = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_7__ident_IdentRegistry[] = {
- {0, 0, 0, 0}
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_IdentRegistry = {
- __pyx_pw_6gevent_7__ident_13IdentRegistry_7__len__, /*sq_length*/
- 0, /*sq_concat*/
- 0, /*sq_repeat*/
- 0, /*sq_item*/
- 0, /*sq_slice*/
- 0, /*sq_ass_item*/
- 0, /*sq_ass_slice*/
- 0, /*sq_contains*/
- 0, /*sq_inplace_concat*/
- 0, /*sq_inplace_repeat*/
-};
-
-static PyMappingMethods __pyx_tp_as_mapping_IdentRegistry = {
- __pyx_pw_6gevent_7__ident_13IdentRegistry_7__len__, /*mp_length*/
- 0, /*mp_subscript*/
- 0, /*mp_ass_subscript*/
-};
-
-static PyTypeObject __pyx_type_6gevent_7__ident_IdentRegistry = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__ident.IdentRegistry", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_7__ident_IdentRegistry), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_7__ident_IdentRegistry, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- &__pyx_tp_as_sequence_IdentRegistry, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_IdentRegistry, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "IdentRegistry()\n\n Maintains a unique mapping of (small) positive integer identifiers\n to objects that can be weakly referenced.\n\n It is guaranteed that no two objects will have the the same\n identifier at the same time, as long as those objects are\n also uniquely hashable.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_7__ident_IdentRegistry, /*tp_traverse*/
- __pyx_tp_clear_6gevent_7__ident_IdentRegistry, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_7__ident_IdentRegistry, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_7__ident_13IdentRegistry_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_7__ident_IdentRegistry, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___ident(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___ident},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__ident",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_IdentRegistry, __pyx_k_IdentRegistry, sizeof(__pyx_k_IdentRegistry), 0, 0, 1, 1},
- {&__pyx_n_s_IdentRegistry__return_ident, __pyx_k_IdentRegistry__return_ident, sizeof(__pyx_k_IdentRegistry__return_ident), 0, 0, 1, 1},
- {&__pyx_n_s_IdentRegistry_get_ident, __pyx_k_IdentRegistry_get_ident, sizeof(__pyx_k_IdentRegistry_get_ident), 0, 0, 1, 1},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_WeakKeyDictionary, __pyx_k_WeakKeyDictionary, sizeof(__pyx_k_WeakKeyDictionary), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_get_ident, __pyx_k_get_ident, sizeof(__pyx_k_get_ident), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___ident, __pyx_k_gevent___ident, sizeof(__pyx_k_gevent___ident), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_heappop, __pyx_k_heappop, sizeof(__pyx_k_heappop), 0, 0, 1, 1},
- {&__pyx_n_s_heappush, __pyx_k_heappush, sizeof(__pyx_k_heappush), 0, 0, 1, 1},
- {&__pyx_n_s_heapq, __pyx_k_heapq, sizeof(__pyx_k_heapq), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
- {&__pyx_n_s_return_ident, __pyx_k_return_ident, sizeof(__pyx_k_return_ident), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__ident_py, __pyx_k_src_gevent__ident_py, sizeof(__pyx_k_src_gevent__ident_py), 0, 0, 1, 0},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_vref, __pyx_k_vref, sizeof(__pyx_k_vref), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 55, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_ident.py":27
- * # weakref.ref descends from object
- * # pylint: disable=slots-on-old-class
- * __slots__ = ('value',) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_value); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_ident.py":47
- * self._available_idents = []
- *
- * def get_ident(self, obj): # <<<<<<<<<<<<<<
- * """
- * Retrieve the identifier for *obj*, creating one
- */
- __pyx_tuple__2 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
- __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__ident_py, __pyx_n_s_get_ident, 47, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 47, __pyx_L1_error)
-
- /* "src/gevent/_ident.py":70
- * return ident
- *
- * def _return_ident(self, vref): # <<<<<<<<<<<<<<
- * # By the time this is called, self._registry has been
- * # updated
- */
- __pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_vref); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
- __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__ident_py, __pyx_n_s_return_ident, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_7__ident_heappop = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_7__ident_heappush = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_7__ident_WeakKeyDictionary = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_heappop, (void *)&__pyx_v_6gevent_7__ident_heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_heappush, (void *)&__pyx_v_6gevent_7__ident_heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_WeakKeyDictionary, (void *)&__pyx_v_6gevent_7__ident_WeakKeyDictionary, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_7__ident_ref = __Pyx_ImportType("weakref", "ref", sizeof(PyWeakReference), 0); if (unlikely(!__pyx_ptype_6gevent_7__ident_ref)) __PYX_ERR(1, 5, __pyx_L1_error)
- __pyx_type_6gevent_7__ident_ValuedWeakRef.tp_base = __pyx_ptype_6gevent_7__ident_ref;
- if (PyType_Ready(&__pyx_type_6gevent_7__ident_ValuedWeakRef) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
- __pyx_type_6gevent_7__ident_ValuedWeakRef.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_7__ident_ValuedWeakRef.tp_dictoffset && __pyx_type_6gevent_7__ident_ValuedWeakRef.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_7__ident_ValuedWeakRef.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "ValuedWeakRef", (PyObject *)&__pyx_type_6gevent_7__ident_ValuedWeakRef) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_ValuedWeakRef = &__pyx_type_6gevent_7__ident_ValuedWeakRef;
- __pyx_vtabptr_6gevent_7__ident_IdentRegistry = &__pyx_vtable_6gevent_7__ident_IdentRegistry;
- __pyx_vtable_6gevent_7__ident_IdentRegistry.get_ident = (PyObject *(*)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_7__ident_13IdentRegistry_get_ident;
- __pyx_vtable_6gevent_7__ident_IdentRegistry._return_ident = (PyObject *(*)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch))__pyx_f_6gevent_7__ident_13IdentRegistry__return_ident;
- if (PyType_Ready(&__pyx_type_6gevent_7__ident_IdentRegistry) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
- __pyx_type_6gevent_7__ident_IdentRegistry.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_7__ident_IdentRegistry.tp_dictoffset && __pyx_type_6gevent_7__ident_IdentRegistry.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_7__ident_IdentRegistry.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_7__ident_IdentRegistry.tp_dict, __pyx_vtabptr_6gevent_7__ident_IdentRegistry) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "IdentRegistry", (PyObject *)&__pyx_type_6gevent_7__ident_IdentRegistry) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_IdentRegistry = &__pyx_type_6gevent_7__ident_IdentRegistry;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__ident(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__ident(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___ident(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___ident(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___ident(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___ident(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__ident", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____ident) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__ident")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__ident", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_type_import_code();
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_ident.py":10
- *
- *
- * from weakref import WeakKeyDictionary # <<<<<<<<<<<<<<
- * from weakref import ref
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_WeakKeyDictionary);
- __Pyx_GIVEREF(__pyx_n_s_WeakKeyDictionary);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WeakKeyDictionary);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WeakKeyDictionary); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_7__ident_WeakKeyDictionary);
- __Pyx_DECREF_SET(__pyx_v_6gevent_7__ident_WeakKeyDictionary, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_ident.py":11
- *
- * from weakref import WeakKeyDictionary
- * from weakref import ref # <<<<<<<<<<<<<<
- *
- * from heapq import heappop
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ref);
- __Pyx_GIVEREF(__pyx_n_s_ref);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ref);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":13
- * from weakref import ref
- *
- * from heapq import heappop # <<<<<<<<<<<<<<
- * from heapq import heappush
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_heappop);
- __Pyx_GIVEREF(__pyx_n_s_heappop);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_heappop);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heappop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_7__ident_heappop);
- __Pyx_DECREF_SET(__pyx_v_6gevent_7__ident_heappop, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_ident.py":14
- *
- * from heapq import heappop
- * from heapq import heappush # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_heappush);
- __Pyx_GIVEREF(__pyx_n_s_heappush);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_heappush);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_heappush); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_7__ident_heappush);
- __Pyx_DECREF_SET(__pyx_v_6gevent_7__ident_heappush, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":16
- * from heapq import heappush
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'IdentRegistry',
- * ]
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_IdentRegistry);
- __Pyx_GIVEREF(__pyx_n_s_IdentRegistry);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_IdentRegistry);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":27
- * # weakref.ref descends from object
- * # pylint: disable=slots-on-old-class
- * __slots__ = ('value',) # <<<<<<<<<<<<<<
- *
- *
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_7__ident_ValuedWeakRef->tp_dict, __pyx_n_s_slots, __pyx_tuple_) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_7__ident_ValuedWeakRef);
-
- /* "src/gevent/_ident.py":47
- * self._available_idents = []
- *
- * def get_ident(self, obj): # <<<<<<<<<<<<<<
- * """
- * Retrieve the identifier for *obj*, creating one
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_7__ident_13IdentRegistry_3get_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IdentRegistry_get_ident, NULL, __pyx_n_s_gevent___ident, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_7__ident_IdentRegistry->tp_dict, __pyx_n_s_get_ident, __pyx_t_1) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_7__ident_IdentRegistry);
-
- /* "src/gevent/_ident.py":70
- * return ident
- *
- * def _return_ident(self, vref): # <<<<<<<<<<<<<<
- * # By the time this is called, self._registry has been
- * # updated
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_7__ident_13IdentRegistry_5_return_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IdentRegistry__return_ident, NULL, __pyx_n_s_gevent___ident, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_7__ident_IdentRegistry->tp_dict, __pyx_n_s_return_ident, __pyx_t_1) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_7__ident_IdentRegistry);
-
- /* "src/gevent/_ident.py":83
- *
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__ident')
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_import_c_accel);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_1) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_ident.py":84
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__ident') # <<<<<<<<<<<<<<
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_gevent___ident);
- __Pyx_GIVEREF(__pyx_n_s_gevent___ident);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___ident);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_ident.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # Copyright 2018 gevent contributors. See LICENSE for details.
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__ident", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__ident");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* KeywordStringCheck */
-static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* ObjectGetItem */
- #if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_ident.py b/python/gevent/_ident.py
deleted file mode 100644
index 56a28df..0000000
--- a/python/gevent/_ident.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2018 gevent contributors. See LICENSE for details.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-from weakref import WeakKeyDictionary
-from weakref import ref
-
-from heapq import heappop
-from heapq import heappush
-
-__all__ = [
- 'IdentRegistry',
-]
-
-class ValuedWeakRef(ref):
- """
- A weak ref with an associated value.
- """
- # This seems entirely spurious; even on Python 2.7
- # weakref.ref descends from object
- # pylint: disable=slots-on-old-class
- __slots__ = ('value',)
-
-
-class IdentRegistry(object):
- """
- Maintains a unique mapping of (small) positive integer identifiers
- to objects that can be weakly referenced.
-
- It is guaranteed that no two objects will have the the same
- identifier at the same time, as long as those objects are
- also uniquely hashable.
- """
-
- def __init__(self):
- # {obj -> (ident, wref(obj))}
- self._registry = WeakKeyDictionary()
-
- # A heap of numbers that have been used and returned
- self._available_idents = []
-
- def get_ident(self, obj):
- """
- Retrieve the identifier for *obj*, creating one
- if necessary.
- """
-
- try:
- return self._registry[obj][0]
- except KeyError:
- pass
-
- if self._available_idents:
- # Take the smallest free number
- ident = heappop(self._available_idents)
- else:
- # Allocate a bigger one
- ident = len(self._registry)
-
- vref = ValuedWeakRef(obj, self._return_ident)
- vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
- self._registry[obj] = (ident, vref)
- return ident
-
- def _return_ident(self, vref):
- # By the time this is called, self._registry has been
- # updated
- if heappush is not None:
- # Under some circumstances we can get called
- # when the interpreter is shutting down, and globals
- # aren't available any more.
- heappush(self._available_idents, vref.value)
-
- def __len__(self):
- return len(self._registry)
-
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__ident')
diff --git a/python/gevent/_imap.c b/python/gevent/_imap.c
deleted file mode 100644
index b3639d1..0000000
--- a/python/gevent/_imap.c
+++ /dev/null
@@ -1,10490 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__imap.pxd",
- "src\\gevent\\__imap.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__imap",
- "sources": [
- "src/gevent/_imap.py"
- ]
- },
- "module_name": "gevent.__imap"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____imap
-#define __PYX_HAVE_API__gevent____imap
-/* Early includes */
-#include "greenlet/greenlet.h"
-#include "frameobject.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_imap.py",
- "src\\gevent\\__imap.pxd",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
- "src\\gevent\\_greenlet.pxd",
- "src\\gevent\\__semaphore.pxd",
- "src\\gevent\\_event.pxd",
- "src\\gevent\\__ident.pxd",
- "src\\gevent\\_queue.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef;
-struct __pyx_obj_6gevent_7__ident_IdentRegistry;
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet__Frame;
-struct __pyx_obj_6gevent_9_greenlet_Greenlet;
-struct __pyx_obj_6gevent_9_greenlet__dummy_event;
-struct __pyx_obj_6gevent_11__semaphore_Semaphore;
-struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore;
-struct __pyx_obj_6gevent_6_event__AbstractLinkable;
-struct __pyx_obj_6gevent_6_event_Event;
-struct __pyx_obj_6gevent_6_event_AsyncResult;
-struct __pyx_obj_6gevent_6_queue_ItemWaiter;
-struct __pyx_obj_6gevent_6_queue_Queue;
-struct __pyx_obj_6gevent_6_queue_UnboundQueue;
-struct __pyx_obj_6gevent_6_queue_PriorityQueue;
-struct __pyx_obj_6gevent_6_queue_LifoQueue;
-struct __pyx_obj_6gevent_6_queue_JoinableQueue;
-struct __pyx_obj_6gevent_6_queue_Channel;
-struct __pyx_obj_6gevent_6__imap_Failure;
-struct __pyx_obj_6gevent_6__imap_IMapUnordered;
-struct __pyx_obj_6gevent_6__imap_IMap;
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join;
-struct __pyx_opt_args_6gevent_9_greenlet_joinall;
-
-/* "gevent/_greenlet.pxd":105
- *
- * cpdef bint has_links(self)
- * cpdef join(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint ready(self)
- * cpdef bint successful(self)
- */
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_greenlet.pxd":174
- *
- * @cython.locals(done=list)
- * cpdef joinall(greenlets, timeout=*, raise_error=*, count=*) # <<<<<<<<<<<<<<
- */
-struct __pyx_opt_args_6gevent_9_greenlet_joinall {
- int __pyx_n;
- PyObject *timeout;
- PyObject *raise_error;
- PyObject *count;
-};
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait;
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire;
-
-/* "gevent/__semaphore.pxd":46
- * cpdef _notify_links(self)
- * cdef _do_wait(self, object timeout)
- * cpdef int wait(self, object timeout=*) except -1000 # <<<<<<<<<<<<<<
- * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000
- * cpdef __enter__(self)
- */
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/__semaphore.pxd":47
- * cdef _do_wait(self, object timeout)
- * cpdef int wait(self, object timeout=*) except -1000
- * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 # <<<<<<<<<<<<<<
- * cpdef __enter__(self)
- * cpdef __exit__(self, object t, object v, object tb)
- */
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire {
- int __pyx_n;
- int blocking;
- PyObject *timeout;
-};
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core;
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait;
-
-/* "gevent/_event.pxd":55
- * @cython.locals(todo=set)
- * cpdef _notify_links(self)
- * cdef _wait_core(self, timeout, catch=*) # <<<<<<<<<<<<<<
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*)
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core {
- int __pyx_n;
- PyObject *catch;
-};
-
-/* "gevent/_event.pxd":57
- * cdef _wait_core(self, timeout, catch=*)
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*) # <<<<<<<<<<<<<<
- *
- *
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":70
- * cdef public int _imap_task_index
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint successful(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":73
- * cpdef bint successful(self)
- *
- * cpdef wait(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint done(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait {
- int __pyx_n;
- PyObject *timeout;
-};
-struct __pyx_opt_args_6gevent_6_queue_5Queue_put;
-struct __pyx_opt_args_6gevent_6_queue_5Queue_get;
-struct __pyx_opt_args_6gevent_6_queue_5Queue_peek;
-struct __pyx_opt_args_6gevent_6_queue_7Channel_get;
-
-/* "gevent/_queue.pxd":37
- * cpdef bint full(self)
- *
- * cpdef put(self, item, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef put_nowait(self, item)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_put {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":42
- * cdef __get_or_peek(self, method, block, timeout)
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef get_nowait(self)
- * cpdef peek(self, block=*, timeout=*)
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":44
- * cpdef get(self, block=*, timeout=*)
- * cpdef get_nowait(self)
- * cpdef peek(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef peek_nowait(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_peek {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":71
- * cdef _event_unlock
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef get_nowait(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_7Channel_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/__ident.pxd":15
- * @cython.internal
- * @cython.final
- * cdef class ValuedWeakRef(ref): # <<<<<<<<<<<<<<
- * cdef object value
- *
- */
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef {
- PyWeakReference __pyx_base;
- PyObject *value;
-};
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-struct __pyx_obj_6gevent_7__ident_IdentRegistry {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtab;
- PyObject *_registry;
- PyObject *_available_idents;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-/* "gevent/_greenlet.pxd":56
- * cdef void _init()
- *
- * cdef class SpawnedLink: # <<<<<<<<<<<<<<
- * cdef public object callback
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink {
- PyObject_HEAD
- PyObject *callback;
-};
-
-
-/* "gevent/_greenlet.pxd":61
- *
- * @cython.final
- * cdef class SuccessSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":65
- *
- * @cython.final
- * cdef class FailureSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":71
- * @cython.internal
- * @cython.freelist(1000)
- * cdef class _Frame: # <<<<<<<<<<<<<<
- * cdef readonly CodeType f_code
- * cdef readonly int f_lineno
- */
-struct __pyx_obj_6gevent_9_greenlet__Frame {
- PyObject_HEAD
- PyCodeObject *f_code;
- int f_lineno;
- struct __pyx_obj_6gevent_9_greenlet__Frame *f_back;
-};
-
-
-/* "gevent/_greenlet.pxd":86
- *
- *
- * cdef class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * cdef readonly object value
- * cdef readonly tuple args
- */
-struct __pyx_obj_6gevent_9_greenlet_Greenlet {
- PyGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtab;
- PyObject *value;
- PyObject *args;
- PyObject *kwargs;
- PyObject *spawning_greenlet;
- PyObject *spawn_tree_locals;
- PyObject *_spawning_stack_frames;
- PyObject *_links;
- PyObject *_exc_info;
- PyObject *_notifier;
- PyObject *_start_event;
- PyObject *_formatted_info;
- PyObject *_ident;
-};
-
-
-/* "gevent/_greenlet.pxd":157
- * @cython.final
- * @cython.internal
- * cdef class _dummy_event: # <<<<<<<<<<<<<<
- * cdef readonly bint pending
- * cdef readonly bint active
- */
-struct __pyx_obj_6gevent_9_greenlet__dummy_event {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtab;
- int pending;
- int active;
-};
-
-
-/* "gevent/__semaphore.pxd":32
- *
- *
- * cdef class Semaphore: # <<<<<<<<<<<<<<
- * cdef public int counter
- * cdef readonly list _links
- */
-struct __pyx_obj_6gevent_11__semaphore_Semaphore {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *__pyx_vtab;
- int counter;
- PyObject *_links;
- PyObject *_notifier;
- int _dirty;
- PyObject *__weakref__;
-};
-
-
-/* "gevent/__semaphore.pxd":51
- * cpdef __exit__(self, object t, object v, object tb)
- *
- * cdef class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<<
- * cdef readonly int _initial_value
- *
- */
-struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore {
- struct __pyx_obj_6gevent_11__semaphore_Semaphore __pyx_base;
- int _initial_value;
-};
-
-
-/* "gevent/_event.pxd":38
- * cdef void _init()
- *
- * cdef class _AbstractLinkable: # <<<<<<<<<<<<<<
- * # We declare the __weakref__ here in the base (even though
- * # that's not really what we want) as a workaround for a Cython
- */
-struct __pyx_obj_6gevent_6_event__AbstractLinkable {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *_notifier;
- PyObject *_links;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
-};
-
-
-/* "gevent/_event.pxd":60
- *
- *
- * cdef class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef bint _flag
- *
- */
-struct __pyx_obj_6gevent_6_event_Event {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- int _flag;
-};
-
-
-/* "gevent/_event.pxd":63
- * cdef bint _flag
- *
- * cdef class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef readonly _value
- * cdef readonly tuple _exc_info
- */
-struct __pyx_obj_6gevent_6_event_AsyncResult {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *_value;
- PyObject *_exc_info;
- int _imap_task_index;
-};
-
-
-/* "gevent/_queue.pxd":14
- * @cython.final
- * @cython.internal
- * cdef class ItemWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef readonly item
- * cdef readonly queue
- */
-struct __pyx_obj_6gevent_6_queue_ItemWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *item;
- PyObject *queue;
-};
-
-
-/* "gevent/_queue.pxd":18
- * cdef readonly queue
- *
- * cdef class Queue: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly hub
- */
-struct __pyx_obj_6gevent_6_queue_Queue {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_queue_Queue *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *hub;
- PyObject *queue;
- PyObject *getters;
- PyObject *putters;
- PyObject *_event_unlock;
- Py_ssize_t _maxsize;
-};
-
-
-/* "gevent/_queue.pxd":50
- *
- * @cython.final
- * cdef class UnboundQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_UnboundQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":53
- * pass
- *
- * cdef class PriorityQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_PriorityQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":56
- * pass
- *
- * cdef class LifoQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_LifoQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":59
- * pass
- *
- * cdef class JoinableQueue(Queue): # <<<<<<<<<<<<<<
- * cdef Event _cond
- * cdef readonly int unfinished_tasks
- */
-struct __pyx_obj_6gevent_6_queue_JoinableQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
- struct __pyx_obj_6gevent_6_event_Event *_cond;
- int unfinished_tasks;
-};
-
-
-/* "gevent/_queue.pxd":64
- *
- *
- * cdef class Channel: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly getters
- */
-struct __pyx_obj_6gevent_6_queue_Channel {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_queue_Channel *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *getters;
- PyObject *putters;
- PyObject *hub;
- PyObject *_event_unlock;
-};
-
-
-/* "gevent/__imap.pxd":9
- * @cython.internal
- * @cython.final
- * cdef class Failure: # <<<<<<<<<<<<<<
- * cdef readonly exc
- * cdef raise_exception
- */
-struct __pyx_obj_6gevent_6__imap_Failure {
- PyObject_HEAD
- PyObject *exc;
- PyObject *raise_exception;
-};
-
-
-/* "gevent/__imap.pxd":15
- * cdef inline _raise_exc(Failure failure)
- *
- * cdef class IMapUnordered(Greenlet): # <<<<<<<<<<<<<<
- * cdef bint _zipped
- * cdef func
- */
-struct __pyx_obj_6gevent_6__imap_IMapUnordered {
- struct __pyx_obj_6gevent_9_greenlet_Greenlet __pyx_base;
- int _zipped;
- PyObject *func;
- PyObject *iterable;
- PyObject *spawn;
- struct __pyx_obj_6gevent_11__semaphore_Semaphore *_result_semaphore;
- int _outstanding_tasks;
- int _max_index;
- struct __pyx_obj_6gevent_6_queue_UnboundQueue *queue;
- int finished;
-};
-
-
-/* "gevent/__imap.pxd":40
- * cdef _iqueue_value_for_self_failure(self, exception)
- *
- * cdef class IMap(IMapUnordered): # <<<<<<<<<<<<<<
- * cdef int index
- * cdef dict _results
- */
-struct __pyx_obj_6gevent_6__imap_IMap {
- struct __pyx_obj_6gevent_6__imap_IMapUnordered __pyx_base;
- int index;
- PyObject *_results;
-};
-
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-
-struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry {
- PyObject *(*get_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_return_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtabptr_6gevent_7__ident_IdentRegistry;
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-
-/* "gevent/_greenlet.pxd":86
- *
- *
- * cdef class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * cdef readonly object value
- * cdef readonly tuple args
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet {
- int (*has_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*join)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args);
- int (*ready)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- int (*successful)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_formatinfo)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*_get_minimal_ident)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___started_but_aborted)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_cancelled_by_kill)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_pending)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___never_started_or_killed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_completed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*__pyx___handle_death_before_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*__pyx___cancel_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*_report_result)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_report_error)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtabptr_6gevent_9_greenlet_Greenlet;
-
-
-/* "gevent/_greenlet.pxd":157
- * @cython.final
- * @cython.internal
- * cdef class _dummy_event: # <<<<<<<<<<<<<<
- * cdef readonly bint pending
- * cdef readonly bint active
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event {
- PyObject *(*stop)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
- PyObject *(*start)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*close)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtabptr_6gevent_9_greenlet__dummy_event;
-
-
-/* "gevent/__semaphore.pxd":32
- *
- *
- * cdef class Semaphore: # <<<<<<<<<<<<<<
- * cdef public int counter
- * cdef readonly list _links
- */
-
-struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore {
- int (*locked)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- int (*release)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*unlink)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_start_notify)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*_do_wait)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *);
- int (*wait)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args);
- int (*acquire)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args);
- PyObject *(*__pyx___enter__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*__pyx___exit__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *__pyx_vtabptr_6gevent_11__semaphore_Semaphore;
-
-
-/* "gevent/__semaphore.pxd":51
- * cpdef __exit__(self, object t, object v, object tb)
- *
- * cdef class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<<
- * cdef readonly int _initial_value
- *
- */
-
-struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore {
- struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore *__pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore;
-
-
-/* "gevent/_event.pxd":38
- * cdef void _init()
- *
- * cdef class _AbstractLinkable: # <<<<<<<<<<<<<<
- * # We declare the __weakref__ here in the base (even though
- * # that's not really what we want) as a workaround for a Cython
- */
-
-struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable {
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- int (*ready)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*unlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_check_and_notify)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*_wait_core)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args);
- PyObject *(*_wait_return_value)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *);
- PyObject *(*_wait)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args);
-};
-static struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtabptr_6gevent_6_event__AbstractLinkable;
-
-
-/* "gevent/_event.pxd":60
- *
- *
- * cdef class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef bint _flag
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_Event {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_event_Event *__pyx_vtabptr_6gevent_6_event_Event;
-
-
-/* "gevent/_event.pxd":63
- * cdef bint _flag
- *
- * cdef class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef readonly _value
- * cdef readonly tuple _exc_info
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_AsyncResult {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *(*get)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args);
- int (*successful)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- PyObject *(*wait)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args);
- int (*done)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancel)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancelled)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *__pyx_vtabptr_6gevent_6_event_AsyncResult;
-
-
-/* "gevent/_queue.pxd":14
- * @cython.final
- * @cython.internal
- * cdef class ItemWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef readonly item
- * cdef readonly queue
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter *__pyx_vtabptr_6gevent_6_queue_ItemWaiter;
-
-
-/* "gevent/_queue.pxd":18
- * cdef readonly queue
- *
- * cdef class Queue: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly hub
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_Queue {
- PyObject *(*_get)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*_put)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_peek)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- Py_ssize_t (*qsize)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- int (*empty)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- int (*full)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*put)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args);
- PyObject *(*put_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*__pyx___get_or_peek)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, PyObject *, PyObject *);
- PyObject *(*get)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_get *__pyx_optional_args);
- PyObject *(*get_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*peek)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_peek *__pyx_optional_args);
- PyObject *(*peek_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*_schedule_unlock)(struct __pyx_obj_6gevent_6_queue_Queue *);
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Queue *__pyx_vtabptr_6gevent_6_queue_Queue;
-
-
-/* "gevent/_queue.pxd":50
- *
- * @cython.final
- * cdef class UnboundQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *__pyx_vtabptr_6gevent_6_queue_UnboundQueue;
-
-
-/* "gevent/_queue.pxd":53
- * pass
- *
- * cdef class PriorityQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue *__pyx_vtabptr_6gevent_6_queue_PriorityQueue;
-
-
-/* "gevent/_queue.pxd":56
- * pass
- *
- * cdef class LifoQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue *__pyx_vtabptr_6gevent_6_queue_LifoQueue;
-
-
-/* "gevent/_queue.pxd":59
- * pass
- *
- * cdef class JoinableQueue(Queue): # <<<<<<<<<<<<<<
- * cdef Event _cond
- * cdef readonly int unfinished_tasks
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue *__pyx_vtabptr_6gevent_6_queue_JoinableQueue;
-
-
-/* "gevent/_queue.pxd":64
- *
- *
- * cdef class Channel: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly getters
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_Channel {
- PyObject *(*get)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_7Channel_get *__pyx_optional_args);
- PyObject *(*get_nowait)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch);
- PyObject *(*_schedule_unlock)(struct __pyx_obj_6gevent_6_queue_Channel *);
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Channel *__pyx_vtabptr_6gevent_6_queue_Channel;
-
-
-/* "src/gevent/_imap.py":43
- * raise failure.exc
- *
- * class IMapUnordered(Greenlet): # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * """
- * At iterator of map results.
- */
-
-struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered {
- struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet __pyx_base;
- PyObject *(*_inext)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *);
- PyObject *(*_ispawn)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *, PyObject *, int);
- PyObject *(*_on_result)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_on_finish)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *);
- PyObject *(*_iqueue_value_for_success)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *);
- PyObject *(*_iqueue_value_for_failure)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *);
- PyObject *(*_iqueue_value_for_self_finished)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *);
- PyObject *(*_iqueue_value_for_self_failure)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *);
-};
-static struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *__pyx_vtabptr_6gevent_6__imap_IMapUnordered;
-
-
-/* "src/gevent/_imap.py":187
- *
- *
- * class IMap(IMapUnordered): # <<<<<<<<<<<<<<
- * # A specialization of IMapUnordered that returns items
- * # in the order in which they were generated, not
- */
-
-struct __pyx_vtabstruct_6gevent_6__imap_IMap {
- struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6__imap_IMap *__pyx_vtabptr_6gevent_6__imap_IMap;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* py_dict_pop.proto */
-static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod2.proto */
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
-#else
-#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
-#endif
-
-/* CallUnboundCMethod1.proto */
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#else
-#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
-#endif
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* None.proto */
-static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__inext(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__ispawn(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_item, int __pyx_v_item_index); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__on_result(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__on_finish(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_exception); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_success(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_failure(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_finished(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_failure(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_exception); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__inext(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_success(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_greenlet); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_failure(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_greenlet); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_finished(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_failure(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_exception); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'weakref' */
-
-/* Module declarations from 'gevent.__ident' */
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ref = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ValuedWeakRef = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_IdentRegistry = 0;
-static PyObject **__pyx_vp_6gevent_7__ident_heappop = 0;
-#define __pyx_v_6gevent_7__ident_heappop (*__pyx_vp_6gevent_7__ident_heappop)
-static PyObject **__pyx_vp_6gevent_7__ident_heappush = 0;
-#define __pyx_v_6gevent_7__ident_heappush (*__pyx_vp_6gevent_7__ident_heappush)
-static PyObject **__pyx_vp_6gevent_7__ident_WeakKeyDictionary = 0;
-#define __pyx_v_6gevent_7__ident_WeakKeyDictionary (*__pyx_vp_6gevent_7__ident_WeakKeyDictionary)
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject **__pyx_vp_6gevent_8__waiter_sys = 0;
-#define __pyx_v_6gevent_8__waiter_sys (*__pyx_vp_6gevent_8__waiter_sys)
-static PyObject **__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-#define __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError (*__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError)
-static int *__pyx_vp_6gevent_8__waiter__greenlet_imported = 0;
-#define __pyx_v_6gevent_8__waiter__greenlet_imported (*__pyx_vp_6gevent_8__waiter__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_8__waiter__NONE = 0;
-#define __pyx_v_6gevent_8__waiter__NONE (*__pyx_vp_6gevent_8__waiter__NONE)
-
-/* Module declarations from 'types' */
-
-/* Module declarations from 'gevent._greenlet' */
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_CodeType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FrameType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__Frame = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_Greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__dummy_event = 0;
-static int *__pyx_vp_6gevent_9_greenlet__PYPY = 0;
-#define __pyx_v_6gevent_9_greenlet__PYPY (*__pyx_vp_6gevent_9_greenlet__PYPY)
-static PyObject **__pyx_vp_6gevent_9_greenlet_sys_getframe = 0;
-#define __pyx_v_6gevent_9_greenlet_sys_getframe (*__pyx_vp_6gevent_9_greenlet_sys_getframe)
-static PyObject **__pyx_vp_6gevent_9_greenlet_sys_exc_info = 0;
-#define __pyx_v_6gevent_9_greenlet_sys_exc_info (*__pyx_vp_6gevent_9_greenlet_sys_exc_info)
-static PyObject **__pyx_vp_6gevent_9_greenlet_Timeout = 0;
-#define __pyx_v_6gevent_9_greenlet_Timeout (*__pyx_vp_6gevent_9_greenlet_Timeout)
-static PyObject **__pyx_vp_6gevent_9_greenlet_GreenletExit = 0;
-#define __pyx_v_6gevent_9_greenlet_GreenletExit (*__pyx_vp_6gevent_9_greenlet_GreenletExit)
-static PyObject **__pyx_vp_6gevent_9_greenlet_InvalidSwitchError = 0;
-#define __pyx_v_6gevent_9_greenlet_InvalidSwitchError (*__pyx_vp_6gevent_9_greenlet_InvalidSwitchError)
-static int *__pyx_vp_6gevent_9_greenlet__greenlet_imported = 0;
-#define __pyx_v_6gevent_9_greenlet__greenlet_imported (*__pyx_vp_6gevent_9_greenlet__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_9_greenlet__greenlet__init__ = 0;
-#define __pyx_v_6gevent_9_greenlet__greenlet__init__ (*__pyx_vp_6gevent_9_greenlet__greenlet__init__)
-static PyObject **__pyx_vp_6gevent_9_greenlet__threadlocal = 0;
-#define __pyx_v_6gevent_9_greenlet__threadlocal (*__pyx_vp_6gevent_9_greenlet__threadlocal)
-static PyObject **__pyx_vp_6gevent_9_greenlet_get_hub_class = 0;
-#define __pyx_v_6gevent_9_greenlet_get_hub_class (*__pyx_vp_6gevent_9_greenlet_get_hub_class)
-static PyObject **__pyx_vp_6gevent_9_greenlet_wref = 0;
-#define __pyx_v_6gevent_9_greenlet_wref (*__pyx_vp_6gevent_9_greenlet_wref)
-static PyObject **__pyx_vp_6gevent_9_greenlet_dump_traceback = 0;
-#define __pyx_v_6gevent_9_greenlet_dump_traceback (*__pyx_vp_6gevent_9_greenlet_dump_traceback)
-static PyObject **__pyx_vp_6gevent_9_greenlet_load_traceback = 0;
-#define __pyx_v_6gevent_9_greenlet_load_traceback (*__pyx_vp_6gevent_9_greenlet_load_traceback)
-static PyObject **__pyx_vp_6gevent_9_greenlet_wait = 0;
-#define __pyx_v_6gevent_9_greenlet_wait (*__pyx_vp_6gevent_9_greenlet_wait)
-static PyObject **__pyx_vp_6gevent_9_greenlet_iwait = 0;
-#define __pyx_v_6gevent_9_greenlet_iwait (*__pyx_vp_6gevent_9_greenlet_iwait)
-static PyObject **__pyx_vp_6gevent_9_greenlet_reraise = 0;
-#define __pyx_v_6gevent_9_greenlet_reraise (*__pyx_vp_6gevent_9_greenlet_reraise)
-static PyObject **__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG = 0;
-#define __pyx_v_6gevent_9_greenlet_GEVENT_CONFIG (*__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG)
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event **__pyx_vp_6gevent_9_greenlet__cancelled_start_event = 0;
-#define __pyx_v_6gevent_9_greenlet__cancelled_start_event (*__pyx_vp_6gevent_9_greenlet__cancelled_start_event)
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event **__pyx_vp_6gevent_9_greenlet__start_completed_event = 0;
-#define __pyx_v_6gevent_9_greenlet__start_completed_event (*__pyx_vp_6gevent_9_greenlet__start_completed_event)
-
-/* Module declarations from 'gevent.__semaphore' */
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_Semaphore = 0;
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore = 0;
-static PyObject **__pyx_vp_6gevent_11__semaphore_Timeout = 0;
-#define __pyx_v_6gevent_11__semaphore_Timeout (*__pyx_vp_6gevent_11__semaphore_Timeout)
-static int *__pyx_vp_6gevent_11__semaphore__greenlet_imported = 0;
-#define __pyx_v_6gevent_11__semaphore__greenlet_imported (*__pyx_vp_6gevent_11__semaphore__greenlet_imported)
-
-/* Module declarations from 'gevent._event' */
-static PyTypeObject *__pyx_ptype_6gevent_6_event_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event__AbstractLinkable = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_Event = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_AsyncResult = 0;
-static PyObject **__pyx_vp_6gevent_6_event__None = 0;
-#define __pyx_v_6gevent_6_event__None (*__pyx_vp_6gevent_6_event__None)
-static PyObject **__pyx_vp_6gevent_6_event_reraise = 0;
-#define __pyx_v_6gevent_6_event_reraise (*__pyx_vp_6gevent_6_event_reraise)
-static PyObject **__pyx_vp_6gevent_6_event_dump_traceback = 0;
-#define __pyx_v_6gevent_6_event_dump_traceback (*__pyx_vp_6gevent_6_event_dump_traceback)
-static PyObject **__pyx_vp_6gevent_6_event_load_traceback = 0;
-#define __pyx_v_6gevent_6_event_load_traceback (*__pyx_vp_6gevent_6_event_load_traceback)
-static PyObject **__pyx_vp_6gevent_6_event_InvalidSwitchError = 0;
-#define __pyx_v_6gevent_6_event_InvalidSwitchError (*__pyx_vp_6gevent_6_event_InvalidSwitchError)
-static PyObject **__pyx_vp_6gevent_6_event_Timeout = 0;
-#define __pyx_v_6gevent_6_event_Timeout (*__pyx_vp_6gevent_6_event_Timeout)
-static int *__pyx_vp_6gevent_6_event__greenlet_imported = 0;
-#define __pyx_v_6gevent_6_event__greenlet_imported (*__pyx_vp_6gevent_6_event__greenlet_imported)
-
-/* Module declarations from 'gevent._queue' */
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_ItemWaiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_Queue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_UnboundQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_PriorityQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_LifoQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_JoinableQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_Channel = 0;
-static PyObject **__pyx_vp_6gevent_6_queue__heappush = 0;
-#define __pyx_v_6gevent_6_queue__heappush (*__pyx_vp_6gevent_6_queue__heappush)
-static PyObject **__pyx_vp_6gevent_6_queue__heappop = 0;
-#define __pyx_v_6gevent_6_queue__heappop (*__pyx_vp_6gevent_6_queue__heappop)
-static PyObject **__pyx_vp_6gevent_6_queue__heapify = 0;
-#define __pyx_v_6gevent_6_queue__heapify (*__pyx_vp_6gevent_6_queue__heapify)
-
-/* Module declarations from 'gevent.__imap' */
-static PyTypeObject *__pyx_ptype_6gevent_6__imap_Failure = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6__imap_IMapUnordered = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6__imap_IMap = 0;
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_6__imap__raise_exc(struct __pyx_obj_6gevent_6__imap_Failure *); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__imap"
-extern int __pyx_module_is_main_gevent____imap;
-int __pyx_module_is_main_gevent____imap = 0;
-
-/* Implementation of 'gevent.__imap' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_BaseException;
-static PyObject *__pyx_builtin_StopIteration;
-static PyObject *__pyx_builtin_KeyError;
-static const char __pyx_k_e[] = "e";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_exc[] = "exc";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_run[] = "_run";
-static const char __pyx_k_IMap[] = "IMap";
-static const char __pyx_k_func[] = "func";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_item[] = "item";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_next[] = "__next__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_queue[] = "queue";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_spawn[] = "spawn";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_next_2[] = "next";
-static const char __pyx_k_zipped[] = "_zipped";
-static const char __pyx_k_maxsize[] = "maxsize";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_Greenlet[] = "Greenlet";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_iterable[] = "iterable";
-static const char __pyx_k_Semaphore[] = "Semaphore";
-static const char __pyx_k_exception[] = "exception";
-static const char __pyx_k_on_result[] = "_on_result";
-static const char __pyx_k_semaphore[] = "_semaphore";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_successful[] = "successful";
-static const char __pyx_k_UnboundQueue[] = "UnboundQueue";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_BaseException[] = "BaseException";
-static const char __pyx_k_IMapUnordered[] = "IMapUnordered";
-static const char __pyx_k_StopIteration[] = "StopIteration";
-static const char __pyx_k_gevent___imap[] = "gevent.__imap";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_imap_task_index[] = "_imap_task_index";
-static const char __pyx_k_raise_exception[] = "raise_exception";
-static const char __pyx_k_raise_exception_2[] = "_raise_exception";
-static const char __pyx_k_IMapUnordered__run[] = "IMapUnordered._run";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_src_gevent__imap_py[] = "src\\gevent\\_imap.py";
-static const char __pyx_k_IMapUnordered__on_result[] = "IMapUnordered._on_result";
-static const char __pyx_k_Iterators_across_greenlets_or_A[] = "\nIterators across greenlets or AsyncResult objects.\n\n";
-static PyObject *__pyx_n_s_BaseException;
-static PyObject *__pyx_n_s_Greenlet;
-static PyObject *__pyx_n_s_IMap;
-static PyObject *__pyx_n_s_IMapUnordered;
-static PyObject *__pyx_n_s_IMapUnordered__on_result;
-static PyObject *__pyx_n_s_IMapUnordered__run;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_Semaphore;
-static PyObject *__pyx_n_s_StopIteration;
-static PyObject *__pyx_n_s_UnboundQueue;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_e;
-static PyObject *__pyx_n_s_exc;
-static PyObject *__pyx_n_s_exception;
-static PyObject *__pyx_n_s_func;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_n_s_gevent___imap;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_imap_task_index;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_item;
-static PyObject *__pyx_n_s_iterable;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_maxsize;
-static PyObject *__pyx_n_s_next;
-static PyObject *__pyx_n_s_next_2;
-static PyObject *__pyx_n_s_on_result;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_queue;
-static PyObject *__pyx_n_s_raise_exception;
-static PyObject *__pyx_n_s_raise_exception_2;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_run;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_semaphore;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_n_s_spawn;
-static PyObject *__pyx_kp_s_src_gevent__imap_py;
-static PyObject *__pyx_n_s_successful;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_zipped;
-static int __pyx_pf_6gevent_6__imap_7Failure___init__(struct __pyx_obj_6gevent_6__imap_Failure *__pyx_v_self, PyObject *__pyx_v_exc, PyObject *__pyx_v_raise_exception); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_7Failure_3exc___get__(struct __pyx_obj_6gevent_6__imap_Failure *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6__imap_13IMapUnordered___init__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_iterable, PyObject *__pyx_v_spawn, PyObject *__pyx_v_maxsize, PyObject *__pyx_v__zipped); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_2__iter__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_4__next__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_6_run(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_8_on_result(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_5queue___get__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_8finished___get__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6__imap_4IMap___init__(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_tp_new_6gevent_6__imap_Failure(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6__imap_IMapUnordered(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6__imap_IMap(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_codeobj__4;
-static PyObject *__pyx_codeobj__6;
-/* Late includes */
-
-/* "src/gevent/_imap.py":31
- * __slots__ = ('exc', 'raise_exception')
- *
- * def __init__(self, exc, raise_exception=None): # <<<<<<<<<<<<<<
- * self.exc = exc
- * self.raise_exception = raise_exception
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6__imap_7Failure_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6__imap_7Failure_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_exc = 0;
- PyObject *__pyx_v_raise_exception = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exc,&__pyx_n_s_raise_exception,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exc)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_raise_exception);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 31, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_exc = values[0];
- __pyx_v_raise_exception = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 31, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__imap.Failure.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6__imap_7Failure___init__(((struct __pyx_obj_6gevent_6__imap_Failure *)__pyx_v_self), __pyx_v_exc, __pyx_v_raise_exception);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6__imap_7Failure___init__(struct __pyx_obj_6gevent_6__imap_Failure *__pyx_v_self, PyObject *__pyx_v_exc, PyObject *__pyx_v_raise_exception) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_imap.py":32
- *
- * def __init__(self, exc, raise_exception=None):
- * self.exc = exc # <<<<<<<<<<<<<<
- * self.raise_exception = raise_exception
- *
- */
- __Pyx_INCREF(__pyx_v_exc);
- __Pyx_GIVEREF(__pyx_v_exc);
- __Pyx_GOTREF(__pyx_v_self->exc);
- __Pyx_DECREF(__pyx_v_self->exc);
- __pyx_v_self->exc = __pyx_v_exc;
-
- /* "src/gevent/_imap.py":33
- * def __init__(self, exc, raise_exception=None):
- * self.exc = exc
- * self.raise_exception = raise_exception # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_INCREF(__pyx_v_raise_exception);
- __Pyx_GIVEREF(__pyx_v_raise_exception);
- __Pyx_GOTREF(__pyx_v_self->raise_exception);
- __Pyx_DECREF(__pyx_v_self->raise_exception);
- __pyx_v_self->raise_exception = __pyx_v_raise_exception;
-
- /* "src/gevent/_imap.py":31
- * __slots__ = ('exc', 'raise_exception')
- *
- * def __init__(self, exc, raise_exception=None): # <<<<<<<<<<<<<<
- * self.exc = exc
- * self.raise_exception = raise_exception
- */
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__imap.pxd":10
- * @cython.final
- * cdef class Failure:
- * cdef readonly exc # <<<<<<<<<<<<<<
- * cdef raise_exception
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_7Failure_3exc_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6__imap_7Failure_3exc_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_7Failure_3exc___get__(((struct __pyx_obj_6gevent_6__imap_Failure *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_7Failure_3exc___get__(struct __pyx_obj_6gevent_6__imap_Failure *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->exc);
- __pyx_r = __pyx_v_self->exc;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":36
- *
- *
- * def _raise_exc(failure): # <<<<<<<<<<<<<<
- * # For cython.
- * if failure.raise_exception:
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_6__imap__raise_exc(struct __pyx_obj_6gevent_6__imap_Failure *__pyx_v_failure) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_raise_exc", 0);
-
- /* "src/gevent/_imap.py":38
- * def _raise_exc(failure):
- * # For cython.
- * if failure.raise_exception: # <<<<<<<<<<<<<<
- * failure.raise_exception()
- * else:
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_failure->raise_exception); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 38, __pyx_L1_error)
- if (likely(__pyx_t_1)) {
-
- /* "src/gevent/_imap.py":39
- * # For cython.
- * if failure.raise_exception:
- * failure.raise_exception() # <<<<<<<<<<<<<<
- * else:
- * raise failure.exc
- */
- __Pyx_INCREF(__pyx_v_failure->raise_exception);
- __pyx_t_3 = __pyx_v_failure->raise_exception; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":38
- * def _raise_exc(failure):
- * # For cython.
- * if failure.raise_exception: # <<<<<<<<<<<<<<
- * failure.raise_exception()
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_imap.py":41
- * failure.raise_exception()
- * else:
- * raise failure.exc # <<<<<<<<<<<<<<
- *
- * class IMapUnordered(Greenlet): # pylint:disable=undefined-variable
- */
- /*else*/ {
- __Pyx_Raise(__pyx_v_failure->exc, 0, 0, 0);
- __PYX_ERR(0, 41, __pyx_L1_error)
- }
- __pyx_L3:;
-
- /* "src/gevent/_imap.py":36
- *
- *
- * def _raise_exc(failure): # <<<<<<<<<<<<<<
- * # For cython.
- * if failure.raise_exception:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__imap._raise_exc", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":48
- * """
- *
- * def __init__(self, func, iterable, spawn, maxsize=None, _zipped=False): # <<<<<<<<<<<<<<
- * """
- * An iterator that.
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6__imap_13IMapUnordered_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6__imap_13IMapUnordered___init__[] = "\n An iterator that.\n\n :param callable spawn: The function we use to create new greenlets.\n :keyword int maxsize: If given and not-None, specifies the maximum number of\n finished results that will be allowed to accumulated awaiting the reader;\n more than that number of results will cause map function greenlets to begin\n to block. This is most useful is there is a great disparity in the speed of\n the mapping code and the consumer and the results consume a great deal of resources.\n Using a bound is more computationally expensive than not using a bound.\n\n .. versionchanged:: 1.1b3\n Added the *maxsize* parameter.\n ";
-#if CYTHON_COMPILING_IN_CPYTHON
-struct wrapperbase __pyx_wrapperbase_6gevent_6__imap_13IMapUnordered___init__;
-#endif
-static int __pyx_pw_6gevent_6__imap_13IMapUnordered_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_func = 0;
- PyObject *__pyx_v_iterable = 0;
- PyObject *__pyx_v_spawn = 0;
- PyObject *__pyx_v_maxsize = 0;
- PyObject *__pyx_v__zipped = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,&__pyx_n_s_iterable,&__pyx_n_s_spawn,&__pyx_n_s_maxsize,&__pyx_n_s_zipped,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_None);
- values[4] = ((PyObject *)Py_False);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iterable)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 48, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_spawn)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 48, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_zipped);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 48, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_func = values[0];
- __pyx_v_iterable = values[1];
- __pyx_v_spawn = values[2];
- __pyx_v_maxsize = values[3];
- __pyx_v__zipped = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered___init__(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self), __pyx_v_func, __pyx_v_iterable, __pyx_v_spawn, __pyx_v_maxsize, __pyx_v__zipped);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6__imap_13IMapUnordered___init__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_iterable, PyObject *__pyx_v_spawn, PyObject *__pyx_v_maxsize, PyObject *__pyx_v__zipped) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_imap.py":63
- * Added the *maxsize* parameter.
- * """
- * Greenlet.__init__(self) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.spawn = spawn
- * self._zipped = _zipped
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":64
- * """
- * Greenlet.__init__(self) # pylint:disable=undefined-variable
- * self.spawn = spawn # <<<<<<<<<<<<<<
- * self._zipped = _zipped
- * self.func = func
- */
- __Pyx_INCREF(__pyx_v_spawn);
- __Pyx_GIVEREF(__pyx_v_spawn);
- __Pyx_GOTREF(__pyx_v_self->spawn);
- __Pyx_DECREF(__pyx_v_self->spawn);
- __pyx_v_self->spawn = __pyx_v_spawn;
-
- /* "src/gevent/_imap.py":65
- * Greenlet.__init__(self) # pylint:disable=undefined-variable
- * self.spawn = spawn
- * self._zipped = _zipped # <<<<<<<<<<<<<<
- * self.func = func
- * self.iterable = iterable
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v__zipped); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 65, __pyx_L1_error)
- __pyx_v_self->_zipped = __pyx_t_5;
-
- /* "src/gevent/_imap.py":66
- * self.spawn = spawn
- * self._zipped = _zipped
- * self.func = func # <<<<<<<<<<<<<<
- * self.iterable = iterable
- * self.queue = UnboundQueue() # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_v_func);
- __Pyx_GIVEREF(__pyx_v_func);
- __Pyx_GOTREF(__pyx_v_self->func);
- __Pyx_DECREF(__pyx_v_self->func);
- __pyx_v_self->func = __pyx_v_func;
-
- /* "src/gevent/_imap.py":67
- * self._zipped = _zipped
- * self.func = func
- * self.iterable = iterable # <<<<<<<<<<<<<<
- * self.queue = UnboundQueue() # pylint:disable=undefined-variable
- *
- */
- __Pyx_INCREF(__pyx_v_iterable);
- __Pyx_GIVEREF(__pyx_v_iterable);
- __Pyx_GOTREF(__pyx_v_self->iterable);
- __Pyx_DECREF(__pyx_v_self->iterable);
- __pyx_v_self->iterable = __pyx_v_iterable;
-
- /* "src/gevent/_imap.py":68
- * self.func = func
- * self.iterable = iterable
- * self.queue = UnboundQueue() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_6_queue_UnboundQueue)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->queue);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->queue));
- __pyx_v_self->queue = ((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":71
- *
- *
- * if maxsize: # <<<<<<<<<<<<<<
- * # Bounding the queue is not enough if we want to keep from
- * # accumulating objects; the result value will be around as
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_maxsize); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 71, __pyx_L1_error)
- if (__pyx_t_5) {
-
- /* "src/gevent/_imap.py":87
- * # of self.rawlink() to avoid having blocking methods called in the
- * # hub greenlet.
- * self._result_semaphore = Semaphore(maxsize) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * else:
- * self._result_semaphore = None
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore), __pyx_v_maxsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_result_semaphore);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_result_semaphore));
- __pyx_v_self->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":71
- *
- *
- * if maxsize: # <<<<<<<<<<<<<<
- * # Bounding the queue is not enough if we want to keep from
- * # accumulating objects; the result value will be around as
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_imap.py":89
- * self._result_semaphore = Semaphore(maxsize) # pylint:disable=undefined-variable
- * else:
- * self._result_semaphore = None # <<<<<<<<<<<<<<
- *
- * self._outstanding_tasks = 0
- */
- /*else*/ {
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_result_semaphore);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_result_semaphore));
- __pyx_v_self->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)Py_None);
- }
- __pyx_L3:;
-
- /* "src/gevent/_imap.py":91
- * self._result_semaphore = None
- *
- * self._outstanding_tasks = 0 # <<<<<<<<<<<<<<
- * # The index (zero based) of the maximum number of
- * # results we will have.
- */
- __pyx_v_self->_outstanding_tasks = 0;
-
- /* "src/gevent/_imap.py":94
- * # The index (zero based) of the maximum number of
- * # results we will have.
- * self._max_index = -1 # <<<<<<<<<<<<<<
- * self.finished = False
- *
- */
- __pyx_v_self->_max_index = -1;
-
- /* "src/gevent/_imap.py":95
- * # results we will have.
- * self._max_index = -1
- * self.finished = False # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_self->finished = 0;
-
- /* "src/gevent/_imap.py":48
- * """
- *
- * def __init__(self, func, iterable, spawn, maxsize=None, _zipped=False): # <<<<<<<<<<<<<<
- * """
- * An iterator that.
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":99
- *
- * # We're iterating in a different greenlet than we're running.
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_3__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_3__iter__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_2__iter__(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_2__iter__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "src/gevent/_imap.py":100
- * # We're iterating in a different greenlet than we're running.
- * def __iter__(self):
- * return self # <<<<<<<<<<<<<<
- *
- * def __next__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":99
- *
- * # We're iterating in a different greenlet than we're running.
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":102
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * if self._result_semaphore is not None:
- * self._result_semaphore.release()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_5__next__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_5__next__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_4__next__(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_4__next__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "src/gevent/_imap.py":103
- *
- * def __next__(self):
- * if self._result_semaphore is not None: # <<<<<<<<<<<<<<
- * self._result_semaphore.release()
- * value = self._inext()
- */
- __pyx_t_1 = (((PyObject *)__pyx_v_self->_result_semaphore) != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_imap.py":104
- * def __next__(self):
- * if self._result_semaphore is not None:
- * self._result_semaphore.release() # <<<<<<<<<<<<<<
- * value = self._inext()
- * if isinstance(value, Failure):
- */
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->_result_semaphore->__pyx_vtab)->release(__pyx_v_self->_result_semaphore, 0); if (unlikely(__pyx_t_3 == ((int)-1000))) __PYX_ERR(0, 104, __pyx_L1_error)
-
- /* "src/gevent/_imap.py":103
- *
- * def __next__(self):
- * if self._result_semaphore is not None: # <<<<<<<<<<<<<<
- * self._result_semaphore.release()
- * value = self._inext()
- */
- }
-
- /* "src/gevent/_imap.py":105
- * if self._result_semaphore is not None:
- * self._result_semaphore.release()
- * value = self._inext() # <<<<<<<<<<<<<<
- * if isinstance(value, Failure):
- * _raise_exc(value)
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_inext(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_value = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":106
- * self._result_semaphore.release()
- * value = self._inext()
- * if isinstance(value, Failure): # <<<<<<<<<<<<<<
- * _raise_exc(value)
- * return value
- */
- __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_6gevent_6__imap_Failure);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/_imap.py":107
- * value = self._inext()
- * if isinstance(value, Failure):
- * _raise_exc(value) # <<<<<<<<<<<<<<
- * return value
- *
- */
- if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_6__imap_Failure))))) __PYX_ERR(0, 107, __pyx_L1_error)
- __pyx_t_4 = __pyx_f_6gevent_6__imap__raise_exc(((struct __pyx_obj_6gevent_6__imap_Failure *)__pyx_v_value)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":106
- * self._result_semaphore.release()
- * value = self._inext()
- * if isinstance(value, Failure): # <<<<<<<<<<<<<<
- * _raise_exc(value)
- * return value
- */
- }
-
- /* "src/gevent/_imap.py":108
- * if isinstance(value, Failure):
- * _raise_exc(value)
- * return value # <<<<<<<<<<<<<<
- *
- * next = __next__ # Py2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_value);
- __pyx_r = __pyx_v_value;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":102
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * if self._result_semaphore is not None:
- * self._result_semaphore.release()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":112
- * next = __next__ # Py2
- *
- * def _inext(self): # <<<<<<<<<<<<<<
- * return self.queue.get()
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__inext(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_inext", 0);
-
- /* "src/gevent/_imap.py":113
- *
- * def _inext(self):
- * return self.queue.get() # <<<<<<<<<<<<<<
- *
- * def _ispawn(self, func, item, item_index):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.get(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":112
- * next = __next__ # Py2
- *
- * def _inext(self): # <<<<<<<<<<<<<<
- * return self.queue.get()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._inext", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":115
- * return self.queue.get()
- *
- * def _ispawn(self, func, item, item_index): # <<<<<<<<<<<<<<
- * if self._result_semaphore is not None:
- * self._result_semaphore.acquire()
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__ispawn(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_item, int __pyx_v_item_index) {
- PyObject *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("_ispawn", 0);
-
- /* "src/gevent/_imap.py":116
- *
- * def _ispawn(self, func, item, item_index):
- * if self._result_semaphore is not None: # <<<<<<<<<<<<<<
- * self._result_semaphore.acquire()
- * self._outstanding_tasks += 1
- */
- __pyx_t_1 = (((PyObject *)__pyx_v_self->_result_semaphore) != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_imap.py":117
- * def _ispawn(self, func, item, item_index):
- * if self._result_semaphore is not None:
- * self._result_semaphore.acquire() # <<<<<<<<<<<<<<
- * self._outstanding_tasks += 1
- * g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item)
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->_result_semaphore->__pyx_vtab)->acquire(__pyx_v_self->_result_semaphore, 0, NULL); if (unlikely(__pyx_t_2 == ((int)-1000))) __PYX_ERR(0, 117, __pyx_L1_error)
-
- /* "src/gevent/_imap.py":116
- *
- * def _ispawn(self, func, item, item_index):
- * if self._result_semaphore is not None: # <<<<<<<<<<<<<<
- * self._result_semaphore.acquire()
- * self._outstanding_tasks += 1
- */
- }
-
- /* "src/gevent/_imap.py":118
- * if self._result_semaphore is not None:
- * self._result_semaphore.acquire()
- * self._outstanding_tasks += 1 # <<<<<<<<<<<<<<
- * g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item)
- * g._imap_task_index = item_index
- */
- __pyx_v_self->_outstanding_tasks = (__pyx_v_self->_outstanding_tasks + 1);
-
- /* "src/gevent/_imap.py":119
- * self._result_semaphore.acquire()
- * self._outstanding_tasks += 1
- * g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item) # <<<<<<<<<<<<<<
- * g._imap_task_index = item_index
- * g.rawlink(self._on_result)
- */
- if (((!(__pyx_v_self->_zipped != 0)) != 0)) {
- __Pyx_INCREF(__pyx_v_self->spawn);
- __pyx_t_5 = __pyx_v_self->spawn; __pyx_t_6 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_func, __pyx_v_item};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_func, __pyx_v_item};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_INCREF(__pyx_v_func);
- __Pyx_GIVEREF(__pyx_v_func);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_func);
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_item);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_3 = __pyx_t_4;
- __pyx_t_4 = 0;
- } else {
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_func);
- __Pyx_GIVEREF(__pyx_v_func);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_func);
- __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_item); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_8 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_self->spawn, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_3 = __pyx_t_5;
- __pyx_t_5 = 0;
- }
- __pyx_v_g = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/_imap.py":120
- * self._outstanding_tasks += 1
- * g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item)
- * g._imap_task_index = item_index # <<<<<<<<<<<<<<
- * g.rawlink(self._on_result)
- * return g
- */
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_item_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_g, __pyx_n_s_imap_task_index, __pyx_t_3) < 0) __PYX_ERR(0, 120, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_imap.py":121
- * g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item)
- * g._imap_task_index = item_index
- * g.rawlink(self._on_result) # <<<<<<<<<<<<<<
- * return g
- *
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_rawlink); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_result); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8);
- __pyx_t_8 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_imap.py":122
- * g._imap_task_index = item_index
- * g.rawlink(self._on_result)
- * return g # <<<<<<<<<<<<<<
- *
- * def _run(self): # pylint:disable=method-hidden
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_g);
- __pyx_r = __pyx_v_g;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":115
- * return self.queue.get()
- *
- * def _ispawn(self, func, item, item_index): # <<<<<<<<<<<<<<
- * if self._result_semaphore is not None:
- * self._result_semaphore.acquire()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._ispawn", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":124
- * return g
- *
- * def _run(self): # pylint:disable=method-hidden # <<<<<<<<<<<<<<
- * try:
- * func = self.func
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_7_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6__imap_13IMapUnordered_6_run[] = "IMapUnordered._run(self)";
-static PyMethodDef __pyx_mdef_6gevent_6__imap_13IMapUnordered_7_run = {"_run", (PyCFunction)__pyx_pw_6gevent_6__imap_13IMapUnordered_7_run, METH_NOARGS, __pyx_doc_6gevent_6__imap_13IMapUnordered_6_run};
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_7_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_run (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_6_run(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_6_run(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_v_func = NULL;
- PyObject *__pyx_v_item = NULL;
- PyObject *__pyx_v_e = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *(*__pyx_t_6)(PyObject *);
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- int __pyx_t_11;
- char const *__pyx_t_12;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- __Pyx_RefNannySetupContext("_run", 0);
-
- /* "src/gevent/_imap.py":125
- *
- * def _run(self): # pylint:disable=method-hidden
- * try: # <<<<<<<<<<<<<<
- * func = self.func
- * for item in self.iterable:
- */
- /*try:*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/_imap.py":126
- * def _run(self): # pylint:disable=method-hidden
- * try:
- * func = self.func # <<<<<<<<<<<<<<
- * for item in self.iterable:
- * self._max_index += 1
- */
- __pyx_t_4 = __pyx_v_self->func;
- __Pyx_INCREF(__pyx_t_4);
- __pyx_v_func = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":127
- * try:
- * func = self.func
- * for item in self.iterable: # <<<<<<<<<<<<<<
- * self._max_index += 1
- * self._ispawn(func, item, self._max_index)
- */
- if (likely(PyList_CheckExact(__pyx_v_self->iterable)) || PyTuple_CheckExact(__pyx_v_self->iterable)) {
- __pyx_t_4 = __pyx_v_self->iterable; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
- __pyx_t_6 = NULL;
- } else {
- __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_self->iterable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L6_error)
- }
- for (;;) {
- if (likely(!__pyx_t_6)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 127, __pyx_L6_error)
- #else
- __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 127, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_7);
- #endif
- } else {
- if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 127, __pyx_L6_error)
- #else
- __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 127, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_7);
- #endif
- }
- } else {
- __pyx_t_7 = __pyx_t_6(__pyx_t_4);
- if (unlikely(!__pyx_t_7)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 127, __pyx_L6_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_7);
- }
- __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
- __pyx_t_7 = 0;
-
- /* "src/gevent/_imap.py":128
- * func = self.func
- * for item in self.iterable:
- * self._max_index += 1 # <<<<<<<<<<<<<<
- * self._ispawn(func, item, self._max_index)
- * self._on_finish(None)
- */
- __pyx_v_self->_max_index = (__pyx_v_self->_max_index + 1);
-
- /* "src/gevent/_imap.py":129
- * for item in self.iterable:
- * self._max_index += 1
- * self._ispawn(func, item, self._max_index) # <<<<<<<<<<<<<<
- * self._on_finish(None)
- * except BaseException as e:
- */
- __pyx_t_7 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_ispawn(__pyx_v_self, __pyx_v_func, __pyx_v_item, __pyx_v_self->_max_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "src/gevent/_imap.py":127
- * try:
- * func = self.func
- * for item in self.iterable: # <<<<<<<<<<<<<<
- * self._max_index += 1
- * self._ispawn(func, item, self._max_index)
- */
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":130
- * self._max_index += 1
- * self._ispawn(func, item, self._max_index)
- * self._on_finish(None) # <<<<<<<<<<<<<<
- * except BaseException as e:
- * self._on_finish(e)
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_finish(__pyx_v_self, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":125
- *
- * def _run(self): # pylint:disable=method-hidden
- * try: # <<<<<<<<<<<<<<
- * func = self.func
- * for item in self.iterable:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L11_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":131
- * self._ispawn(func, item, self._max_index)
- * self._on_finish(None)
- * except BaseException as e: # <<<<<<<<<<<<<<
- * self._on_finish(e)
- * raise
- */
- __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
- if (__pyx_t_8) {
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_9) < 0) __PYX_ERR(0, 131, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_7);
- __pyx_v_e = __pyx_t_7;
-
- /* "src/gevent/_imap.py":132
- * self._on_finish(None)
- * except BaseException as e:
- * self._on_finish(e) # <<<<<<<<<<<<<<
- * raise
- * finally:
- */
- __pyx_t_10 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_on_finish(__pyx_v_self, __pyx_v_e); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 132, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-
- /* "src/gevent/_imap.py":133
- * except BaseException as e:
- * self._on_finish(e)
- * raise # <<<<<<<<<<<<<<
- * finally:
- * self.spawn = None
- */
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_7, __pyx_t_9);
- __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_9 = 0;
- __PYX_ERR(0, 133, __pyx_L8_except_error)
- }
- goto __pyx_L8_except_error;
- __pyx_L8_except_error:;
-
- /* "src/gevent/_imap.py":125
- *
- * def _run(self): # pylint:disable=method-hidden
- * try: # <<<<<<<<<<<<<<
- * func = self.func
- * for item in self.iterable:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L4_error;
- __pyx_L11_try_end:;
- }
- }
-
- /* "src/gevent/_imap.py":135
- * raise
- * finally:
- * self.spawn = None # <<<<<<<<<<<<<<
- * self.func = None
- * self.iterable = None
- */
- /*finally:*/ {
- /*normal exit:*/{
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->spawn);
- __Pyx_DECREF(__pyx_v_self->spawn);
- __pyx_v_self->spawn = Py_None;
-
- /* "src/gevent/_imap.py":136
- * finally:
- * self.spawn = None
- * self.func = None # <<<<<<<<<<<<<<
- * self.iterable = None
- * self._result_semaphore = None
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->func);
- __Pyx_DECREF(__pyx_v_self->func);
- __pyx_v_self->func = Py_None;
-
- /* "src/gevent/_imap.py":137
- * self.spawn = None
- * self.func = None
- * self.iterable = None # <<<<<<<<<<<<<<
- * self._result_semaphore = None
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->iterable);
- __Pyx_DECREF(__pyx_v_self->iterable);
- __pyx_v_self->iterable = Py_None;
-
- /* "src/gevent/_imap.py":138
- * self.func = None
- * self.iterable = None
- * self._result_semaphore = None # <<<<<<<<<<<<<<
- *
- * def _on_result(self, greenlet):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_result_semaphore);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_result_semaphore));
- __pyx_v_self->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)Py_None);
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __pyx_t_8 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename;
- {
-
- /* "src/gevent/_imap.py":135
- * raise
- * finally:
- * self.spawn = None # <<<<<<<<<<<<<<
- * self.func = None
- * self.iterable = None
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->spawn);
- __Pyx_DECREF(__pyx_v_self->spawn);
- __pyx_v_self->spawn = Py_None;
-
- /* "src/gevent/_imap.py":136
- * finally:
- * self.spawn = None
- * self.func = None # <<<<<<<<<<<<<<
- * self.iterable = None
- * self._result_semaphore = None
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->func);
- __Pyx_DECREF(__pyx_v_self->func);
- __pyx_v_self->func = Py_None;
-
- /* "src/gevent/_imap.py":137
- * self.spawn = None
- * self.func = None
- * self.iterable = None # <<<<<<<<<<<<<<
- * self._result_semaphore = None
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->iterable);
- __Pyx_DECREF(__pyx_v_self->iterable);
- __pyx_v_self->iterable = Py_None;
-
- /* "src/gevent/_imap.py":138
- * self.func = None
- * self.iterable = None
- * self._result_semaphore = None # <<<<<<<<<<<<<<
- *
- * def _on_result(self, greenlet):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_result_semaphore);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_result_semaphore));
- __pyx_v_self->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)Py_None);
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
- }
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_ErrRestore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
- __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12;
- goto __pyx_L1_error;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/_imap.py":124
- * return g
- *
- * def _run(self): # pylint:disable=method-hidden # <<<<<<<<<<<<<<
- * try:
- * func = self.func
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_func);
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XDECREF(__pyx_v_e);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":140
- * self._result_semaphore = None
- *
- * def _on_result(self, greenlet): # <<<<<<<<<<<<<<
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1
- */
-
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_9_on_result(PyObject *__pyx_v_self, PyObject *__pyx_v_greenlet); /*proto*/
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__on_result(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet, int __pyx_skip_dispatch) {
- int __pyx_v_count;
- int __pyx_v_finished;
- int __pyx_v_ready;
- int __pyx_v_put_finished;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("_on_result", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6__imap_13IMapUnordered_9_on_result)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_greenlet};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_greenlet};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_greenlet);
- __Pyx_GIVEREF(__pyx_v_greenlet);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_greenlet);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_imap.py":142
- * def _on_result(self, greenlet):
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1 # <<<<<<<<<<<<<<
- * count = self._outstanding_tasks
- * finished = self.finished
- */
- __pyx_v_self->_outstanding_tasks = (__pyx_v_self->_outstanding_tasks - 1);
-
- /* "src/gevent/_imap.py":143
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1
- * count = self._outstanding_tasks # <<<<<<<<<<<<<<
- * finished = self.finished
- * ready = self.ready()
- */
- __pyx_t_6 = __pyx_v_self->_outstanding_tasks;
- __pyx_v_count = __pyx_t_6;
-
- /* "src/gevent/_imap.py":144
- * self._outstanding_tasks -= 1
- * count = self._outstanding_tasks
- * finished = self.finished # <<<<<<<<<<<<<<
- * ready = self.ready()
- * put_finished = False
- */
- __pyx_t_7 = __pyx_v_self->finished;
- __pyx_v_finished = __pyx_t_7;
-
- /* "src/gevent/_imap.py":145
- * count = self._outstanding_tasks
- * finished = self.finished
- * ready = self.ready() # <<<<<<<<<<<<<<
- * put_finished = False
- *
- */
- __pyx_v_ready = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.ready(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), 0);
-
- /* "src/gevent/_imap.py":146
- * finished = self.finished
- * ready = self.ready()
- * put_finished = False # <<<<<<<<<<<<<<
- *
- * if ready and count <= 0 and not finished:
- */
- __pyx_v_put_finished = 0;
-
- /* "src/gevent/_imap.py":148
- * put_finished = False
- *
- * if ready and count <= 0 and not finished: # <<<<<<<<<<<<<<
- * finished = self.finished = True
- * put_finished = True
- */
- __pyx_t_8 = (__pyx_v_ready != 0);
- if (__pyx_t_8) {
- } else {
- __pyx_t_7 = __pyx_t_8;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_8 = ((__pyx_v_count <= 0) != 0);
- if (__pyx_t_8) {
- } else {
- __pyx_t_7 = __pyx_t_8;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_8 = ((!(__pyx_v_finished != 0)) != 0);
- __pyx_t_7 = __pyx_t_8;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "src/gevent/_imap.py":149
- *
- * if ready and count <= 0 and not finished:
- * finished = self.finished = True # <<<<<<<<<<<<<<
- * put_finished = True
- *
- */
- __pyx_v_finished = 1;
- __pyx_v_self->finished = 1;
-
- /* "src/gevent/_imap.py":150
- * if ready and count <= 0 and not finished:
- * finished = self.finished = True
- * put_finished = True # <<<<<<<<<<<<<<
- *
- * if greenlet.successful():
- */
- __pyx_v_put_finished = 1;
-
- /* "src/gevent/_imap.py":148
- * put_finished = False
- *
- * if ready and count <= 0 and not finished: # <<<<<<<<<<<<<<
- * finished = self.finished = True
- * put_finished = True
- */
- }
-
- /* "src/gevent/_imap.py":152
- * put_finished = True
- *
- * if greenlet.successful(): # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_success(greenlet))
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_greenlet, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_7) {
-
- /* "src/gevent/_imap.py":153
- *
- * if greenlet.successful():
- * self.queue.put(self._iqueue_value_for_success(greenlet)) # <<<<<<<<<<<<<<
- * else:
- * self.queue.put(self._iqueue_value_for_failure(greenlet))
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_iqueue_value_for_success(__pyx_v_self, __pyx_v_greenlet); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), __pyx_t_1, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":152
- * put_finished = True
- *
- * if greenlet.successful(): # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_success(greenlet))
- * else:
- */
- goto __pyx_L7;
- }
-
- /* "src/gevent/_imap.py":155
- * self.queue.put(self._iqueue_value_for_success(greenlet))
- * else:
- * self.queue.put(self._iqueue_value_for_failure(greenlet)) # <<<<<<<<<<<<<<
- *
- * if put_finished:
- */
- /*else*/ {
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_iqueue_value_for_failure(__pyx_v_self, __pyx_v_greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), __pyx_t_2, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L7:;
-
- /* "src/gevent/_imap.py":157
- * self.queue.put(self._iqueue_value_for_failure(greenlet))
- *
- * if put_finished: # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- */
- __pyx_t_7 = (__pyx_v_put_finished != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/_imap.py":158
- *
- * if put_finished:
- * self.queue.put(self._iqueue_value_for_self_finished()) # <<<<<<<<<<<<<<
- *
- * def _on_finish(self, exception):
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_iqueue_value_for_self_finished(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), __pyx_t_1, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":157
- * self.queue.put(self._iqueue_value_for_failure(greenlet))
- *
- * if put_finished: # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- */
- }
-
- /* "src/gevent/_imap.py":140
- * self._result_semaphore = None
- *
- * def _on_result(self, greenlet): # <<<<<<<<<<<<<<
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._on_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_9_on_result(PyObject *__pyx_v_self, PyObject *__pyx_v_greenlet); /*proto*/
-static char __pyx_doc_6gevent_6__imap_13IMapUnordered_8_on_result[] = "IMapUnordered._on_result(self, greenlet)";
-static PyMethodDef __pyx_mdef_6gevent_6__imap_13IMapUnordered_9_on_result = {"_on_result", (PyCFunction)__pyx_pw_6gevent_6__imap_13IMapUnordered_9_on_result, METH_O, __pyx_doc_6gevent_6__imap_13IMapUnordered_8_on_result};
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_9_on_result(PyObject *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_on_result (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_8_on_result(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self), ((PyObject *)__pyx_v_greenlet));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_8_on_result(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_on_result", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6__imap_13IMapUnordered__on_result(__pyx_v_self, __pyx_v_greenlet, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._on_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":160
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- * def _on_finish(self, exception): # <<<<<<<<<<<<<<
- * # Called in this greenlet.
- * if self.finished:
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__on_finish(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_exception) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_on_finish", 0);
-
- /* "src/gevent/_imap.py":162
- * def _on_finish(self, exception):
- * # Called in this greenlet.
- * if self.finished: # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_1 = (__pyx_v_self->finished != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/_imap.py":163
- * # Called in this greenlet.
- * if self.finished:
- * return # <<<<<<<<<<<<<<
- *
- * if exception is not None:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":162
- * def _on_finish(self, exception):
- * # Called in this greenlet.
- * if self.finished: # <<<<<<<<<<<<<<
- * return
- *
- */
- }
-
- /* "src/gevent/_imap.py":165
- * return
- *
- * if exception is not None: # <<<<<<<<<<<<<<
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_failure(exception))
- */
- __pyx_t_1 = (__pyx_v_exception != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_imap.py":166
- *
- * if exception is not None:
- * self.finished = True # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_self_failure(exception))
- * return
- */
- __pyx_v_self->finished = 1;
-
- /* "src/gevent/_imap.py":167
- * if exception is not None:
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_failure(exception)) # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_iqueue_value_for_self_failure(__pyx_v_self, __pyx_v_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), __pyx_t_3, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/_imap.py":168
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_failure(exception))
- * return # <<<<<<<<<<<<<<
- *
- * if self._outstanding_tasks <= 0:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":165
- * return
- *
- * if exception is not None: # <<<<<<<<<<<<<<
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_failure(exception))
- */
- }
-
- /* "src/gevent/_imap.py":170
- * return
- *
- * if self._outstanding_tasks <= 0: # <<<<<<<<<<<<<<
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_finished())
- */
- __pyx_t_2 = ((__pyx_v_self->_outstanding_tasks <= 0) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_imap.py":171
- *
- * if self._outstanding_tasks <= 0:
- * self.finished = True # <<<<<<<<<<<<<<
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- */
- __pyx_v_self->finished = 1;
-
- /* "src/gevent/_imap.py":172
- * if self._outstanding_tasks <= 0:
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_finished()) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_success(self, greenlet):
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered *)__pyx_v_self->__pyx_base.__pyx_vtab)->_iqueue_value_for_self_finished(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->queue->__pyx_base.__pyx_vtab)->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->queue), __pyx_t_4, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_imap.py":170
- * return
- *
- * if self._outstanding_tasks <= 0: # <<<<<<<<<<<<<<
- * self.finished = True
- * self.queue.put(self._iqueue_value_for_self_finished())
- */
- }
-
- /* "src/gevent/_imap.py":160
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- * def _on_finish(self, exception): # <<<<<<<<<<<<<<
- * # Called in this greenlet.
- * if self.finished:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._on_finish", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":174
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- * def _iqueue_value_for_success(self, greenlet): # <<<<<<<<<<<<<<
- * return greenlet.value
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_success(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_success", 0);
-
- /* "src/gevent/_imap.py":175
- *
- * def _iqueue_value_for_success(self, greenlet):
- * return greenlet.value # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_failure(self, greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_greenlet, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":174
- * self.queue.put(self._iqueue_value_for_self_finished())
- *
- * def _iqueue_value_for_success(self, greenlet): # <<<<<<<<<<<<<<
- * return greenlet.value
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._iqueue_value_for_success", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":177
- * return greenlet.value
- *
- * def _iqueue_value_for_failure(self, greenlet): # <<<<<<<<<<<<<<
- * return Failure(greenlet.exception, getattr(greenlet, '_raise_exception'))
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_failure(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_failure", 0);
-
- /* "src/gevent/_imap.py":178
- *
- * def _iqueue_value_for_failure(self, greenlet):
- * return Failure(greenlet.exception, getattr(greenlet, '_raise_exception')) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_self_finished(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_greenlet, __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_GetAttr(__pyx_v_greenlet, __pyx_n_s_raise_exception_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6__imap_Failure), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":177
- * return greenlet.value
- *
- * def _iqueue_value_for_failure(self, greenlet): # <<<<<<<<<<<<<<
- * return Failure(greenlet.exception, getattr(greenlet, '_raise_exception'))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._iqueue_value_for_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":180
- * return Failure(greenlet.exception, getattr(greenlet, '_raise_exception'))
- *
- * def _iqueue_value_for_self_finished(self): # <<<<<<<<<<<<<<
- * return Failure(StopIteration())
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_finished(CYTHON_UNUSED struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_self_finished", 0);
-
- /* "src/gevent/_imap.py":181
- *
- * def _iqueue_value_for_self_finished(self):
- * return Failure(StopIteration()) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_self_failure(self, exception):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_StopIteration); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_6__imap_Failure), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":180
- * return Failure(greenlet.exception, getattr(greenlet, '_raise_exception'))
- *
- * def _iqueue_value_for_self_finished(self): # <<<<<<<<<<<<<<
- * return Failure(StopIteration())
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._iqueue_value_for_self_finished", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":183
- * return Failure(StopIteration())
- *
- * def _iqueue_value_for_self_failure(self, exception): # <<<<<<<<<<<<<<
- * return Failure(exception, self._raise_exception)
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_failure(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self, PyObject *__pyx_v_exception) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_self_failure", 0);
-
- /* "src/gevent/_imap.py":184
- *
- * def _iqueue_value_for_self_failure(self, exception):
- * return Failure(exception, self._raise_exception) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_raise_exception_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_exception);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6__imap_Failure), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":183
- * return Failure(StopIteration())
- *
- * def _iqueue_value_for_self_failure(self, exception): # <<<<<<<<<<<<<<
- * return Failure(exception, self._raise_exception)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered._iqueue_value_for_self_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__imap.pxd":24
- * cdef int _max_index
- *
- * cdef readonly UnboundQueue queue # <<<<<<<<<<<<<<
- * cdef readonly bint finished
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_5queue_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_5queue_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_5queue___get__(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_5queue___get__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->queue));
- __pyx_r = ((PyObject *)__pyx_v_self->queue);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__imap.pxd":25
- *
- * cdef readonly UnboundQueue queue
- * cdef readonly bint finished # <<<<<<<<<<<<<<
- *
- * cdef _inext(self)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_8finished_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6__imap_13IMapUnordered_8finished_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6__imap_13IMapUnordered_8finished___get__(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6__imap_13IMapUnordered_8finished___get__(struct __pyx_obj_6gevent_6__imap_IMapUnordered *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->finished); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__imap.IMapUnordered.finished.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":192
- * # the order in which they finish.
- *
- * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<<
- * # The result dictionary: {index: value}
- * self._results = {}
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6__imap_4IMap_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6__imap_4IMap_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
- if (unlikely(__pyx_kwds)) {
- __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1;
- __Pyx_GOTREF(__pyx_v_kwargs);
- } else {
- __pyx_v_kwargs = NULL;
- }
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_6__imap_4IMap___init__(((struct __pyx_obj_6gevent_6__imap_IMap *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6__imap_4IMap___init__(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_imap.py":194
- * def __init__(self, *args, **kwargs):
- * # The result dictionary: {index: value}
- * self._results = {} # <<<<<<<<<<<<<<
- *
- * # The index of the result to return next.
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_results);
- __Pyx_DECREF(__pyx_v_self->_results);
- __pyx_v_self->_results = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":197
- *
- * # The index of the result to return next.
- * self.index = 0 # <<<<<<<<<<<<<<
- * IMapUnordered.__init__(self, *args, **kwargs)
- *
- */
- __pyx_v_self->index = 0;
-
- /* "src/gevent/_imap.py":198
- * # The index of the result to return next.
- * self.index = 0
- * IMapUnordered.__init__(self, *args, **kwargs) # <<<<<<<<<<<<<<
- *
- * def _inext(self):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6__imap_IMapUnordered), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":192
- * # the order in which they finish.
- *
- * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<<
- * # The result dictionary: {index: value}
- * self._results = {}
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMap.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":200
- * IMapUnordered.__init__(self, *args, **kwargs)
- *
- * def _inext(self): # <<<<<<<<<<<<<<
- * try:
- * value = self._results.pop(self.index)
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__inext(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self) {
- int __pyx_v_index;
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *(*__pyx_t_12)(PyObject *);
- int __pyx_t_13;
- __Pyx_RefNannySetupContext("_inext", 0);
-
- /* "src/gevent/_imap.py":201
- *
- * def _inext(self):
- * try: # <<<<<<<<<<<<<<
- * value = self._results.pop(self.index)
- * except KeyError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/_imap.py":202
- * def _inext(self):
- * try:
- * value = self._results.pop(self.index) # <<<<<<<<<<<<<<
- * except KeyError:
- * # Wait for our index to finish.
- */
- if (unlikely(__pyx_v_self->_results == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
- __PYX_ERR(0, 202, __pyx_L3_error)
- }
- __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyDict_Pop(__pyx_v_self->_results, __pyx_t_4, ((PyObject *)NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_value = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "src/gevent/_imap.py":201
- *
- * def _inext(self):
- * try: # <<<<<<<<<<<<<<
- * value = self._results.pop(self.index)
- * except KeyError:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/_imap.py":203
- * try:
- * value = self._results.pop(self.index)
- * except KeyError: # <<<<<<<<<<<<<<
- * # Wait for our index to finish.
- * while 1:
- */
- __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_6) {
- __Pyx_AddTraceback("gevent.__imap.IMap._inext", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 203, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "src/gevent/_imap.py":205
- * except KeyError:
- * # Wait for our index to finish.
- * while 1: # <<<<<<<<<<<<<<
- * index, value = self.queue.get()
- * if index == self.index:
- */
- while (1) {
-
- /* "src/gevent/_imap.py":206
- * # Wait for our index to finish.
- * while 1:
- * index, value = self.queue.get() # <<<<<<<<<<<<<<
- * if index == self.index:
- * break
- */
- __pyx_t_8 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->__pyx_base.queue->__pyx_base.__pyx_vtab)->__pyx_base.get(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_base.queue), 0, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
- PyObject* sequence = __pyx_t_8;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 206, __pyx_L5_except_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_9 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_10 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_10);
- #else
- __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- #endif
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_11 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
- index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_9);
- index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_10);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __pyx_t_12 = NULL;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L14_unpacking_done;
- __pyx_L13_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_12 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 206, __pyx_L5_except_error)
- __pyx_L14_unpacking_done:;
- }
- __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 206, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_v_index = __pyx_t_6;
- __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_10);
- __pyx_t_10 = 0;
-
- /* "src/gevent/_imap.py":207
- * while 1:
- * index, value = self.queue.get()
- * if index == self.index: # <<<<<<<<<<<<<<
- * break
- * else:
- */
- __pyx_t_13 = ((__pyx_v_index == __pyx_v_self->index) != 0);
- if (__pyx_t_13) {
-
- /* "src/gevent/_imap.py":208
- * index, value = self.queue.get()
- * if index == self.index:
- * break # <<<<<<<<<<<<<<
- * else:
- * self._results[index] = value
- */
- goto __pyx_L12_break;
-
- /* "src/gevent/_imap.py":207
- * while 1:
- * index, value = self.queue.get()
- * if index == self.index: # <<<<<<<<<<<<<<
- * break
- * else:
- */
- }
-
- /* "src/gevent/_imap.py":210
- * break
- * else:
- * self._results[index] = value # <<<<<<<<<<<<<<
- * self.index += 1
- * return value
- */
- /*else*/ {
- if (unlikely(__pyx_v_self->_results == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 210, __pyx_L5_except_error)
- }
- __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 210, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (unlikely(PyDict_SetItem(__pyx_v_self->_results, __pyx_t_8, __pyx_v_value) < 0)) __PYX_ERR(0, 210, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __pyx_L12_break:;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/_imap.py":201
- *
- * def _inext(self):
- * try: # <<<<<<<<<<<<<<
- * value = self._results.pop(self.index)
- * except KeyError:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/_imap.py":211
- * else:
- * self._results[index] = value
- * self.index += 1 # <<<<<<<<<<<<<<
- * return value
- *
- */
- __pyx_v_self->index = (__pyx_v_self->index + 1);
-
- /* "src/gevent/_imap.py":212
- * self._results[index] = value
- * self.index += 1
- * return value # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_success(self, greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(!__pyx_v_value)) { __Pyx_RaiseUnboundLocalError("value"); __PYX_ERR(0, 212, __pyx_L1_error) }
- __Pyx_INCREF(__pyx_v_value);
- __pyx_r = __pyx_v_value;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":200
- * IMapUnordered.__init__(self, *args, **kwargs)
- *
- * def _inext(self): # <<<<<<<<<<<<<<
- * try:
- * value = self._results.pop(self.index)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_AddTraceback("gevent.__imap.IMap._inext", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":214
- * return value
- *
- * def _iqueue_value_for_success(self, greenlet): # <<<<<<<<<<<<<<
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet))
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_success(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_success", 0);
-
- /* "src/gevent/_imap.py":215
- *
- * def _iqueue_value_for_success(self, greenlet):
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet)) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_failure(self, greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_greenlet, __pyx_n_s_imap_task_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_success(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self), __pyx_v_greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":214
- * return value
- *
- * def _iqueue_value_for_success(self, greenlet): # <<<<<<<<<<<<<<
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMap._iqueue_value_for_success", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":217
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet))
- *
- * def _iqueue_value_for_failure(self, greenlet): # <<<<<<<<<<<<<<
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet))
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_failure(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_failure", 0);
-
- /* "src/gevent/_imap.py":218
- *
- * def _iqueue_value_for_failure(self, greenlet):
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet)) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_self_finished(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_greenlet, __pyx_n_s_imap_task_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_failure(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self), __pyx_v_greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":217
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet))
- *
- * def _iqueue_value_for_failure(self, greenlet): # <<<<<<<<<<<<<<
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMap._iqueue_value_for_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":220
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet))
- *
- * def _iqueue_value_for_self_finished(self): # <<<<<<<<<<<<<<
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self))
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_finished(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_self_finished", 0);
-
- /* "src/gevent/_imap.py":221
- *
- * def _iqueue_value_for_self_finished(self):
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self)) # <<<<<<<<<<<<<<
- *
- * def _iqueue_value_for_self_failure(self, exception):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_self->__pyx_base._max_index + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_finished(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":220
- * return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet))
- *
- * def _iqueue_value_for_self_finished(self): # <<<<<<<<<<<<<<
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMap._iqueue_value_for_self_finished", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_imap.py":223
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self))
- *
- * def _iqueue_value_for_self_failure(self, exception): # <<<<<<<<<<<<<<
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_failure(self, exception))
- *
- */
-
-static PyObject *__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_failure(struct __pyx_obj_6gevent_6__imap_IMap *__pyx_v_self, PyObject *__pyx_v_exception) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_iqueue_value_for_self_failure", 0);
-
- /* "src/gevent/_imap.py":224
- *
- * def _iqueue_value_for_self_failure(self, exception):
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_failure(self, exception)) # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_self->__pyx_base._max_index + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_failure(((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)__pyx_v_self), __pyx_v_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_imap.py":223
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self))
- *
- * def _iqueue_value_for_self_failure(self, exception): # <<<<<<<<<<<<<<
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_failure(self, exception))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__imap.IMap._iqueue_value_for_self_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_9_greenlet_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_greenlet.pxd":28
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_9_greenlet_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_9_greenlet__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_greenlet.pxd":35
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_greenlet.pxd":36
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef extern from "Python.h":
- */
- __pyx_v_6gevent_9_greenlet__greenlet_imported = 1;
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__semaphore.pxd":19
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_11__semaphore_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__semaphore.pxd":20
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__semaphore.pxd":19
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":22
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_11__semaphore_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__semaphore.pxd":24
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_11__semaphore__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__semaphore.pxd":25
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__semaphore.pxd":26
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_6gevent_11__semaphore__greenlet_imported = 1;
-
- /* "gevent/__semaphore.pxd":24
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__semaphore.pxd":22
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_event_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_event.pxd":28
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_6_event_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_6_event__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_event.pxd":33
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_event.pxd":34
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef void _init()
- */
- __pyx_v_6gevent_6_event__greenlet_imported = 1;
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static PyObject *__pyx_tp_new_6gevent_6__imap_Failure(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6__imap_Failure *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6__imap_Failure *)o);
- p->exc = Py_None; Py_INCREF(Py_None);
- p->raise_exception = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6__imap_Failure(PyObject *o) {
- struct __pyx_obj_6gevent_6__imap_Failure *p = (struct __pyx_obj_6gevent_6__imap_Failure *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->exc);
- Py_CLEAR(p->raise_exception);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6__imap_Failure(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6__imap_Failure *p = (struct __pyx_obj_6gevent_6__imap_Failure *)o;
- if (p->exc) {
- e = (*v)(p->exc, a); if (e) return e;
- }
- if (p->raise_exception) {
- e = (*v)(p->raise_exception, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6__imap_Failure(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6__imap_Failure *p = (struct __pyx_obj_6gevent_6__imap_Failure *)o;
- tmp = ((PyObject*)p->exc);
- p->exc = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->raise_exception);
- p->raise_exception = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6__imap_7Failure_exc(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6__imap_7Failure_3exc_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6__imap_Failure[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6__imap_Failure[] = {
- {(char *)"exc", __pyx_getprop_6gevent_6__imap_7Failure_exc, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6__imap_Failure = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__imap.Failure", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6__imap_Failure), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6__imap_Failure, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Failure(exc, raise_exception=None)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6__imap_Failure, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6__imap_Failure, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6__imap_Failure, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6__imap_Failure, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6__imap_7Failure_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6__imap_Failure, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6__imap_IMapUnordered __pyx_vtable_6gevent_6__imap_IMapUnordered;
-
-static PyObject *__pyx_tp_new_6gevent_6__imap_IMapUnordered(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6__imap_IMapUnordered *p;
- PyObject *o = __pyx_ptype_6gevent_9_greenlet_Greenlet->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6__imap_IMapUnordered *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet*)__pyx_vtabptr_6gevent_6__imap_IMapUnordered;
- p->func = Py_None; Py_INCREF(Py_None);
- p->iterable = Py_None; Py_INCREF(Py_None);
- p->spawn = Py_None; Py_INCREF(Py_None);
- p->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)Py_None); Py_INCREF(Py_None);
- p->queue = ((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6__imap_IMapUnordered(PyObject *o) {
- struct __pyx_obj_6gevent_6__imap_IMapUnordered *p = (struct __pyx_obj_6gevent_6__imap_IMapUnordered *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->func);
- Py_CLEAR(p->iterable);
- Py_CLEAR(p->spawn);
- Py_CLEAR(p->_result_semaphore);
- Py_CLEAR(p->queue);
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_9_greenlet_Greenlet)) __pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_6__imap_IMapUnordered);
-}
-
-static int __pyx_tp_traverse_6gevent_6__imap_IMapUnordered(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6__imap_IMapUnordered *p = (struct __pyx_obj_6gevent_6__imap_IMapUnordered *)o;
- e = ((likely(__pyx_ptype_6gevent_9_greenlet_Greenlet)) ? ((__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_traverse) ? __pyx_ptype_6gevent_9_greenlet_Greenlet->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_6__imap_IMapUnordered)); if (e) return e;
- if (p->func) {
- e = (*v)(p->func, a); if (e) return e;
- }
- if (p->iterable) {
- e = (*v)(p->iterable, a); if (e) return e;
- }
- if (p->spawn) {
- e = (*v)(p->spawn, a); if (e) return e;
- }
- if (p->_result_semaphore) {
- e = (*v)(((PyObject *)p->_result_semaphore), a); if (e) return e;
- }
- if (p->queue) {
- e = (*v)(((PyObject *)p->queue), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6__imap_IMapUnordered(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6__imap_IMapUnordered *p = (struct __pyx_obj_6gevent_6__imap_IMapUnordered *)o;
- if (likely(__pyx_ptype_6gevent_9_greenlet_Greenlet)) { if (__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_clear) __pyx_ptype_6gevent_9_greenlet_Greenlet->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_6__imap_IMapUnordered);
- tmp = ((PyObject*)p->func);
- p->func = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->iterable);
- p->iterable = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->spawn);
- p->spawn = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_result_semaphore);
- p->_result_semaphore = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->queue);
- p->queue = ((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6__imap_13IMapUnordered_queue(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6__imap_13IMapUnordered_5queue_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6__imap_13IMapUnordered_finished(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6__imap_13IMapUnordered_8finished_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6__imap_IMapUnordered[] = {
- {"__next__", (PyCFunction)__pyx_pw_6gevent_6__imap_13IMapUnordered_5__next__, METH_NOARGS|METH_COEXIST, 0},
- {"_run", (PyCFunction)__pyx_pw_6gevent_6__imap_13IMapUnordered_7_run, METH_NOARGS, __pyx_doc_6gevent_6__imap_13IMapUnordered_6_run},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6__imap_IMapUnordered[] = {
- {(char *)"queue", __pyx_getprop_6gevent_6__imap_13IMapUnordered_queue, 0, (char *)0, 0},
- {(char *)"finished", __pyx_getprop_6gevent_6__imap_13IMapUnordered_finished, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6__imap_IMapUnordered = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__imap.IMapUnordered", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6__imap_IMapUnordered), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6__imap_IMapUnordered, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "IMapUnordered(func, iterable, spawn, maxsize=None, _zipped=False)\n\n At iterator of map results.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6__imap_IMapUnordered, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6__imap_IMapUnordered, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- __pyx_pw_6gevent_6__imap_13IMapUnordered_3__iter__, /*tp_iter*/
- __pyx_pw_6gevent_6__imap_13IMapUnordered_5__next__, /*tp_iternext*/
- __pyx_methods_6gevent_6__imap_IMapUnordered, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6__imap_IMapUnordered, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6__imap_13IMapUnordered_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6__imap_IMapUnordered, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6__imap_IMap __pyx_vtable_6gevent_6__imap_IMap;
-
-static PyObject *__pyx_tp_new_6gevent_6__imap_IMap(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6__imap_IMap *p;
- PyObject *o = __pyx_tp_new_6gevent_6__imap_IMapUnordered(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6__imap_IMap *)o);
- p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet*)__pyx_vtabptr_6gevent_6__imap_IMap;
- p->_results = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6__imap_IMap(PyObject *o) {
- struct __pyx_obj_6gevent_6__imap_IMap *p = (struct __pyx_obj_6gevent_6__imap_IMap *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_results);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_6__imap_IMapUnordered(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6__imap_IMap(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6__imap_IMap *p = (struct __pyx_obj_6gevent_6__imap_IMap *)o;
- e = __pyx_tp_traverse_6gevent_6__imap_IMapUnordered(o, v, a); if (e) return e;
- if (p->_results) {
- e = (*v)(p->_results, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6__imap_IMap(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6__imap_IMap *p = (struct __pyx_obj_6gevent_6__imap_IMap *)o;
- __pyx_tp_clear_6gevent_6__imap_IMapUnordered(o);
- tmp = ((PyObject*)p->_results);
- p->_results = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6__imap_IMap[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6__imap_IMap = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__imap.IMap", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6__imap_IMap), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6__imap_IMap, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "IMap(*args, **kwargs)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6__imap_IMap, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6__imap_IMap, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6__imap_13IMapUnordered_3__iter__, /*tp_iter*/
- #else
- 0, /*tp_iter*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6__imap_13IMapUnordered_5__next__, /*tp_iternext*/
- #else
- 0, /*tp_iternext*/
- #endif
- __pyx_methods_6gevent_6__imap_IMap, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6__imap_4IMap_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6__imap_IMap, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___imap(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___imap},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__imap",
- __pyx_k_Iterators_across_greenlets_or_A, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_BaseException, __pyx_k_BaseException, sizeof(__pyx_k_BaseException), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet, __pyx_k_Greenlet, sizeof(__pyx_k_Greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_IMap, __pyx_k_IMap, sizeof(__pyx_k_IMap), 0, 0, 1, 1},
- {&__pyx_n_s_IMapUnordered, __pyx_k_IMapUnordered, sizeof(__pyx_k_IMapUnordered), 0, 0, 1, 1},
- {&__pyx_n_s_IMapUnordered__on_result, __pyx_k_IMapUnordered__on_result, sizeof(__pyx_k_IMapUnordered__on_result), 0, 0, 1, 1},
- {&__pyx_n_s_IMapUnordered__run, __pyx_k_IMapUnordered__run, sizeof(__pyx_k_IMapUnordered__run), 0, 0, 1, 1},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore, __pyx_k_Semaphore, sizeof(__pyx_k_Semaphore), 0, 0, 1, 1},
- {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
- {&__pyx_n_s_UnboundQueue, __pyx_k_UnboundQueue, sizeof(__pyx_k_UnboundQueue), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
- {&__pyx_n_s_exc, __pyx_k_exc, sizeof(__pyx_k_exc), 0, 0, 1, 1},
- {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
- {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___imap, __pyx_k_gevent___imap, sizeof(__pyx_k_gevent___imap), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_imap_task_index, __pyx_k_imap_task_index, sizeof(__pyx_k_imap_task_index), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
- {&__pyx_n_s_iterable, __pyx_k_iterable, sizeof(__pyx_k_iterable), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_maxsize, __pyx_k_maxsize, sizeof(__pyx_k_maxsize), 0, 0, 1, 1},
- {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
- {&__pyx_n_s_next_2, __pyx_k_next_2, sizeof(__pyx_k_next_2), 0, 0, 1, 1},
- {&__pyx_n_s_on_result, __pyx_k_on_result, sizeof(__pyx_k_on_result), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_queue, __pyx_k_queue, sizeof(__pyx_k_queue), 0, 0, 1, 1},
- {&__pyx_n_s_raise_exception, __pyx_k_raise_exception, sizeof(__pyx_k_raise_exception), 0, 0, 1, 1},
- {&__pyx_n_s_raise_exception_2, __pyx_k_raise_exception_2, sizeof(__pyx_k_raise_exception_2), 0, 0, 1, 1},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_run, __pyx_k_run, sizeof(__pyx_k_run), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_semaphore, __pyx_k_semaphore, sizeof(__pyx_k_semaphore), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_n_s_spawn, __pyx_k_spawn, sizeof(__pyx_k_spawn), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__imap_py, __pyx_k_src_gevent__imap_py, sizeof(__pyx_k_src_gevent__imap_py), 0, 0, 1, 0},
- {&__pyx_n_s_successful, __pyx_k_successful, sizeof(__pyx_k_successful), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_zipped, __pyx_k_zipped, sizeof(__pyx_k_zipped), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 23, __pyx_L1_error)
- __pyx_builtin_BaseException = __Pyx_GetBuiltinName(__pyx_n_s_BaseException); if (!__pyx_builtin_BaseException) __PYX_ERR(0, 131, __pyx_L1_error)
- __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 181, __pyx_L1_error)
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 203, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_imap.py":23
- * ]
- *
- * locals()['Greenlet'] = __import__('gevent').Greenlet # <<<<<<<<<<<<<<
- * locals()['Semaphore'] = _semaphore.Semaphore
- * locals()['UnboundQueue'] = queue.UnboundQueue
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_gevent); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_imap.py":29
- *
- * class Failure(object):
- * __slots__ = ('exc', 'raise_exception') # <<<<<<<<<<<<<<
- *
- * def __init__(self, exc, raise_exception=None):
- */
- __pyx_tuple__2 = PyTuple_Pack(2, __pyx_n_s_exc, __pyx_n_s_raise_exception); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "src/gevent/_imap.py":124
- * return g
- *
- * def _run(self): # pylint:disable=method-hidden # <<<<<<<<<<<<<<
- * try:
- * func = self.func
- */
- __pyx_tuple__3 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_func, __pyx_n_s_item, __pyx_n_s_e); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
- __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__imap_py, __pyx_n_s_run, 124, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 124, __pyx_L1_error)
-
- /* "src/gevent/_imap.py":140
- * self._result_semaphore = None
- *
- * def _on_result(self, greenlet): # <<<<<<<<<<<<<<
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1
- */
- __pyx_tuple__5 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
- __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__imap_py, __pyx_n_s_on_result, 140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_raise_exc", (void (*)(void))__pyx_f_6gevent_6__imap__raise_exc, "PyObject *(struct __pyx_obj_6gevent_6__imap_Failure *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_6gevent_6__imap_Failure) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
- __pyx_type_6gevent_6__imap_Failure.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6__imap_Failure.tp_dictoffset && __pyx_type_6gevent_6__imap_Failure.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6__imap_Failure.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "Failure", (PyObject *)&__pyx_type_6gevent_6__imap_Failure) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
- __pyx_ptype_6gevent_6__imap_Failure = &__pyx_type_6gevent_6__imap_Failure;
- __pyx_ptype_6gevent_9_greenlet_Greenlet = __Pyx_ImportType("gevent._greenlet", "Greenlet", sizeof(struct __pyx_obj_6gevent_9_greenlet_Greenlet), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_Greenlet)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_9_greenlet_Greenlet = (struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet*)__Pyx_GetVtable(__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_9_greenlet_Greenlet)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6__imap_IMapUnordered = &__pyx_vtable_6gevent_6__imap_IMapUnordered;
- __pyx_vtable_6gevent_6__imap_IMapUnordered.__pyx_base = *__pyx_vtabptr_6gevent_9_greenlet_Greenlet;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._inext = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *))__pyx_f_6gevent_6__imap_13IMapUnordered__inext;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._ispawn = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *, PyObject *, int))__pyx_f_6gevent_6__imap_13IMapUnordered__ispawn;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._on_result = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6__imap_13IMapUnordered__on_result;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._on_finish = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_13IMapUnordered__on_finish;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._iqueue_value_for_success = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_success;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._iqueue_value_for_failure = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_failure;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._iqueue_value_for_self_finished = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *))__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_finished;
- __pyx_vtable_6gevent_6__imap_IMapUnordered._iqueue_value_for_self_failure = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_13IMapUnordered__iqueue_value_for_self_failure;
- __pyx_type_6gevent_6__imap_IMapUnordered.tp_base = __pyx_ptype_6gevent_9_greenlet_Greenlet;
- if (PyType_Ready(&__pyx_type_6gevent_6__imap_IMapUnordered) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- __pyx_type_6gevent_6__imap_IMapUnordered.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6__imap_IMapUnordered.tp_dictoffset && __pyx_type_6gevent_6__imap_IMapUnordered.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6__imap_IMapUnordered.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- #if CYTHON_COMPILING_IN_CPYTHON
- {
- PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gevent_6__imap_IMapUnordered, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 43, __pyx_L1_error)
- if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
- __pyx_wrapperbase_6gevent_6__imap_13IMapUnordered___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
- __pyx_wrapperbase_6gevent_6__imap_13IMapUnordered___init__.doc = __pyx_doc_6gevent_6__imap_13IMapUnordered___init__;
- ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gevent_6__imap_13IMapUnordered___init__;
- }
- }
- #endif
- if (__Pyx_SetVtable(__pyx_type_6gevent_6__imap_IMapUnordered.tp_dict, __pyx_vtabptr_6gevent_6__imap_IMapUnordered) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "IMapUnordered", (PyObject *)&__pyx_type_6gevent_6__imap_IMapUnordered) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- __pyx_ptype_6gevent_6__imap_IMapUnordered = &__pyx_type_6gevent_6__imap_IMapUnordered;
- __pyx_vtabptr_6gevent_6__imap_IMap = &__pyx_vtable_6gevent_6__imap_IMap;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base = *__pyx_vtabptr_6gevent_6__imap_IMapUnordered;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base._inext = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *))__pyx_f_6gevent_6__imap_4IMap__inext;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base._iqueue_value_for_success = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_success;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base._iqueue_value_for_failure = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_failure;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base._iqueue_value_for_self_finished = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *))__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_finished;
- __pyx_vtable_6gevent_6__imap_IMap.__pyx_base._iqueue_value_for_self_failure = (PyObject *(*)(struct __pyx_obj_6gevent_6__imap_IMapUnordered *, PyObject *))__pyx_f_6gevent_6__imap_4IMap__iqueue_value_for_self_failure;
- __pyx_type_6gevent_6__imap_IMap.tp_base = __pyx_ptype_6gevent_6__imap_IMapUnordered;
- if (PyType_Ready(&__pyx_type_6gevent_6__imap_IMap) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
- __pyx_type_6gevent_6__imap_IMap.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6__imap_IMap.tp_dictoffset && __pyx_type_6gevent_6__imap_IMap.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6__imap_IMap.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6__imap_IMap.tp_dict, __pyx_vtabptr_6gevent_6__imap_IMap) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "IMap", (PyObject *)&__pyx_type_6gevent_6__imap_IMap) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
- __pyx_ptype_6gevent_6__imap_IMap = &__pyx_type_6gevent_6__imap_IMap;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_7__ident_ref = __Pyx_ImportType("weakref", "ref", sizeof(PyWeakReference), 0); if (unlikely(!__pyx_ptype_6gevent_7__ident_ref)) __PYX_ERR(7, 5, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_ValuedWeakRef = __Pyx_ImportType("gevent.__ident", "ValuedWeakRef", sizeof(struct __pyx_obj_6gevent_7__ident_ValuedWeakRef), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_ValuedWeakRef)) __PYX_ERR(7, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_IdentRegistry = __Pyx_ImportType("gevent.__ident", "IdentRegistry", sizeof(struct __pyx_obj_6gevent_7__ident_IdentRegistry), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_IdentRegistry)) __PYX_ERR(7, 19, __pyx_L1_error)
- __pyx_vtabptr_6gevent_7__ident_IdentRegistry = (struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry*)__Pyx_GetVtable(__pyx_ptype_6gevent_7__ident_IdentRegistry->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_7__ident_IdentRegistry)) __PYX_ERR(7, 19, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(2, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(2, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(3, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_Waiter = __Pyx_ImportType("gevent.__waiter", "Waiter", sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_Waiter)) __PYX_ERR(3, 33, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_Waiter)) __PYX_ERR(3, 33, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = __Pyx_ImportType("gevent.__waiter", "MultipleWaiter", sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = (struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_greenlet)) __PYX_ERR(4, 17, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_CodeType = __Pyx_ImportType("types", "CodeType", sizeof(PyCodeObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_CodeType)) __PYX_ERR(4, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FrameType = __Pyx_ImportType("types", "FrameType", sizeof(PyFrameObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_FrameType)) __PYX_ERR(4, 45, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SpawnedLink = __Pyx_ImportType("gevent._greenlet", "SpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_SpawnedLink)) __PYX_ERR(4, 56, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = __Pyx_ImportType("gevent._greenlet", "SuccessSpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink)) __PYX_ERR(4, 61, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = __Pyx_ImportType("gevent._greenlet", "FailureSpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink)) __PYX_ERR(4, 65, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__Frame = __Pyx_ImportType("gevent._greenlet", "_Frame", sizeof(struct __pyx_obj_6gevent_9_greenlet__Frame), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet__Frame)) __PYX_ERR(4, 71, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__dummy_event = __Pyx_ImportType("gevent._greenlet", "_dummy_event", sizeof(struct __pyx_obj_6gevent_9_greenlet__dummy_event), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet__dummy_event)) __PYX_ERR(4, 157, __pyx_L1_error)
- __pyx_vtabptr_6gevent_9_greenlet__dummy_event = (struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event*)__Pyx_GetVtable(__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_9_greenlet__dummy_event)) __PYX_ERR(4, 157, __pyx_L1_error)
- __pyx_ptype_6gevent_11__semaphore_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_11__semaphore_greenlet)) __PYX_ERR(5, 10, __pyx_L1_error)
- __pyx_ptype_6gevent_11__semaphore_Semaphore = __Pyx_ImportType("gevent.__semaphore", "Semaphore", sizeof(struct __pyx_obj_6gevent_11__semaphore_Semaphore), 1); if (unlikely(!__pyx_ptype_6gevent_11__semaphore_Semaphore)) __PYX_ERR(5, 32, __pyx_L1_error)
- __pyx_vtabptr_6gevent_11__semaphore_Semaphore = (struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore*)__Pyx_GetVtable(__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_11__semaphore_Semaphore)) __PYX_ERR(5, 32, __pyx_L1_error)
- __pyx_ptype_6gevent_11__semaphore_BoundedSemaphore = __Pyx_ImportType("gevent.__semaphore", "BoundedSemaphore", sizeof(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore), 1); if (unlikely(!__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore)) __PYX_ERR(5, 51, __pyx_L1_error)
- __pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore = (struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore*)__Pyx_GetVtable(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore)) __PYX_ERR(5, 51, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_6_event_greenlet)) __PYX_ERR(6, 18, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event__AbstractLinkable = __Pyx_ImportType("gevent._event", "_AbstractLinkable", sizeof(struct __pyx_obj_6gevent_6_event__AbstractLinkable), 1); if (unlikely(!__pyx_ptype_6gevent_6_event__AbstractLinkable)) __PYX_ERR(6, 38, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event__AbstractLinkable = (struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event__AbstractLinkable)) __PYX_ERR(6, 38, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_Event = __Pyx_ImportType("gevent._event", "Event", sizeof(struct __pyx_obj_6gevent_6_event_Event), 1); if (unlikely(!__pyx_ptype_6gevent_6_event_Event)) __PYX_ERR(6, 60, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event_Event = (struct __pyx_vtabstruct_6gevent_6_event_Event*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event_Event->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event_Event)) __PYX_ERR(6, 60, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_AsyncResult = __Pyx_ImportType("gevent._event", "AsyncResult", sizeof(struct __pyx_obj_6gevent_6_event_AsyncResult), 1); if (unlikely(!__pyx_ptype_6gevent_6_event_AsyncResult)) __PYX_ERR(6, 63, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event_AsyncResult = (struct __pyx_vtabstruct_6gevent_6_event_AsyncResult*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event_AsyncResult)) __PYX_ERR(6, 63, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_ItemWaiter = __Pyx_ImportType("gevent._queue", "ItemWaiter", sizeof(struct __pyx_obj_6gevent_6_queue_ItemWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_ItemWaiter)) __PYX_ERR(8, 14, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_ItemWaiter = (struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_ItemWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_ItemWaiter)) __PYX_ERR(8, 14, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_Queue = __Pyx_ImportType("gevent._queue", "Queue", sizeof(struct __pyx_obj_6gevent_6_queue_Queue), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_Queue)) __PYX_ERR(8, 18, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_Queue = (struct __pyx_vtabstruct_6gevent_6_queue_Queue*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_Queue->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_Queue)) __PYX_ERR(8, 18, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_UnboundQueue = __Pyx_ImportType("gevent._queue", "UnboundQueue", sizeof(struct __pyx_obj_6gevent_6_queue_UnboundQueue), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_UnboundQueue)) __PYX_ERR(8, 50, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_UnboundQueue = (struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_UnboundQueue->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_UnboundQueue)) __PYX_ERR(8, 50, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_PriorityQueue = __Pyx_ImportType("gevent._queue", "PriorityQueue", sizeof(struct __pyx_obj_6gevent_6_queue_PriorityQueue), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_PriorityQueue)) __PYX_ERR(8, 53, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_PriorityQueue = (struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_PriorityQueue->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_PriorityQueue)) __PYX_ERR(8, 53, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_LifoQueue = __Pyx_ImportType("gevent._queue", "LifoQueue", sizeof(struct __pyx_obj_6gevent_6_queue_LifoQueue), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_LifoQueue)) __PYX_ERR(8, 56, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_LifoQueue = (struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_LifoQueue)) __PYX_ERR(8, 56, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_JoinableQueue = __Pyx_ImportType("gevent._queue", "JoinableQueue", sizeof(struct __pyx_obj_6gevent_6_queue_JoinableQueue), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_JoinableQueue)) __PYX_ERR(8, 59, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_JoinableQueue = (struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_JoinableQueue)) __PYX_ERR(8, 59, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_Channel = __Pyx_ImportType("gevent._queue", "Channel", sizeof(struct __pyx_obj_6gevent_6_queue_Channel), 1); if (unlikely(!__pyx_ptype_6gevent_6_queue_Channel)) __PYX_ERR(8, 64, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_Channel = (struct __pyx_vtabstruct_6gevent_6_queue_Channel*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_queue_Channel->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_queue_Channel)) __PYX_ERR(8, 64, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__ident"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappop", (void **)&__pyx_vp_6gevent_7__ident_heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappush", (void **)&__pyx_vp_6gevent_7__ident_heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "WeakKeyDictionary", (void **)&__pyx_vp_6gevent_7__ident_WeakKeyDictionary, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = __Pyx_ImportModule("gevent.__waiter"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "sys", (void **)&__pyx_vp_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "ConcurrentObjectUseError", (void **)&__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_greenlet_imported", (void **)&__pyx_vp_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_NONE", (void **)&__pyx_vp_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_5 = __Pyx_ImportModule("gevent._greenlet"); if (!__pyx_t_5) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_PYPY", (void **)&__pyx_vp_6gevent_9_greenlet__PYPY, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "sys_getframe", (void **)&__pyx_vp_6gevent_9_greenlet_sys_getframe, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "sys_exc_info", (void **)&__pyx_vp_6gevent_9_greenlet_sys_exc_info, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "Timeout", (void **)&__pyx_vp_6gevent_9_greenlet_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "GreenletExit", (void **)&__pyx_vp_6gevent_9_greenlet_GreenletExit, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "InvalidSwitchError", (void **)&__pyx_vp_6gevent_9_greenlet_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_greenlet_imported", (void **)&__pyx_vp_6gevent_9_greenlet__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_greenlet__init__", (void **)&__pyx_vp_6gevent_9_greenlet__greenlet__init__, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_threadlocal", (void **)&__pyx_vp_6gevent_9_greenlet__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "get_hub_class", (void **)&__pyx_vp_6gevent_9_greenlet_get_hub_class, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "wref", (void **)&__pyx_vp_6gevent_9_greenlet_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "dump_traceback", (void **)&__pyx_vp_6gevent_9_greenlet_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "load_traceback", (void **)&__pyx_vp_6gevent_9_greenlet_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "wait", (void **)&__pyx_vp_6gevent_9_greenlet_wait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "iwait", (void **)&__pyx_vp_6gevent_9_greenlet_iwait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "reraise", (void **)&__pyx_vp_6gevent_9_greenlet_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "GEVENT_CONFIG", (void **)&__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_cancelled_start_event", (void **)&__pyx_vp_6gevent_9_greenlet__cancelled_start_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_start_completed_event", (void **)&__pyx_vp_6gevent_9_greenlet__start_completed_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_6 = __Pyx_ImportModule("gevent.__semaphore"); if (!__pyx_t_6) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_6, "Timeout", (void **)&__pyx_vp_6gevent_11__semaphore_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_6, "_greenlet_imported", (void **)&__pyx_vp_6gevent_11__semaphore__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_7 = __Pyx_ImportModule("gevent._event"); if (!__pyx_t_7) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "_None", (void **)&__pyx_vp_6gevent_6_event__None, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "reraise", (void **)&__pyx_vp_6gevent_6_event_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "dump_traceback", (void **)&__pyx_vp_6gevent_6_event_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "load_traceback", (void **)&__pyx_vp_6gevent_6_event_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "InvalidSwitchError", (void **)&__pyx_vp_6gevent_6_event_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "Timeout", (void **)&__pyx_vp_6gevent_6_event_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_7, "_greenlet_imported", (void **)&__pyx_vp_6gevent_6_event__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_8 = __Pyx_ImportModule("gevent._queue"); if (!__pyx_t_8) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_8, "_heappush", (void **)&__pyx_vp_6gevent_6_queue__heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_8, "_heappop", (void **)&__pyx_vp_6gevent_6_queue__heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_8, "_heapify", (void **)&__pyx_vp_6gevent_6_queue__heapify, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__imap(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__imap(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___imap(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___imap(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___imap(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___imap(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__imap", __pyx_methods, __pyx_k_Iterators_across_greenlets_or_A, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____imap) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__imap")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__imap", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- (void)__Pyx_modinit_variable_export_code();
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_imap.py":14
- *
- *
- * from gevent import _semaphore # <<<<<<<<<<<<<<
- * from gevent import queue
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_semaphore);
- __Pyx_GIVEREF(__pyx_n_s_semaphore);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_semaphore);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_semaphore); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_semaphore, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":15
- *
- * from gevent import _semaphore
- * from gevent import queue # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_queue);
- __Pyx_GIVEREF(__pyx_n_s_queue);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_queue);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_queue); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_queue, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":18
- *
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'IMapUnordered',
- * 'IMap',
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_IMapUnordered);
- __Pyx_GIVEREF(__pyx_n_s_IMapUnordered);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_IMapUnordered);
- __Pyx_INCREF(__pyx_n_s_IMap);
- __Pyx_GIVEREF(__pyx_n_s_IMap);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_IMap);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":23
- * ]
- *
- * locals()['Greenlet'] = __import__('gevent').Greenlet # <<<<<<<<<<<<<<
- * locals()['Semaphore'] = _semaphore.Semaphore
- * locals()['UnboundQueue'] = queue.UnboundQueue
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_Greenlet, __pyx_t_2) < 0)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":24
- *
- * locals()['Greenlet'] = __import__('gevent').Greenlet
- * locals()['Semaphore'] = _semaphore.Semaphore # <<<<<<<<<<<<<<
- * locals()['UnboundQueue'] = queue.UnboundQueue
- *
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_semaphore); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Semaphore); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_Semaphore, __pyx_t_1) < 0)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":25
- * locals()['Greenlet'] = __import__('gevent').Greenlet
- * locals()['Semaphore'] = _semaphore.Semaphore
- * locals()['UnboundQueue'] = queue.UnboundQueue # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_queue); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UnboundQueue); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_UnboundQueue, __pyx_t_2) < 0)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":29
- *
- * class Failure(object):
- * __slots__ = ('exc', 'raise_exception') # <<<<<<<<<<<<<<
- *
- * def __init__(self, exc, raise_exception=None):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6__imap_Failure->tp_dict, __pyx_n_s_slots, __pyx_tuple__2) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6__imap_Failure);
-
- /* "src/gevent/_imap.py":110
- * return value
- *
- * next = __next__ # Py2 # <<<<<<<<<<<<<<
- *
- * def _inext(self):
- */
- __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_6__imap_IMapUnordered, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6__imap_IMapUnordered->tp_dict, __pyx_n_s_next_2, __pyx_t_2) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6__imap_IMapUnordered);
-
- /* "src/gevent/_imap.py":124
- * return g
- *
- * def _run(self): # pylint:disable=method-hidden # <<<<<<<<<<<<<<
- * try:
- * func = self.func
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6__imap_13IMapUnordered_7_run, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IMapUnordered__run, NULL, __pyx_n_s_gevent___imap, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6__imap_IMapUnordered->tp_dict, __pyx_n_s_run, __pyx_t_2) < 0) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6__imap_IMapUnordered);
-
- /* "src/gevent/_imap.py":140
- * self._result_semaphore = None
- *
- * def _on_result(self, greenlet): # <<<<<<<<<<<<<<
- * # This method will be called in the hub greenlet (we rawlink)
- * self._outstanding_tasks -= 1
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6__imap_13IMapUnordered_9_on_result, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IMapUnordered__on_result, NULL, __pyx_n_s_gevent___imap, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6__imap_IMapUnordered->tp_dict, __pyx_n_s_on_result, __pyx_t_2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6__imap_IMapUnordered);
-
- /* "src/gevent/_imap.py":226
- * return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_failure(self, exception))
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__imap')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_imap.py":227
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__imap') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___imap);
- __Pyx_GIVEREF(__pyx_n_s_gevent___imap);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___imap);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_imap.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # Copyright (c) 2018 gevent
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__imap", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__imap");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* UnpackUnboundCMethod */
- static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod2 */
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
- if (likely(cfunc->func)) {
- PyObject *args[2] = {arg1, arg2};
- if (cfunc->flag == METH_FASTCALL) {
- #if PY_VERSION_HEX >= 0x030700A0
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
- #else
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- #if PY_VERSION_HEX >= 0x030700A0
- if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(3);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 1, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 2, arg2);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(3, self, arg1, arg2);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* CallUnboundCMethod1 */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
- if (likely(cfunc->func)) {
- int flag = cfunc->flag;
- if (flag == METH_O) {
- return (*(cfunc->func))(self, arg);
- } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
- if (PY_VERSION_HEX >= 0x030700A0) {
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
- } else {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- }
- return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(2, self, arg);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* py_dict_pop */
- static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
- if ((1)) {
- return _PyDict_Pop(d, key, default_value);
- } else
-#endif
- if (default_value) {
- return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
- } else {
- return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
- }
-}
-
-/* RaiseTooManyValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* None */
- static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
- PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
-}
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_imap.py b/python/gevent/_imap.py
deleted file mode 100644
index e976b67..0000000
--- a/python/gevent/_imap.py
+++ /dev/null
@@ -1,227 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2018 gevent
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
-
-"""
-Iterators across greenlets or AsyncResult objects.
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-from gevent import _semaphore
-from gevent import queue
-
-
-__all__ = [
- 'IMapUnordered',
- 'IMap',
-]
-
-locals()['Greenlet'] = __import__('gevent').Greenlet
-locals()['Semaphore'] = _semaphore.Semaphore
-locals()['UnboundQueue'] = queue.UnboundQueue
-
-
-class Failure(object):
- __slots__ = ('exc', 'raise_exception')
-
- def __init__(self, exc, raise_exception=None):
- self.exc = exc
- self.raise_exception = raise_exception
-
-
-def _raise_exc(failure):
- # For cython.
- if failure.raise_exception:
- failure.raise_exception()
- else:
- raise failure.exc
-
-class IMapUnordered(Greenlet): # pylint:disable=undefined-variable
- """
- At iterator of map results.
- """
-
- def __init__(self, func, iterable, spawn, maxsize=None, _zipped=False):
- """
- An iterator that.
-
- :param callable spawn: The function we use to create new greenlets.
- :keyword int maxsize: If given and not-None, specifies the maximum number of
- finished results that will be allowed to accumulated awaiting the reader;
- more than that number of results will cause map function greenlets to begin
- to block. This is most useful is there is a great disparity in the speed of
- the mapping code and the consumer and the results consume a great deal of resources.
- Using a bound is more computationally expensive than not using a bound.
-
- .. versionchanged:: 1.1b3
- Added the *maxsize* parameter.
- """
- Greenlet.__init__(self) # pylint:disable=undefined-variable
- self.spawn = spawn
- self._zipped = _zipped
- self.func = func
- self.iterable = iterable
- self.queue = UnboundQueue() # pylint:disable=undefined-variable
-
-
- if maxsize:
- # Bounding the queue is not enough if we want to keep from
- # accumulating objects; the result value will be around as
- # the greenlet's result, blocked on self.queue.put(), and
- # we'll go on to spawn another greenlet, which in turn can
- # create the result. So we need a semaphore to prevent a
- # greenlet from exiting while the queue is full so that we
- # don't spawn the next greenlet (assuming that self.spawn
- # is of course bounded). (Alternatively we could have the
- # greenlet itself do the insert into the pool, but that
- # takes some rework).
- #
- # Given the use of a semaphore at this level, sizing the queue becomes
- # redundant, and that lets us avoid having to use self.link() instead
- # of self.rawlink() to avoid having blocking methods called in the
- # hub greenlet.
- self._result_semaphore = Semaphore(maxsize) # pylint:disable=undefined-variable
- else:
- self._result_semaphore = None
-
- self._outstanding_tasks = 0
- # The index (zero based) of the maximum number of
- # results we will have.
- self._max_index = -1
- self.finished = False
-
-
- # We're iterating in a different greenlet than we're running.
- def __iter__(self):
- return self
-
- def __next__(self):
- if self._result_semaphore is not None:
- self._result_semaphore.release()
- value = self._inext()
- if isinstance(value, Failure):
- _raise_exc(value)
- return value
-
- next = __next__ # Py2
-
- def _inext(self):
- return self.queue.get()
-
- def _ispawn(self, func, item, item_index):
- if self._result_semaphore is not None:
- self._result_semaphore.acquire()
- self._outstanding_tasks += 1
- g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item)
- g._imap_task_index = item_index
- g.rawlink(self._on_result)
- return g
-
- def _run(self): # pylint:disable=method-hidden
- try:
- func = self.func
- for item in self.iterable:
- self._max_index += 1
- self._ispawn(func, item, self._max_index)
- self._on_finish(None)
- except BaseException as e:
- self._on_finish(e)
- raise
- finally:
- self.spawn = None
- self.func = None
- self.iterable = None
- self._result_semaphore = None
-
- def _on_result(self, greenlet):
- # This method will be called in the hub greenlet (we rawlink)
- self._outstanding_tasks -= 1
- count = self._outstanding_tasks
- finished = self.finished
- ready = self.ready()
- put_finished = False
-
- if ready and count <= 0 and not finished:
- finished = self.finished = True
- put_finished = True
-
- if greenlet.successful():
- self.queue.put(self._iqueue_value_for_success(greenlet))
- else:
- self.queue.put(self._iqueue_value_for_failure(greenlet))
-
- if put_finished:
- self.queue.put(self._iqueue_value_for_self_finished())
-
- def _on_finish(self, exception):
- # Called in this greenlet.
- if self.finished:
- return
-
- if exception is not None:
- self.finished = True
- self.queue.put(self._iqueue_value_for_self_failure(exception))
- return
-
- if self._outstanding_tasks <= 0:
- self.finished = True
- self.queue.put(self._iqueue_value_for_self_finished())
-
- def _iqueue_value_for_success(self, greenlet):
- return greenlet.value
-
- def _iqueue_value_for_failure(self, greenlet):
- return Failure(greenlet.exception, getattr(greenlet, '_raise_exception'))
-
- def _iqueue_value_for_self_finished(self):
- return Failure(StopIteration())
-
- def _iqueue_value_for_self_failure(self, exception):
- return Failure(exception, self._raise_exception)
-
-
-class IMap(IMapUnordered):
- # A specialization of IMapUnordered that returns items
- # in the order in which they were generated, not
- # the order in which they finish.
-
- def __init__(self, *args, **kwargs):
- # The result dictionary: {index: value}
- self._results = {}
-
- # The index of the result to return next.
- self.index = 0
- IMapUnordered.__init__(self, *args, **kwargs)
-
- def _inext(self):
- try:
- value = self._results.pop(self.index)
- except KeyError:
- # Wait for our index to finish.
- while 1:
- index, value = self.queue.get()
- if index == self.index:
- break
- else:
- self._results[index] = value
- self.index += 1
- return value
-
- def _iqueue_value_for_success(self, greenlet):
- return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_success(self, greenlet))
-
- def _iqueue_value_for_failure(self, greenlet):
- return (greenlet._imap_task_index, IMapUnordered._iqueue_value_for_failure(self, greenlet))
-
- def _iqueue_value_for_self_finished(self):
- return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_finished(self))
-
- def _iqueue_value_for_self_failure(self, exception):
- return (self._max_index + 1, IMapUnordered._iqueue_value_for_self_failure(self, exception))
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__imap')
diff --git a/python/gevent/_interfaces.py b/python/gevent/_interfaces.py
deleted file mode 100644
index 099a6e2..0000000
--- a/python/gevent/_interfaces.py
+++ /dev/null
@@ -1,220 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2018 gevent contributors. See LICENSE for details.
-"""
-Interfaces gevent uses that don't belong any one place.
-
-This is not a public module, these interfaces are not
-currently exposed to the public, they mostly exist for
-documentation and testing purposes.
-
-.. versionadded:: 1.3b2
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-from gevent._util import Interface
-from gevent._util import Attribute
-
-# pylint:disable=no-method-argument, unused-argument, no-self-argument
-
-__all__ = [
- 'ILoop',
- 'IWatcher',
-]
-
-class ILoop(Interface):
- """
- The common interface expected for all event loops.
-
- .. caution::
- This is an internal, low-level interface. It may change
- between minor versions of gevent.
-
- .. rubric:: Watchers
-
- The methods that create event loop watchers are `io`, `timer`,
- `signal`, `idle`, `prepare`, `check`, `fork`, `async_`, `child`,
- `stat`. These all return various types of :class:`IWatcher`.
-
- All of those methods have one or two common arguments. *ref* is a
- boolean saying whether the event loop is allowed to exit even if
- this watcher is still started. *priority* is event loop specific.
- """
-
- default = Attribute("Boolean indicating whether this is the default loop")
-
- def run(nowait=False, once=False):
- """
- Run the event loop.
-
- This is usually called automatically by the hub greenlet, but
- in special cases (when the hub is *not* running) you can use
- this to control how the event loop runs (for example, to integrate
- it with another event loop).
- """
-
- def now():
- """
- now() -> float
-
- Return the loop's notion of the current time.
-
- This may not necessarily be related to :func:`time.time` (it
- may have a different starting point), but it must be expressed
- in fractional seconds (the same *units* used by :func:`time.time`).
- """
-
- def update_now():
- """
- Update the loop's notion of the current time.
-
- .. versionadded:: 1.3
- In the past, this available as ``update``. This is still available as
- an alias but will be removed in the future.
- """
-
- def destroy():
- """
- Clean up resources used by this loop.
-
- If you create loops
- (especially loops that are not the default) you *should* call
- this method when you are done with the loop.
-
- .. caution::
-
- As an implementation note, the libev C loop implementation has a
- finalizer (``__del__``) that destroys the object, but the libuv
- and libev CFFI implementations do not. The C implementation may change.
-
- """
-
- def io(fd, events, ref=True, priority=None):
- """
- Create and return a new IO watcher for the given *fd*.
-
- *events* is a bitmask specifying which events to watch
- for. 1 means read, and 2 means write.
- """
-
- def timer(after, repeat=0.0, ref=True, priority=None):
- """
- Create and return a timer watcher that will fire after *after* seconds.
-
- If *repeat* is given, the timer will continue to fire every *repeat* seconds.
- """
-
- def signal(signum, ref=True, priority=None):
- """
- Create and return a signal watcher for the signal *signum*,
- one of the constants defined in :mod:`signal`.
-
- This is platform and event loop specific.
- """
-
- def idle(ref=True, priority=None):
- """
- Create and return a watcher that fires when the event loop is idle.
- """
-
- def prepare(ref=True, priority=None):
- """
- Create and return a watcher that fires before the event loop
- polls for IO.
-
- .. caution:: This method is not supported by libuv.
- """
-
- def check(ref=True, priority=None):
- """
- Create and return a watcher that fires after the event loop
- polls for IO.
- """
-
- def fork(ref=True, priority=None):
- """
- Create a watcher that fires when the process forks.
-
- Availability: POSIX
- """
-
- def async_(ref=True, priority=None):
- """
- Create a watcher that fires when triggered, possibly
- from another thread.
-
- .. versionchanged:: 1.3
- This was previously just named ``async``; for compatibility
- with Python 3.7 where ``async`` is a keyword it was renamed.
- On older versions of Python the old name is still around, but
- it will be removed in the future.
- """
-
- def child(pid, trace=0, ref=True):
- """
- Create a watcher that fires for events on the child with process ID *pid*.
-
- This is platform specific.
- """
-
- def stat(path, interval=0.0, ref=True, priority=None):
- """
- Create a watcher that monitors the filesystem item at *path*.
-
- If the operating system doesn't support event notifications
- from the filesystem, poll for changes every *interval* seconds.
- """
-
- def run_callback(func, *args):
- """
- Run the *func* passing it *args* at the next opportune moment.
-
- This is a way of handing control to the event loop and deferring
- an action.
- """
-
-class IWatcher(Interface):
- """
- An event loop watcher.
-
- These objects call their *callback* function when the event
- loop detects the event has happened.
-
- .. important:: You *must* call :meth:`close` when you are
- done with this object to avoid leaking native resources.
- """
-
- def start(callback, *args, **kwargs):
- """
- Have the event loop begin watching for this event.
-
- When the event is detected, *callback* will be called with
- *args*.
-
- .. caution::
-
- Not all watchers accept ``**kwargs``,
- and some watchers define special meanings for certain keyword args.
- """
-
- def stop():
- """
- Have the event loop stop watching this event.
-
- In the future you may call :meth:`start` to begin watching
- again.
- """
-
- def close():
- """
- Dispose of any native resources associated with the watcher.
-
- If we were active, stop.
-
- Attempting to operate on this object after calling close is
- undefined. You should dispose of any references you have to it
- after calling this method.
- """
diff --git a/python/gevent/_local.cp36-win32.pyd b/python/gevent/_local.cp36-win32.pyd
deleted file mode 100644
index 1fa6947..0000000
--- a/python/gevent/_local.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/_local.pxd b/python/gevent/_local.pxd
deleted file mode 100644
index 331ce28..0000000
--- a/python/gevent/_local.pxd
+++ /dev/null
@@ -1,113 +0,0 @@
-# cython: auto_pickle=False
-
-cimport cython
-from gevent._greenlet cimport Greenlet
-
-cdef bint _PYPY
-cdef ref
-cdef copy
-
-cdef object _marker
-cdef str key_prefix
-cdef bint _greenlet_imported
-
-
-cdef extern from "greenlet/greenlet.h":
-
- ctypedef class greenlet.greenlet [object PyGreenlet]:
- pass
-
- # These are actually macros and so much be included
- # (defined) in each .pxd, as are the two functions
- # that call them.
- greenlet PyGreenlet_GetCurrent()
- void PyGreenlet_Import()
-
-cdef inline greenlet getcurrent():
- return PyGreenlet_GetCurrent()
-
-cdef inline void greenlet_init():
- global _greenlet_imported
- if not _greenlet_imported:
- PyGreenlet_Import()
- _greenlet_imported = True
-
-
-cdef void _init()
-
-@cython.final
-@cython.internal
-cdef class _wrefdict(dict):
- cdef object __weakref__
-
-@cython.final
-@cython.internal
-cdef class _greenlet_deleted:
- cdef object idt
- cdef object wrdicts
-
-
-@cython.final
-@cython.internal
-cdef class _local_deleted:
- cdef str key
- cdef object wrthread
- cdef _greenlet_deleted greenlet_deleted
-
-@cython.final
-@cython.internal
-cdef class _localimpl:
- cdef str key
- cdef dict dicts
- cdef tuple localargs
- cdef dict localkwargs
- cdef tuple localtypeid
- cdef object __weakref__
-
-
-@cython.final
-@cython.internal
-cdef class _localimpl_dict_entry:
- cdef object wrgreenlet
- cdef dict localdict
-
-@cython.locals(localdict=dict, key=str,
- greenlet_deleted=_greenlet_deleted,
- local_deleted=_local_deleted)
-cdef dict _localimpl_create_dict(_localimpl self,
- greenlet greenlet,
- object idt)
-
-cdef set _local_attrs
-
-cdef class local:
- cdef _localimpl _local__impl
- cdef set _local_type_get_descriptors
- cdef set _local_type_set_or_del_descriptors
- cdef set _local_type_del_descriptors
- cdef set _local_type_set_descriptors
- cdef set _local_type_vars
- cdef type _local_type
-
- @cython.locals(entry=_localimpl_dict_entry,
- dct=dict, duplicate=dict,
- instance=local)
- cpdef local __copy__(local self)
-
-
-@cython.locals(impl=_localimpl,dct=dict,
- dct=dict, entry=_localimpl_dict_entry)
-cdef inline dict _local_get_dict(local self)
-
-@cython.locals(entry=_localimpl_dict_entry)
-cdef _local__copy_dict_from(local self, _localimpl impl, dict duplicate)
-
-@cython.locals(mro=list, gets=set, dels=set, set_or_del=set,
- type_self=type, type_attr=type,
- sets=set)
-cdef tuple _local_find_descriptors(local self)
-
-@cython.locals(result=list, local_impl=_localimpl,
- entry=_localimpl_dict_entry, k=str,
- greenlet_dict=dict)
-cpdef all_local_dicts_for_greenlet(greenlet greenlet)
diff --git a/python/gevent/_monitor.py b/python/gevent/_monitor.py
deleted file mode 100644
index 2c4ef03..0000000
--- a/python/gevent/_monitor.py
+++ /dev/null
@@ -1,325 +0,0 @@
-# Copyright (c) 2018 gevent. See LICENSE for details.
-from __future__ import print_function, absolute_import, division
-
-import os
-import sys
-
-from weakref import ref as wref
-
-from greenlet import getcurrent
-
-from gevent import config as GEVENT_CONFIG
-from gevent.monkey import get_original
-from gevent.events import notify
-from gevent.events import EventLoopBlocked
-from gevent.events import MemoryUsageThresholdExceeded
-from gevent.events import MemoryUsageUnderThreshold
-from gevent.events import IPeriodicMonitorThread
-from gevent.events import implementer
-
-from gevent._tracer import GreenletTracer
-from gevent._compat import thread_mod_name
-from gevent._compat import perf_counter
-
-
-
-__all__ = [
- 'PeriodicMonitoringThread',
-]
-
-get_thread_ident = get_original(thread_mod_name, 'get_ident')
-start_new_thread = get_original(thread_mod_name, 'start_new_thread')
-thread_sleep = get_original('time', 'sleep')
-
-
-
-class MonitorWarning(RuntimeWarning):
- """The type of warnings we emit."""
-
-
-class _MonitorEntry(object):
-
- __slots__ = ('function', 'period', 'last_run_time')
-
- def __init__(self, function, period):
- self.function = function
- self.period = period
- self.last_run_time = 0
-
- def __eq__(self, other):
- return self.function == other.function and self.period == other.period
-
- def __repr__(self):
- return repr((self.function, self.period, self.last_run_time))
-
-
-@implementer(IPeriodicMonitorThread)
-class PeriodicMonitoringThread(object):
- # This doesn't extend threading.Thread because that gets monkey-patched.
- # We use the low-level 'start_new_thread' primitive instead.
-
- # The amount of seconds we will sleep when we think we have nothing
- # to do.
- inactive_sleep_time = 2.0
-
- # The absolute minimum we will sleep, regardless of
- # what particular monitoring functions want to say.
- min_sleep_time = 0.005
-
- # The minimum period in seconds at which we will check memory usage.
- # Getting memory usage is fairly expensive.
- min_memory_monitor_period = 2
-
- # A list of _MonitorEntry objects: [(function(hub), period, last_run_time))]
- # The first entry is always our entry for self.monitor_blocking
- _monitoring_functions = None
-
- # The calculated min sleep time for the monitoring functions list.
- _calculated_sleep_time = None
-
- # A boolean value that also happens to capture the
- # memory usage at the time we exceeded the threshold. Reset
- # to 0 when we go back below.
- _memory_exceeded = 0
-
- # The instance of GreenletTracer we're using
- _greenlet_tracer = None
-
- def __init__(self, hub):
- self._hub_wref = wref(hub, self._on_hub_gc)
- self.should_run = True
-
- # Must be installed in the thread that the hub is running in;
- # the trace function is threadlocal
- assert get_thread_ident() == hub.thread_ident
- self._greenlet_tracer = GreenletTracer()
-
- self._monitoring_functions = [_MonitorEntry(self.monitor_blocking,
- GEVENT_CONFIG.max_blocking_time)]
- self._calculated_sleep_time = GEVENT_CONFIG.max_blocking_time
- # Create the actual monitoring thread. This is effectively a "daemon"
- # thread.
- self.monitor_thread_ident = start_new_thread(self, ())
-
- # We must track the PID to know if your thread has died after a fork
- self.pid = os.getpid()
-
- def _on_fork(self):
- # Pseudo-standard method that resolver_ares and threadpool
- # also have, called by hub.reinit()
- pid = os.getpid()
- if pid != self.pid:
- self.pid = pid
- self.monitor_thread_ident = start_new_thread(self, ())
-
- @property
- def hub(self):
- return self._hub_wref()
-
-
- def monitoring_functions(self):
- # Return a list of _MonitorEntry objects
-
- # Update max_blocking_time each time.
- mbt = GEVENT_CONFIG.max_blocking_time # XXX: Events so we know when this changes.
- if mbt != self._monitoring_functions[0].period:
- self._monitoring_functions[0].period = mbt
- self._calculated_sleep_time = min(x.period for x in self._monitoring_functions)
- return self._monitoring_functions
-
- def add_monitoring_function(self, function, period):
- if not callable(function):
- raise ValueError("function must be callable")
-
- if period is None:
- # Remove.
- self._monitoring_functions = [
- x for x in self._monitoring_functions
- if x.function != function
- ]
- elif period <= 0:
- raise ValueError("Period must be positive.")
- else:
- # Add or update period
- entry = _MonitorEntry(function, period)
- self._monitoring_functions = [
- x if x.function != function else entry
- for x in self._monitoring_functions
- ]
- if entry not in self._monitoring_functions:
- self._monitoring_functions.append(entry)
- self._calculated_sleep_time = min(x.period for x in self._monitoring_functions)
-
- def calculate_sleep_time(self):
- min_sleep = self._calculated_sleep_time
- if min_sleep <= 0:
- # Everyone wants to be disabled. Sleep for a longer period of
- # time than usual so we don't spin unnecessarily. We might be
- # enabled again in the future.
- return self.inactive_sleep_time
- return max((min_sleep, self.min_sleep_time))
-
- def kill(self):
- if not self.should_run:
- # Prevent overwriting trace functions.
- return
- # Stop this monitoring thread from running.
- self.should_run = False
- # Uninstall our tracing hook
- self._greenlet_tracer.kill()
-
- def _on_hub_gc(self, _):
- self.kill()
-
- def __call__(self):
- # The function that runs in the monitoring thread.
- # We cannot use threading.current_thread because it would
- # create an immortal DummyThread object.
- getcurrent().gevent_monitoring_thread = wref(self)
-
- try:
- while self.should_run:
- functions = self.monitoring_functions()
- assert functions
- sleep_time = self.calculate_sleep_time()
-
- thread_sleep(sleep_time)
-
- # Make sure the hub is still around, and still active,
- # and keep it around while we are here.
- hub = self.hub
- if not hub:
- self.kill()
-
- if self.should_run:
- this_run = perf_counter()
- for entry in functions:
- f = entry.function
- period = entry.period
- last_run = entry.last_run_time
- if period and last_run + period <= this_run:
- entry.last_run_time = this_run
- f(hub)
- del hub # break our reference to hub while we sleep
-
- except SystemExit:
- pass
- except: # pylint:disable=bare-except
- # We're a daemon thread, so swallow any exceptions that get here
- # during interpreter shutdown.
- if not sys or not sys.stderr: # pragma: no cover
- # Interpreter is shutting down
- pass
- else:
- hub = self.hub
- if hub is not None:
- # XXX: This tends to do bad things like end the process, because we
- # try to switch *threads*, which can't happen. Need something better.
- hub.handle_error(self, *sys.exc_info())
-
- def monitor_blocking(self, hub):
- # Called periodically to see if the trace function has
- # fired to switch greenlets. If not, we will print
- # the greenlet tree.
-
- # For tests, we return a true value when we think we found something
- # blocking
-
- did_block = self._greenlet_tracer.did_block_hub(hub)
- if not did_block:
- return
-
- active_greenlet = did_block[1]
- report = self._greenlet_tracer.did_block_hub_report(
- hub, active_greenlet,
- dict(greenlet_stacks=False, current_thread_ident=self.monitor_thread_ident))
-
- stream = hub.exception_stream
- for line in report:
- # Printing line by line may interleave with other things,
- # but it should also prevent a "reentrant call to print"
- # when the report is large.
- print(line, file=stream)
-
- notify(EventLoopBlocked(active_greenlet, GEVENT_CONFIG.max_blocking_time, report))
- return (active_greenlet, report)
-
- def ignore_current_greenlet_blocking(self):
- self._greenlet_tracer.ignore_current_greenlet_blocking()
-
- def monitor_current_greenlet_blocking(self):
- self._greenlet_tracer.monitor_current_greenlet_blocking()
-
- def _get_process(self): # pylint:disable=method-hidden
- try:
- # The standard library 'resource' module doesn't provide
- # a standard way to get the RSS measure, only the maximum.
- # You might be tempted to try to compute something by adding
- # together text and data sizes, but on many systems those come back
- # zero. So our only option is psutil.
- from psutil import Process, AccessDenied
- # Make sure it works (why would we be denied access to our own process?)
- try:
- proc = Process()
- proc.memory_full_info()
- except AccessDenied: # pragma: no cover
- proc = None
- except ImportError:
- proc = None
-
- self._get_process = lambda: proc
- return proc
-
- def can_monitor_memory_usage(self):
- return self._get_process() is not None
-
- def install_monitor_memory_usage(self):
- # Start monitoring memory usage, if possible.
- # If not possible, emit a warning.
- if not self.can_monitor_memory_usage():
- import warnings
- warnings.warn("Unable to monitor memory usage. Install psutil.",
- MonitorWarning)
- return
-
- self.add_monitoring_function(self.monitor_memory_usage,
- max(GEVENT_CONFIG.memory_monitor_period,
- self.min_memory_monitor_period))
-
- def monitor_memory_usage(self, _hub):
- max_allowed = GEVENT_CONFIG.max_memory_usage
- if not max_allowed:
- # They disabled it.
- return -1 # value for tests
-
- rusage = self._get_process().memory_full_info()
- # uss only documented available on Windows, Linux, and OS X.
- # If not available, fall back to rss as an aproximation.
- mem_usage = getattr(rusage, 'uss', 0) or rusage.rss
-
- event = None # Return value for tests
-
- if mem_usage > max_allowed:
- if mem_usage > self._memory_exceeded:
- # We're still growing
- event = MemoryUsageThresholdExceeded(
- mem_usage, max_allowed, rusage)
- notify(event)
- self._memory_exceeded = mem_usage
- else:
- # we're below. Were we above it last time?
- if self._memory_exceeded:
- event = MemoryUsageUnderThreshold(
- mem_usage, max_allowed, rusage, self._memory_exceeded)
- notify(event)
- self._memory_exceeded = 0
-
- return event
-
- def __repr__(self):
- return '<%s at %s in thread %s greenlet %r for %r>' % (
- self.__class__.__name__,
- hex(id(self)),
- hex(self.monitor_thread_ident),
- getcurrent(),
- self._hub_wref())
diff --git a/python/gevent/_patcher.py b/python/gevent/_patcher.py
deleted file mode 100644
index 2ced50c..0000000
--- a/python/gevent/_patcher.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# Copyright 2018 gevent. See LICENSE for details.
-
-# Portions of the following are inspired by code from eventlet. I
-# believe they are distinct enough that no eventlet copyright would
-# apply (they are not a copy or substantial portion of the eventlot
-# code).
-
-# Added in gevent 1.3a2. Not public in that release.
-
-from __future__ import absolute_import, print_function
-
-import importlib
-import sys
-
-from gevent._compat import PY3
-from gevent._compat import iteritems
-from gevent._compat import imp_acquire_lock
-from gevent._compat import imp_release_lock
-
-
-from gevent.builtins import __import__ as _import
-
-
-MAPPING = {
- 'gevent.local': '_threading_local',
- 'gevent.socket': 'socket',
- 'gevent.select': 'select',
- 'gevent.ssl': 'ssl',
- 'gevent.thread': '_thread' if PY3 else 'thread',
- 'gevent.subprocess': 'subprocess',
- 'gevent.os': 'os',
- 'gevent.threading': 'threading',
- 'gevent.builtins': 'builtins' if PY3 else '__builtin__',
- 'gevent.signal': 'signal',
- 'gevent.time': 'time',
- 'gevent.queue': 'queue' if PY3 else 'Queue',
-}
-
-_PATCH_PREFIX = '__g_patched_module_'
-
-class _SysModulesPatcher(object):
-
- def __init__(self, importing):
- self._saved = {}
- self.importing = importing
- self.green_modules = {
- stdlib_name: importlib.import_module(gevent_name)
- for gevent_name, stdlib_name
- in iteritems(MAPPING)
- }
- self.orig_imported = frozenset(sys.modules)
-
- def _save(self):
- for modname in self.green_modules:
- self._saved[modname] = sys.modules.get(modname, None)
-
- self._saved[self.importing] = sys.modules.get(self.importing, None)
- # Anything we've already patched regains its original name during this
- # process
- for mod_name, mod in iteritems(sys.modules):
- if mod_name.startswith(_PATCH_PREFIX):
- orig_mod_name = mod_name[len(_PATCH_PREFIX):]
- self._saved[mod_name] = sys.modules.get(orig_mod_name, None)
- self.green_modules[orig_mod_name] = mod
-
- def _replace(self):
- # Cover the target modules so that when you import the module it
- # sees only the patched versions
- for name, mod in iteritems(self.green_modules):
- sys.modules[name] = mod
-
- def _restore(self):
- for modname, mod in iteritems(self._saved):
- if mod is not None:
- sys.modules[modname] = mod
- else:
- try:
- del sys.modules[modname]
- except KeyError:
- pass
- # Anything from the same package tree we imported this time
- # needs to be saved so we can restore it later, and so it doesn't
- # leak into the namespace.
- pkg_prefix = self.importing.split('.', 1)[0]
- for modname, mod in list(iteritems(sys.modules)):
- if (modname not in self.orig_imported
- and modname != self.importing
- and not modname.startswith(_PATCH_PREFIX)
- and modname.startswith(pkg_prefix)):
- sys.modules[_PATCH_PREFIX + modname] = mod
- del sys.modules[modname]
-
- def __exit__(self, t, v, tb):
- try:
- self._restore()
- finally:
- imp_release_lock()
-
- def __enter__(self):
- imp_acquire_lock()
- self._save()
- self._replace()
-
-
-def import_patched(module_name):
- """
- Import *module_name* with gevent monkey-patches active,
- and return the greened module.
-
- Any sub-modules that were imported by the package are also
- saved.
-
- """
- patched_name = _PATCH_PREFIX + module_name
- if patched_name in sys.modules:
- return sys.modules[patched_name]
-
-
- # Save the current module state, and restore on exit,
- # capturing desirable changes in the modules package.
- with _SysModulesPatcher(module_name):
- sys.modules.pop(module_name, None)
-
- module = _import(module_name, {}, {}, module_name.split('.')[:-1])
- sys.modules[patched_name] = module
-
- return module
diff --git a/python/gevent/_queue.cp36-win32.pyd b/python/gevent/_queue.cp36-win32.pyd
deleted file mode 100644
index f346273..0000000
--- a/python/gevent/_queue.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/_queue.pxd b/python/gevent/_queue.pxd
deleted file mode 100644
index d4d9da7..0000000
--- a/python/gevent/_queue.pxd
+++ /dev/null
@@ -1,74 +0,0 @@
-cimport cython
-from gevent.__waiter cimport Waiter
-from gevent._event cimport Event
-
-cdef _heappush
-cdef _heappop
-cdef _heapify
-
-@cython.final
-cdef _safe_remove(deq, item)
-
-@cython.final
-@cython.internal
-cdef class ItemWaiter(Waiter):
- cdef readonly item
- cdef readonly queue
-
-cdef class Queue:
- cdef __weakref__
- cdef readonly hub
- cdef readonly queue
-
- cdef getters
- cdef putters
-
- cdef _event_unlock
- cdef Py_ssize_t _maxsize
-
- cpdef _get(self)
- cpdef _put(self, item)
- cpdef _peek(self)
-
- cpdef Py_ssize_t qsize(self)
- cpdef bint empty(self)
- cpdef bint full(self)
-
- cpdef put(self, item, block=*, timeout=*)
- cpdef put_nowait(self, item)
-
- cdef __get_or_peek(self, method, block, timeout)
-
- cpdef get(self, block=*, timeout=*)
- cpdef get_nowait(self)
- cpdef peek(self, block=*, timeout=*)
- cpdef peek_nowait(self)
-
- cdef _schedule_unlock(self)
-
-@cython.final
-cdef class UnboundQueue(Queue):
- pass
-
-cdef class PriorityQueue(Queue):
- pass
-
-cdef class LifoQueue(Queue):
- pass
-
-cdef class JoinableQueue(Queue):
- cdef Event _cond
- cdef readonly int unfinished_tasks
-
-
-cdef class Channel:
- cdef __weakref__
- cdef readonly getters
- cdef readonly putters
- cdef readonly hub
- cdef _event_unlock
-
- cpdef get(self, block=*, timeout=*)
- cpdef get_nowait(self)
-
- cdef _schedule_unlock(self)
diff --git a/python/gevent/_semaphore.c b/python/gevent/_semaphore.c
deleted file mode 100644
index 54b9cc2..0000000
--- a/python/gevent/_semaphore.c
+++ /dev/null
@@ -1,10292 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__semaphore.pxd",
- "src\\gevent\\__semaphore.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__semaphore",
- "sources": [
- "src/gevent/_semaphore.py"
- ]
- },
- "module_name": "gevent.__semaphore"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____semaphore
-#define __PYX_HAVE_API__gevent____semaphore
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_semaphore.py",
- "src\\gevent\\__semaphore.pxd",
- "src\\gevent\\__greenlet_primitives.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_11__semaphore_Semaphore;
-struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore;
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait;
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire;
-
-/* "gevent/__semaphore.pxd":46
- * cpdef _notify_links(self)
- * cdef _do_wait(self, object timeout)
- * cpdef int wait(self, object timeout=*) except -1000 # <<<<<<<<<<<<<<
- * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000
- * cpdef __enter__(self)
- */
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/__semaphore.pxd":47
- * cdef _do_wait(self, object timeout)
- * cpdef int wait(self, object timeout=*) except -1000
- * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 # <<<<<<<<<<<<<<
- * cpdef __enter__(self)
- * cpdef __exit__(self, object t, object v, object tb)
- */
-struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire {
- int __pyx_n;
- int blocking;
- PyObject *timeout;
-};
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__semaphore.pxd":32
- *
- *
- * cdef class Semaphore: # <<<<<<<<<<<<<<
- * cdef public int counter
- * cdef readonly list _links
- */
-struct __pyx_obj_6gevent_11__semaphore_Semaphore {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *__pyx_vtab;
- int counter;
- PyObject *_links;
- PyObject *_notifier;
- int _dirty;
- PyObject *__weakref__;
-};
-
-
-/* "gevent/__semaphore.pxd":51
- * cpdef __exit__(self, object t, object v, object tb)
- *
- * cdef class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<<
- * cdef readonly int _initial_value
- *
- */
-struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore {
- struct __pyx_obj_6gevent_11__semaphore_Semaphore __pyx_base;
- int _initial_value;
-};
-
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "src/gevent/_semaphore.py":21
- * locals()['get_hub'] = __import__('gevent').get_hub
- *
- * class Semaphore(object): # <<<<<<<<<<<<<<
- * """
- * Semaphore(value=1) -> Semaphore
- */
-
-struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore {
- int (*locked)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- int (*release)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*unlink)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_start_notify)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*_do_wait)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *);
- int (*wait)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args);
- int (*acquire)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args);
- PyObject *(*__pyx___enter__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
- PyObject *(*__pyx___exit__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *__pyx_vtabptr_6gevent_11__semaphore_Semaphore;
-
-
-/* "src/gevent/_semaphore.py":259
- *
- *
- * class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<<
- * """
- * BoundedSemaphore(value=1) -> BoundedSemaphore
- */
-
-struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore {
- struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore *__pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* CallableCheck.proto */
-#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
-#else
-#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
-#endif
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args); /* proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__semaphore' */
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_Semaphore = 0;
-static PyTypeObject *__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore = 0;
-static PyObject *__pyx_v_6gevent_11__semaphore_Timeout = 0;
-static int __pyx_v_6gevent_11__semaphore__greenlet_imported;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_11__semaphore_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_11__semaphore_greenlet_init(void); /*proto*/
-static void __pyx_f_6gevent_11__semaphore__init(void); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__semaphore"
-extern int __pyx_module_is_main_gevent____semaphore;
-int __pyx_module_is_main_gevent____semaphore = 0;
-
-/* Implementation of 'gevent.__semaphore' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_AttributeError;
-static const char __pyx_k_t[] = "t";
-static const char __pyx_k_v[] = "v";
-static const char __pyx_k_tb[] = "tb";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_exit[] = "__exit__";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wait[] = "wait";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_enter[] = "__enter__";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_cancel[] = "cancel";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_locked[] = "locked";
-static const char __pyx_k_remove[] = "remove";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_unlink[] = "unlink";
-static const char __pyx_k_Timeout[] = "Timeout";
-static const char __pyx_k_acquire[] = "acquire";
-static const char __pyx_k_get_hub[] = "get_hub";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_release[] = "release";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_blocking[] = "blocking";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_Semaphore[] = "Semaphore";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_notify_links[] = "_notify_links";
-static const char __pyx_k_py3k_acquire[] = "_py3k_acquire";
-static const char __pyx_k_run_callback[] = "run_callback";
-static const char __pyx_k_start_notify[] = "_start_notify";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_AttributeError[] = "AttributeError";
-static const char __pyx_k_Semaphore_wait[] = "Semaphore.wait";
-static const char __pyx_k_gevent_timeout[] = "gevent.timeout";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_BoundedSemaphore[] = "BoundedSemaphore";
-static const char __pyx_k_Semaphore___exit[] = "Semaphore.__exit__";
-static const char __pyx_k_Semaphore_locked[] = "Semaphore.locked";
-static const char __pyx_k_Semaphore_unlink[] = "Semaphore.unlink";
-static const char __pyx_k_Expected_callable[] = "Expected callable:";
-static const char __pyx_k_Semaphore___enter[] = "Semaphore.__enter__";
-static const char __pyx_k_Semaphore_acquire[] = "Semaphore.acquire";
-static const char __pyx_k_Semaphore_rawlink[] = "Semaphore.rawlink";
-static const char __pyx_k_Semaphore_release[] = "Semaphore.release";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_OVER_RELEASE_ERROR[] = "_OVER_RELEASE_ERROR";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_gevent___semaphore[] = "gevent.__semaphore";
-static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy";
-static const char __pyx_k_s_counter_s__links_s[] = "<%s counter=%s _links[%s]>";
-static const char __pyx_k_Semaphore__notify_links[] = "Semaphore._notify_links";
-static const char __pyx_k_Semaphore__start_notify[] = "Semaphore._start_notify";
-static const char __pyx_k_BoundedSemaphore_release[] = "BoundedSemaphore.release";
-static const char __pyx_k_src_gevent__semaphore_py[] = "src\\gevent\\_semaphore.py";
-static const char __pyx_k_semaphore_initial_value_must_be[] = "semaphore initial value must be >= 0";
-static const char __pyx_k_Invalid_switch_into_Semaphore_wa[] = "Invalid switch into Semaphore.wait/acquire(): %r";
-static const char __pyx_k_Semaphore_released_too_many_time[] = "Semaphore released too many times";
-static PyObject *__pyx_n_s_AttributeError;
-static PyObject *__pyx_n_s_BoundedSemaphore;
-static PyObject *__pyx_n_s_BoundedSemaphore_release;
-static PyObject *__pyx_kp_s_Expected_callable;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Semaphore_wa;
-static PyObject *__pyx_n_s_OVER_RELEASE_ERROR;
-static PyObject *__pyx_n_s_Semaphore;
-static PyObject *__pyx_n_s_Semaphore___enter;
-static PyObject *__pyx_n_s_Semaphore___exit;
-static PyObject *__pyx_n_s_Semaphore__notify_links;
-static PyObject *__pyx_n_s_Semaphore__start_notify;
-static PyObject *__pyx_n_s_Semaphore_acquire;
-static PyObject *__pyx_n_s_Semaphore_locked;
-static PyObject *__pyx_n_s_Semaphore_rawlink;
-static PyObject *__pyx_n_s_Semaphore_release;
-static PyObject *__pyx_kp_s_Semaphore_released_too_many_time;
-static PyObject *__pyx_n_s_Semaphore_unlink;
-static PyObject *__pyx_n_s_Semaphore_wait;
-static PyObject *__pyx_n_s_Timeout;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_n_s_acquire;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_blocking;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_n_s_cancel;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_enter;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_exit;
-static PyObject *__pyx_n_s_get_hub;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_n_s_gevent___semaphore;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_timeout;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_locked;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_notify_links;
-static PyObject *__pyx_n_s_py3k_acquire;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_release;
-static PyObject *__pyx_n_s_remove;
-static PyObject *__pyx_n_s_run_callback;
-static PyObject *__pyx_kp_s_s_counter_s__links_s;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_kp_s_semaphore_initial_value_must_be;
-static PyObject *__pyx_kp_s_src_gevent__semaphore_py;
-static PyObject *__pyx_n_s_start_new_or_dummy;
-static PyObject *__pyx_n_s_start_notify;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_t;
-static PyObject *__pyx_n_s_tb;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_unlink;
-static PyObject *__pyx_n_s_v;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_wait;
-static PyObject *__pyx_lambda_funcdef_6gevent_11__semaphore_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_11__semaphore_Semaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_11__semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_tuple__25;
-static PyObject *__pyx_codeobj__6;
-static PyObject *__pyx_codeobj__8;
-static PyObject *__pyx_codeobj__10;
-static PyObject *__pyx_codeobj__12;
-static PyObject *__pyx_codeobj__14;
-static PyObject *__pyx_codeobj__16;
-static PyObject *__pyx_codeobj__18;
-static PyObject *__pyx_codeobj__20;
-static PyObject *__pyx_codeobj__22;
-static PyObject *__pyx_codeobj__24;
-static PyObject *__pyx_codeobj__26;
-/* Late includes */
-
-/* "src/gevent/_semaphore.py":18
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['get_hub'] = __import__('gevent').get_hub
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_11__semaphore_lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_11__semaphore_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_11__semaphore_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_11__semaphore_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":41
- * """
- *
- * def __init__(self, value=1): # <<<<<<<<<<<<<<
- * if value < 0:
- * raise ValueError("semaphore initial value must be >= 0")
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_value = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)__pyx_int_1);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 41, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_value = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 41, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore___init__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_value);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_semaphore.py":42
- *
- * def __init__(self, value=1):
- * if value < 0: # <<<<<<<<<<<<<<
- * raise ValueError("semaphore initial value must be >= 0")
- * self.counter = value
- */
- __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/_semaphore.py":43
- * def __init__(self, value=1):
- * if value < 0:
- * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<<
- * self.counter = value
- * self._dirty = False
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 43, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":42
- *
- * def __init__(self, value=1):
- * if value < 0: # <<<<<<<<<<<<<<
- * raise ValueError("semaphore initial value must be >= 0")
- * self.counter = value
- */
- }
-
- /* "src/gevent/_semaphore.py":44
- * if value < 0:
- * raise ValueError("semaphore initial value must be >= 0")
- * self.counter = value # <<<<<<<<<<<<<<
- * self._dirty = False
- * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef
- */
- __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error)
- __pyx_v_self->counter = __pyx_t_3;
-
- /* "src/gevent/_semaphore.py":45
- * raise ValueError("semaphore initial value must be >= 0")
- * self.counter = value
- * self._dirty = False # <<<<<<<<<<<<<<
- * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef
- * # readonly` or simply `cdef` attributes of type `object` can appear to leak if
- */
- __pyx_v_self->_dirty = 0;
-
- /* "src/gevent/_semaphore.py":59
- * # CPython ("No attribute...")
- * # See https://github.com/gevent/gevent/issues/660
- * self._links = None # <<<<<<<<<<<<<<
- * self._notifier = None
- * # we don't want to do get_hub() here to allow defining module-level locks
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_links);
- __Pyx_DECREF(__pyx_v_self->_links);
- __pyx_v_self->_links = ((PyObject*)Py_None);
-
- /* "src/gevent/_semaphore.py":60
- * # See https://github.com/gevent/gevent/issues/660
- * self._links = None
- * self._notifier = None # <<<<<<<<<<<<<<
- * # we don't want to do get_hub() here to allow defining module-level locks
- * # without initializing the hub
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
-
- /* "src/gevent/_semaphore.py":41
- * """
- *
- * def __init__(self, value=1): # <<<<<<<<<<<<<<
- * if value < 0:
- * raise ValueError("semaphore initial value must be >= 0")
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":64
- * # without initializing the hub
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0)
- * return '<%s counter=%s _links[%s]>' % params
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_2__str__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_v_params = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- Py_ssize_t __pyx_t_6;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/_semaphore.py":65
- *
- * def __str__(self):
- * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) # <<<<<<<<<<<<<<
- * return '<%s counter=%s _links[%s]>' % params
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_4) {
- __pyx_t_5 = __pyx_v_self->_links;
- __Pyx_INCREF(__pyx_t_5);
- if (unlikely(__pyx_t_5 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 65, __pyx_L1_error)
- }
- __pyx_t_6 = PyList_GET_SIZE(__pyx_t_5); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_3 = __pyx_t_5;
- __pyx_t_5 = 0;
- } else {
- __Pyx_INCREF(__pyx_int_0);
- __pyx_t_3 = __pyx_int_0;
- }
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_v_params = ((PyObject*)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/_semaphore.py":66
- * def __str__(self):
- * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0)
- * return '<%s counter=%s _links[%s]>' % params # <<<<<<<<<<<<<<
- *
- * def locked(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_counter_s__links_s, __pyx_v_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":64
- * # without initializing the hub
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0)
- * return '<%s counter=%s _links[%s]>' % params
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_params);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":68
- * return '<%s counter=%s _links[%s]>' % params
- *
- * def locked(self): # <<<<<<<<<<<<<<
- * """Return a boolean indicating whether the semaphore can be acquired.
- * Most useful with binary semaphores."""
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("locked", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_locked); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":71
- * """Return a boolean indicating whether the semaphore can be acquired.
- * Most useful with binary semaphores."""
- * return self.counter <= 0 # <<<<<<<<<<<<<<
- *
- * def release(self):
- */
- __pyx_r = (__pyx_v_self->counter <= 0);
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":68
- * return '<%s counter=%s _links[%s]>' % params
- *
- * def locked(self): # <<<<<<<<<<<<<<
- * """Return a boolean indicating whether the semaphore can be acquired.
- * Most useful with binary semaphores."""
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_4locked[] = "Semaphore.locked(self) -> bool\nReturn a boolean indicating whether the semaphore can be acquired.\n Most useful with binary semaphores.";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_5locked = {"locked", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_4locked};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("locked (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_4locked(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("locked", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_11__semaphore_9Semaphore_locked(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":73
- * return self.counter <= 0
- *
- * def release(self): # <<<<<<<<<<<<<<
- * """
- * Release the semaphore, notifying any waiters if needed.
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("release", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_7release)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":77
- * Release the semaphore, notifying any waiters if needed.
- * """
- * self.counter += 1 # <<<<<<<<<<<<<<
- * self._start_notify()
- * return self.counter
- */
- __pyx_v_self->counter = (__pyx_v_self->counter + 1);
-
- /* "src/gevent/_semaphore.py":78
- * """
- * self.counter += 1
- * self._start_notify() # <<<<<<<<<<<<<<
- * return self.counter
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_start_notify(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":79
- * self.counter += 1
- * self._start_notify()
- * return self.counter # <<<<<<<<<<<<<<
- *
- * def _start_notify(self):
- */
- __pyx_r = __pyx_v_self->counter;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":73
- * return self.counter <= 0
- *
- * def release(self): # <<<<<<<<<<<<<<
- * """
- * Release the semaphore, notifying any waiters if needed.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1000;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_6release[] = "Semaphore.release(self) -> int\n\n Release the semaphore, notifying any waiters if needed.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_7release = {"release", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_7release, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_6release};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("release (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_6release(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("release", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 73, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":81
- * return self.counter
- *
- * def _start_notify(self): # <<<<<<<<<<<<<<
- * if self._links and self.counter > 0 and not self._notifier:
- * # We create a new self._notifier each time through the loop,
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("_start_notify", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_start_notify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_9_start_notify)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":82
- *
- * def _start_notify(self):
- * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<<
- * # We create a new self._notifier each time through the loop,
- * # if needed. (it has a __bool__ method that tells whether it has
- */
- __pyx_t_6 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_5 = __pyx_t_6;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_6 = ((__pyx_v_self->counter > 0) != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_5 = __pyx_t_6;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 82, __pyx_L1_error)
- __pyx_t_7 = ((!__pyx_t_6) != 0);
- __pyx_t_5 = __pyx_t_7;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_5) {
-
- /* "src/gevent/_semaphore.py":90
- * # with Cython <= 0.23.3. You must use >= 0.23.4.
- * # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546
- * hub = get_hub() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self._notifier = hub.loop.run_callback(self._notify_links)
- *
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":91
- * # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546
- * hub = get_hub() # pylint:disable=undefined-variable
- * self._notifier = hub.loop.run_callback(self._notify_links) # <<<<<<<<<<<<<<
- *
- * def _notify_links(self):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":82
- *
- * def _start_notify(self):
- * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<<
- * # We create a new self._notifier each time through the loop,
- * # if needed. (it has a __bool__ method that tells whether it has
- */
- }
-
- /* "src/gevent/_semaphore.py":81
- * return self.counter
- *
- * def _start_notify(self): # <<<<<<<<<<<<<<
- * if self._links and self.counter > 0 and not self._notifier:
- * # We create a new self._notifier each time through the loop,
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_hub);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_8_start_notify[] = "Semaphore._start_notify(self)";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_9_start_notify = {"_start_notify", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_9_start_notify, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_8_start_notify};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_start_notify (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_8_start_notify(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_start_notify", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":93
- * self._notifier = hub.loop.run_callback(self._notify_links)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Subclasses CANNOT override. This is a cdef method.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_notifier = NULL;
- PyObject *__pyx_v_link = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- Py_ssize_t __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- int __pyx_t_16;
- int __pyx_t_17;
- char const *__pyx_t_18;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- PyObject *__pyx_t_21 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_11_notify_links)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":102
- * # no need to keep it around until that point (making it potentially climb
- * # into older GC generations, notably on PyPy)
- * notifier = self._notifier # <<<<<<<<<<<<<<
- * try:
- * while True:
- */
- __pyx_t_1 = __pyx_v_self->_notifier;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_notifier = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":103
- * # into older GC generations, notably on PyPy)
- * notifier = self._notifier
- * try: # <<<<<<<<<<<<<<
- * while True:
- * self._dirty = False
- */
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":104
- * notifier = self._notifier
- * try:
- * while True: # <<<<<<<<<<<<<<
- * self._dirty = False
- * if not self._links:
- */
- while (1) {
-
- /* "src/gevent/_semaphore.py":105
- * try:
- * while True:
- * self._dirty = False # <<<<<<<<<<<<<<
- * if not self._links:
- * # In case we were manually unlinked before
- */
- __pyx_v_self->_dirty = 0;
-
- /* "src/gevent/_semaphore.py":106
- * while True:
- * self._dirty = False
- * if not self._links: # <<<<<<<<<<<<<<
- * # In case we were manually unlinked before
- * # the callback. Which shouldn't happen
- */
- __pyx_t_5 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- __pyx_t_6 = ((!__pyx_t_5) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_semaphore.py":109
- * # In case we were manually unlinked before
- * # the callback. Which shouldn't happen
- * return # <<<<<<<<<<<<<<
- * for link in self._links:
- * if self.counter <= 0:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L3_return;
-
- /* "src/gevent/_semaphore.py":106
- * while True:
- * self._dirty = False
- * if not self._links: # <<<<<<<<<<<<<<
- * # In case we were manually unlinked before
- * # the callback. Which shouldn't happen
- */
- }
-
- /* "src/gevent/_semaphore.py":110
- * # the callback. Which shouldn't happen
- * return
- * for link in self._links: # <<<<<<<<<<<<<<
- * if self.counter <= 0:
- * return
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 110, __pyx_L4_error)
- }
- __pyx_t_1 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
- for (;;) {
- if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 110, __pyx_L4_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":111
- * return
- * for link in self._links:
- * if self.counter <= 0: # <<<<<<<<<<<<<<
- * return
- * try:
- */
- __pyx_t_6 = ((__pyx_v_self->counter <= 0) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_semaphore.py":112
- * for link in self._links:
- * if self.counter <= 0:
- * return # <<<<<<<<<<<<<<
- * try:
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L3_return;
-
- /* "src/gevent/_semaphore.py":111
- * return
- * for link in self._links:
- * if self.counter <= 0: # <<<<<<<<<<<<<<
- * return
- * try:
- */
- }
-
- /* "src/gevent/_semaphore.py":113
- * if self.counter <= 0:
- * return
- * try: # <<<<<<<<<<<<<<
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":114
- * return
- * try:
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_v_link);
- __pyx_t_3 = __pyx_v_link; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L12_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L12_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 114, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_11, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":113
- * if self.counter <= 0:
- * return
- * try: # <<<<<<<<<<<<<<
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L19_try_end;
- __pyx_L12_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":115
- * try:
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable
- * if self._dirty:
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_11) < 0) __PYX_ERR(0, 115, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_11);
-
- /* "src/gevent/_semaphore.py":116
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- * except: # pylint:disable=bare-except
- * getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * if self._dirty:
- * # We mutated self._links so we need to start over
- */
- __pyx_t_4 = ((PyObject *)__pyx_f_6gevent_11__semaphore_getcurrent()); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_link);
- __Pyx_GIVEREF(__pyx_v_link);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_link);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self));
- __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_14 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
- __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
- if (likely(__pyx_t_14)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
- __Pyx_INCREF(__pyx_t_14);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_15, function);
- }
- }
- if (__pyx_t_14) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __pyx_t_15 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyNumber_Add(__pyx_t_13, __pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 116, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L13_exception_handled;
- }
- __pyx_L14_except_error:;
-
- /* "src/gevent/_semaphore.py":113
- * if self.counter <= 0:
- * return
- * try: # <<<<<<<<<<<<<<
- * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
- goto __pyx_L4_error;
- __pyx_L13_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
- __pyx_L19_try_end:;
- }
-
- /* "src/gevent/_semaphore.py":117
- * except: # pylint:disable=bare-except
- * getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable
- * if self._dirty: # <<<<<<<<<<<<<<
- * # We mutated self._links so we need to start over
- * break
- */
- __pyx_t_6 = (__pyx_v_self->_dirty != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_semaphore.py":119
- * if self._dirty:
- * # We mutated self._links so we need to start over
- * break # <<<<<<<<<<<<<<
- * if not self._dirty:
- * return
- */
- goto __pyx_L10_break;
-
- /* "src/gevent/_semaphore.py":117
- * except: # pylint:disable=bare-except
- * getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable
- * if self._dirty: # <<<<<<<<<<<<<<
- * # We mutated self._links so we need to start over
- * break
- */
- }
-
- /* "src/gevent/_semaphore.py":110
- * # the callback. Which shouldn't happen
- * return
- * for link in self._links: # <<<<<<<<<<<<<<
- * if self.counter <= 0:
- * return
- */
- }
- __pyx_L10_break:;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":120
- * # We mutated self._links so we need to start over
- * break
- * if not self._dirty: # <<<<<<<<<<<<<<
- * return
- * finally:
- */
- __pyx_t_6 = ((!(__pyx_v_self->_dirty != 0)) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_semaphore.py":121
- * break
- * if not self._dirty:
- * return # <<<<<<<<<<<<<<
- * finally:
- * # We should not have created a new notifier even if callbacks
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L3_return;
-
- /* "src/gevent/_semaphore.py":120
- * # We mutated self._links so we need to start over
- * break
- * if not self._dirty: # <<<<<<<<<<<<<<
- * return
- * finally:
- */
- }
- }
- }
-
- /* "src/gevent/_semaphore.py":126
- * # released us because we loop through *all* of our links on the
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier # <<<<<<<<<<<<<<
- * self._notifier = None
- *
- */
- /*finally:*/ {
- /*normal exit:*/{
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier);
- if (unlikely(!(__pyx_t_6 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 126, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/_semaphore.py":127
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier
- * self._notifier = None # <<<<<<<<<<<<<<
- *
- * def rawlink(self, callback):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_19);
- __Pyx_XGOTREF(__pyx_t_20);
- __Pyx_XGOTREF(__pyx_t_21);
- __pyx_t_16 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
- {
-
- /* "src/gevent/_semaphore.py":126
- * # released us because we loop through *all* of our links on the
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier # <<<<<<<<<<<<<<
- * self._notifier = None
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier);
- if (unlikely(!(__pyx_t_6 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 126, __pyx_L25_error)
- }
- }
- #endif
-
- /* "src/gevent/_semaphore.py":127
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier
- * self._notifier = None # <<<<<<<<<<<<<<
- *
- * def rawlink(self, callback):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_XGIVEREF(__pyx_t_21);
- __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
- }
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ErrRestore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
- __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
- __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
- goto __pyx_L1_error;
- __pyx_L25_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_XGIVEREF(__pyx_t_21);
- __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
- }
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_21 = __pyx_r;
- __pyx_r = 0;
-
- /* "src/gevent/_semaphore.py":126
- * # released us because we loop through *all* of our links on the
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier # <<<<<<<<<<<<<<
- * self._notifier = None
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier);
- if (unlikely(!(__pyx_t_6 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 126, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/_semaphore.py":127
- * # same callback while self._notifier is still true.
- * assert self._notifier is notifier
- * self._notifier = None # <<<<<<<<<<<<<<
- *
- * def rawlink(self, callback):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
- __pyx_r = __pyx_t_21;
- __pyx_t_21 = 0;
- goto __pyx_L0;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/_semaphore.py":93
- * self._notifier = hub.loop.run_callback(self._notify_links)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Subclasses CANNOT override. This is a cdef method.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_notifier);
- __Pyx_XDECREF(__pyx_v_link);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_10_notify_links[] = "Semaphore._notify_links(self)";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_11_notify_links = {"_notify_links", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_11_notify_links, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_10_notify_links};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_10_notify_links(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore__notify_links(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":129
- * self._notifier = None
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * rawlink(callback) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("rawlink", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_13rawlink)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":141
- * will not need to use it.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable:', callback)
- * if self._links is None:
- */
- __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 141, __pyx_L1_error)
- __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/_semaphore.py":142
- * """
- * if not callable(callback):
- * raise TypeError('Expected callable:', callback) # <<<<<<<<<<<<<<
- * if self._links is None:
- * self._links = [callback]
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_kp_s_Expected_callable);
- __Pyx_GIVEREF(__pyx_kp_s_Expected_callable);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_Expected_callable);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 142, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":141
- * will not need to use it.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable:', callback)
- * if self._links is None:
- */
- }
-
- /* "src/gevent/_semaphore.py":143
- * if not callable(callback):
- * raise TypeError('Expected callable:', callback)
- * if self._links is None: # <<<<<<<<<<<<<<
- * self._links = [callback]
- * else:
- */
- __pyx_t_7 = (__pyx_v_self->_links == ((PyObject*)Py_None));
- __pyx_t_6 = (__pyx_t_7 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_semaphore.py":144
- * raise TypeError('Expected callable:', callback)
- * if self._links is None:
- * self._links = [callback] # <<<<<<<<<<<<<<
- * else:
- * self._links.append(callback)
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_v_self->_links);
- __Pyx_DECREF(__pyx_v_self->_links);
- __pyx_v_self->_links = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":143
- * if not callable(callback):
- * raise TypeError('Expected callable:', callback)
- * if self._links is None: # <<<<<<<<<<<<<<
- * self._links = [callback]
- * else:
- */
- goto __pyx_L4;
- }
-
- /* "src/gevent/_semaphore.py":146
- * self._links = [callback]
- * else:
- * self._links.append(callback) # <<<<<<<<<<<<<<
- * self._dirty = True
- *
- */
- /*else*/ {
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
- __PYX_ERR(0, 146, __pyx_L1_error)
- }
- __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 146, __pyx_L1_error)
- }
- __pyx_L4:;
-
- /* "src/gevent/_semaphore.py":147
- * else:
- * self._links.append(callback)
- * self._dirty = True # <<<<<<<<<<<<<<
- *
- * def unlink(self, callback):
- */
- __pyx_v_self->_dirty = 1;
-
- /* "src/gevent/_semaphore.py":129
- * self._notifier = None
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * rawlink(callback) -> None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_12rawlink[] = "Semaphore.rawlink(self, callback)\n\n rawlink(callback) -> None\n\n Register a callback to call when a counter is more than zero.\n\n *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.\n *callback* will be passed one argument: this instance.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code\n will not need to use it.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_13rawlink = {"rawlink", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_13rawlink, METH_O, __pyx_doc_6gevent_11__semaphore_9Semaphore_12rawlink};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("rawlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_12rawlink(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("rawlink", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":149
- * self._dirty = True
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * unlink(callback) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- int __pyx_t_10;
- int __pyx_t_11;
- __Pyx_RefNannySetupContext("unlink", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_15unlink)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":158
- * code will not need to use it.
- * """
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * self._dirty = True
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":159
- * """
- * try:
- * self._links.remove(callback) # <<<<<<<<<<<<<<
- * self._dirty = True
- * except (ValueError, AttributeError):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_links, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":160
- * try:
- * self._links.remove(callback)
- * self._dirty = True # <<<<<<<<<<<<<<
- * except (ValueError, AttributeError):
- * pass
- */
- __pyx_v_self->_dirty = 1;
-
- /* "src/gevent/_semaphore.py":158
- * code will not need to use it.
- * """
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * self._dirty = True
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":161
- * self._links.remove(callback)
- * self._dirty = True
- * except (ValueError, AttributeError): # <<<<<<<<<<<<<<
- * pass
- * if not self._links:
- */
- __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_9) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/_semaphore.py":158
- * code will not need to use it.
- * """
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * self._dirty = True
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/_semaphore.py":163
- * except (ValueError, AttributeError):
- * pass
- * if not self._links: # <<<<<<<<<<<<<<
- * self._links = None
- * # TODO: Cancel a notifier if there are no links?
- */
- __pyx_t_10 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- __pyx_t_11 = ((!__pyx_t_10) != 0);
- if (__pyx_t_11) {
-
- /* "src/gevent/_semaphore.py":164
- * pass
- * if not self._links:
- * self._links = None # <<<<<<<<<<<<<<
- * # TODO: Cancel a notifier if there are no links?
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_links);
- __Pyx_DECREF(__pyx_v_self->_links);
- __pyx_v_self->_links = ((PyObject*)Py_None);
-
- /* "src/gevent/_semaphore.py":163
- * except (ValueError, AttributeError):
- * pass
- * if not self._links: # <<<<<<<<<<<<<<
- * self._links = None
- * # TODO: Cancel a notifier if there are no links?
- */
- }
-
- /* "src/gevent/_semaphore.py":149
- * self._dirty = True
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * unlink(callback) -> None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_14unlink[] = "Semaphore.unlink(self, callback)\n\n unlink(callback) -> None\n\n Remove the callback set by :meth:`rawlink`.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most\n code will not need to use it.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_15unlink = {"unlink", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_15unlink, METH_O, __pyx_doc_6gevent_11__semaphore_9Semaphore_14unlink};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_14unlink(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("unlink", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore_unlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":167
- * # TODO: Cancel a notifier if there are no links?
- *
- * def _do_wait(self, timeout): # <<<<<<<<<<<<<<
- * """
- * Wait for up to *timeout* seconds to expire. If timeout
- */
-
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_v_switch = NULL;
- PyObject *__pyx_v_timer = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_ex = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- int __pyx_t_11;
- char const *__pyx_t_12;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- char const *__pyx_t_16;
- __Pyx_RefNannySetupContext("_do_wait", 0);
-
- /* "src/gevent/_semaphore.py":173
- * Raises timeout if a different timer expires.
- * """
- * switch = getcurrent().switch # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.rawlink(switch)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__semaphore_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_switch = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":174
- * """
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch) # <<<<<<<<<<<<<<
- * try:
- * timer = Timeout._start_new_or_dummy(timeout)
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":175
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * timer = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":176
- * self.rawlink(switch)
- * try:
- * timer = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<<
- * try:
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_11__semaphore_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_timer = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":177
- * try:
- * timer = Timeout._start_new_or_dummy(timeout)
- * try: # <<<<<<<<<<<<<<
- * try:
- * result = get_hub().switch() # pylint:disable=undefined-variable
- */
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":178
- * timer = Timeout._start_new_or_dummy(timeout)
- * try:
- * try: # <<<<<<<<<<<<<<
- * result = get_hub().switch() # pylint:disable=undefined-variable
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- /*try:*/ {
-
- /* "src/gevent/_semaphore.py":179
- * try:
- * try:
- * result = get_hub().switch() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- * except Timeout as ex:
- */
- __pyx_t_2 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_2)->__pyx_vtab)->__pyx_switch(((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_2), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":180
- * try:
- * result = get_hub().switch() # pylint:disable=undefined-variable
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) # <<<<<<<<<<<<<<
- * except Timeout as ex:
- * if ex is not timer:
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_8 = (__pyx_v_result == ((PyObject *)__pyx_v_self));
- if (unlikely(!(__pyx_t_8 != 0))) {
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_result);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyErr_SetObject(PyExc_AssertionError, __pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 180, __pyx_L9_error)
- }
- }
- #endif
-
- /* "src/gevent/_semaphore.py":178
- * timer = Timeout._start_new_or_dummy(timeout)
- * try:
- * try: # <<<<<<<<<<<<<<
- * result = get_hub().switch() # pylint:disable=undefined-variable
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- */
- }
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L14_try_end;
- __pyx_L9_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":181
- * result = get_hub().switch() # pylint:disable=undefined-variable
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- * except Timeout as ex: # <<<<<<<<<<<<<<
- * if ex is not timer:
- * raise
- */
- __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_v_6gevent_11__semaphore_Timeout);
- if (__pyx_t_9) {
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 181, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_ex = __pyx_t_1;
-
- /* "src/gevent/_semaphore.py":182
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- * except Timeout as ex:
- * if ex is not timer: # <<<<<<<<<<<<<<
- * raise
- * return ex
- */
- __pyx_t_8 = (__pyx_v_ex != __pyx_v_timer);
- __pyx_t_10 = (__pyx_t_8 != 0);
- if (unlikely(__pyx_t_10)) {
-
- /* "src/gevent/_semaphore.py":183
- * except Timeout as ex:
- * if ex is not timer:
- * raise # <<<<<<<<<<<<<<
- * return ex
- * finally:
- */
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_4);
- __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_4 = 0;
- __PYX_ERR(0, 183, __pyx_L11_except_error)
-
- /* "src/gevent/_semaphore.py":182
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- * except Timeout as ex:
- * if ex is not timer: # <<<<<<<<<<<<<<
- * raise
- * return ex
- */
- }
-
- /* "src/gevent/_semaphore.py":184
- * if ex is not timer:
- * raise
- * return ex # <<<<<<<<<<<<<<
- * finally:
- * timer.cancel()
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_ex);
- __pyx_r = __pyx_v_ex;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L12_except_return;
- }
- goto __pyx_L11_except_error;
- __pyx_L11_except_error:;
-
- /* "src/gevent/_semaphore.py":178
- * timer = Timeout._start_new_or_dummy(timeout)
- * try:
- * try: # <<<<<<<<<<<<<<
- * result = get_hub().switch() # pylint:disable=undefined-variable
- * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- */
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- goto __pyx_L7_error;
- __pyx_L12_except_return:;
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- goto __pyx_L6_return;
- __pyx_L14_try_end:;
- }
- }
-
- /* "src/gevent/_semaphore.py":186
- * return ex
- * finally:
- * timer.cancel() # <<<<<<<<<<<<<<
- * finally:
- * self.unlink(switch)
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L4_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L4_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L8;
- }
- __pyx_L7_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __pyx_t_9 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename;
- {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L19_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L19_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L19_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
- }
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ErrRestore(__pyx_t_7, __pyx_t_6, __pyx_t_5);
- __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12;
- goto __pyx_L4_error;
- __pyx_L19_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
- }
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- goto __pyx_L4_error;
- }
- __pyx_L6_return: {
- __pyx_t_15 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L4_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L4_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_15;
- __pyx_t_15 = 0;
- goto __pyx_L3_return;
- }
- __pyx_L8:;
- }
- }
-
- /* "src/gevent/_semaphore.py":188
- * timer.cancel()
- * finally:
- * self.unlink(switch) # <<<<<<<<<<<<<<
- *
- * def wait(self, timeout=None):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __pyx_t_11 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
- {
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L21_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- }
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
- __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_16;
- goto __pyx_L1_error;
- __pyx_L21_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- }
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_7 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_7;
- __pyx_t_7 = 0;
- goto __pyx_L0;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/_semaphore.py":167
- * # TODO: Cancel a notifier if there are no links?
- *
- * def _do_wait(self, timeout): # <<<<<<<<<<<<<<
- * """
- * Wait for up to *timeout* seconds to expire. If timeout
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_switch);
- __Pyx_XDECREF(__pyx_v_timer);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_ex);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":190
- * self.unlink(switch)
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * wait(timeout=None) -> int
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("wait", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_17wait)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_6;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":205
- * before blocking.
- * """
- * if self.counter > 0: # <<<<<<<<<<<<<<
- * return self.counter
- *
- */
- __pyx_t_7 = ((__pyx_v_self->counter > 0) != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/_semaphore.py":206
- * """
- * if self.counter > 0:
- * return self.counter # <<<<<<<<<<<<<<
- *
- * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout
- */
- __pyx_r = __pyx_v_self->counter;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":205
- * before blocking.
- * """
- * if self.counter > 0: # <<<<<<<<<<<<<<
- * return self.counter
- *
- */
- }
-
- /* "src/gevent/_semaphore.py":208
- * return self.counter
- *
- * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout # <<<<<<<<<<<<<<
- * return self.counter
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":209
- *
- * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout
- * return self.counter # <<<<<<<<<<<<<<
- *
- * def acquire(self, blocking=True, timeout=None):
- */
- __pyx_r = __pyx_v_self->counter;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":190
- * self.unlink(switch)
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * wait(timeout=None) -> int
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1000;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_16wait[] = "Semaphore.wait(self, timeout=None) -> int\n\n wait(timeout=None) -> int\n\n Wait until it is possible to acquire this semaphore, or until the optional\n *timeout* elapses.\n\n .. caution:: If this semaphore was initialized with a size of 0,\n this method will block forever if no timeout is given.\n\n :keyword float timeout: If given, specifies the maximum amount of seconds\n this method will block.\n :return: A number indicating how many times the semaphore can be acquired\n before blocking.\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_17wait = {"wait", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_17wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_16wait};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) __PYX_ERR(0, 190, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 190, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_16wait(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("wait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_11__semaphore_Semaphore->wait(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 190, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":211
- * return self.counter
- *
- * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * acquire(blocking=True, timeout=None) -> bool
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_f_6gevent_11__semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args) {
- int __pyx_v_blocking = ((int)1);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("acquire", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_blocking = __pyx_optional_args->blocking;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- __Pyx_INCREF(__pyx_v_timeout);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_19acquire)) {
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_blocking); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_timeout);
- __pyx_t_3 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_8;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":232
- * raise a ``Timeout`` exception, if some other caller had already started a timer.)
- * """
- * if self.counter > 0: # <<<<<<<<<<<<<<
- * self.counter -= 1
- * return True
- */
- __pyx_t_8 = ((__pyx_v_self->counter > 0) != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_semaphore.py":233
- * """
- * if self.counter > 0:
- * self.counter -= 1 # <<<<<<<<<<<<<<
- * return True
- *
- */
- __pyx_v_self->counter = (__pyx_v_self->counter - 1);
-
- /* "src/gevent/_semaphore.py":234
- * if self.counter > 0:
- * self.counter -= 1
- * return True # <<<<<<<<<<<<<<
- *
- * if not blocking:
- */
- __pyx_r = 1;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":232
- * raise a ``Timeout`` exception, if some other caller had already started a timer.)
- * """
- * if self.counter > 0: # <<<<<<<<<<<<<<
- * self.counter -= 1
- * return True
- */
- }
-
- /* "src/gevent/_semaphore.py":236
- * return True
- *
- * if not blocking: # <<<<<<<<<<<<<<
- * return False
- *
- */
- __pyx_t_8 = ((!(__pyx_v_blocking != 0)) != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_semaphore.py":237
- *
- * if not blocking:
- * return False # <<<<<<<<<<<<<<
- *
- * timeout = self._do_wait(timeout)
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":236
- * return True
- *
- * if not blocking: # <<<<<<<<<<<<<<
- * return False
- *
- */
- }
-
- /* "src/gevent/_semaphore.py":239
- * return False
- *
- * timeout = self._do_wait(timeout) # <<<<<<<<<<<<<<
- * if timeout is not None:
- * # Our timer expired.
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":240
- *
- * timeout = self._do_wait(timeout)
- * if timeout is not None: # <<<<<<<<<<<<<<
- * # Our timer expired.
- * return False
- */
- __pyx_t_8 = (__pyx_v_timeout != Py_None);
- __pyx_t_9 = (__pyx_t_8 != 0);
- if (__pyx_t_9) {
-
- /* "src/gevent/_semaphore.py":242
- * if timeout is not None:
- * # Our timer expired.
- * return False # <<<<<<<<<<<<<<
- *
- * # Neither our timer no another one expired, so we blocked until
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":240
- *
- * timeout = self._do_wait(timeout)
- * if timeout is not None: # <<<<<<<<<<<<<<
- * # Our timer expired.
- * return False
- */
- }
-
- /* "src/gevent/_semaphore.py":246
- * # Neither our timer no another one expired, so we blocked until
- * # awoke. Therefore, the counter is ours
- * self.counter -= 1 # <<<<<<<<<<<<<<
- * assert self.counter >= 0
- * return True
- */
- __pyx_v_self->counter = (__pyx_v_self->counter - 1);
-
- /* "src/gevent/_semaphore.py":247
- * # awoke. Therefore, the counter is ours
- * self.counter -= 1
- * assert self.counter >= 0 # <<<<<<<<<<<<<<
- * return True
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- if (unlikely(!((__pyx_v_self->counter >= 0) != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 247, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/_semaphore.py":248
- * self.counter -= 1
- * assert self.counter >= 0
- * return True # <<<<<<<<<<<<<<
- *
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
- */
- __pyx_r = 1;
- goto __pyx_L0;
-
- /* "src/gevent/_semaphore.py":211
- * return self.counter
- *
- * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * acquire(blocking=True, timeout=None) -> bool
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1000;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_18acquire[] = "Semaphore.acquire(self, int blocking=True, timeout=None) -> bool\n\n acquire(blocking=True, timeout=None) -> bool\n\n Acquire the semaphore.\n\n .. caution:: If this semaphore was initialized with a size of 0,\n this method will block forever (unless a timeout is given or blocking is\n set to false).\n\n :keyword bool blocking: If True (the default), this function will block\n until the semaphore is acquired.\n :keyword float timeout: If given, specifies the maximum amount of seconds\n this method will block.\n :return: A boolean indicating whether the semaphore was acquired.\n If ``blocking`` is True and ``timeout`` is None (the default), then\n (so long as this semaphore was initialized with a size greater than 0)\n this will always return True. If a timeout was given, and it expired before\n the semaphore was acquired, False will be returned. (Note that this can still\n raise a ``Timeout`` exception, if some other caller had already started a timer.)\n ";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_19acquire = {"acquire", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_19acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_18acquire};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_blocking;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("acquire (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_blocking);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) __PYX_ERR(0, 211, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- if (values[0]) {
- __pyx_v_blocking = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L3_error)
- } else {
- __pyx_v_blocking = ((int)1);
- }
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_18acquire(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_blocking, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("acquire", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.blocking = __pyx_v_blocking;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_11__semaphore_Semaphore->acquire(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 211, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":252
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
- *
- * def __enter__(self): # <<<<<<<<<<<<<<
- * self.acquire()
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("__enter__", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_21__enter__)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":253
- *
- * def __enter__(self):
- * self.acquire() # <<<<<<<<<<<<<<
- *
- * def __exit__(self, t, v, tb):
- */
- __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->acquire(__pyx_v_self, 0, NULL); if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 253, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":252
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
- *
- * def __enter__(self): # <<<<<<<<<<<<<<
- * self.acquire()
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_20__enter__[] = "Semaphore.__enter__(self)";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_21__enter__ = {"__enter__", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_21__enter__, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_20__enter__};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_20__enter__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__enter__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore___enter__(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":255
- * self.acquire()
- *
- * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<<
- * self.release()
- *
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("__exit__", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_23__exit__)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_t);
- __Pyx_GIVEREF(__pyx_v_t);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_t);
- __Pyx_INCREF(__pyx_v_v);
- __Pyx_GIVEREF(__pyx_v_v);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_v);
- __Pyx_INCREF(__pyx_v_tb);
- __Pyx_GIVEREF(__pyx_v_tb);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":256
- *
- * def __exit__(self, t, v, tb):
- * self.release() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->release(__pyx_v_self, 0); if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 256, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":255
- * self.acquire()
- *
- * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<<
- * self.release()
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_9Semaphore_22__exit__[] = "Semaphore.__exit__(self, t, v, tb)";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_23__exit__ = {"__exit__", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_23__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_22__exit__};
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_t = 0;
- PyObject *__pyx_v_v = 0;
- PyObject *__pyx_v_tb = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 255, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 255, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 255, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_t = values[0];
- __pyx_v_v = values[1];
- __pyx_v_tb = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 255, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_22__exit__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__exit__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore___exit__(__pyx_v_self, __pyx_v_t, __pyx_v_v, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":33
- *
- * cdef class Semaphore:
- * cdef public int counter # <<<<<<<<<<<<<<
- * cdef readonly list _links
- * cdef readonly object _notifier
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_7counter___get__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.counter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_7counter_2__set__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 33, __pyx_L1_error)
- __pyx_v_self->counter = __pyx_t_1;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore.counter.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":34
- * cdef class Semaphore:
- * cdef public int counter
- * cdef readonly list _links # <<<<<<<<<<<<<<
- * cdef readonly object _notifier
- * cdef public int _dirty
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_6_links___get__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_links);
- __pyx_r = __pyx_v_self->_links;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":35
- * cdef public int counter
- * cdef readonly list _links
- * cdef readonly object _notifier # <<<<<<<<<<<<<<
- * cdef public int _dirty
- * cdef object __weakref__
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_9_notifier___get__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_notifier);
- __pyx_r = __pyx_v_self->_notifier;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":36
- * cdef readonly list _links
- * cdef readonly object _notifier
- * cdef public int _dirty # <<<<<<<<<<<<<<
- * cdef object __weakref__
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty___get__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_dirty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._dirty.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty_2__set__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_11__semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 36, __pyx_L1_error)
- __pyx_v_self->_dirty = __pyx_t_1;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.__semaphore.Semaphore._dirty.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":275
- * _OVER_RELEASE_ERROR = ValueError
- *
- * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<<
- * Semaphore.__init__(self, *args, **kwargs)
- * self._initial_value = self.counter
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
- if (unlikely(__pyx_kwds)) {
- __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1;
- __Pyx_GOTREF(__pyx_v_kwargs);
- } else {
- __pyx_v_kwargs = NULL;
- }
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore___init__(((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_semaphore.py":276
- *
- * def __init__(self, *args, **kwargs):
- * Semaphore.__init__(self, *args, **kwargs) # <<<<<<<<<<<<<<
- * self._initial_value = self.counter
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":277
- * def __init__(self, *args, **kwargs):
- * Semaphore.__init__(self, *args, **kwargs)
- * self._initial_value = self.counter # <<<<<<<<<<<<<<
- *
- * def release(self):
- */
- __pyx_t_4 = __pyx_v_self->__pyx_base.counter;
- __pyx_v_self->_initial_value = __pyx_t_4;
-
- /* "src/gevent/_semaphore.py":275
- * _OVER_RELEASE_ERROR = ValueError
- *
- * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<<
- * Semaphore.__init__(self, *args, **kwargs)
- * self._initial_value = self.counter
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__semaphore.BoundedSemaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":279
- * self._initial_value = self.counter
- *
- * def release(self): # <<<<<<<<<<<<<<
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- */
-
-static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("release", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_semaphore.py":280
- *
- * def release(self):
- * if self.counter >= self._initial_value: # <<<<<<<<<<<<<<
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- * Semaphore.release(self)
- */
- __pyx_t_6 = ((__pyx_v_self->__pyx_base.counter >= __pyx_v_self->_initial_value) != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "src/gevent/_semaphore.py":281
- * def release(self):
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<<
- * Semaphore.release(self)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_OVER_RELEASE_ERROR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 281, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":280
- *
- * def release(self):
- * if self.counter >= self._initial_value: # <<<<<<<<<<<<<<
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- * Semaphore.release(self)
- */
- }
-
- /* "src/gevent/_semaphore.py":282
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- * Semaphore.release(self) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), 1); if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 282, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":279
- * self._initial_value = self.counter
- *
- * def release(self): # <<<<<<<<<<<<<<
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1000;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_11__semaphore_16BoundedSemaphore_2release[] = "BoundedSemaphore.release(self) -> int";
-static PyMethodDef __pyx_mdef_6gevent_11__semaphore_16BoundedSemaphore_3release = {"release", (PyCFunction)__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_16BoundedSemaphore_2release};
-static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("release (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_2release(((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("release", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 279, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":52
- *
- * cdef class BoundedSemaphore(Semaphore):
- * cdef readonly int _initial_value # <<<<<<<<<<<<<<
- *
- * cpdef int release(self) except -1000
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value___get__(((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_initial_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.BoundedSemaphore._initial_value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_semaphore.py":285
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-static void __pyx_f_6gevent_11__semaphore__init(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/_semaphore.py":286
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_11__semaphore_greenlet_init();
-
- /* "src/gevent/_semaphore.py":285
- *
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":19
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_11__semaphore_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__semaphore.pxd":20
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__semaphore.pxd":19
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__semaphore.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__semaphore.pxd":22
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_11__semaphore_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__semaphore.pxd":24
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_11__semaphore__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__semaphore.pxd":25
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__semaphore.pxd":26
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_6gevent_11__semaphore__greenlet_imported = 1;
-
- /* "gevent/__semaphore.pxd":24
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__semaphore.pxd":22
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-static struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore __pyx_vtable_6gevent_11__semaphore_Semaphore;
-
-static PyObject *__pyx_tp_new_6gevent_11__semaphore_Semaphore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_11__semaphore_Semaphore *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_11__semaphore_Semaphore;
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_notifier = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_11__semaphore_Semaphore(PyObject *o) {
- struct __pyx_obj_6gevent_11__semaphore_Semaphore *p = (struct __pyx_obj_6gevent_11__semaphore_Semaphore *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- Py_CLEAR(p->_links);
- Py_CLEAR(p->_notifier);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_11__semaphore_Semaphore(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_11__semaphore_Semaphore *p = (struct __pyx_obj_6gevent_11__semaphore_Semaphore *)o;
- if (p->_links) {
- e = (*v)(p->_links, a); if (e) return e;
- }
- if (p->_notifier) {
- e = (*v)(p->_notifier, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_11__semaphore_Semaphore(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_11__semaphore_Semaphore *p = (struct __pyx_obj_6gevent_11__semaphore_Semaphore *)o;
- tmp = ((PyObject*)p->_links);
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_notifier);
- p->_notifier = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_11__semaphore_9Semaphore_counter(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_11__semaphore_9Semaphore_counter(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_7counter_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_11__semaphore_9Semaphore__links(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_6_links_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_11__semaphore_9Semaphore__notifier(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_9_notifier_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_11__semaphore_9Semaphore__dirty(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_11__semaphore_9Semaphore__dirty(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_11__semaphore_9Semaphore_6_dirty_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_11__semaphore_Semaphore[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_11__semaphore_Semaphore[] = {
- {(char *)"counter", __pyx_getprop_6gevent_11__semaphore_9Semaphore_counter, __pyx_setprop_6gevent_11__semaphore_9Semaphore_counter, (char *)"counter: 'int'", 0},
- {(char *)"_links", __pyx_getprop_6gevent_11__semaphore_9Semaphore__links, 0, (char *)0, 0},
- {(char *)"_notifier", __pyx_getprop_6gevent_11__semaphore_9Semaphore__notifier, 0, (char *)0, 0},
- {(char *)"_dirty", __pyx_getprop_6gevent_11__semaphore_9Semaphore__dirty, __pyx_setprop_6gevent_11__semaphore_9Semaphore__dirty, (char *)"_dirty: 'int'", 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_11__semaphore_Semaphore = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__semaphore.Semaphore", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_11__semaphore_Semaphore), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_11__semaphore_Semaphore, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Semaphore(value=1)\n\n Semaphore(value=1) -> Semaphore\n\n A semaphore manages a counter representing the number of release()\n calls minus the number of acquire() calls, plus an initial value.\n The acquire() method blocks if necessary until it can return\n without making the counter negative.\n\n If not given, ``value`` defaults to 1.\n\n The semaphore is a context manager and can be used in ``with`` statements.\n\n This Semaphore's ``__exit__`` method does not call the trace function\n on CPython, but does under PyPy.\n\n .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents\n some classes of bugs.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_11__semaphore_Semaphore, /*tp_traverse*/
- __pyx_tp_clear_6gevent_11__semaphore_Semaphore, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_11__semaphore_Semaphore, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_11__semaphore_Semaphore, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_11__semaphore_9Semaphore_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_11__semaphore_Semaphore, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore __pyx_vtable_6gevent_11__semaphore_BoundedSemaphore;
-
-static PyObject *__pyx_tp_new_6gevent_11__semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *p;
- PyObject *o = __pyx_tp_new_6gevent_11__semaphore_Semaphore(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore*)__pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore;
- return o;
-}
-
-static PyObject *__pyx_getprop_6gevent_11__semaphore_16BoundedSemaphore__initial_value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_14_initial_value_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_11__semaphore_BoundedSemaphore[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_11__semaphore_BoundedSemaphore[] = {
- {(char *)"_initial_value", __pyx_getprop_6gevent_11__semaphore_16BoundedSemaphore__initial_value, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_11__semaphore_BoundedSemaphore = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__semaphore.BoundedSemaphore", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_11__semaphore_Semaphore, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "BoundedSemaphore(*args, **kwargs)\n\n BoundedSemaphore(value=1) -> BoundedSemaphore\n\n A bounded semaphore checks to make sure its current value doesn't\n exceed its initial value. If it does, :class:`ValueError` is\n raised. In most situations semaphores are used to guard resources\n with limited capacity. If the semaphore is released too many times\n it's a sign of a bug.\n\n If not given, *value* defaults to 1.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_11__semaphore_Semaphore, /*tp_traverse*/
- __pyx_tp_clear_6gevent_11__semaphore_Semaphore, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_11__semaphore_BoundedSemaphore, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_11__semaphore_BoundedSemaphore, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_11__semaphore_BoundedSemaphore, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___semaphore(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___semaphore},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__semaphore",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
- {&__pyx_n_s_BoundedSemaphore, __pyx_k_BoundedSemaphore, sizeof(__pyx_k_BoundedSemaphore), 0, 0, 1, 1},
- {&__pyx_n_s_BoundedSemaphore_release, __pyx_k_BoundedSemaphore_release, sizeof(__pyx_k_BoundedSemaphore_release), 0, 0, 1, 1},
- {&__pyx_kp_s_Expected_callable, __pyx_k_Expected_callable, sizeof(__pyx_k_Expected_callable), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_k_Invalid_switch_into_Semaphore_wa, sizeof(__pyx_k_Invalid_switch_into_Semaphore_wa), 0, 0, 1, 0},
- {&__pyx_n_s_OVER_RELEASE_ERROR, __pyx_k_OVER_RELEASE_ERROR, sizeof(__pyx_k_OVER_RELEASE_ERROR), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore, __pyx_k_Semaphore, sizeof(__pyx_k_Semaphore), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore___enter, __pyx_k_Semaphore___enter, sizeof(__pyx_k_Semaphore___enter), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore___exit, __pyx_k_Semaphore___exit, sizeof(__pyx_k_Semaphore___exit), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore__notify_links, __pyx_k_Semaphore__notify_links, sizeof(__pyx_k_Semaphore__notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore__start_notify, __pyx_k_Semaphore__start_notify, sizeof(__pyx_k_Semaphore__start_notify), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore_acquire, __pyx_k_Semaphore_acquire, sizeof(__pyx_k_Semaphore_acquire), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore_locked, __pyx_k_Semaphore_locked, sizeof(__pyx_k_Semaphore_locked), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore_rawlink, __pyx_k_Semaphore_rawlink, sizeof(__pyx_k_Semaphore_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore_release, __pyx_k_Semaphore_release, sizeof(__pyx_k_Semaphore_release), 0, 0, 1, 1},
- {&__pyx_kp_s_Semaphore_released_too_many_time, __pyx_k_Semaphore_released_too_many_time, sizeof(__pyx_k_Semaphore_released_too_many_time), 0, 0, 1, 0},
- {&__pyx_n_s_Semaphore_unlink, __pyx_k_Semaphore_unlink, sizeof(__pyx_k_Semaphore_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_Semaphore_wait, __pyx_k_Semaphore_wait, sizeof(__pyx_k_Semaphore_wait), 0, 0, 1, 1},
- {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub, __pyx_k_get_hub, sizeof(__pyx_k_get_hub), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___semaphore, __pyx_k_gevent___semaphore, sizeof(__pyx_k_gevent___semaphore), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_locked, __pyx_k_locked, sizeof(__pyx_k_locked), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_notify_links, __pyx_k_notify_links, sizeof(__pyx_k_notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_py3k_acquire, __pyx_k_py3k_acquire, sizeof(__pyx_k_py3k_acquire), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1},
- {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
- {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1},
- {&__pyx_kp_s_s_counter_s__links_s, __pyx_k_s_counter_s__links_s, sizeof(__pyx_k_s_counter_s__links_s), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_kp_s_semaphore_initial_value_must_be, __pyx_k_semaphore_initial_value_must_be, sizeof(__pyx_k_semaphore_initial_value_must_be), 0, 0, 1, 0},
- {&__pyx_kp_s_src_gevent__semaphore_py, __pyx_k_src_gevent__semaphore_py, sizeof(__pyx_k_src_gevent__semaphore_py), 0, 0, 1, 0},
- {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1},
- {&__pyx_n_s_start_notify, __pyx_k_start_notify, sizeof(__pyx_k_start_notify), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
- {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 17, __pyx_L1_error)
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 273, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 142, __pyx_L1_error)
- __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 161, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_semaphore.py":43
- * def __init__(self, value=1):
- * if value < 0:
- * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<<
- * self.counter = value
- * self._dirty = False
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_semaphore_initial_value_must_be); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_semaphore.py":281
- * def release(self):
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<<
- * Semaphore.release(self)
- *
- */
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Semaphore_released_too_many_time); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "src/gevent/_semaphore.py":17
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['get_hub'] = __import__('gevent').get_hub
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
-
- /* "src/gevent/_semaphore.py":19
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None
- * locals()['get_hub'] = __import__('gevent').get_hub # <<<<<<<<<<<<<<
- *
- * class Semaphore(object):
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_gevent); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "src/gevent/_semaphore.py":68
- * return '<%s counter=%s _links[%s]>' % params
- *
- * def locked(self): # <<<<<<<<<<<<<<
- * """Return a boolean indicating whether the semaphore can be acquired.
- * Most useful with binary semaphores."""
- */
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
- __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_locked, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 68, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":73
- * return self.counter <= 0
- *
- * def release(self): # <<<<<<<<<<<<<<
- * """
- * Release the semaphore, notifying any waiters if needed.
- */
- __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
- __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_release, 73, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 73, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":81
- * return self.counter
- *
- * def _start_notify(self): # <<<<<<<<<<<<<<
- * if self._links and self.counter > 0 and not self._notifier:
- * # We create a new self._notifier each time through the loop,
- */
- __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
- __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_start_notify, 81, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 81, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":93
- * self._notifier = hub.loop.run_callback(self._notify_links)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Subclasses CANNOT override. This is a cdef method.
- *
- */
- __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
- __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_notify_links, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 93, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":129
- * self._notifier = None
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * rawlink(callback) -> None
- */
- __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
- __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_rawlink, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 129, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":149
- * self._dirty = True
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * unlink(callback) -> None
- */
- __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
- __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_unlink, 149, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 149, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":190
- * self.unlink(switch)
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * wait(timeout=None) -> int
- */
- __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
- __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_wait, 190, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 190, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":211
- * return self.counter
- *
- * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * acquire(blocking=True, timeout=None) -> bool
- */
- __pyx_tuple__19 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_blocking, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
- __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_acquire, 211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 211, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":252
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
- *
- * def __enter__(self): # <<<<<<<<<<<<<<
- * self.acquire()
- *
- */
- __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_enter, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 252, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":255
- * self.acquire()
- *
- * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<<
- * self.release()
- *
- */
- __pyx_tuple__23 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
- __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_exit, 255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 255, __pyx_L1_error)
-
- /* "src/gevent/_semaphore.py":279
- * self._initial_value = self.counter
- *
- * def release(self): # <<<<<<<<<<<<<<
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- */
- __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__25);
- __Pyx_GIVEREF(__pyx_tuple__25);
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_release, 279, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_11__semaphore_Timeout = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_Timeout, (void *)&__pyx_v_6gevent_11__semaphore_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_11__semaphore__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_init", (void (*)(void))__pyx_f_6gevent_11__semaphore__init, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_11__semaphore_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_11__semaphore_greenlet)) __PYX_ERR(1, 10, __pyx_L1_error)
- __pyx_vtabptr_6gevent_11__semaphore_Semaphore = &__pyx_vtable_6gevent_11__semaphore_Semaphore;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.locked = (int (*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore_locked;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.release = (int (*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore_release;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.rawlink = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore_rawlink;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.unlink = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore_unlink;
- __pyx_vtable_6gevent_11__semaphore_Semaphore._start_notify = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore__start_notify;
- __pyx_vtable_6gevent_11__semaphore_Semaphore._notify_links = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore__notify_links;
- __pyx_vtable_6gevent_11__semaphore_Semaphore._do_wait = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *))__pyx_f_6gevent_11__semaphore_9Semaphore__do_wait;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.wait = (int (*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args))__pyx_f_6gevent_11__semaphore_9Semaphore_wait;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.acquire = (int (*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args))__pyx_f_6gevent_11__semaphore_9Semaphore_acquire;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.__pyx___enter__ = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore___enter__;
- __pyx_vtable_6gevent_11__semaphore_Semaphore.__pyx___exit__ = (PyObject *(*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_9Semaphore___exit__;
- if (PyType_Ready(&__pyx_type_6gevent_11__semaphore_Semaphore) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
- __pyx_type_6gevent_11__semaphore_Semaphore.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_11__semaphore_Semaphore.tp_dictoffset && __pyx_type_6gevent_11__semaphore_Semaphore.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_11__semaphore_Semaphore.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_11__semaphore_Semaphore.tp_dict, __pyx_vtabptr_6gevent_11__semaphore_Semaphore) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Semaphore", (PyObject *)&__pyx_type_6gevent_11__semaphore_Semaphore) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
- if (__pyx_type_6gevent_11__semaphore_Semaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_11__semaphore_Semaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_11__semaphore_Semaphore, __weakref__);
- __pyx_ptype_6gevent_11__semaphore_Semaphore = &__pyx_type_6gevent_11__semaphore_Semaphore;
- __pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore = &__pyx_vtable_6gevent_11__semaphore_BoundedSemaphore;
- __pyx_vtable_6gevent_11__semaphore_BoundedSemaphore.__pyx_base = *__pyx_vtabptr_6gevent_11__semaphore_Semaphore;
- __pyx_vtable_6gevent_11__semaphore_BoundedSemaphore.__pyx_base.release = (int (*)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release;
- __pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_base = __pyx_ptype_6gevent_11__semaphore_Semaphore;
- if (PyType_Ready(&__pyx_type_6gevent_11__semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
- __pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_dictoffset && __pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_dict, __pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "BoundedSemaphore", (PyObject *)&__pyx_type_6gevent_11__semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
- if (__pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_11__semaphore_BoundedSemaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_11__semaphore_BoundedSemaphore = &__pyx_type_6gevent_11__semaphore_BoundedSemaphore;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(2, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(2, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__semaphore(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__semaphore(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___semaphore(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___semaphore(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___semaphore(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___semaphore(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__semaphore", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____semaphore) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__semaphore")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__semaphore", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_semaphore.py":3
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- * from __future__ import print_function, absolute_import, division
- * import sys # <<<<<<<<<<<<<<
- *
- * from gevent.timeout import Timeout
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":5
- * import sys
- *
- * from gevent.timeout import Timeout # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Timeout);
- __Pyx_GIVEREF(__pyx_n_s_Timeout);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Timeout);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_11__semaphore_Timeout);
- __Pyx_DECREF_SET(__pyx_v_6gevent_11__semaphore_Timeout, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":8
- *
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'Semaphore',
- * 'BoundedSemaphore',
- */
- __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_Semaphore);
- __Pyx_GIVEREF(__pyx_n_s_Semaphore);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Semaphore);
- __Pyx_INCREF(__pyx_n_s_BoundedSemaphore);
- __Pyx_GIVEREF(__pyx_n_s_BoundedSemaphore);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_BoundedSemaphore);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":17
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['get_hub'] = __import__('gevent').get_hub
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_getcurrent, __pyx_t_1) < 0)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":18
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['get_hub'] = __import__('gevent').get_hub
- *
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_greenlet_init, __pyx_t_1) < 0)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":19
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None
- * locals()['get_hub'] = __import__('gevent').get_hub # <<<<<<<<<<<<<<
- *
- * class Semaphore(object):
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_get_hub, __pyx_t_2) < 0)) __PYX_ERR(0, 19, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":68
- * return '<%s counter=%s _links[%s]>' % params
- *
- * def locked(self): # <<<<<<<<<<<<<<
- * """Return a boolean indicating whether the semaphore can be acquired.
- * Most useful with binary semaphores."""
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_5locked, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_locked, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_locked, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":73
- * return self.counter <= 0
- *
- * def release(self): # <<<<<<<<<<<<<<
- * """
- * Release the semaphore, notifying any waiters if needed.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":81
- * return self.counter
- *
- * def _start_notify(self): # <<<<<<<<<<<<<<
- * if self._links and self.counter > 0 and not self._notifier:
- * # We create a new self._notifier each time through the loop,
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_9_start_notify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__start_notify, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_start_notify, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":93
- * self._notifier = hub.loop.run_callback(self._notify_links)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Subclasses CANNOT override. This is a cdef method.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_11_notify_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__notify_links, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_notify_links, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":129
- * self._notifier = None
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * rawlink(callback) -> None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_13rawlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_rawlink, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_rawlink, __pyx_t_2) < 0) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":149
- * self._dirty = True
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * unlink(callback) -> None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_15unlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_unlink, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_unlink, __pyx_t_2) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":190
- * self.unlink(switch)
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * wait(timeout=None) -> int
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_17wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_wait, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":211
- * return self.counter
- *
- * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * acquire(blocking=True, timeout=None) -> bool
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_19acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_acquire, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":250
- * return True
- *
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython # <<<<<<<<<<<<<<
- *
- * def __enter__(self):
- */
- __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore, __pyx_n_s_acquire); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_py3k_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":252
- * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
- *
- * def __enter__(self): # <<<<<<<<<<<<<<
- * self.acquire()
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_21__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___enter, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_enter, __pyx_t_2) < 0) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":255
- * self.acquire()
- *
- * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<<
- * self.release()
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_23__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___exit, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_exit, __pyx_t_2) < 0) __PYX_ERR(0, 255, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
-
- /* "src/gevent/_semaphore.py":273
- *
- * #: For monkey-patching, allow changing the class of error we raise
- * _OVER_RELEASE_ERROR = ValueError # <<<<<<<<<<<<<<
- *
- * def __init__(self, *args, **kwargs):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) __PYX_ERR(0, 273, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore);
-
- /* "src/gevent/_semaphore.py":279
- * self._initial_value = self.counter
- *
- * def release(self): # <<<<<<<<<<<<<<
- * if self.counter >= self._initial_value:
- * raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_11__semaphore_16BoundedSemaphore_3release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BoundedSemaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore);
-
- /* "src/gevent/_semaphore.py":288
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- * # By building the semaphore with Cython under PyPy, we get
- */
- __pyx_f_6gevent_11__semaphore__init();
-
- /* "src/gevent/_semaphore.py":302
- * # for PyPy in all cases anyway, so this does nothing.
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__semaphore')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_semaphore.py":303
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__semaphore') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___semaphore);
- __Pyx_GIVEREF(__pyx_n_s_gevent___semaphore);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___semaphore);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_semaphore.py":1
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False # <<<<<<<<<<<<<<
- * from __future__ import print_function, absolute_import, division
- * import sys
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/__semaphore.pxd":22
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__semaphore", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__semaphore");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_semaphore.py b/python/gevent/_semaphore.py
deleted file mode 100644
index d7c67ce..0000000
--- a/python/gevent/_semaphore.py
+++ /dev/null
@@ -1,303 +0,0 @@
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-from __future__ import print_function, absolute_import, division
-import sys
-
-from gevent.timeout import Timeout
-
-
-__all__ = [
- 'Semaphore',
- 'BoundedSemaphore',
-]
-
-# In Cython, we define these as 'cdef [inline]' functions. The
-# compilation unit cannot have a direct assignment to them (import
-# is assignment) without generating a 'lvalue is not valid target'
-# error.
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-locals()['get_hub'] = __import__('gevent').get_hub
-
-class Semaphore(object):
- """
- Semaphore(value=1) -> Semaphore
-
- A semaphore manages a counter representing the number of release()
- calls minus the number of acquire() calls, plus an initial value.
- The acquire() method blocks if necessary until it can return
- without making the counter negative.
-
- If not given, ``value`` defaults to 1.
-
- The semaphore is a context manager and can be used in ``with`` statements.
-
- This Semaphore's ``__exit__`` method does not call the trace function
- on CPython, but does under PyPy.
-
- .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents
- some classes of bugs.
- """
-
- def __init__(self, value=1):
- if value < 0:
- raise ValueError("semaphore initial value must be >= 0")
- self.counter = value
- self._dirty = False
- # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef
- # readonly` or simply `cdef` attributes of type `object` can appear to leak if
- # a Python subclass is used (this is visible simply
- # instantiating this subclass if _links=[]). Our _links and
- # _notifier are such attributes, and gevent.thread subclasses
- # this class. Thus, we carefully manage the lifetime of the
- # objects we put in these attributes so that, in the normal
- # case of a semaphore used correctly (deallocated when it's not
- # locked and no one is waiting), the leak goes away (because
- # these objects are back to None). This can also be solved on PyPy
- # by simply not declaring these objects in the pxd file, but that doesn't work for
- # CPython ("No attribute...")
- # See https://github.com/gevent/gevent/issues/660
- self._links = None
- self._notifier = None
- # we don't want to do get_hub() here to allow defining module-level locks
- # without initializing the hub
-
- def __str__(self):
- params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0)
- return '<%s counter=%s _links[%s]>' % params
-
- def locked(self):
- """Return a boolean indicating whether the semaphore can be acquired.
- Most useful with binary semaphores."""
- return self.counter <= 0
-
- def release(self):
- """
- Release the semaphore, notifying any waiters if needed.
- """
- self.counter += 1
- self._start_notify()
- return self.counter
-
- def _start_notify(self):
- if self._links and self.counter > 0 and not self._notifier:
- # We create a new self._notifier each time through the loop,
- # if needed. (it has a __bool__ method that tells whether it has
- # been run; once it's run once---at the end of the loop---it becomes
- # false.)
- # NOTE: Passing the bound method will cause a memory leak on PyPy
- # with Cython <= 0.23.3. You must use >= 0.23.4.
- # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546
- hub = get_hub() # pylint:disable=undefined-variable
- self._notifier = hub.loop.run_callback(self._notify_links)
-
- def _notify_links(self):
- # Subclasses CANNOT override. This is a cdef method.
-
- # We release self._notifier here. We are called by it
- # at the end of the loop, and it is now false in a boolean way (as soon
- # as this method returns).
- # If we get acquired/released again, we will create a new one, but there's
- # no need to keep it around until that point (making it potentially climb
- # into older GC generations, notably on PyPy)
- notifier = self._notifier
- try:
- while True:
- self._dirty = False
- if not self._links:
- # In case we were manually unlinked before
- # the callback. Which shouldn't happen
- return
- for link in self._links:
- if self.counter <= 0:
- return
- try:
- link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory
- except: # pylint:disable=bare-except
- getcurrent().handle_error((link, self), *sys.exc_info()) # pylint:disable=undefined-variable
- if self._dirty:
- # We mutated self._links so we need to start over
- break
- if not self._dirty:
- return
- finally:
- # We should not have created a new notifier even if callbacks
- # released us because we loop through *all* of our links on the
- # same callback while self._notifier is still true.
- assert self._notifier is notifier
- self._notifier = None
-
- def rawlink(self, callback):
- """
- rawlink(callback) -> None
-
- Register a callback to call when a counter is more than zero.
-
- *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.
- *callback* will be passed one argument: this instance.
-
- This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code
- will not need to use it.
- """
- if not callable(callback):
- raise TypeError('Expected callable:', callback)
- if self._links is None:
- self._links = [callback]
- else:
- self._links.append(callback)
- self._dirty = True
-
- def unlink(self, callback):
- """
- unlink(callback) -> None
-
- Remove the callback set by :meth:`rawlink`.
-
- This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most
- code will not need to use it.
- """
- try:
- self._links.remove(callback)
- self._dirty = True
- except (ValueError, AttributeError):
- pass
- if not self._links:
- self._links = None
- # TODO: Cancel a notifier if there are no links?
-
- def _do_wait(self, timeout):
- """
- Wait for up to *timeout* seconds to expire. If timeout
- elapses, return the exception. Otherwise, return None.
- Raises timeout if a different timer expires.
- """
- switch = getcurrent().switch # pylint:disable=undefined-variable
- self.rawlink(switch)
- try:
- timer = Timeout._start_new_or_dummy(timeout)
- try:
- try:
- result = get_hub().switch() # pylint:disable=undefined-variable
- assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, )
- except Timeout as ex:
- if ex is not timer:
- raise
- return ex
- finally:
- timer.cancel()
- finally:
- self.unlink(switch)
-
- def wait(self, timeout=None):
- """
- wait(timeout=None) -> int
-
- Wait until it is possible to acquire this semaphore, or until the optional
- *timeout* elapses.
-
- .. caution:: If this semaphore was initialized with a size of 0,
- this method will block forever if no timeout is given.
-
- :keyword float timeout: If given, specifies the maximum amount of seconds
- this method will block.
- :return: A number indicating how many times the semaphore can be acquired
- before blocking.
- """
- if self.counter > 0:
- return self.counter
-
- self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout
- return self.counter
-
- def acquire(self, blocking=True, timeout=None):
- """
- acquire(blocking=True, timeout=None) -> bool
-
- Acquire the semaphore.
-
- .. caution:: If this semaphore was initialized with a size of 0,
- this method will block forever (unless a timeout is given or blocking is
- set to false).
-
- :keyword bool blocking: If True (the default), this function will block
- until the semaphore is acquired.
- :keyword float timeout: If given, specifies the maximum amount of seconds
- this method will block.
- :return: A boolean indicating whether the semaphore was acquired.
- If ``blocking`` is True and ``timeout`` is None (the default), then
- (so long as this semaphore was initialized with a size greater than 0)
- this will always return True. If a timeout was given, and it expired before
- the semaphore was acquired, False will be returned. (Note that this can still
- raise a ``Timeout`` exception, if some other caller had already started a timer.)
- """
- if self.counter > 0:
- self.counter -= 1
- return True
-
- if not blocking:
- return False
-
- timeout = self._do_wait(timeout)
- if timeout is not None:
- # Our timer expired.
- return False
-
- # Neither our timer no another one expired, so we blocked until
- # awoke. Therefore, the counter is ours
- self.counter -= 1
- assert self.counter >= 0
- return True
-
- _py3k_acquire = acquire # PyPy needs this; it must be static for Cython
-
- def __enter__(self):
- self.acquire()
-
- def __exit__(self, t, v, tb):
- self.release()
-
-
-class BoundedSemaphore(Semaphore):
- """
- BoundedSemaphore(value=1) -> BoundedSemaphore
-
- A bounded semaphore checks to make sure its current value doesn't
- exceed its initial value. If it does, :class:`ValueError` is
- raised. In most situations semaphores are used to guard resources
- with limited capacity. If the semaphore is released too many times
- it's a sign of a bug.
-
- If not given, *value* defaults to 1.
- """
-
- #: For monkey-patching, allow changing the class of error we raise
- _OVER_RELEASE_ERROR = ValueError
-
- def __init__(self, *args, **kwargs):
- Semaphore.__init__(self, *args, **kwargs)
- self._initial_value = self.counter
-
- def release(self):
- if self.counter >= self._initial_value:
- raise self._OVER_RELEASE_ERROR("Semaphore released too many times")
- Semaphore.release(self)
-
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-# By building the semaphore with Cython under PyPy, we get
-# atomic operations (specifically, exiting/releasing), at the
-# cost of some speed (one trivial semaphore micro-benchmark put the pure-python version
-# at around 1s and the compiled version at around 4s). Some clever subclassing
-# and having only the bare minimum be in cython might help reduce that penalty.
-# NOTE: You must use version 0.23.4 or later to avoid a memory leak.
-# https://mail.python.org/pipermail/cython-devel/2015-October/004571.html
-# However, that's all for naught on up to and including PyPy 4.0.1 which
-# have some serious crashing bugs with GC interacting with cython.
-# It hasn't been tested since then, and PURE_PYTHON is assumed to be true
-# for PyPy in all cases anyway, so this does nothing.
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__semaphore')
diff --git a/python/gevent/_socket2.py b/python/gevent/_socket2.py
deleted file mode 100644
index d2377b2..0000000
--- a/python/gevent/_socket2.py
+++ /dev/null
@@ -1,473 +0,0 @@
-# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
-"""
-Python 2 socket module.
-"""
-from __future__ import absolute_import
-
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable
-
-from gevent import _socketcommon
-from gevent._util import copy_globals
-from gevent._compat import PYPY
-from gevent.timeout import Timeout
-
-copy_globals(_socketcommon, globals(),
- names_to_ignore=_socketcommon.__py3_imports__ + _socketcommon.__extensions__,
- dunder_names_to_keep=())
-
-__socket__ = _socketcommon.__socket__
-__implements__ = _socketcommon._implements
-__extensions__ = _socketcommon.__extensions__
-__imports__ = [i for i in _socketcommon.__imports__ if i not in _socketcommon.__py3_imports__]
-__dns__ = _socketcommon.__dns__
-try:
- _fileobject = __socket__._fileobject
- _socketmethods = __socket__._socketmethods
-except AttributeError:
- # Allow this module to be imported under Python 3
- # for building the docs
- _fileobject = object
- _socketmethods = ('bind', 'connect', 'connect_ex',
- 'fileno', 'listen', 'getpeername',
- 'getsockname', 'getsockopt',
- 'setsockopt', 'sendall',
- 'setblocking', 'settimeout',
- 'gettimeout', 'shutdown')
-else:
- # Python 2 doesn't natively support with statements on _fileobject;
- # but it eases our test cases if we can do the same with on both Py3
- # and Py2. Implementation copied from Python 3
- assert not hasattr(_fileobject, '__enter__')
- # we could either patch in place:
- #_fileobject.__enter__ = lambda self: self
- #_fileobject.__exit__ = lambda self, *args: self.close() if not self.closed else None
- # or we could subclass. subclassing has the benefit of not
- # changing the behaviour of the stdlib if we're just imported; OTOH,
- # under Python 2.6/2.7, test_urllib2net.py asserts that the class IS
- # socket._fileobject (sigh), so we have to work around that.
-
- # We also make it call our custom socket closing method that disposes
- # if IO watchers but not the actual socket itself.
-
- # Python 2 relies on reference counting to close sockets, so this is all
- # very ugly and fragile.
-
- class _fileobject(_fileobject): # pylint:disable=function-redefined
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args):
- if not self.closed:
- self.close()
-
- def close(self):
- if self._sock is not None:
- self._sock._drop_events()
- super(_fileobject, self).close()
-
-
-def _get_memory(data):
- try:
- mv = memoryview(data)
- if mv.shape:
- return mv
- # No shape, probably working with a ctypes object,
- # or something else exotic that supports the buffer interface
- return mv.tobytes()
- except TypeError:
- # fixes "python2.7 array.array doesn't support memoryview used in
- # gevent.socket.send" issue
- # (http://code.google.com/p/gevent/issues/detail?id=94)
- return buffer(data)
-
-
-class _closedsocket(object):
- __slots__ = []
-
- def _dummy(*args, **kwargs): # pylint:disable=no-method-argument,unused-argument
- raise error(EBADF, 'Bad file descriptor')
- # All _delegate_methods must also be initialized here.
- send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
-
- if PYPY:
-
- def _drop(self):
- pass
-
- def _reuse(self):
- pass
-
- __getattr__ = _dummy
-
-
-timeout_default = object()
-
-from gevent._hub_primitives import wait_on_socket as _wait_on_socket
-
-class socket(object):
- """
- gevent `socket.socket <https://docs.python.org/2/library/socket.html#socket-objects>`_
- for Python 2.
-
- This object should have the same API as the standard library socket linked to above. Not all
- methods are specifically documented here; when they are they may point out a difference
- to be aware of or may document a method the standard library does not.
- """
-
- # pylint:disable=too-many-public-methods
-
- def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
- if _sock is None:
- self._sock = _realsocket(family, type, proto)
- self.timeout = _socket.getdefaulttimeout()
- else:
- if hasattr(_sock, '_sock'):
- # passed a gevent socket
- self._sock = _sock._sock
- self.timeout = getattr(_sock, 'timeout', False)
- if self.timeout is False:
- self.timeout = _socket.getdefaulttimeout()
- else:
- # passed a native socket
- self._sock = _sock
- self.timeout = _socket.getdefaulttimeout()
- if PYPY:
- self._sock._reuse()
- self._sock.setblocking(0)
- fileno = self._sock.fileno()
- self.hub = get_hub()
- io = self.hub.loop.io
- self._read_event = io(fileno, 1)
- self._write_event = io(fileno, 2)
-
- def __repr__(self):
- return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo())
-
- def __str__(self):
- return '<%s %s>' % (type(self).__name__, self._formatinfo())
-
- def _formatinfo(self):
- # pylint:disable=broad-except
- try:
- fileno = self.fileno()
- except Exception as ex:
- fileno = str(ex)
- try:
- sockname = self.getsockname()
- sockname = '%s:%s' % sockname
- except Exception:
- sockname = None
- try:
- peername = self.getpeername()
- peername = '%s:%s' % peername
- except Exception:
- peername = None
- result = 'fileno=%s' % fileno
- if sockname is not None:
- result += ' sock=' + str(sockname)
- if peername is not None:
- result += ' peer=' + str(peername)
- if getattr(self, 'timeout', None) is not None:
- result += ' timeout=' + str(self.timeout)
- return result
-
- def _get_ref(self):
- return self._read_event.ref or self._write_event.ref
-
- def _set_ref(self, value):
- self._read_event.ref = value
- self._write_event.ref = value
-
- ref = property(_get_ref, _set_ref)
-
- _wait = _wait_on_socket
-
- def accept(self):
- sock = self._sock
- while True:
- try:
- client_socket, address = sock.accept()
- break
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
- sockobj = socket(_sock=client_socket)
- if PYPY:
- client_socket._drop()
- return sockobj, address
-
- def _drop_events(self, cancel_wait_ex=cancel_wait_ex):
- if self._read_event is not None:
- self.hub.cancel_wait(self._read_event, cancel_wait_ex, True)
- self._read_event = None
- if self._write_event is not None:
- self.hub.cancel_wait(self._write_event, cancel_wait_ex, True)
- self._write_event = None
-
-
- def close(self, _closedsocket=_closedsocket):
- # This function should not reference any globals. See Python issue #808164.
-
- # Also break any reference to the loop.io objects. Our fileno, which they were
- # tied to, is now free to be reused, so these objects are no longer functional.
- self._drop_events()
- s = self._sock
- self._sock = _closedsocket()
- if PYPY:
- s._drop()
-
- @property
- def closed(self):
- return isinstance(self._sock, _closedsocket)
-
- def connect(self, address):
- if self.timeout == 0.0:
- return self._sock.connect(address)
- sock = self._sock
- address = _socketcommon._resolve_addr(sock, address)
-
- timer = Timeout._start_new_or_dummy(self.timeout, timeout('timed out'))
- try:
- while True:
- err = sock.getsockopt(SOL_SOCKET, SO_ERROR)
- if err:
- raise error(err, strerror(err))
- result = sock.connect_ex(address)
- if not result or result == EISCONN:
- break
- elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows):
- self._wait(self._write_event)
- else:
- raise error(result, strerror(result))
- finally:
- timer.close()
-
- def connect_ex(self, address):
- try:
- return self.connect(address) or 0
- except timeout:
- return EAGAIN
- except error as ex:
- if type(ex) is error: # pylint:disable=unidiomatic-typecheck
- return ex.args[0]
- raise # gaierror is not silenced by connect_ex
-
- def dup(self):
- """dup() -> socket object
-
- Return a new socket object connected to the same system resource.
- Note, that the new socket does not inherit the timeout."""
- return socket(_sock=self._sock)
-
- def makefile(self, mode='r', bufsize=-1):
- # Two things to look out for:
- # 1) Closing the original socket object should not close the
- # fileobject (hence creating a new socket instance);
- # An alternate approach is what _socket3.py does, which is to
- # keep count of the times makefile objects have been opened (Py3's
- # SocketIO helps with that). But the newly created socket, which
- # has its own read/write watchers, does need those to be closed
- # when the fileobject is; our custom subclass does that. Note that
- # we can't pass the 'close=True' argument, as that causes reference counts
- # to get screwed up, and Python2 sockets rely on those.
- # 2) The resulting fileobject must keep the timeout in order
- # to be compatible with the stdlib's socket.makefile.
- # Pass self as _sock to preserve timeout.
- fobj = _fileobject(type(self)(_sock=self), mode, bufsize)
- if PYPY:
- self._sock._drop()
- return fobj
-
- def recv(self, *args):
- sock = self._sock # keeping the reference so that fd is not closed during waiting
- while True:
- try:
- return sock.recv(*args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- # QQQ without clearing exc_info test__refcount.test_clean_exit fails
- sys.exc_clear()
- self._wait(self._read_event)
-
- def recvfrom(self, *args):
- sock = self._sock
- while True:
- try:
- return sock.recvfrom(*args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
-
- def recvfrom_into(self, *args):
- sock = self._sock
- while True:
- try:
- return sock.recvfrom_into(*args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
-
- def recv_into(self, *args):
- sock = self._sock
- while True:
- try:
- return sock.recv_into(*args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
-
- def send(self, data, flags=0, timeout=timeout_default):
- sock = self._sock
- if timeout is timeout_default:
- timeout = self.timeout
- try:
- return sock.send(data, flags)
- except error as ex:
- if ex.args[0] not in _socketcommon.GSENDAGAIN or timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event)
- try:
- return sock.send(data, flags)
- except error as ex2:
- if ex2.args[0] == EWOULDBLOCK:
- return 0
- raise
-
- def sendall(self, data, flags=0):
- if isinstance(data, unicode):
- data = data.encode()
- # this sendall is also reused by gevent.ssl.SSLSocket subclass,
- # so it should not call self._sock methods directly
- data_memory = _get_memory(data)
- return _socketcommon._sendall(self, data_memory, flags)
-
- def sendto(self, *args):
- sock = self._sock
- try:
- return sock.sendto(*args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event)
- try:
- return sock.sendto(*args)
- except error as ex2:
- if ex2.args[0] == EWOULDBLOCK:
- return 0
- raise
-
- def setblocking(self, flag):
- if flag:
- self.timeout = None
- else:
- self.timeout = 0.0
-
- def settimeout(self, howlong):
- if howlong is not None:
- try:
- f = howlong.__float__
- except AttributeError:
- raise TypeError('a float is required')
- howlong = f()
- if howlong < 0.0:
- raise ValueError('Timeout value out of range')
- self.__dict__['timeout'] = howlong # avoid recursion with any property on self.timeout
-
- def gettimeout(self):
- return self.__dict__['timeout'] # avoid recursion with any property on self.timeout
-
- def shutdown(self, how):
- if how == 0: # SHUT_RD
- self.hub.cancel_wait(self._read_event, cancel_wait_ex)
- elif how == 1: # SHUT_WR
- self.hub.cancel_wait(self._write_event, cancel_wait_ex)
- else:
- self.hub.cancel_wait(self._read_event, cancel_wait_ex)
- self.hub.cancel_wait(self._write_event, cancel_wait_ex)
- self._sock.shutdown(how)
-
- family = property(lambda self: self._sock.family)
- type = property(lambda self: self._sock.type)
- proto = property(lambda self: self._sock.proto)
-
- def fileno(self):
- return self._sock.fileno()
-
- def getsockname(self):
- return self._sock.getsockname()
-
- def getpeername(self):
- return self._sock.getpeername()
-
- # delegate the functions that we haven't implemented to the real socket object
-
- _s = "def %s(self, *args): return self._sock.%s(*args)\n\n"
- _m = None
- for _m in set(_socketmethods) - set(locals()):
- exec(_s % (_m, _m,))
- del _m, _s
-
- if PYPY:
-
- def _reuse(self):
- self._sock._reuse()
-
- def _drop(self):
- self._sock._drop()
-
-
-SocketType = socket
-
-if hasattr(_socket, 'socketpair'):
-
- def socketpair(family=getattr(_socket, 'AF_UNIX', _socket.AF_INET),
- type=_socket.SOCK_STREAM, proto=0):
- one, two = _socket.socketpair(family, type, proto)
- result = socket(_sock=one), socket(_sock=two)
- if PYPY:
- one._drop()
- two._drop()
- return result
-elif 'socketpair' in __implements__:
- __implements__.remove('socketpair')
-
-if hasattr(_socket, 'fromfd'):
-
- def fromfd(fd, family, type, proto=0):
- s = _socket.fromfd(fd, family, type, proto)
- result = socket(_sock=s)
- if PYPY:
- s._drop()
- return result
-
-elif 'fromfd' in __implements__:
- __implements__.remove('fromfd')
-
-if hasattr(__socket__, 'ssl'):
-
- def ssl(sock, keyfile=None, certfile=None):
- # deprecated in 2.7.9 but still present;
- # sometimes backported by distros. See ssl.py
- # Note that we import gevent.ssl, not _ssl2, to get the correct
- # version.
- from gevent import ssl as _sslmod
- # wrap_socket is 2.7.9/backport, sslwrap_simple is older. They take
- # the same arguments.
- wrap = getattr(_sslmod, 'wrap_socket', None) or getattr(_sslmod, 'sslwrap_simple')
- return wrap(sock, keyfile, certfile)
- __implements__.append('ssl')
-
-__all__ = __implements__ + __extensions__ + __imports__
diff --git a/python/gevent/_socket3.py b/python/gevent/_socket3.py
deleted file mode 100644
index 973b5a9..0000000
--- a/python/gevent/_socket3.py
+++ /dev/null
@@ -1,756 +0,0 @@
-# Port of Python 3.3's socket module to gevent
-"""
-Python 3 socket module.
-"""
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable
-# pylint: disable=too-many-statements,too-many-branches
-# pylint: disable=too-many-public-methods,unused-argument
-from __future__ import absolute_import
-import io
-import os
-import sys
-
-from gevent import _socketcommon
-from gevent._util import copy_globals
-from gevent._compat import PYPY
-from gevent.timeout import Timeout
-import _socket
-from os import dup
-
-
-copy_globals(_socketcommon, globals(),
- names_to_ignore=_socketcommon.__extensions__,
- dunder_names_to_keep=())
-
-try:
- from errno import EHOSTUNREACH
- from errno import ECONNREFUSED
-except ImportError:
- EHOSTUNREACH = -1
- ECONNREFUSED = -1
-
-
-__socket__ = _socketcommon.__socket__
-__implements__ = _socketcommon._implements
-__extensions__ = _socketcommon.__extensions__
-__imports__ = _socketcommon.__imports__
-__dns__ = _socketcommon.__dns__
-
-
-SocketIO = __socket__.SocketIO # pylint:disable=no-member
-
-
-def _get_memory(data):
- mv = memoryview(data)
- if mv.shape:
- return mv
- # No shape, probably working with a ctypes object,
- # or something else exotic that supports the buffer interface
- return mv.tobytes()
-
-timeout_default = object()
-
-
-class _wrefsocket(_socket.socket):
- # Plain stdlib socket.socket objects subclass _socket.socket
- # and add weakref ability. The ssl module, for one, counts on this.
- # We don't create socket.socket objects (because they may have been
- # monkey patched to be the object from this module), but we still
- # need to make sure what we do create can be weakrefd.
-
- __slots__ = ("__weakref__", )
-
- if PYPY:
- # server.py unwraps the socket object to get the raw _sock;
- # it depends on having a timeout property alias, which PyPy does not
- # provide.
- timeout = property(lambda s: s.gettimeout(),
- lambda s, nv: s.settimeout(nv))
-
-from gevent._hub_primitives import wait_on_socket as _wait_on_socket
-
-class socket(object):
- """
- gevent `socket.socket <https://docs.python.org/3/library/socket.html#socket-objects>`_
- for Python 3.
-
- This object should have the same API as the standard library socket linked to above. Not all
- methods are specifically documented here; when they are they may point out a difference
- to be aware of or may document a method the standard library does not.
- """
-
- # Subclasses can set this to customize the type of the
- # native _socket.socket we create. It MUST be a subclass
- # of _wrefsocket. (gevent internal usage only)
- _gevent_sock_class = _wrefsocket
-
- _io_refs = 0
- _closed = False
- _read_event = None
- _write_event = None
-
-
- # Take the same approach as socket2: wrap a real socket object,
- # don't subclass it. This lets code that needs the raw _sock (not tied to the hub)
- # get it. This shows up in tests like test__example_udp_server.
-
- if sys.version_info[:2] < (3, 7):
- def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None):
- self._sock = self._gevent_sock_class(family, type, proto, fileno)
- self.timeout = None
- self.__init_common()
- else:
- # In 3.7, socket changed to auto-detecting family, type, and proto
- # when given a fileno.
- def __init__(self, family=-1, type=-1, proto=-1, fileno=None):
- if fileno is None:
- if family == -1:
- family = AF_INET
- if type == -1:
- type = SOCK_STREAM
- if proto == -1:
- proto = 0
- self._sock = self._gevent_sock_class(family, type, proto, fileno)
- self.timeout = None
- self.__init_common()
-
- def __init_common(self):
- _socket.socket.setblocking(self._sock, False)
- fileno = _socket.socket.fileno(self._sock)
- self.hub = get_hub()
- io_class = self.hub.loop.io
- self._read_event = io_class(fileno, 1)
- self._write_event = io_class(fileno, 2)
- self.timeout = _socket.getdefaulttimeout()
-
- def __getattr__(self, name):
- return getattr(self._sock, name)
-
- if hasattr(_socket, 'SOCK_NONBLOCK'):
- # Only defined under Linux
- @property
- def type(self):
- # See https://github.com/gevent/gevent/pull/399
- if self.timeout != 0.0:
- return self._sock.type & ~_socket.SOCK_NONBLOCK # pylint:disable=no-member
- return self._sock.type
-
- def getblocking(self):
- """
- Returns whether the socket will approximate blocking
- behaviour.
-
- .. versionadded:: 1.3a2
- Added in Python 3.7.
- """
- return self.timeout != 0.0
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args):
- if not self._closed:
- self.close()
-
- def __repr__(self):
- """Wrap __repr__() to reveal the real class name."""
- try:
- s = _socket.socket.__repr__(self._sock)
- except Exception as ex: # pylint:disable=broad-except
- # Observed on Windows Py3.3, printing the repr of a socket
- # that just suffered a ConnectionResetError [WinError 10054]:
- # "OverflowError: no printf formatter to display the socket descriptor in decimal"
- # Not sure what the actual cause is or if there's a better way to handle this
- s = '<socket [%r]>' % ex
-
- if s.startswith("<socket object"):
- s = "<%s.%s%s%s" % (self.__class__.__module__,
- self.__class__.__name__,
- getattr(self, '_closed', False) and " [closed] " or "",
- s[7:])
- return s
-
- def __getstate__(self):
- raise TypeError("Cannot serialize socket object")
-
- def _get_ref(self):
- return self._read_event.ref or self._write_event.ref
-
- def _set_ref(self, value):
- self._read_event.ref = value
- self._write_event.ref = value
-
- ref = property(_get_ref, _set_ref)
-
- _wait = _wait_on_socket
-
- def dup(self):
- """dup() -> socket object
-
- Return a new socket object connected to the same system resource.
- """
- fd = dup(self.fileno())
- sock = self.__class__(self.family, self.type, self.proto, fileno=fd)
- sock.settimeout(self.gettimeout())
- return sock
-
- def accept(self):
- """accept() -> (socket object, address info)
-
- Wait for an incoming connection. Return a new socket
- representing the connection, and the address of the client.
- For IP sockets, the address info is a pair (hostaddr, port).
- """
- while True:
- try:
- fd, addr = self._accept()
- break
- except BlockingIOError:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event)
- sock = socket(self.family, self.type, self.proto, fileno=fd)
- # Python Issue #7995: if no default timeout is set and the listening
- # socket had a (non-zero) timeout, force the new socket in blocking
- # mode to override platform-specific socket flags inheritance.
- # XXX do we need to do this?
- if getdefaulttimeout() is None and self.gettimeout():
- sock.setblocking(True)
- return sock, addr
-
- def makefile(self, mode="r", buffering=None, *,
- encoding=None, errors=None, newline=None):
- """Return an I/O stream connected to the socket
-
- The arguments are as for io.open() after the filename,
- except the only mode characters supported are 'r', 'w' and 'b'.
- The semantics are similar too.
- """
- # (XXX refactor to share code?)
- for c in mode:
- if c not in {"r", "w", "b"}:
- raise ValueError("invalid mode %r (only r, w, b allowed)")
- writing = "w" in mode
- reading = "r" in mode or not writing
- assert reading or writing
- binary = "b" in mode
- rawmode = ""
- if reading:
- rawmode += "r"
- if writing:
- rawmode += "w"
- raw = SocketIO(self, rawmode)
- self._io_refs += 1
- if buffering is None:
- buffering = -1
- if buffering < 0:
- buffering = io.DEFAULT_BUFFER_SIZE
- if buffering == 0:
- if not binary:
- raise ValueError("unbuffered streams must be binary")
- return raw
- if reading and writing:
- buffer = io.BufferedRWPair(raw, raw, buffering)
- elif reading:
- buffer = io.BufferedReader(raw, buffering)
- else:
- assert writing
- buffer = io.BufferedWriter(raw, buffering)
- if binary:
- return buffer
- text = io.TextIOWrapper(buffer, encoding, errors, newline)
- text.mode = mode
- return text
-
- def _decref_socketios(self):
- # Called by SocketIO when it is closed.
- if self._io_refs > 0:
- self._io_refs -= 1
- if self._closed:
- self.close()
-
- def _drop_events(self):
- if self._read_event is not None:
- self.hub.cancel_wait(self._read_event, cancel_wait_ex, True)
- self._read_event = None
- if self._write_event is not None:
- self.hub.cancel_wait(self._write_event, cancel_wait_ex, True)
- self._write_event = None
-
- def _real_close(self, _ss=_socket.socket, cancel_wait_ex=cancel_wait_ex):
- # This function should not reference any globals. See Python issue #808164.
-
- # Break any reference to the loop.io objects. Our fileno,
- # which they were tied to, is now free to be reused, so these
- # objects are no longer functional.
- self._drop_events()
-
- _ss.close(self._sock)
-
- # Break any references to the underlying socket object. Tested
- # by test__refcount. (Why does this matter?). Be sure to
- # preserve our same family/type/proto if possible (if we
- # don't, we can get TypeError instead of OSError; see
- # test_socket.SendmsgUDP6Test.testSendmsgAfterClose)... but
- # this isn't always possible (see test_socket.test_unknown_socket_family_repr)
- # TODO: Can we use a simpler proxy, like _socket2 does?
- try:
- self._sock = self._gevent_sock_class(self.family, self.type, self.proto)
- except OSError:
- pass
- else:
- _ss.close(self._sock)
-
-
- def close(self):
- # This function should not reference any globals. See Python issue #808164.
- self._closed = True
- if self._io_refs <= 0:
- self._real_close()
-
- @property
- def closed(self):
- return self._closed
-
- def detach(self):
- """detach() -> file descriptor
-
- Close the socket object without closing the underlying file descriptor.
- The object cannot be used after this call, but the file descriptor
- can be reused for other purposes. The file descriptor is returned.
- """
- self._closed = True
- return self._sock.detach()
-
- def connect(self, address):
- if self.timeout == 0.0:
- return _socket.socket.connect(self._sock, address)
- address = _socketcommon._resolve_addr(self._sock, address)
-
- with Timeout._start_new_or_dummy(self.timeout, timeout("timed out")):
- while True:
- err = self.getsockopt(SOL_SOCKET, SO_ERROR)
- if err:
- raise error(err, strerror(err))
- result = _socket.socket.connect_ex(self._sock, address)
-
- if not result or result == EISCONN:
- break
- elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows):
- self._wait(self._write_event)
- else:
- if (isinstance(address, tuple)
- and address[0] == 'fe80::1'
- and result == EHOSTUNREACH):
- # On Python 3.7 on mac, we see EHOSTUNREACH
- # returned for this link-local address, but it really is
- # supposed to be ECONNREFUSED according to the standard library
- # tests (test_socket.NetworkConnectionNoServer.test_create_connection)
- # (On previous versions, that code passed the '127.0.0.1' IPv4 address, so
- # ipv6 link locals were never a factor; 3.7 passes 'localhost'.)
- # It is something of a mystery how the stdlib socket code doesn't
- # produce EHOSTUNREACH---I (JAM) can't see how socketmodule.c would avoid
- # that. The normal connect just calls connect_ex much like we do.
- result = ECONNREFUSED
- raise error(result, strerror(result))
-
- def connect_ex(self, address):
- try:
- return self.connect(address) or 0
- except timeout:
- return EAGAIN
- except gaierror: # pylint:disable=try-except-raise
- # gaierror/overflowerror/typerror is not silenced by connect_ex;
- # gaierror extends OSError (aka error) so catch it first
- raise
- except error as ex:
- # error is now OSError and it has various subclasses.
- # Only those that apply to actually connecting are silenced by
- # connect_ex.
- if ex.errno:
- return ex.errno
- raise # pragma: no cover
-
- def recv(self, *args):
- while True:
- try:
- return _socket.socket.recv(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- if hasattr(_socket.socket, 'recvmsg'):
- # Only on Unix; PyPy 3.5 5.10.0 provides sendmsg and recvmsg, but not
- # recvmsg_into (at least on os x)
-
- def recvmsg(self, *args):
- while True:
- try:
- return _socket.socket.recvmsg(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- if hasattr(_socket.socket, 'recvmsg_into'):
-
- def recvmsg_into(self, *args):
- while True:
- try:
- return _socket.socket.recvmsg_into(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- def recvfrom(self, *args):
- while True:
- try:
- return _socket.socket.recvfrom(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- def recvfrom_into(self, *args):
- while True:
- try:
- return _socket.socket.recvfrom_into(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- def recv_into(self, *args):
- while True:
- try:
- return _socket.socket.recv_into(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._read_event)
-
- def send(self, data, flags=0, timeout=timeout_default):
- if timeout is timeout_default:
- timeout = self.timeout
- try:
- return _socket.socket.send(self._sock, data, flags)
- except error as ex:
- if ex.args[0] not in _socketcommon.GSENDAGAIN or timeout == 0.0:
- raise
- self._wait(self._write_event)
- try:
- return _socket.socket.send(self._sock, data, flags)
- except error as ex2:
- if ex2.args[0] == EWOULDBLOCK:
- return 0
- raise
-
- def sendall(self, data, flags=0):
- # XXX Now that we run on PyPy3, see the notes in _socket2.py's sendall()
- # and implement that here if needed.
- # PyPy3 is not optimized for performance yet, and is known to be slower than
- # PyPy2, so it's possibly premature to do this. However, there is a 3.5 test case that
- # possibly exposes this in a severe way.
- data_memory = _get_memory(data)
- return _socketcommon._sendall(self, data_memory, flags)
-
- def sendto(self, *args):
- try:
- return _socket.socket.sendto(self._sock, *args)
- except error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._write_event)
- try:
- return _socket.socket.sendto(self._sock, *args)
- except error as ex2:
- if ex2.args[0] == EWOULDBLOCK:
- return 0
- raise
-
- if hasattr(_socket.socket, 'sendmsg'):
- # Only on Unix
- def sendmsg(self, buffers, ancdata=(), flags=0, address=None):
- try:
- return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address)
- except error as ex:
- if flags & getattr(_socket, 'MSG_DONTWAIT', 0):
- # Enable non-blocking behaviour
- # XXX: Do all platforms that have sendmsg have MSG_DONTWAIT?
- raise
-
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- self._wait(self._write_event)
- try:
- return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address)
- except error as ex2:
- if ex2.args[0] == EWOULDBLOCK:
- return 0
- raise
-
- def setblocking(self, flag):
- # Beginning in 3.6.0b3 this is supposed to raise
- # if the file descriptor is closed, but the test for it
- # involves closing the fileno directly. Since we
- # don't touch the fileno here, it doesn't make sense for
- # us.
- if flag:
- self.timeout = None
- else:
- self.timeout = 0.0
-
- def settimeout(self, howlong):
- if howlong is not None:
- try:
- f = howlong.__float__
- except AttributeError:
- raise TypeError('a float is required')
- howlong = f()
- if howlong < 0.0:
- raise ValueError('Timeout value out of range')
- self.__dict__['timeout'] = howlong
-
- def gettimeout(self):
- return self.__dict__['timeout']
-
- def shutdown(self, how):
- if how == 0: # SHUT_RD
- self.hub.cancel_wait(self._read_event, cancel_wait_ex)
- elif how == 1: # SHUT_WR
- self.hub.cancel_wait(self._write_event, cancel_wait_ex)
- else:
- self.hub.cancel_wait(self._read_event, cancel_wait_ex)
- self.hub.cancel_wait(self._write_event, cancel_wait_ex)
- self._sock.shutdown(how)
-
- # sendfile: new in 3.5. But there's no real reason to not
- # support it everywhere. Note that we can't use os.sendfile()
- # because it's not cooperative.
- def _sendfile_use_sendfile(self, file, offset=0, count=None):
- # This is called directly by tests
- raise __socket__._GiveupOnSendfile() # pylint:disable=no-member
-
- def _sendfile_use_send(self, file, offset=0, count=None):
- self._check_sendfile_params(file, offset, count)
- if self.gettimeout() == 0:
- raise ValueError("non-blocking sockets are not supported")
- if offset:
- file.seek(offset)
- blocksize = min(count, 8192) if count else 8192
- total_sent = 0
- # localize variable access to minimize overhead
- file_read = file.read
- sock_send = self.send
- try:
- while True:
- if count:
- blocksize = min(count - total_sent, blocksize)
- if blocksize <= 0:
- break
- data = memoryview(file_read(blocksize))
- if not data:
- break # EOF
- while True:
- try:
- sent = sock_send(data)
- except BlockingIOError:
- continue
- else:
- total_sent += sent
- if sent < len(data):
- data = data[sent:]
- else:
- break
- return total_sent
- finally:
- if total_sent > 0 and hasattr(file, 'seek'):
- file.seek(offset + total_sent)
-
- def _check_sendfile_params(self, file, offset, count):
- if 'b' not in getattr(file, 'mode', 'b'):
- raise ValueError("file should be opened in binary mode")
- if not self.type & SOCK_STREAM:
- raise ValueError("only SOCK_STREAM type sockets are supported")
- if count is not None:
- if not isinstance(count, int):
- raise TypeError(
- "count must be a positive integer (got {!r})".format(count))
- if count <= 0:
- raise ValueError(
- "count must be a positive integer (got {!r})".format(count))
-
- def sendfile(self, file, offset=0, count=None):
- """sendfile(file[, offset[, count]]) -> sent
-
- Send a file until EOF is reached by using high-performance
- os.sendfile() and return the total number of bytes which
- were sent.
- *file* must be a regular file object opened in binary mode.
- If os.sendfile() is not available (e.g. Windows) or file is
- not a regular file socket.send() will be used instead.
- *offset* tells from where to start reading the file.
- If specified, *count* is the total number of bytes to transmit
- as opposed to sending the file until EOF is reached.
- File position is updated on return or also in case of error in
- which case file.tell() can be used to figure out the number of
- bytes which were sent.
- The socket must be of SOCK_STREAM type.
- Non-blocking sockets are not supported.
-
- .. versionadded:: 1.1rc4
- Added in Python 3.5, but available under all Python 3 versions in
- gevent.
- """
- return self._sendfile_use_send(file, offset, count)
-
- # get/set_inheritable new in 3.4
- if hasattr(os, 'get_inheritable') or hasattr(os, 'get_handle_inheritable'):
- # pylint:disable=no-member
- if os.name == 'nt':
- def get_inheritable(self):
- return os.get_handle_inheritable(self.fileno())
-
- def set_inheritable(self, inheritable):
- os.set_handle_inheritable(self.fileno(), inheritable)
- else:
- def get_inheritable(self):
- return os.get_inheritable(self.fileno())
-
- def set_inheritable(self, inheritable):
- os.set_inheritable(self.fileno(), inheritable)
- _added = "\n\n.. versionadded:: 1.1rc4 Added in Python 3.4"
- get_inheritable.__doc__ = "Get the inheritable flag of the socket" + _added
- set_inheritable.__doc__ = "Set the inheritable flag of the socket" + _added
- del _added
-
-
-if sys.version_info[:2] == (3, 4) and sys.version_info[:3] <= (3, 4, 2):
- # Python 3.4, up to and including 3.4.2, had a bug where the
- # SocketType enumeration overwrote the SocketType class imported
- # from _socket. This was fixed in 3.4.3 (http://bugs.python.org/issue20386
- # and https://github.com/python/cpython/commit/0d2f85f38a9691efdfd1e7285c4262cab7f17db7).
- # Prior to that, if we replace SocketType with our own class, the implementation
- # of socket.type breaks with "OSError: [Errno 97] Address family not supported by protocol".
- # Therefore, on these old versions, we must preserve it as an enum; while this
- # seems like it could lead to non-green behaviour, code on those versions
- # cannot possibly be using SocketType as a class anyway.
- SocketType = __socket__.SocketType # pylint:disable=no-member
- # Fixup __all__; note that we get exec'd multiple times during unit tests
- if 'SocketType' in __implements__:
- __implements__.remove('SocketType')
- if 'SocketType' not in __imports__:
- __imports__.append('SocketType')
-else:
- SocketType = socket
-
-
-def fromfd(fd, family, type, proto=0):
- """ fromfd(fd, family, type[, proto]) -> socket object
-
- Create a socket object from a duplicate of the given file
- descriptor. The remaining arguments are the same as for socket().
- """
- nfd = dup(fd)
- return socket(family, type, proto, nfd)
-
-
-if hasattr(_socket.socket, "share"):
- def fromshare(info):
- """ fromshare(info) -> socket object
-
- Create a socket object from a the bytes object returned by
- socket.share(pid).
- """
- return socket(0, 0, 0, info)
-
- __implements__.append('fromshare')
-
-if hasattr(_socket, "socketpair"):
-
- def socketpair(family=None, type=SOCK_STREAM, proto=0):
- """socketpair([family[, type[, proto]]]) -> (socket object, socket object)
-
- Create a pair of socket objects from the sockets returned by the platform
- socketpair() function.
- The arguments are the same as for socket() except the default family is
- AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
-
- .. versionchanged:: 1.2
- All Python 3 versions on Windows supply this function (natively
- supplied by Python 3.5 and above).
- """
- if family is None:
- try:
- family = AF_UNIX
- except NameError:
- family = AF_INET
- a, b = _socket.socketpair(family, type, proto)
- a = socket(family, type, proto, a.detach())
- b = socket(family, type, proto, b.detach())
- return a, b
-
-else: # pragma: no cover
- # Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain.
-
- # gevent: taken from 3.6 release. Expected to be used only on Win. Added to Win/3.5
- # gevent: for < 3.5, pass the default value of 128 to lsock.listen()
- # (3.5+ uses this as a default and the original code passed no value)
-
- _LOCALHOST = '127.0.0.1'
- _LOCALHOST_V6 = '::1'
-
- def socketpair(family=AF_INET, type=SOCK_STREAM, proto=0):
- if family == AF_INET:
- host = _LOCALHOST
- elif family == AF_INET6:
- host = _LOCALHOST_V6
- else:
- raise ValueError("Only AF_INET and AF_INET6 socket address families "
- "are supported")
- if type != SOCK_STREAM:
- raise ValueError("Only SOCK_STREAM socket type is supported")
- if proto != 0:
- raise ValueError("Only protocol zero is supported")
-
- # We create a connected TCP socket. Note the trick with
- # setblocking(False) that prevents us from having to create a thread.
- lsock = socket(family, type, proto)
- try:
- lsock.bind((host, 0))
- lsock.listen(128)
- # On IPv6, ignore flow_info and scope_id
- addr, port = lsock.getsockname()[:2]
- csock = socket(family, type, proto)
- try:
- csock.setblocking(False)
- try:
- csock.connect((addr, port))
- except (BlockingIOError, InterruptedError):
- pass
- csock.setblocking(True)
- ssock, _ = lsock.accept()
- except:
- csock.close()
- raise
- finally:
- lsock.close()
- return (ssock, csock)
-
- if sys.version_info[:2] < (3, 5):
- # Not provided natively
- if 'socketpair' in __implements__:
- # Multiple imports can cause this to be missing if _socketcommon
- # was successfully imported, leading to subsequent imports to cause
- # ValueError
- __implements__.remove('socketpair')
-
-
-if hasattr(__socket__, 'close'): # Python 3.7b1+
- close = __socket__.close # pylint:disable=no-member
- __imports__ += ['close']
-
-__all__ = __implements__ + __extensions__ + __imports__
diff --git a/python/gevent/_socketcommon.py b/python/gevent/_socketcommon.py
deleted file mode 100644
index c1c778f..0000000
--- a/python/gevent/_socketcommon.py
+++ /dev/null
@@ -1,382 +0,0 @@
-# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
-from __future__ import absolute_import
-
-# standard functions and classes that this module re-implements in a gevent-aware way:
-_implements = [
- 'create_connection',
- 'socket',
- 'SocketType',
- 'fromfd',
- 'socketpair',
-]
-
-__dns__ = [
- 'getaddrinfo',
- 'gethostbyname',
- 'gethostbyname_ex',
- 'gethostbyaddr',
- 'getnameinfo',
- 'getfqdn',
-]
-
-_implements += __dns__
-
-# non-standard functions that this module provides:
-__extensions__ = [
- 'cancel_wait',
- 'wait_read',
- 'wait_write',
- 'wait_readwrite',
-]
-
-# standard functions and classes that this module re-imports
-__imports__ = [
- 'error',
- 'gaierror',
- 'herror',
- 'htonl',
- 'htons',
- 'ntohl',
- 'ntohs',
- 'inet_aton',
- 'inet_ntoa',
- 'inet_pton',
- 'inet_ntop',
- 'timeout',
- 'gethostname',
- 'getprotobyname',
- 'getservbyname',
- 'getservbyport',
- 'getdefaulttimeout',
- 'setdefaulttimeout',
- # Windows:
- 'errorTab',
-]
-
-__py3_imports__ = [
- # Python 3
- 'AddressFamily',
- 'SocketKind',
- 'CMSG_LEN',
- 'CMSG_SPACE',
- 'dup',
- 'if_indextoname',
- 'if_nameindex',
- 'if_nametoindex',
- 'sethostname',
-]
-
-__imports__.extend(__py3_imports__)
-
-import time
-import sys
-from gevent._hub_local import get_hub_noargs as get_hub
-from gevent._compat import string_types, integer_types, PY3
-from gevent._util import copy_globals
-
-is_windows = sys.platform == 'win32'
-is_macos = sys.platform == 'darwin'
-
-# pylint:disable=no-name-in-module,unused-import
-if is_windows:
- # no such thing as WSAEPERM or error code 10001 according to winsock.h or MSDN
- from errno import WSAEINVAL as EINVAL
- from errno import WSAEWOULDBLOCK as EWOULDBLOCK
- from errno import WSAEINPROGRESS as EINPROGRESS
- from errno import WSAEALREADY as EALREADY
- from errno import WSAEISCONN as EISCONN
- from gevent.win32util import formatError as strerror
- EAGAIN = EWOULDBLOCK
-else:
- from errno import EINVAL
- from errno import EWOULDBLOCK
- from errno import EINPROGRESS
- from errno import EALREADY
- from errno import EAGAIN
- from errno import EISCONN
- from os import strerror
-
-try:
- from errno import EBADF
-except ImportError:
- EBADF = 9
-
-# macOS can return EPROTOTYPE when writing to a socket that is shutting
-# Down. Retrying the write should return the expected EPIPE error.
-# Downstream classes (like pywsgi) know how to handle/ignore EPIPE.
-# This set is used by socket.send() to decide whether the write should
-# be retried. The default is to retry only on EWOULDBLOCK. Here we add
-# EPROTOTYPE on macOS to handle this platform-specific race condition.
-GSENDAGAIN = (EWOULDBLOCK,)
-if is_macos:
- from errno import EPROTOTYPE
- GSENDAGAIN += (EPROTOTYPE,)
-
-import _socket
-_realsocket = _socket.socket
-import socket as __socket__
-
-_name = _value = None
-__imports__ = copy_globals(__socket__, globals(),
- only_names=__imports__,
- ignore_missing_names=True)
-
-for _name in __socket__.__all__:
- _value = getattr(__socket__, _name)
- if isinstance(_value, (integer_types, string_types)):
- globals()[_name] = _value
- __imports__.append(_name)
-
-del _name, _value
-
-_timeout_error = timeout # pylint: disable=undefined-variable
-
-from gevent import _hub_primitives
-_hub_primitives.set_default_timeout_error(_timeout_error)
-
-wait = _hub_primitives.wait_on_watcher
-wait_read = _hub_primitives.wait_read
-wait_write = _hub_primitives.wait_write
-wait_readwrite = _hub_primitives.wait_readwrite
-
-#: The exception raised by default on a call to :func:`cancel_wait`
-class cancel_wait_ex(error): # pylint: disable=undefined-variable
- def __init__(self):
- super(cancel_wait_ex, self).__init__(
- EBADF,
- 'File descriptor was closed in another greenlet')
-
-
-def cancel_wait(watcher, error=cancel_wait_ex):
- """See :meth:`gevent.hub.Hub.cancel_wait`"""
- get_hub().cancel_wait(watcher, error)
-
-
-def gethostbyname(hostname):
- """
- gethostbyname(host) -> address
-
- Return the IP address (a string of the form '255.255.255.255') for a host.
-
- .. seealso:: :doc:`/dns`
- """
- return get_hub().resolver.gethostbyname(hostname)
-
-
-def gethostbyname_ex(hostname):
- """
- gethostbyname_ex(host) -> (name, aliaslist, addresslist)
-
- Return the true host name, a list of aliases, and a list of IP addresses,
- for a host. The host argument is a string giving a host name or IP number.
- Resolve host and port into list of address info entries.
-
- .. seealso:: :doc:`/dns`
- """
- return get_hub().resolver.gethostbyname_ex(hostname)
-
-
-def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
- """
- Resolve host and port into list of address info entries.
-
- Translate the host/port argument into a sequence of 5-tuples that contain
- all the necessary arguments for creating a socket connected to that service.
- host is a domain name, a string representation of an IPv4/v6 address or
- None. port is a string service name such as 'http', a numeric port number or
- None. By passing None as the value of host and port, you can pass NULL to
- the underlying C API.
-
- The family, type and proto arguments can be optionally specified in order to
- narrow the list of addresses returned. Passing zero as a value for each of
- these arguments selects the full range of results.
-
- .. seealso:: :doc:`/dns`
- """
- return get_hub().resolver.getaddrinfo(host, port, family, socktype, proto, flags)
-
-if PY3:
- # The name of the socktype param changed to type in Python 3.
- # See https://github.com/gevent/gevent/issues/960
- # Using inspect here to directly detect the condition is painful because we have to
- # wrap it with a try/except TypeError because not all Python 2
- # versions can get the args of a builtin; we also have to use a with to suppress
- # the deprecation warning.
- d = getaddrinfo.__doc__
-
- def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): # pylint:disable=function-redefined
- return get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
- getaddrinfo.__doc__ = d
- del d
-
-
-def gethostbyaddr(ip_address):
- """
- gethostbyaddr(ip_address) -> (name, aliaslist, addresslist)
-
- Return the true host name, a list of aliases, and a list of IP addresses,
- for a host. The host argument is a string giving a host name or IP number.
-
- .. seealso:: :doc:`/dns`
- """
- return get_hub().resolver.gethostbyaddr(ip_address)
-
-
-def getnameinfo(sockaddr, flags):
- """
- getnameinfo(sockaddr, flags) -> (host, port)
-
- Get host and port for a sockaddr.
-
- .. seealso:: :doc:`/dns`
- """
- return get_hub().resolver.getnameinfo(sockaddr, flags)
-
-
-def getfqdn(name=''):
- """Get fully qualified domain name from name.
-
- An empty argument is interpreted as meaning the local host.
-
- First the hostname returned by gethostbyaddr() is checked, then
- possibly existing aliases. In case no FQDN is available, hostname
- from gethostname() is returned.
- """
- # pylint: disable=undefined-variable
- name = name.strip()
- if not name or name == '0.0.0.0':
- name = gethostname()
- try:
- hostname, aliases, _ = gethostbyaddr(name)
- except error:
- pass
- else:
- aliases.insert(0, hostname)
- for name in aliases: # EWW! pylint:disable=redefined-argument-from-local
- if isinstance(name, bytes):
- if b'.' in name:
- break
- elif '.' in name:
- break
- else:
- name = hostname
- return name
-
-def __send_chunk(socket, data_memory, flags, timeleft, end, timeout=_timeout_error):
- """
- Send the complete contents of ``data_memory`` before returning.
- This is the core loop around :meth:`send`.
-
- :param timeleft: Either ``None`` if there is no timeout involved,
- or a float indicating the timeout to use.
- :param end: Either ``None`` if there is no timeout involved, or
- a float giving the absolute end time.
- :return: An updated value for ``timeleft`` (or None)
- :raises timeout: If ``timeleft`` was given and elapsed while
- sending this chunk.
- """
- data_sent = 0
- len_data_memory = len(data_memory)
- started_timer = 0
- while data_sent < len_data_memory:
- chunk = data_memory[data_sent:]
- if timeleft is None:
- data_sent += socket.send(chunk, flags)
- elif started_timer and timeleft <= 0:
- # Check before sending to guarantee a check
- # happens even if each chunk successfully sends its data
- # (especially important for SSL sockets since they have large
- # buffers). But only do this if we've actually tried to
- # send something once to avoid spurious timeouts on non-blocking
- # sockets.
- raise timeout('timed out')
- else:
- started_timer = 1
- data_sent += socket.send(chunk, flags, timeout=timeleft)
- timeleft = end - time.time()
-
- return timeleft
-
-def _sendall(socket, data_memory, flags,
- SOL_SOCKET=__socket__.SOL_SOCKET, # pylint:disable=no-member
- SO_SNDBUF=__socket__.SO_SNDBUF): # pylint:disable=no-member
- """
- Send the *data_memory* (which should be a memoryview)
- using the gevent *socket*, performing well on PyPy.
- """
-
- # On PyPy up through 5.10.0, both PyPy2 and PyPy3, subviews
- # (slices) of a memoryview() object copy the underlying bytes the
- # first time the builtin socket.send() method is called. On a
- # non-blocking socket (that thus calls socket.send() many times)
- # with a large input, this results in many repeated copies of an
- # ever smaller string, depending on the networking buffering. For
- # example, if each send() can process 1MB of a 50MB input, and we
- # naively pass the entire remaining subview each time, we'd copy
- # 49MB, 48MB, 47MB, etc, thus completely killing performance. To
- # workaround this problem, we work in reasonable, fixed-size
- # chunks. This results in a 10x improvement to bench_sendall.py,
- # while having no measurable impact on CPython (since it doesn't
- # copy at all the only extra overhead is a few python function
- # calls, which is negligible for large inputs).
-
- # On one macOS machine, PyPy3 5.10.1 produced ~ 67.53 MB/s before this change,
- # and ~ 616.01 MB/s after.
-
- # See https://bitbucket.org/pypy/pypy/issues/2091/non-blocking-socketsend-slow-gevent
-
- # Too small of a chunk (the socket's buf size is usually too
- # small) results in reduced perf due to *too many* calls to send and too many
- # small copies. With a buffer of 143K (the default on my system), for
- # example, bench_sendall.py yields ~264MB/s, while using 1MB yields
- # ~653MB/s (matching CPython). 1MB is arbitrary and might be better
- # chosen, say, to match a page size?
-
- len_data_memory = len(data_memory)
- if not len_data_memory:
- # Don't try to send empty data at all, no point, and breaks ssl
- # See issue 719
- return 0
-
-
- chunk_size = max(socket.getsockopt(SOL_SOCKET, SO_SNDBUF), 1024 * 1024)
-
- data_sent = 0
- end = None
- timeleft = None
- if socket.timeout is not None:
- timeleft = socket.timeout
- end = time.time() + timeleft
-
- while data_sent < len_data_memory:
- chunk_end = min(data_sent + chunk_size, len_data_memory)
- chunk = data_memory[data_sent:chunk_end]
-
- timeleft = __send_chunk(socket, chunk, flags, timeleft, end)
- data_sent += len(chunk) # Guaranteed it sent the whole thing
-
-# pylint:disable=no-member
-_RESOLVABLE_FAMILIES = (__socket__.AF_INET,)
-if __socket__.has_ipv6:
- _RESOLVABLE_FAMILIES += (__socket__.AF_INET6,)
-
-def _resolve_addr(sock, address):
- # Internal method: resolve the AF_INET[6] address using
- # getaddrinfo.
- if sock.family not in _RESOLVABLE_FAMILIES or not isinstance(address, tuple):
- return address
- # address is (host, port) (ipv4) or (host, port, flowinfo, scopeid) (ipv6).
-
- # We don't pass the port to getaddrinfo because the C
- # socket module doesn't either (on some systems its
- # illegal to do that without also passing socket type and
- # protocol). Instead we join the port back at the end.
- # See https://github.com/gevent/gevent/issues/1252
- host, port = address[:2]
- r = getaddrinfo(host, None, sock.family)
- address = r[0][-1]
- if len(address) == 2:
- address = (address[0], port)
- else:
- address = (address[0], port, address[2], address[3])
- return address
diff --git a/python/gevent/_ssl2.py b/python/gevent/_ssl2.py
deleted file mode 100644
index 051e364..0000000
--- a/python/gevent/_ssl2.py
+++ /dev/null
@@ -1,441 +0,0 @@
-# Wrapper module for _ssl. Written by Bill Janssen.
-# Ported to gevent by Denis Bilenko.
-"""
-SSL wrapper for socket objects on Python 2.7.8 and below.
-
-For the documentation, refer to :mod:`ssl` module manual.
-
-This module implements cooperative SSL socket wrappers.
-
-.. deprecated:: 1.3
- This module is not secure. Support for Python versions
- with only this level of SSL will be dropped in gevent 1.4.
-"""
-
-from __future__ import absolute_import
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable,arguments-differ,no-member
-
-import ssl as __ssl__
-
-_ssl = __ssl__._ssl
-
-import sys
-import errno
-from gevent._socket2 import socket
-from gevent.socket import _fileobject, timeout_default
-from gevent.socket import error as socket_error, EWOULDBLOCK
-from gevent.socket import timeout as _socket_timeout
-from gevent._compat import PYPY
-from gevent._util import copy_globals
-
-
-__implements__ = [
- 'SSLSocket',
- 'wrap_socket',
- 'get_server_certificate',
- 'sslwrap_simple',
-]
-
-# Import all symbols from Python's ssl.py, except those that we are implementing
-# and "private" symbols.
-__imports__ = copy_globals(__ssl__, globals(),
- # SSLSocket *must* subclass gevent.socket.socket; see issue 597
- names_to_ignore=__implements__ + ['socket'],
- dunder_names_to_keep=())
-
-
-# Py2.6 can get RAND_status added twice
-__all__ = list(set(__implements__) | set(__imports__))
-if 'namedtuple' in __all__:
- __all__.remove('namedtuple')
-
-class SSLSocket(socket):
- """
- gevent `ssl.SSLSocket <https://docs.python.org/2.6/library/ssl.html#sslsocket-objects>`_
- for Pythons < 2.7.9.
- """
-
- def __init__(self, sock, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True,
- ciphers=None):
- socket.__init__(self, _sock=sock)
-
- if PYPY:
- sock._drop()
-
- if certfile and not keyfile:
- keyfile = certfile
- # see if it's connected
- try:
- socket.getpeername(self)
- except socket_error as e:
- if e.args[0] != errno.ENOTCONN:
- raise
- # no, no connection yet
- self._sslobj = None
- else:
- # yes, create the SSL object
- if ciphers is None:
- self._sslobj = _ssl.sslwrap(self._sock, server_side,
- keyfile, certfile,
- cert_reqs, ssl_version, ca_certs)
- else:
- self._sslobj = _ssl.sslwrap(self._sock, server_side,
- keyfile, certfile,
- cert_reqs, ssl_version, ca_certs,
- ciphers)
- if do_handshake_on_connect:
- self.do_handshake()
- self.keyfile = keyfile
- self.certfile = certfile
- self.cert_reqs = cert_reqs
- self.ssl_version = ssl_version
- self.ca_certs = ca_certs
- self.ciphers = ciphers
- self.do_handshake_on_connect = do_handshake_on_connect
- self.suppress_ragged_eofs = suppress_ragged_eofs
- self._makefile_refs = 0
-
- def read(self, len=1024):
- """Read up to LEN bytes and return them.
- Return zero-length string on EOF."""
- while True:
- try:
- return self._sslobj.read(len)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- return ''
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional
- self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout)
- else:
- raise
-
- def write(self, data):
- """Write DATA to the underlying SSL channel. Returns
- number of bytes of DATA actually transmitted."""
- while True:
- try:
- return self._sslobj.write(data)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
- else:
- raise
-
- def getpeercert(self, binary_form=False):
- """Returns a formatted version of the data in the
- certificate provided by the other end of the SSL channel.
- Return None if no certificate was provided, {} if a
- certificate was provided, but not validated."""
- return self._sslobj.peer_certificate(binary_form)
-
- def cipher(self):
- if not self._sslobj:
- return None
- return self._sslobj.cipher()
-
- def send(self, data, flags=0, timeout=timeout_default):
- if timeout is timeout_default:
- timeout = self.timeout
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to send() on %s" %
- self.__class__)
- while True:
- try:
- v = self._sslobj.write(data)
- except SSLError as x:
- if x.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- return 0
- sys.exc_clear()
- self._wait(self._read_event)
- elif x.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- return 0
- sys.exc_clear()
- self._wait(self._write_event)
- else:
- raise
- else:
- return v
- else:
- return socket.send(self, data, flags, timeout)
- # is it possible for sendall() to send some data without encryption if another end shut down SSL?
-
- def sendall(self, data, flags=0):
- try:
- socket.sendall(self, data)
- except _socket_timeout as ex:
- if self.timeout == 0.0:
- # Python 2 simply *hangs* in this case, which is bad, but
- # Python 3 raises SSLWantWriteError. We do the same.
- raise SSLError(SSL_ERROR_WANT_WRITE)
- # Convert the socket.timeout back to the sslerror
- raise SSLError(*ex.args)
-
- def sendto(self, *args):
- if self._sslobj:
- raise ValueError("sendto not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.sendto(self, *args)
-
- def recv(self, buflen=1024, flags=0):
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to recv() on %s" %
- self.__class__)
- # QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior?
- return self.read(buflen)
- return socket.recv(self, buflen, flags)
-
- def recv_into(self, buffer, nbytes=None, flags=0):
- if buffer and (nbytes is None):
- nbytes = len(buffer)
- elif nbytes is None:
- nbytes = 1024
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to recv_into() on %s" %
- self.__class__)
- while True:
- try:
- tmp_buffer = self.read(nbytes)
- v = len(tmp_buffer)
- buffer[:v] = tmp_buffer
- return v
- except SSLError as x:
- if x.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
- continue
- else:
- raise
- else:
- return socket.recv_into(self, buffer, nbytes, flags)
-
- def recvfrom(self, *args):
- if self._sslobj:
- raise ValueError("recvfrom not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.recvfrom(self, *args)
-
- def recvfrom_into(self, *args):
- if self._sslobj:
- raise ValueError("recvfrom_into not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.recvfrom_into(self, *args)
-
- def pending(self):
- if self._sslobj:
- return self._sslobj.pending()
- return 0
-
- def _sslobj_shutdown(self):
- while True:
- try:
- return self._sslobj.shutdown()
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- return ''
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
- else:
- raise
-
- def unwrap(self):
- if not self._sslobj:
- raise ValueError("No SSL wrapper around " + str(self))
- s = self._sslobj_shutdown()
- self._sslobj = None
- return socket(_sock=s)
-
- def shutdown(self, how):
- self._sslobj = None
- socket.shutdown(self, how)
-
- def close(self):
- if self._makefile_refs < 1:
- self._sslobj = None
- socket.close(self)
- else:
- self._makefile_refs -= 1
-
- if PYPY:
-
- def _reuse(self):
- self._makefile_refs += 1
-
- def _drop(self):
- if self._makefile_refs < 1:
- self.close()
- else:
- self._makefile_refs -= 1
-
- def do_handshake(self):
- """Perform a TLS/SSL handshake."""
- while True:
- try:
- return self._sslobj.do_handshake()
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout)
- else:
- raise
-
- def connect(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
- # Here we assume that the socket is client-side, and not
- # connected at the time of the call. We connect it, then wrap it.
- if self._sslobj:
- raise ValueError("attempt to connect already-connected SSLSocket!")
- socket.connect(self, addr)
- if self.ciphers is None:
- self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
- self.cert_reqs, self.ssl_version,
- self.ca_certs)
- else:
- self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
- self.cert_reqs, self.ssl_version,
- self.ca_certs, self.ciphers)
- if self.do_handshake_on_connect:
- self.do_handshake()
-
- def accept(self):
- """Accepts a new connection from a remote client, and returns
- a tuple containing that new connection wrapped with a server-side
- SSL channel, and the address of the remote client."""
- sock = self._sock
- while True:
- try:
- client_socket, address = sock.accept()
- break
- except socket_error as ex:
- if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event)
-
- sslobj = SSLSocket(client_socket,
- keyfile=self.keyfile,
- certfile=self.certfile,
- server_side=True,
- cert_reqs=self.cert_reqs,
- ssl_version=self.ssl_version,
- ca_certs=self.ca_certs,
- do_handshake_on_connect=self.do_handshake_on_connect,
- suppress_ragged_eofs=self.suppress_ragged_eofs,
- ciphers=self.ciphers)
-
- return sslobj, address
-
- def makefile(self, mode='r', bufsize=-1):
- """Make and return a file-like object that
- works with the SSL connection. Just use the code
- from the socket module."""
- if not PYPY:
- self._makefile_refs += 1
- # close=True so as to decrement the reference count when done with
- # the file-like object.
- return _fileobject(self, mode, bufsize, close=True)
-
-if PYPY or not hasattr(SSLSocket, 'timeout'):
- # PyPy (and certain versions of CPython) doesn't have a direct
- # 'timeout' property on raw sockets, because that's not part of
- # the documented specification. We may wind up wrapping a raw
- # socket (when ssl is used with PyWSGI) or a gevent socket, which
- # does have a read/write timeout property as an alias for
- # get/settimeout, so make sure that's always the case because
- # pywsgi can depend on that.
- SSLSocket.timeout = property(lambda self: self.gettimeout(),
- lambda self, value: self.settimeout(value))
-
-
-_SSLErrorReadTimeout = SSLError('The read operation timed out')
-_SSLErrorWriteTimeout = SSLError('The write operation timed out')
-_SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out')
-
-
-def wrap_socket(sock, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True, ciphers=None):
- """Create a new :class:`SSLSocket` instance."""
- return SSLSocket(sock, keyfile=keyfile, certfile=certfile,
- server_side=server_side, cert_reqs=cert_reqs,
- ssl_version=ssl_version, ca_certs=ca_certs,
- do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs,
- ciphers=ciphers)
-
-
-def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
- """Retrieve the certificate from the server at the specified address,
- and return it as a PEM-encoded string.
- If 'ca_certs' is specified, validate the server cert against it.
- If 'ssl_version' is specified, use it in the connection attempt."""
-
- if ca_certs is not None:
- cert_reqs = CERT_REQUIRED
- else:
- cert_reqs = CERT_NONE
- s = wrap_socket(socket(), ssl_version=ssl_version,
- cert_reqs=cert_reqs, ca_certs=ca_certs)
- s.connect(addr)
- dercert = s.getpeercert(True)
- s.close()
- return DER_cert_to_PEM_cert(dercert)
-
-
-def sslwrap_simple(sock, keyfile=None, certfile=None):
- """A replacement for the old socket.ssl function. Designed
- for compatibility with Python 2.5 and earlier. Will disappear in
- Python 3.0."""
- return SSLSocket(sock, keyfile, certfile)
diff --git a/python/gevent/_ssl3.py b/python/gevent/_ssl3.py
deleted file mode 100644
index 71e2f76..0000000
--- a/python/gevent/_ssl3.py
+++ /dev/null
@@ -1,712 +0,0 @@
-# Wrapper module for _ssl. Written by Bill Janssen.
-# Ported to gevent by Denis Bilenko.
-"""SSL wrapper for socket objects on Python 3.
-
-For the documentation, refer to :mod:`ssl` module manual.
-
-This module implements cooperative SSL socket wrappers.
-"""
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable
-# pylint:disable=no-member
-
-from __future__ import absolute_import
-import ssl as __ssl__
-
-_ssl = __ssl__._ssl
-
-import errno
-from gevent.socket import socket, timeout_default
-from gevent.socket import error as socket_error
-from gevent.socket import timeout as _socket_timeout
-from gevent._util import copy_globals
-
-from weakref import ref as _wref
-
-__implements__ = [
- 'SSLContext',
- 'SSLSocket',
- 'wrap_socket',
- 'get_server_certificate',
-]
-
-# Import all symbols from Python's ssl.py, except those that we are implementing
-# and "private" symbols.
-__imports__ = copy_globals(__ssl__, globals(),
- # SSLSocket *must* subclass gevent.socket.socket; see issue 597
- names_to_ignore=__implements__ + ['socket'],
- dunder_names_to_keep=())
-
-__all__ = __implements__ + __imports__
-if 'namedtuple' in __all__:
- __all__.remove('namedtuple')
-
-orig_SSLContext = __ssl__.SSLContext # pylint:disable=no-member
-
-
-class SSLContext(orig_SSLContext):
-
- # Added in Python 3.7
- sslsocket_class = None # SSLSocket is assigned later
-
- def wrap_socket(self, sock, server_side=False,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True,
- server_hostname=None,
- session=None):
- # pylint:disable=arguments-differ,not-callable
- # (3.6 adds session)
- # Sadly, using *args and **kwargs doesn't work
- return self.sslsocket_class(
- sock=sock, server_side=server_side,
- do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs,
- server_hostname=server_hostname,
- _context=self,
- _session=session)
-
- if not hasattr(orig_SSLContext, 'check_hostname'):
- # Python 3.3 lacks this
- check_hostname = False
-
- if hasattr(orig_SSLContext.options, 'setter'):
- # In 3.6, these became properties. They want to access the
- # property __set__ method in the superclass, and they do so by using
- # super(SSLContext, SSLContext). But we rebind SSLContext when we monkey
- # patch, which causes infinite recursion.
- # https://github.com/python/cpython/commit/328067c468f82e4ec1b5c510a4e84509e010f296
- # pylint:disable=no-member
- @orig_SSLContext.options.setter
- def options(self, value):
- super(orig_SSLContext, orig_SSLContext).options.__set__(self, value)
-
- @orig_SSLContext.verify_flags.setter
- def verify_flags(self, value):
- super(orig_SSLContext, orig_SSLContext).verify_flags.__set__(self, value)
-
- @orig_SSLContext.verify_mode.setter
- def verify_mode(self, value):
- super(orig_SSLContext, orig_SSLContext).verify_mode.__set__(self, value)
-
- if hasattr(orig_SSLContext, 'minimum_version'):
- # Like the above, added in 3.7
- @orig_SSLContext.minimum_version.setter
- def minimum_version(self, value):
- super(orig_SSLContext, orig_SSLContext).minimum_version.__set__(self, value)
-
- @orig_SSLContext.maximum_version.setter
- def maximum_version(self, value):
- super(orig_SSLContext, orig_SSLContext).maximum_version.__set__(self, value)
-
-
-class _contextawaresock(socket._gevent_sock_class): # Python 2: pylint:disable=slots-on-old-class
- # We have to pass the raw stdlib socket to SSLContext.wrap_socket.
- # That method in turn can pass that object on to things like SNI callbacks.
- # It wouldn't have access to any of the attributes on the SSLSocket, like
- # context, that it's supposed to (see test_ssl.test_sni_callback). Our
- # solution is to keep a weak reference to the SSLSocket on the raw
- # socket and delegate.
-
- # We keep it in a slot to avoid having the ability to set any attributes
- # we're not prepared for (because we don't know what to delegate.)
-
- __slots__ = ('_sslsock',)
-
- @property
- def context(self):
- return self._sslsock().context
-
- @context.setter
- def context(self, ctx):
- self._sslsock().context = ctx
-
- @property
- def session(self):
- """The SSLSession for client socket."""
- return self._sslsock().session
-
- @session.setter
- def session(self, session):
- self._sslsock().session = session
-
- def __getattr__(self, name):
- try:
- return getattr(self._sslsock(), name)
- except RuntimeError:
- # XXX: If the attribute doesn't exist,
- # we infinitely recurse
- pass
- raise AttributeError(name)
-
-try:
- _SSLObject_factory = SSLObject
-except NameError:
- # 3.4 and below do not have SSLObject, something
- # we magically import through copy_globals
- pass
-else:
- if hasattr(SSLObject, '_create'):
- # 3.7 is making thing difficult and won't let you
- # actually construct an object
- def _SSLObject_factory(sslobj, owner=None, session=None):
- s = SSLObject.__new__(SSLObject)
- s._sslobj = sslobj
- s._sslobj.owner = owner or s
- if session is not None:
- s._sslobj.session = session
- return s
-
-class SSLSocket(socket):
- """
- gevent `ssl.SSLSocket <https://docs.python.org/3/library/ssl.html#ssl-sockets>`_
- for Python 3.
- """
-
- # pylint:disable=too-many-instance-attributes,too-many-public-methods
-
- _gevent_sock_class = _contextawaresock
-
- def __init__(self, sock=None, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
- suppress_ragged_eofs=True, npn_protocols=None, ciphers=None,
- server_hostname=None,
- _session=None, # 3.6
- _context=None):
-
- # pylint:disable=too-many-locals,too-many-statements,too-many-branches
- if _context:
- self._context = _context
- else:
- if server_side and not certfile:
- raise ValueError("certfile must be specified for server-side "
- "operations")
- if keyfile and not certfile:
- raise ValueError("certfile must be specified")
- if certfile and not keyfile:
- keyfile = certfile
- self._context = SSLContext(ssl_version)
- self._context.verify_mode = cert_reqs
- if ca_certs:
- self._context.load_verify_locations(ca_certs)
- if certfile:
- self._context.load_cert_chain(certfile, keyfile)
- if npn_protocols:
- self._context.set_npn_protocols(npn_protocols)
- if ciphers:
- self._context.set_ciphers(ciphers)
- self.keyfile = keyfile
- self.certfile = certfile
- self.cert_reqs = cert_reqs
- self.ssl_version = ssl_version
- self.ca_certs = ca_certs
- self.ciphers = ciphers
- # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get
- # mixed in.
- if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
- raise NotImplementedError("only stream sockets are supported")
- if server_side:
- if server_hostname:
- raise ValueError("server_hostname can only be specified "
- "in client mode")
- if _session is not None:
- raise ValueError("session can only be specified "
- "in client mode")
- if self._context.check_hostname and not server_hostname:
- raise ValueError("check_hostname requires server_hostname")
- self._session = _session
- self.server_side = server_side
- self.server_hostname = server_hostname
- self.do_handshake_on_connect = do_handshake_on_connect
- self.suppress_ragged_eofs = suppress_ragged_eofs
- connected = False
- if sock is not None:
- socket.__init__(self,
- family=sock.family,
- type=sock.type,
- proto=sock.proto,
- fileno=sock.fileno())
- self.settimeout(sock.gettimeout())
- # see if it's connected
- try:
- sock.getpeername()
- except socket_error as e:
- if e.errno != errno.ENOTCONN:
- raise
- else:
- connected = True
- sock.detach()
- elif fileno is not None:
- socket.__init__(self, fileno=fileno)
- else:
- socket.__init__(self, family=family, type=type, proto=proto)
-
- self._sock._sslsock = _wref(self)
- self._closed = False
- self._sslobj = None
- self._connected = connected
- if connected:
- # create the SSL object
- try:
- self._sslobj = self._context._wrap_socket(self._sock, server_side,
- server_hostname)
- if _session is not None: # 3.6+
- self._sslobj = _SSLObject_factory(self._sslobj, owner=self,
- session=self._session)
- if do_handshake_on_connect:
- timeout = self.gettimeout()
- if timeout == 0.0:
- # non-blocking
- raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
- self.do_handshake()
-
- except socket_error as x:
- self.close()
- raise x
-
- @property
- def context(self):
- return self._context
-
- @context.setter
- def context(self, ctx):
- self._context = ctx
- self._sslobj.context = ctx
-
- @property
- def session(self):
- """The SSLSession for client socket."""
- if self._sslobj is not None:
- return self._sslobj.session
-
- @session.setter
- def session(self, session):
- self._session = session
- if self._sslobj is not None:
- self._sslobj.session = session
-
- @property
- def session_reused(self):
- """Was the client session reused during handshake"""
- if self._sslobj is not None:
- return self._sslobj.session_reused
-
- def dup(self):
- raise NotImplementedError("Can't dup() %s instances" %
- self.__class__.__name__)
-
- def _checkClosed(self, msg=None):
- # raise an exception here if you wish to check for spurious closes
- pass
-
- def _check_connected(self):
- if not self._connected:
- # getpeername() will raise ENOTCONN if the socket is really
- # not connected; note that we can be connected even without
- # _connected being set, e.g. if connect() first returned
- # EAGAIN.
- self.getpeername()
-
- def read(self, len=1024, buffer=None):
- """Read up to LEN bytes and return them.
- Return zero-length string on EOF."""
- # pylint:disable=too-many-branches
- self._checkClosed()
-
- while True:
- if not self._sslobj:
- raise ValueError("Read on closed or unwrapped SSL socket.")
- if len == 0:
- return b'' if buffer is None else 0
- # Negative lengths are handled natively when the buffer is None
- # to raise a ValueError
- try:
- if buffer is not None:
- return self._sslobj.read(len, buffer)
- return self._sslobj.read(len or 1024)
- except SSLWantReadError:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- raise
- # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional
- self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- if buffer is None:
- return b''
- return 0
- raise
-
- def write(self, data):
- """Write DATA to the underlying SSL channel. Returns
- number of bytes of DATA actually transmitted."""
- self._checkClosed()
-
- while True:
- if not self._sslobj:
- raise ValueError("Write on closed or unwrapped SSL socket.")
-
- try:
- return self._sslobj.write(data)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
- else:
- raise
-
- def getpeercert(self, binary_form=False):
- """Returns a formatted version of the data in the
- certificate provided by the other end of the SSL channel.
- Return None if no certificate was provided, {} if a
- certificate was provided, but not validated."""
-
- self._checkClosed()
- self._check_connected()
- try:
- c = self._sslobj.peer_certificate
- except AttributeError:
- # 3.6
- c = self._sslobj.getpeercert
-
- return c(binary_form)
-
- def selected_npn_protocol(self):
- self._checkClosed()
- if not self._sslobj or not _ssl.HAS_NPN:
- return None
- return self._sslobj.selected_npn_protocol()
-
- if hasattr(_ssl, 'HAS_ALPN'):
- # 3.5+
- def selected_alpn_protocol(self):
- self._checkClosed()
- if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member
- return None
- return self._sslobj.selected_alpn_protocol()
-
- def shared_ciphers(self):
- """Return a list of ciphers shared by the client during the handshake or
- None if this is not a valid server connection.
- """
- return self._sslobj.shared_ciphers()
-
- def version(self):
- """Return a string identifying the protocol version used by the
- current SSL channel. """
- if not self._sslobj:
- return None
- return self._sslobj.version()
-
- # We inherit sendfile from super(); it always uses `send`
-
- def cipher(self):
- self._checkClosed()
- if not self._sslobj:
- return None
- return self._sslobj.cipher()
-
- def compression(self):
- self._checkClosed()
- if not self._sslobj:
- return None
- return self._sslobj.compression()
-
- def send(self, data, flags=0, timeout=timeout_default):
- self._checkClosed()
- if timeout is timeout_default:
- timeout = self.timeout
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to send() on %s" %
- self.__class__)
- while True:
- try:
- return self._sslobj.write(data)
- except SSLWantReadError:
- if self.timeout == 0.0:
- return 0
- self._wait(self._read_event)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- return 0
- self._wait(self._write_event)
- else:
- return socket.send(self, data, flags, timeout)
-
- def sendto(self, data, flags_or_addr, addr=None):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("sendto not allowed on instances of %s" %
- self.__class__)
- elif addr is None:
- return socket.sendto(self, data, flags_or_addr)
- else:
- return socket.sendto(self, data, flags_or_addr, addr)
-
- def sendmsg(self, *args, **kwargs):
- # Ensure programs don't send data unencrypted if they try to
- # use this method.
- raise NotImplementedError("sendmsg not allowed on instances of %s" %
- self.__class__)
-
- def sendall(self, data, flags=0):
- self._checkClosed()
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to sendall() on %s" %
- self.__class__)
-
- try:
- return socket.sendall(self, data, flags)
- except _socket_timeout:
- if self.timeout == 0.0:
- # Raised by the stdlib on non-blocking sockets
- raise SSLWantWriteError("The operation did not complete (write)")
- raise
-
- def recv(self, buflen=1024, flags=0):
- self._checkClosed()
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to recv() on %s" %
- self.__class__)
- if buflen == 0:
- # https://github.com/python/cpython/commit/00915577dd84ba75016400793bf547666e6b29b5
- # Python #23804
- return b''
- return self.read(buflen)
- return socket.recv(self, buflen, flags)
-
- def recv_into(self, buffer, nbytes=None, flags=0):
- self._checkClosed()
- if buffer and (nbytes is None):
- nbytes = len(buffer)
- elif nbytes is None:
- nbytes = 1024
- if self._sslobj:
- if flags != 0:
- raise ValueError("non-zero flags not allowed in calls to recv_into() on %s" % self.__class__)
- return self.read(nbytes, buffer)
- return socket.recv_into(self, buffer, nbytes, flags)
-
- def recvfrom(self, buflen=1024, flags=0):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("recvfrom not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.recvfrom(self, buflen, flags)
-
- def recvfrom_into(self, buffer, nbytes=None, flags=0):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("recvfrom_into not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.recvfrom_into(self, buffer, nbytes, flags)
-
- def recvmsg(self, *args, **kwargs):
- raise NotImplementedError("recvmsg not allowed on instances of %s" %
- self.__class__)
-
- def recvmsg_into(self, *args, **kwargs):
- raise NotImplementedError("recvmsg_into not allowed on instances of "
- "%s" % self.__class__)
-
- def pending(self):
- self._checkClosed()
- if self._sslobj:
- return self._sslobj.pending()
- return 0
-
- def shutdown(self, how):
- self._checkClosed()
- self._sslobj = None
- socket.shutdown(self, how)
-
- def unwrap(self):
- if not self._sslobj:
- raise ValueError("No SSL wrapper around " + str(self))
-
- while True:
- try:
- s = self._sslobj.shutdown()
- break
- except SSLWantReadError:
- # Callers of this method expect to get a socket
- # back, so we can't simply return 0, we have
- # to let these be raised
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- raise
- self._wait(self._write_event)
-
- self._sslobj = None
-
- # The return value of shutting down the SSLObject is the
- # original wrapped socket passed to _wrap_socket, i.e.,
- # _contextawaresock. But that object doesn't have the
- # gevent wrapper around it so it can't be used. We have to
- # wrap it back up with a gevent wrapper.
- assert s is self._sock
- # In the stdlib, SSLSocket subclasses socket.socket and passes itself
- # to _wrap_socket, so it gets itself back. We can't do that, we have to
- # pass our subclass of _socket.socket, _contextawaresock.
- # So ultimately we should return ourself.
-
- # See test_ftplib.py:TestTLS_FTPClass.test_ccc
- return self
-
- def _real_close(self):
- self._sslobj = None
- # self._closed = True
- socket._real_close(self)
-
- def do_handshake(self):
- """Perform a TLS/SSL handshake."""
- self._check_connected()
- while True:
- try:
- self._sslobj.do_handshake()
- break
- except SSLWantReadError:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- raise
- self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout)
-
- if sys.version_info[:2] < (3, 7) and self._context.check_hostname:
- # In Python 3.7, the underlying OpenSSL name matching is used.
- # The version implemented in Python doesn't understand IDNA encoding.
- if not self.server_hostname:
- raise ValueError("check_hostname needs server_hostname "
- "argument")
- match_hostname(self.getpeercert(), self.server_hostname)
-
- def _real_connect(self, addr, connect_ex):
- if self.server_side:
- raise ValueError("can't connect in server-side mode")
- # Here we assume that the socket is client-side, and not
- # connected at the time of the call. We connect it, then wrap it.
- if self._connected:
- raise ValueError("attempt to connect already-connected SSLSocket!")
- self._sslobj = self._context._wrap_socket(self._sock, False, self.server_hostname)
- if self._session is not None: # 3.6+
- self._sslobj = _SSLObject_factory(self._sslobj, owner=self, session=self._session)
- try:
- if connect_ex:
- rc = socket.connect_ex(self, addr)
- else:
- rc = None
- socket.connect(self, addr)
- if not rc:
- if self.do_handshake_on_connect:
- self.do_handshake()
- self._connected = True
- return rc
- except socket_error:
- self._sslobj = None
- raise
-
- def connect(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
- self._real_connect(addr, False)
-
- def connect_ex(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
- return self._real_connect(addr, True)
-
- def accept(self):
- """Accepts a new connection from a remote client, and returns
- a tuple containing that new connection wrapped with a server-side
- SSL channel, and the address of the remote client."""
-
- newsock, addr = socket.accept(self)
- newsock._drop_events()
- newsock = self._context.wrap_socket(newsock,
- do_handshake_on_connect=self.do_handshake_on_connect,
- suppress_ragged_eofs=self.suppress_ragged_eofs,
- server_side=True)
- return newsock, addr
-
- def get_channel_binding(self, cb_type="tls-unique"):
- """Get channel binding data for current connection. Raise ValueError
- if the requested `cb_type` is not supported. Return bytes of the data
- or None if the data is not available (e.g. before the handshake).
- """
- if hasattr(self._sslobj, 'get_channel_binding'):
- # 3.7+, and sslobj is not None
- return self._sslobj.get_channel_binding(cb_type)
- if cb_type not in CHANNEL_BINDING_TYPES:
- raise ValueError("Unsupported channel binding type")
- if cb_type != "tls-unique":
- raise NotImplementedError("{0} channel binding type not implemented".format(cb_type))
- if self._sslobj is None:
- return None
- return self._sslobj.tls_unique_cb()
-
-
-# Python does not support forward declaration of types
-SSLContext.sslsocket_class = SSLSocket
-
-# Python 3.2 onwards raise normal timeout errors, not SSLError.
-# See https://bugs.python.org/issue10272
-_SSLErrorReadTimeout = _socket_timeout('The read operation timed out')
-_SSLErrorWriteTimeout = _socket_timeout('The write operation timed out')
-_SSLErrorHandshakeTimeout = _socket_timeout('The handshake operation timed out')
-
-
-def wrap_socket(sock, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True,
- ciphers=None):
-
- return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile,
- server_side=server_side, cert_reqs=cert_reqs,
- ssl_version=ssl_version, ca_certs=ca_certs,
- do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs,
- ciphers=ciphers)
-
-
-def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
- """Retrieve the certificate from the server at the specified address,
- and return it as a PEM-encoded string.
- If 'ca_certs' is specified, validate the server cert against it.
- If 'ssl_version' is specified, use it in the connection attempt."""
-
- _, _ = addr
- if ca_certs is not None:
- cert_reqs = CERT_REQUIRED
- else:
- cert_reqs = CERT_NONE
- s = create_connection(addr)
- s = wrap_socket(s, ssl_version=ssl_version,
- cert_reqs=cert_reqs, ca_certs=ca_certs)
- dercert = s.getpeercert(True)
- s.close()
- return DER_cert_to_PEM_cert(dercert)
diff --git a/python/gevent/_sslgte279.py b/python/gevent/_sslgte279.py
deleted file mode 100644
index 5580762..0000000
--- a/python/gevent/_sslgte279.py
+++ /dev/null
@@ -1,714 +0,0 @@
-# Wrapper module for _ssl. Written by Bill Janssen.
-# Ported to gevent by Denis Bilenko.
-"""SSL wrapper for socket objects on Python 2.7.9 and above.
-
-For the documentation, refer to :mod:`ssl` module manual.
-
-This module implements cooperative SSL socket wrappers.
-"""
-
-from __future__ import absolute_import
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable
-# pylint: disable=too-many-instance-attributes,too-many-locals,too-many-statements,too-many-branches
-# pylint: disable=arguments-differ,too-many-public-methods
-
-import ssl as __ssl__
-
-_ssl = __ssl__._ssl # pylint:disable=no-member
-
-import errno
-from gevent._socket2 import socket
-from gevent.socket import timeout_default
-from gevent.socket import create_connection
-from gevent.socket import error as socket_error
-from gevent.socket import timeout as _socket_timeout
-from gevent._compat import PYPY
-from gevent._util import copy_globals
-
-__implements__ = [
- 'SSLContext',
- 'SSLSocket',
- 'wrap_socket',
- 'get_server_certificate',
- 'create_default_context',
- '_create_unverified_context',
- '_create_default_https_context',
- '_create_stdlib_context',
-]
-
-# Import all symbols from Python's ssl.py, except those that we are implementing
-# and "private" symbols.
-__imports__ = copy_globals(__ssl__, globals(),
- # SSLSocket *must* subclass gevent.socket.socket; see issue 597 and 801
- names_to_ignore=__implements__ + ['socket', 'create_connection'],
- dunder_names_to_keep=())
-
-try:
- _delegate_methods
-except NameError: # PyPy doesn't expose this detail
- _delegate_methods = ('recv', 'recvfrom', 'recv_into', 'recvfrom_into', 'send', 'sendto')
-
-__all__ = __implements__ + __imports__
-if 'namedtuple' in __all__:
- __all__.remove('namedtuple')
-
-orig_SSLContext = __ssl__.SSLContext # pylint: disable=no-member
-
-
-class SSLContext(orig_SSLContext):
- def wrap_socket(self, sock, server_side=False,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True,
- server_hostname=None):
- return SSLSocket(sock=sock, server_side=server_side,
- do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs,
- server_hostname=server_hostname,
- _context=self)
-
-
-def create_default_context(purpose=Purpose.SERVER_AUTH, cafile=None,
- capath=None, cadata=None):
- """Create a SSLContext object with default settings.
-
- NOTE: The protocol and settings may change anytime without prior
- deprecation. The values represent a fair balance between maximum
- compatibility and security.
- """
- if not isinstance(purpose, _ASN1Object):
- raise TypeError(purpose)
-
- context = SSLContext(PROTOCOL_SSLv23)
-
- # SSLv2 considered harmful.
- context.options |= OP_NO_SSLv2
-
- # SSLv3 has problematic security and is only required for really old
- # clients such as IE6 on Windows XP
- context.options |= OP_NO_SSLv3
-
- # disable compression to prevent CRIME attacks (OpenSSL 1.0+)
- context.options |= getattr(_ssl, "OP_NO_COMPRESSION", 0)
-
- if purpose == Purpose.SERVER_AUTH:
- # verify certs and host name in client mode
- context.verify_mode = CERT_REQUIRED
- context.check_hostname = True # pylint: disable=attribute-defined-outside-init
- elif purpose == Purpose.CLIENT_AUTH:
- # Prefer the server's ciphers by default so that we get stronger
- # encryption
- context.options |= getattr(_ssl, "OP_CIPHER_SERVER_PREFERENCE", 0)
-
- # Use single use keys in order to improve forward secrecy
- context.options |= getattr(_ssl, "OP_SINGLE_DH_USE", 0)
- context.options |= getattr(_ssl, "OP_SINGLE_ECDH_USE", 0)
-
- # disallow ciphers with known vulnerabilities
- context.set_ciphers(_RESTRICTED_SERVER_CIPHERS)
-
- if cafile or capath or cadata:
- context.load_verify_locations(cafile, capath, cadata)
- elif context.verify_mode != CERT_NONE:
- # no explicit cafile, capath or cadata but the verify mode is
- # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system
- # root CA certificates for the given purpose. This may fail silently.
- context.load_default_certs(purpose)
- return context
-
-def _create_unverified_context(protocol=PROTOCOL_SSLv23, cert_reqs=None,
- check_hostname=False, purpose=Purpose.SERVER_AUTH,
- certfile=None, keyfile=None,
- cafile=None, capath=None, cadata=None):
- """Create a SSLContext object for Python stdlib modules
-
- All Python stdlib modules shall use this function to create SSLContext
- objects in order to keep common settings in one place. The configuration
- is less restrict than create_default_context()'s to increase backward
- compatibility.
- """
- if not isinstance(purpose, _ASN1Object):
- raise TypeError(purpose)
-
- context = SSLContext(protocol)
- # SSLv2 considered harmful.
- context.options |= OP_NO_SSLv2
- # SSLv3 has problematic security and is only required for really old
- # clients such as IE6 on Windows XP
- context.options |= OP_NO_SSLv3
-
- if cert_reqs is not None:
- context.verify_mode = cert_reqs
- context.check_hostname = check_hostname # pylint: disable=attribute-defined-outside-init
-
- if keyfile and not certfile:
- raise ValueError("certfile must be specified")
- if certfile or keyfile:
- context.load_cert_chain(certfile, keyfile)
-
- # load CA root certs
- if cafile or capath or cadata:
- context.load_verify_locations(cafile, capath, cadata)
- elif context.verify_mode != CERT_NONE:
- # no explicit cafile, capath or cadata but the verify mode is
- # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system
- # root CA certificates for the given purpose. This may fail silently.
- context.load_default_certs(purpose)
-
- return context
-
-# Used by http.client if no context is explicitly passed.
-_create_default_https_context = create_default_context
-
-
-# Backwards compatibility alias, even though it's not a public name.
-_create_stdlib_context = _create_unverified_context
-
-class SSLSocket(socket):
- """
- gevent `ssl.SSLSocket <https://docs.python.org/2/library/ssl.html#ssl-sockets>`_
- for Pythons >= 2.7.9 but less than 3.
- """
-
- def __init__(self, sock=None, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
- suppress_ragged_eofs=True, npn_protocols=None, ciphers=None,
- server_hostname=None,
- _context=None):
- # fileno is ignored
- # pylint: disable=unused-argument
- if _context:
- self._context = _context
- else:
- if server_side and not certfile:
- raise ValueError("certfile must be specified for server-side "
- "operations")
- if keyfile and not certfile:
- raise ValueError("certfile must be specified")
- if certfile and not keyfile:
- keyfile = certfile
- self._context = SSLContext(ssl_version)
- self._context.verify_mode = cert_reqs
- if ca_certs:
- self._context.load_verify_locations(ca_certs)
- if certfile:
- self._context.load_cert_chain(certfile, keyfile)
- if npn_protocols:
- self._context.set_npn_protocols(npn_protocols)
- if ciphers:
- self._context.set_ciphers(ciphers)
- self.keyfile = keyfile
- self.certfile = certfile
- self.cert_reqs = cert_reqs
- self.ssl_version = ssl_version
- self.ca_certs = ca_certs
- self.ciphers = ciphers
- # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get
- # mixed in.
- if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
- raise NotImplementedError("only stream sockets are supported")
-
- if PYPY:
- socket.__init__(self, _sock=sock)
- sock._drop()
- else:
- # CPython: XXX: Must pass the underlying socket, not our
- # potential wrapper; test___example_servers fails the SSL test
- # with a client-side EOF error. (Why?)
- socket.__init__(self, _sock=sock._sock)
-
- # The initializer for socket overrides the methods send(), recv(), etc.
- # in the instance, which we don't need -- but we want to provide the
- # methods defined in SSLSocket.
- for attr in _delegate_methods:
- try:
- delattr(self, attr)
- except AttributeError:
- pass
- if server_side and server_hostname:
- raise ValueError("server_hostname can only be specified "
- "in client mode")
- if self._context.check_hostname and not server_hostname:
- raise ValueError("check_hostname requires server_hostname")
- self.server_side = server_side
- self.server_hostname = server_hostname
- self.do_handshake_on_connect = do_handshake_on_connect
- self.suppress_ragged_eofs = suppress_ragged_eofs
- self.settimeout(sock.gettimeout())
-
- # See if we are connected
- try:
- self.getpeername()
- except socket_error as e:
- if e.errno != errno.ENOTCONN:
- raise
- connected = False
- else:
- connected = True
-
- self._makefile_refs = 0
- self._closed = False
- self._sslobj = None
- self._connected = connected
- if connected:
- # create the SSL object
- try:
- self._sslobj = self._context._wrap_socket(self._sock, server_side,
- server_hostname, ssl_sock=self)
- if do_handshake_on_connect:
- timeout = self.gettimeout()
- if timeout == 0.0:
- # non-blocking
- raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
- self.do_handshake()
-
- except socket_error as x:
- self.close()
- raise x
-
-
- @property
- def context(self):
- return self._context
-
- @context.setter
- def context(self, ctx):
- self._context = ctx
- self._sslobj.context = ctx
-
- def dup(self):
- raise NotImplementedError("Can't dup() %s instances" %
- self.__class__.__name__)
-
- def _checkClosed(self, msg=None):
- # raise an exception here if you wish to check for spurious closes
- pass
-
- def _check_connected(self):
- if not self._connected:
- # getpeername() will raise ENOTCONN if the socket is really
- # not connected; note that we can be connected even without
- # _connected being set, e.g. if connect() first returned
- # EAGAIN.
- self.getpeername()
-
- def read(self, len=1024, buffer=None):
- """Read up to LEN bytes and return them.
- Return zero-length string on EOF."""
- self._checkClosed()
-
- while 1:
- if not self._sslobj:
- raise ValueError("Read on closed or unwrapped SSL socket.")
- if len == 0:
- return b'' if buffer is None else 0
- if len < 0 and buffer is None:
- # This is handled natively in python 2.7.12+
- raise ValueError("Negative read length")
- try:
- if buffer is not None:
- return self._sslobj.read(len, buffer)
- return self._sslobj.read(len or 1024)
- except SSLWantReadError:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- raise
- # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional
- self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- if buffer is not None:
- return 0
- return b''
- raise
-
- def write(self, data):
- """Write DATA to the underlying SSL channel. Returns
- number of bytes of DATA actually transmitted."""
- self._checkClosed()
-
- while 1:
- if not self._sslobj:
- raise ValueError("Write on closed or unwrapped SSL socket.")
-
- try:
- return self._sslobj.write(data)
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
- else:
- raise
-
- def getpeercert(self, binary_form=False):
- """Returns a formatted version of the data in the
- certificate provided by the other end of the SSL channel.
- Return None if no certificate was provided, {} if a
- certificate was provided, but not validated."""
-
- self._checkClosed()
- self._check_connected()
- return self._sslobj.peer_certificate(binary_form)
-
- def selected_npn_protocol(self):
- self._checkClosed()
- if not self._sslobj or not _ssl.HAS_NPN:
- return None
- return self._sslobj.selected_npn_protocol()
-
- if hasattr(_ssl, 'HAS_ALPN'):
- # 2.7.10+
- def selected_alpn_protocol(self):
- self._checkClosed()
- if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member
- return None
- return self._sslobj.selected_alpn_protocol()
-
- def cipher(self):
- self._checkClosed()
- if not self._sslobj:
- return None
- return self._sslobj.cipher()
-
- def compression(self):
- self._checkClosed()
- if not self._sslobj:
- return None
- return self._sslobj.compression()
-
- def __check_flags(self, meth, flags):
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to %s on %s" %
- (meth, self.__class__))
-
- def send(self, data, flags=0, timeout=timeout_default):
- self._checkClosed()
- self.__check_flags('send', flags)
-
- if timeout is timeout_default:
- timeout = self.timeout
-
- if not self._sslobj:
- return socket.send(self, data, flags, timeout)
-
- while True:
- try:
- return self._sslobj.write(data)
- except SSLWantReadError:
- if self.timeout == 0.0:
- return 0
- self._wait(self._read_event)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- return 0
- self._wait(self._write_event)
-
- def sendto(self, data, flags_or_addr, addr=None):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("sendto not allowed on instances of %s" %
- self.__class__)
- elif addr is None:
- return socket.sendto(self, data, flags_or_addr)
- else:
- return socket.sendto(self, data, flags_or_addr, addr)
-
- def sendmsg(self, *args, **kwargs):
- # Ensure programs don't send data unencrypted if they try to
- # use this method.
- raise NotImplementedError("sendmsg not allowed on instances of %s" %
- self.__class__)
-
- def sendall(self, data, flags=0):
- self._checkClosed()
- self.__check_flags('sendall', flags)
-
- try:
- socket.sendall(self, data)
- except _socket_timeout as ex:
- if self.timeout == 0.0:
- # Python 2 simply *hangs* in this case, which is bad, but
- # Python 3 raises SSLWantWriteError. We do the same.
- raise SSLWantWriteError("The operation did not complete (write)")
- # Convert the socket.timeout back to the sslerror
- raise SSLError(*ex.args)
-
- def recv(self, buflen=1024, flags=0):
- self._checkClosed()
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to recv() on %s" %
- self.__class__)
- if buflen == 0:
- return b''
- return self.read(buflen)
- return socket.recv(self, buflen, flags)
-
- def recv_into(self, buffer, nbytes=None, flags=0):
- self._checkClosed()
- if buffer is not None and (nbytes is None):
- # Fix for python bug #23804: bool(bytearray()) is False,
- # but we should read 0 bytes.
- nbytes = len(buffer)
- elif nbytes is None:
- nbytes = 1024
- if self._sslobj:
- if flags != 0:
- raise ValueError(
- "non-zero flags not allowed in calls to recv_into() on %s" %
- self.__class__)
- return self.read(nbytes, buffer)
- return socket.recv_into(self, buffer, nbytes, flags)
-
- def recvfrom(self, buflen=1024, flags=0):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("recvfrom not allowed on instances of %s" %
- self.__class__)
- return socket.recvfrom(self, buflen, flags)
-
- def recvfrom_into(self, buffer, nbytes=None, flags=0):
- self._checkClosed()
- if self._sslobj:
- raise ValueError("recvfrom_into not allowed on instances of %s" %
- self.__class__)
- else:
- return socket.recvfrom_into(self, buffer, nbytes, flags)
-
- def recvmsg(self, *args, **kwargs):
- raise NotImplementedError("recvmsg not allowed on instances of %s" %
- self.__class__)
-
- def recvmsg_into(self, *args, **kwargs):
- raise NotImplementedError("recvmsg_into not allowed on instances of "
- "%s" % self.__class__)
-
- def pending(self):
- self._checkClosed()
- if self._sslobj:
- return self._sslobj.pending()
- return 0
-
- def shutdown(self, how):
- self._checkClosed()
- self._sslobj = None
- socket.shutdown(self, how)
-
- def close(self):
- if self._makefile_refs < 1:
- self._sslobj = None
- socket.close(self)
- else:
- self._makefile_refs -= 1
-
- if PYPY:
-
- def _reuse(self):
- self._makefile_refs += 1
-
- def _drop(self):
- if self._makefile_refs < 1:
- self.close()
- else:
- self._makefile_refs -= 1
-
- def _sslobj_shutdown(self):
- while True:
- try:
- return self._sslobj.shutdown()
- except SSLError as ex:
- if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- return ''
- if ex.args[0] == SSL_ERROR_WANT_READ:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
- elif ex.args[0] == SSL_ERROR_WANT_WRITE:
- if self.timeout == 0.0:
- raise
- sys.exc_clear()
- self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
- else:
- raise
-
- def unwrap(self):
- if not self._sslobj:
- raise ValueError("No SSL wrapper around " + str(self))
-
- s = self._sslobj_shutdown()
- self._sslobj = None
- # match _ssl2; critical to drop/reuse here on PyPy
- # XXX: _ssl3 returns an SSLSocket. Is that what the standard lib does on
- # Python 2? Should we do that?
- return socket(_sock=s)
-
- def _real_close(self):
- self._sslobj = None
- socket._real_close(self) # pylint: disable=no-member
-
- def do_handshake(self):
- """Perform a TLS/SSL handshake."""
- self._check_connected()
- while True:
- try:
- self._sslobj.do_handshake()
- break
- except SSLWantReadError:
- if self.timeout == 0.0:
- raise
- self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout)
- except SSLWantWriteError:
- if self.timeout == 0.0:
- raise
- self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout)
-
- if self._context.check_hostname:
- if not self.server_hostname:
- raise ValueError("check_hostname needs server_hostname "
- "argument")
- match_hostname(self.getpeercert(), self.server_hostname)
-
- def _real_connect(self, addr, connect_ex):
- if self.server_side:
- raise ValueError("can't connect in server-side mode")
- # Here we assume that the socket is client-side, and not
- # connected at the time of the call. We connect it, then wrap it.
- if self._connected:
- raise ValueError("attempt to connect already-connected SSLSocket!")
- self._sslobj = self._context._wrap_socket(self._sock, False, self.server_hostname, ssl_sock=self)
- try:
- if connect_ex:
- rc = socket.connect_ex(self, addr)
- else:
- rc = None
- socket.connect(self, addr)
- if not rc:
- self._connected = True
- if self.do_handshake_on_connect:
- self.do_handshake()
- return rc
- except socket_error:
- self._sslobj = None
- raise
-
- def connect(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
- self._real_connect(addr, False)
-
- def connect_ex(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
- return self._real_connect(addr, True)
-
- def accept(self):
- """Accepts a new connection from a remote client, and returns
- a tuple containing that new connection wrapped with a server-side
- SSL channel, and the address of the remote client."""
-
- newsock, addr = socket.accept(self)
- newsock._drop_events()
- newsock = self._context.wrap_socket(newsock,
- do_handshake_on_connect=self.do_handshake_on_connect,
- suppress_ragged_eofs=self.suppress_ragged_eofs,
- server_side=True)
- return newsock, addr
-
- def makefile(self, mode='r', bufsize=-1):
-
- """Make and return a file-like object that
- works with the SSL connection. Just use the code
- from the socket module."""
- if not PYPY:
- self._makefile_refs += 1
- # close=True so as to decrement the reference count when done with
- # the file-like object.
- return _fileobject(self, mode, bufsize, close=True)
-
- def get_channel_binding(self, cb_type="tls-unique"):
- """Get channel binding data for current connection. Raise ValueError
- if the requested `cb_type` is not supported. Return bytes of the data
- or None if the data is not available (e.g. before the handshake).
- """
- if cb_type not in CHANNEL_BINDING_TYPES:
- raise ValueError("Unsupported channel binding type")
- if cb_type != "tls-unique":
- raise NotImplementedError(
- "{0} channel binding type not implemented"
- .format(cb_type))
- if self._sslobj is None:
- return None
- return self._sslobj.tls_unique_cb()
-
- def version(self):
- """
- Return a string identifying the protocol version used by the
- current SSL channel, or None if there is no established channel.
- """
- if self._sslobj is None:
- return None
- return self._sslobj.version()
-
-if PYPY or not hasattr(SSLSocket, 'timeout'):
- # PyPy (and certain versions of CPython) doesn't have a direct
- # 'timeout' property on raw sockets, because that's not part of
- # the documented specification. We may wind up wrapping a raw
- # socket (when ssl is used with PyWSGI) or a gevent socket, which
- # does have a read/write timeout property as an alias for
- # get/settimeout, so make sure that's always the case because
- # pywsgi can depend on that.
- SSLSocket.timeout = property(lambda self: self.gettimeout(),
- lambda self, value: self.settimeout(value))
-
-
-
-_SSLErrorReadTimeout = SSLError('The read operation timed out')
-_SSLErrorWriteTimeout = SSLError('The write operation timed out')
-_SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out')
-
-def wrap_socket(sock, keyfile=None, certfile=None,
- server_side=False, cert_reqs=CERT_NONE,
- ssl_version=PROTOCOL_SSLv23, ca_certs=None,
- do_handshake_on_connect=True,
- suppress_ragged_eofs=True,
- ciphers=None):
-
- return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile,
- server_side=server_side, cert_reqs=cert_reqs,
- ssl_version=ssl_version, ca_certs=ca_certs,
- do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs,
- ciphers=ciphers)
-
-def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
- """Retrieve the certificate from the server at the specified address,
- and return it as a PEM-encoded string.
- If 'ca_certs' is specified, validate the server cert against it.
- If 'ssl_version' is specified, use it in the connection attempt."""
-
- _, _ = addr
- if ca_certs is not None:
- cert_reqs = CERT_REQUIRED
- else:
- cert_reqs = CERT_NONE
- context = _create_stdlib_context(ssl_version,
- cert_reqs=cert_reqs,
- cafile=ca_certs)
- with closing(create_connection(addr)) as sock:
- with closing(context.wrap_socket(sock)) as sslsock:
- dercert = sslsock.getpeercert(True)
- return DER_cert_to_PEM_cert(dercert)
diff --git a/python/gevent/_tblib.py b/python/gevent/_tblib.py
deleted file mode 100644
index 1336401..0000000
--- a/python/gevent/_tblib.py
+++ /dev/null
@@ -1,432 +0,0 @@
-# -*- coding: utf-8 -*-
-# A vendored version of part of https://github.com/ionelmc/python-tblib
-# pylint:disable=redefined-outer-name,reimported,function-redefined,bare-except,no-else-return,broad-except
-####
-# Copyright (c) 2013-2016, Ionel Cristian Mărieș
-# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
-# following conditions are met:
-
-# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
-# disclaimer.
-
-# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided with the distribution.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-####
-
-# cpython.py
-
-"""
-Taken verbatim from Jinja2.
-
-https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267
-"""
-# pylint:disable=consider-using-dict-comprehension
-#import platform # XXX: gevent cannot import platform at the top level; interferes with monkey patching
-import sys
-
-
-def _init_ugly_crap():
- """This function implements a few ugly things so that we can patch the
- traceback objects. The function returned allows resetting `tb_next` on
- any python traceback object. Do not attempt to use this on non cpython
- interpreters
- """
- import ctypes
- from types import TracebackType
-
- # figure out side of _Py_ssize_t
- if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
- _Py_ssize_t = ctypes.c_int64
- else:
- _Py_ssize_t = ctypes.c_int
-
- # regular python
- class _PyObject(ctypes.Structure):
- pass
-
- _PyObject._fields_ = [
- ('ob_refcnt', _Py_ssize_t),
- ('ob_type', ctypes.POINTER(_PyObject))
- ]
-
- # python with trace
- if hasattr(sys, 'getobjects'):
- class _PyObject(ctypes.Structure):
- pass
-
- _PyObject._fields_ = [
- ('_ob_next', ctypes.POINTER(_PyObject)),
- ('_ob_prev', ctypes.POINTER(_PyObject)),
- ('ob_refcnt', _Py_ssize_t),
- ('ob_type', ctypes.POINTER(_PyObject))
- ]
-
- class _Traceback(_PyObject):
- pass
-
- _Traceback._fields_ = [
- ('tb_next', ctypes.POINTER(_Traceback)),
- ('tb_frame', ctypes.POINTER(_PyObject)),
- ('tb_lasti', ctypes.c_int),
- ('tb_lineno', ctypes.c_int)
- ]
-
- def tb_set_next(tb, next):
- """Set the tb_next attribute of a traceback object."""
- if not (isinstance(tb, TracebackType) and (next is None or isinstance(next, TracebackType))):
- raise TypeError('tb_set_next arguments must be traceback objects')
- obj = _Traceback.from_address(id(tb))
- if tb.tb_next is not None:
- old = _Traceback.from_address(id(tb.tb_next))
- old.ob_refcnt -= 1
- if next is None:
- obj.tb_next = ctypes.POINTER(_Traceback)()
- else:
- next = _Traceback.from_address(id(next))
- next.ob_refcnt += 1
- obj.tb_next = ctypes.pointer(next)
-
- return tb_set_next
-
-
-tb_set_next = None
-#try:
-# if platform.python_implementation() == 'CPython':
-# tb_set_next = _init_ugly_crap()
-#except Exception as exc:
-# sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc))
-#del _init_ugly_crap
-
-# __init__.py
-import re
-from types import CodeType
-from types import TracebackType
-
-try:
- from __pypy__ import tproxy
-except ImportError:
- tproxy = None
-
-__version__ = '1.3.0'
-__all__ = ('Traceback',)
-
-PY3 = sys.version_info[0] == 3
-FRAME_RE = re.compile(r'^\s*File "(?P<co_filename>.+)", line (?P<tb_lineno>\d+)(, in (?P<co_name>.+))?$')
-
-
-class _AttrDict(dict):
- __slots__ = ()
- __getattr__ = dict.__getitem__
-
-
-# noinspection PyPep8Naming
-class __traceback_maker(Exception):
- pass
-
-
-class TracebackParseError(Exception):
- pass
-
-
-class Code(object):
- def __init__(self, code):
- self.co_filename = code.co_filename
- self.co_name = code.co_name
- # gevent: copy more attributes
- self.co_nlocals = code.co_nlocals
- self.co_stacksize = code.co_stacksize
- self.co_flags = code.co_flags
- self.co_firstlineno = code.co_firstlineno
-
-
-class Frame(object):
- def __init__(self, frame):
- self.f_globals = dict([
- (k, v)
- for k, v in frame.f_globals.items()
- if k in ("__file__", "__name__")
- ])
- self.f_code = Code(frame.f_code)
-
- def clear(self):
- # For compatibility with PyPy 3.5;
- # clear was added to frame in Python 3.4
- # and is called by traceback.clear_frames(), which
- # in turn is called by unittest.TestCase.assertRaises
- pass
-
-class Traceback(object):
-
- tb_next = None
-
- def __init__(self, tb):
- self.tb_frame = Frame(tb.tb_frame)
- # noinspection SpellCheckingInspection
- self.tb_lineno = int(tb.tb_lineno)
-
- # Build in place to avoid exceeding the recursion limit
- tb = tb.tb_next
- prev_traceback = self
- cls = type(self)
- while tb is not None:
- traceback = object.__new__(cls)
- traceback.tb_frame = Frame(tb.tb_frame)
- traceback.tb_lineno = int(tb.tb_lineno)
- prev_traceback.tb_next = traceback
- prev_traceback = traceback
- tb = tb.tb_next
-
- def as_traceback(self):
- if tproxy:
- return tproxy(TracebackType, self.__tproxy_handler)
- if not tb_set_next:
- raise RuntimeError("Cannot re-create traceback !")
-
- current = self
- top_tb = None
- tb = None
- while current:
- f_code = current.tb_frame.f_code
- code = compile('\n' * (current.tb_lineno - 1) + 'raise __traceback_maker', current.tb_frame.f_code.co_filename, 'exec')
- if PY3:
- code = CodeType(
- 0, code.co_kwonlyargcount,
- code.co_nlocals, code.co_stacksize, code.co_flags,
- code.co_code, code.co_consts, code.co_names, code.co_varnames,
- f_code.co_filename, f_code.co_name,
- code.co_firstlineno, code.co_lnotab, (), ()
- )
- else:
- code = CodeType(
- 0,
- code.co_nlocals, code.co_stacksize, code.co_flags,
- code.co_code, code.co_consts, code.co_names, code.co_varnames,
- f_code.co_filename.encode(), f_code.co_name.encode(),
- code.co_firstlineno, code.co_lnotab, (), ()
- )
-
- # noinspection PyBroadException
- try:
- exec(code, current.tb_frame.f_globals, {})
- except:
- next_tb = sys.exc_info()[2].tb_next
- if top_tb is None:
- top_tb = next_tb
- if tb is not None:
- tb_set_next(tb, next_tb)
- tb = next_tb
- del next_tb
-
- current = current.tb_next
- try:
- return top_tb
- finally:
- del top_tb
- del tb
-
-
- # noinspection SpellCheckingInspection
- def __tproxy_handler(self, operation, *args, **kwargs):
- if operation in ('__getattribute__', '__getattr__'):
- if args[0] == 'tb_next':
- return self.tb_next and self.tb_next.as_traceback()
- else:
- return getattr(self, args[0])
- else:
- return getattr(self, operation)(*args, **kwargs)
-
- def to_dict(self):
- """Convert a Traceback into a dictionary representation"""
- if self.tb_next is None:
- tb_next = None
- else:
- tb_next = self.tb_next.to_dict()
-
- code = {
- 'co_filename': self.tb_frame.f_code.co_filename,
- 'co_name': self.tb_frame.f_code.co_name,
- }
- frame = {
- 'f_globals': self.tb_frame.f_globals,
- 'f_code': code,
- }
- return {
- 'tb_frame': frame,
- 'tb_lineno': self.tb_lineno,
- 'tb_next': tb_next,
- }
-
- @classmethod
- def from_dict(cls, dct):
- if dct['tb_next']:
- tb_next = cls.from_dict(dct['tb_next'])
- else:
- tb_next = None
-
- code = _AttrDict(
- co_filename=dct['tb_frame']['f_code']['co_filename'],
- co_name=dct['tb_frame']['f_code']['co_name'],
- )
- frame = _AttrDict(
- f_globals=dct['tb_frame']['f_globals'],
- f_code=code,
- )
- tb = _AttrDict(
- tb_frame=frame,
- tb_lineno=dct['tb_lineno'],
- tb_next=tb_next,
- )
- return cls(tb)
-
- @classmethod
- def from_string(cls, string, strict=True):
- frames = []
- header = strict
-
- for line in string.splitlines():
- line = line.rstrip()
- if header:
- if line == 'Traceback (most recent call last):':
- header = False
- continue
- frame_match = FRAME_RE.match(line)
- if frame_match:
- frames.append(frame_match.groupdict())
- elif line.startswith(' '):
- pass
- elif strict:
- break # traceback ended
-
- if frames:
- previous = None
- for frame in reversed(frames):
- previous = _AttrDict(
- frame,
- tb_frame=_AttrDict(
- frame,
- f_globals=_AttrDict(
- __file__=frame['co_filename'],
- __name__='?',
- ),
- f_code=_AttrDict(frame),
- ),
- tb_next=previous,
- )
- return cls(previous)
- else:
- raise TracebackParseError("Could not find any frames in %r." % string)
-
-# pickling_support.py
-
-
-def unpickle_traceback(tb_frame, tb_lineno, tb_next):
- ret = object.__new__(Traceback)
- ret.tb_frame = tb_frame
- ret.tb_lineno = tb_lineno
- ret.tb_next = tb_next
- return ret.as_traceback()
-
-
-def pickle_traceback(tb):
- return unpickle_traceback, (Frame(tb.tb_frame), tb.tb_lineno, tb.tb_next and Traceback(tb.tb_next))
-
-
-def install():
- try:
- import copy_reg
- except ImportError:
- import copyreg as copy_reg
-
- copy_reg.pickle(TracebackType, pickle_traceback)
-
-# Added by gevent
-
-# We have to defer the initialization, and especially the import of platform,
-# until runtime. If we're monkey patched, we need to be sure to use
-# the original __import__ to avoid switching through the hub due to
-# import locks on Python 2. See also builtins.py for details.
-
-
-def _unlocked_imports(f):
- def g(a):
- if sys is None: # pragma: no cover
- # interpreter shutdown on Py2
- return
-
- gb = None
- if 'gevent.builtins' in sys.modules:
- gb = sys.modules['gevent.builtins']
- gb._unlock_imports()
- try:
- return f(a)
- finally:
- if gb is not None:
- gb._lock_imports()
- g.__name__ = f.__name__
- g.__module__ = f.__module__
- return g
-
-
-def _import_dump_load():
- global dumps
- global loads
- try:
- import cPickle as pickle
- except ImportError:
- import pickle
- dumps = pickle.dumps
- loads = pickle.loads
-
-dumps = loads = None
-
-_installed = False
-
-
-def _init():
- global _installed
- global tb_set_next
- if _installed:
- return
-
- _installed = True
- import platform
- try:
- if platform.python_implementation() == 'CPython':
- tb_set_next = _init_ugly_crap()
- except Exception as exc:
- sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc))
-
- try:
- from __pypy__ import tproxy
- except ImportError:
- tproxy = None
-
- if not tb_set_next and not tproxy:
- raise ImportError("Cannot use tblib. Runtime not supported.")
- _import_dump_load()
- install()
-
-
-@_unlocked_imports
-def dump_traceback(tb):
- # Both _init and dump/load have to be unlocked, because
- # copy_reg and pickle can do imports to resolve class names; those
- # class names are in this module and greenlet safe though
- _init()
- return dumps(tb)
-
-
-@_unlocked_imports
-def load_traceback(s):
- _init()
- return loads(s)
diff --git a/python/gevent/_threading.py b/python/gevent/_threading.py
deleted file mode 100644
index 9258dfb..0000000
--- a/python/gevent/_threading.py
+++ /dev/null
@@ -1,168 +0,0 @@
-"""A clone of threading module (version 2.7.2) that always
-targets real OS threads. (Unlike 'threading' which flips between
-green and OS threads based on whether the monkey patching is in effect
-or not).
-
-This module is missing 'Thread' class, but includes 'Queue'.
-"""
-from __future__ import absolute_import
-
-from collections import deque
-
-from gevent import monkey
-from gevent._compat import thread_mod_name
-
-
-__all__ = [
- 'Lock',
- 'Queue',
-]
-
-
-start_new_thread, Lock, get_thread_ident, = monkey.get_original(thread_mod_name, [
- 'start_new_thread', 'allocate_lock', 'get_ident',
-])
-
-
-# pylint 2.0.dev2 things collections.dequeue.popleft() doesn't return
-# pylint:disable=assignment-from-no-return
-
-
-class _Condition(object):
- # pylint:disable=method-hidden
-
- def __init__(self, lock):
- self.__lock = lock
- self.__waiters = []
-
- # If the lock defines _release_save() and/or _acquire_restore(),
- # these override the default implementations (which just call
- # release() and acquire() on the lock). Ditto for _is_owned().
- try:
- self._release_save = lock._release_save
- except AttributeError:
- pass
- try:
- self._acquire_restore = lock._acquire_restore
- except AttributeError:
- pass
- try:
- self._is_owned = lock._is_owned
- except AttributeError:
- pass
-
- def __enter__(self):
- return self.__lock.__enter__()
-
- def __exit__(self, t, v, tb):
- return self.__lock.__exit__(t, v, tb)
-
- def __repr__(self):
- return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters))
-
- def _release_save(self):
- self.__lock.release() # No state to save
-
- def _acquire_restore(self, x): # pylint:disable=unused-argument
- self.__lock.acquire() # Ignore saved state
-
- def _is_owned(self):
- # Return True if lock is owned by current_thread.
- # This method is called only if __lock doesn't have _is_owned().
- if self.__lock.acquire(0):
- self.__lock.release()
- return False
- return True
-
- def wait(self):
- # The condition MUST be owned, but we don't check that.
- waiter = Lock()
- waiter.acquire()
- self.__waiters.append(waiter)
- saved_state = self._release_save()
- try: # restore state no matter what (e.g., KeyboardInterrupt)
- waiter.acquire() # Block on the native lock
- finally:
- self._acquire_restore(saved_state)
-
- def notify_one(self):
- # The condition MUST be owned, but we don't check that.
- try:
- waiter = self.__waiters.pop()
- except IndexError:
- # Nobody around
- pass
- else:
- waiter.release()
-
-
-class Queue(object):
- """Create a queue object.
-
- The queue is always infinite size.
- """
-
- __slots__ = ('_queue', '_mutex', '_not_empty', 'unfinished_tasks')
-
- def __init__(self):
- self._queue = deque()
- # mutex must be held whenever the queue is mutating. All methods
- # that acquire mutex must release it before returning. mutex
- # is shared between the three conditions, so acquiring and
- # releasing the conditions also acquires and releases mutex.
- self._mutex = Lock()
- # Notify not_empty whenever an item is added to the queue; a
- # thread waiting to get is notified then.
- self._not_empty = _Condition(self._mutex)
-
- self.unfinished_tasks = 0
-
- def task_done(self):
- """Indicate that a formerly enqueued task is complete.
-
- Used by Queue consumer threads. For each get() used to fetch a task,
- a subsequent call to task_done() tells the queue that the processing
- on the task is complete.
-
- If a join() is currently blocking, it will resume when all items
- have been processed (meaning that a task_done() call was received
- for every item that had been put() into the queue).
-
- Raises a ValueError if called more times than there were items
- placed in the queue.
- """
- with self._mutex:
- unfinished = self.unfinished_tasks - 1
- if unfinished <= 0:
- if unfinished < 0:
- raise ValueError('task_done() called too many times')
- self.unfinished_tasks = unfinished
-
- def qsize(self, len=len):
- """Return the approximate size of the queue (not reliable!)."""
- return len(self._queue)
-
- def empty(self):
- """Return True if the queue is empty, False otherwise (not reliable!)."""
- return not self.qsize()
-
- def full(self):
- """Return True if the queue is full, False otherwise (not reliable!)."""
- return False
-
- def put(self, item):
- """Put an item into the queue.
- """
- with self._not_empty:
- self._queue.append(item)
- self.unfinished_tasks += 1
- self._not_empty.notify_one()
-
- def get(self):
- """Remove and return an item from the queue.
- """
- with self._not_empty:
- while not self._queue:
- self._not_empty.wait()
- item = self._queue.popleft()
- return item
diff --git a/python/gevent/_tracer.c b/python/gevent/_tracer.c
deleted file mode 100644
index caef6dd..0000000
--- a/python/gevent/_tracer.c
+++ /dev/null
@@ -1,9571 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__tracer.pxd",
- "src\\gevent\\__tracer.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__tracer",
- "sources": [
- "src/gevent/_tracer.py"
- ]
- },
- "module_name": "gevent.__tracer"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____tracer
-#define __PYX_HAVE_API__gevent____tracer
-/* Early includes */
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_tracer.py",
- "src\\gevent\\__tracer.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_8__tracer_GreenletTracer;
-struct __pyx_obj_6gevent_8__tracer__HubTracer;
-struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer;
-struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer;
-
-/* "gevent/__tracer.pxd":15
- *
- *
- * cdef class GreenletTracer: # <<<<<<<<<<<<<<
- * cpdef readonly object active_greenlet
- * cpdef readonly object previous_trace_function
- */
-struct __pyx_obj_6gevent_8__tracer_GreenletTracer {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer *__pyx_vtab;
- PyObject *active_greenlet;
- PyObject *previous_trace_function;
- Py_ssize_t greenlet_switch_counter;
- int _killed;
-};
-
-
-/* "gevent/__tracer.pxd":30
- *
- * @cython.internal
- * cdef class _HubTracer(GreenletTracer): # <<<<<<<<<<<<<<
- * cpdef readonly object hub
- * cpdef readonly double max_blocking_time
- */
-struct __pyx_obj_6gevent_8__tracer__HubTracer {
- struct __pyx_obj_6gevent_8__tracer_GreenletTracer __pyx_base;
- PyObject *hub;
- double max_blocking_time;
-};
-
-
-/* "gevent/__tracer.pxd":35
- *
- *
- * cdef class HubSwitchTracer(_HubTracer): # <<<<<<<<<<<<<<
- * cpdef readonly double last_entered_hub
- *
- */
-struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer {
- struct __pyx_obj_6gevent_8__tracer__HubTracer __pyx_base;
- double last_entered_hub;
-};
-
-
-/* "gevent/__tracer.pxd":38
- * cpdef readonly double last_entered_hub
- *
- * cdef class MaxSwitchTracer(_HubTracer): # <<<<<<<<<<<<<<
- * cpdef readonly double max_blocking
- * cpdef readonly double last_switch
- */
-struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer {
- struct __pyx_obj_6gevent_8__tracer__HubTracer __pyx_base;
- double max_blocking;
- double last_switch;
-};
-
-
-
-/* "src/gevent/_tracer.py":27
- *
- *
- * class GreenletTracer(object): # <<<<<<<<<<<<<<
- * def __init__(self):
- * # A counter, incremented by the greenlet trace function
- */
-
-struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer {
- PyObject *(*_trace)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*did_block_hub)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*kill)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer *__pyx_vtabptr_6gevent_8__tracer_GreenletTracer;
-
-
-/* "src/gevent/_tracer.py":122
- *
- *
- * class _HubTracer(GreenletTracer): # <<<<<<<<<<<<<<
- * def __init__(self, hub, max_blocking_time):
- * GreenletTracer.__init__(self)
- */
-
-struct __pyx_vtabstruct_6gevent_8__tracer__HubTracer {
- struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer__HubTracer *__pyx_vtabptr_6gevent_8__tracer__HubTracer;
-
-
-/* "src/gevent/_tracer.py":133
- *
- *
- * class HubSwitchTracer(_HubTracer): # <<<<<<<<<<<<<<
- * # A greenlet tracer that records the last time we switched *into* the hub.
- *
- */
-
-struct __pyx_vtabstruct_6gevent_8__tracer_HubSwitchTracer {
- struct __pyx_vtabstruct_6gevent_8__tracer__HubTracer __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer_HubSwitchTracer *__pyx_vtabptr_6gevent_8__tracer_HubSwitchTracer;
-
-
-/* "src/gevent/_tracer.py":150
- *
- *
- * class MaxSwitchTracer(_HubTracer): # <<<<<<<<<<<<<<
- * # A greenlet tracer that records the maximum time between switches,
- * # not including time spent in the hub.
- */
-
-struct __pyx_vtabstruct_6gevent_8__tracer_MaxSwitchTracer {
- struct __pyx_vtabstruct_6gevent_8__tracer__HubTracer __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer_MaxSwitchTracer *__pyx_vtabptr_6gevent_8__tracer_MaxSwitchTracer;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* IncludeStringH.proto */
-#include <string.h>
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* StrEquals.proto */
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
-#else
-#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
-#endif
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* StringJoin.proto */
-#if PY_MAJOR_VERSION < 3
-#define __Pyx_PyString_Join __Pyx_PyBytes_Join
-#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
-#else
-#define __Pyx_PyString_Join PyUnicode_Join
-#define __Pyx_PyBaseString_Join PyUnicode_Join
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION < 3
- #define __Pyx_PyBytes_Join _PyString_Join
- #else
- #define __Pyx_PyBytes_Join _PyBytes_Join
- #endif
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
-#endif
-
-/* ListExtend.proto */
-static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject* none = _PyList_Extend((PyListObject*)L, v);
- if (unlikely(!none))
- return -1;
- Py_DECREF(none);
- return 0;
-#else
- return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
-#endif
-}
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer_kill(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer__trace(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_10_HubTracer_kill(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15HubSwitchTracer__trace(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15HubSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15MaxSwitchTracer__trace(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15MaxSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'gevent.__tracer' */
-static PyTypeObject *__pyx_ptype_6gevent_8__tracer_GreenletTracer = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__tracer__HubTracer = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__tracer_HubSwitchTracer = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__tracer_MaxSwitchTracer = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_sys = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_traceback = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_settrace = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_getcurrent = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_format_run_info = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_perf_counter = 0;
-static PyObject *__pyx_v_6gevent_8__tracer_gmctime = 0;
-#define __Pyx_MODULE_NAME "gevent.__tracer"
-extern int __pyx_module_is_main_gevent____tracer;
-int __pyx_module_is_main_gevent____tracer = 0;
-
-/* Implementation of 'gevent.__tracer' */
-static PyObject *__pyx_builtin_KeyError;
-static PyObject *__pyx_builtin_hex;
-#if PY_MAJOR_VERSION >= 3
-static const char __pyx_k_[] = "================================================================================";
-#endif
-#if PY_MAJOR_VERSION < 3
-static const char __pyx_k_b[] = "b'================================================================================'";
-#endif
-static const char __pyx_k__2[] = "";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_hex[] = "hex";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_Info[] = "Info:";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_kill[] = "kill";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_event[] = "event";
-static const char __pyx_k_frame[] = "frame";
-static const char __pyx_k_stack[] = "stack";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_trace[] = "_trace";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_report[] = "report";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_gmctime[] = "gmctime";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_settrace[] = "settrace";
-static const char __pyx_k_traceback[] = "traceback";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_gevent_util[] = "gevent.util";
-static const char __pyx_k_format_stack[] = "format_stack";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_perf_counter[] = "perf_counter";
-static const char __pyx_k_thread_ident[] = "thread_ident";
-static const char __pyx_k_Reported_by_s[] = " Reported by %s";
-static const char __pyx_k_did_block_hub[] = "did_block_hub";
-static const char __pyx_k_format_kwargs[] = "format_kwargs";
-static const char __pyx_k_GreenletTracer[] = "GreenletTracer";
-static const char __pyx_k_HubTracer_kill[] = "_HubTracer.kill";
-static const char __pyx_k_current_frames[] = "_current_frames";
-static const char __pyx_k_gevent__compat[] = "gevent._compat";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_HubSwitchTracer[] = "HubSwitchTracer";
-static const char __pyx_k_MaxSwitchTracer[] = "MaxSwitchTracer";
-static const char __pyx_k_active_greenlet[] = "active_greenlet";
-static const char __pyx_k_format_run_info[] = "format_run_info";
-static const char __pyx_k_gevent___tracer[] = "gevent.__tracer";
-static const char __pyx_k_max_blocking_time[] = "max_blocking_time";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_GreenletTracer_kill[] = "GreenletTracer.kill";
-static const char __pyx_k_did_block_hub_report[] = "did_block_hub_report";
-static const char __pyx_k_GreenletTracer__trace[] = "GreenletTracer._trace";
-static const char __pyx_k_src_gevent__tracer_py[] = "src\\gevent\\_tracer.py";
-static const char __pyx_k_HubSwitchTracer__trace[] = "HubSwitchTracer._trace";
-static const char __pyx_k_MaxSwitchTracer__trace[] = "MaxSwitchTracer._trace";
-static const char __pyx_k_GreenletTracer_did_block_hub[] = "GreenletTracer.did_block_hub";
-static const char __pyx_k_Blocked_Stack_for_thread_id_s[] = "Blocked Stack (for thread id %s):";
-static const char __pyx_k_HubSwitchTracer_did_block_hub[] = "HubSwitchTracer.did_block_hub";
-static const char __pyx_k_MaxSwitchTracer_did_block_hub[] = "MaxSwitchTracer.did_block_hub";
-static const char __pyx_k_Unknown_No_thread_found_for_hub[] = "Unknown: No thread found for hub %r\n";
-static const char __pyx_k_s_Greenlet_s_appears_to_be_bloc[] = "\n%s : Greenlet %s appears to be blocked";
-static const char __pyx_k_GreenletTracer_did_block_hub_rep[] = "GreenletTracer.did_block_hub_report";
-static const char __pyx_k_GreenletTracer_ignore_current_gr[] = "GreenletTracer.ignore_current_greenlet_blocking";
-static const char __pyx_k_GreenletTracer_monitor_current_g[] = "GreenletTracer.monitor_current_greenlet_blocking";
-static const char __pyx_k_ignore_current_greenlet_blocking[] = "ignore_current_greenlet_blocking";
-static const char __pyx_k_monitor_current_greenlet_blockin[] = "monitor_current_greenlet_blocking";
-static PyObject *__pyx_kp_s_Blocked_Stack_for_thread_id_s;
-static PyObject *__pyx_n_s_GreenletTracer;
-static PyObject *__pyx_n_s_GreenletTracer__trace;
-static PyObject *__pyx_n_s_GreenletTracer_did_block_hub;
-static PyObject *__pyx_n_s_GreenletTracer_did_block_hub_rep;
-static PyObject *__pyx_n_s_GreenletTracer_ignore_current_gr;
-static PyObject *__pyx_n_s_GreenletTracer_kill;
-static PyObject *__pyx_n_s_GreenletTracer_monitor_current_g;
-static PyObject *__pyx_n_s_HubSwitchTracer;
-static PyObject *__pyx_n_s_HubSwitchTracer__trace;
-static PyObject *__pyx_n_s_HubSwitchTracer_did_block_hub;
-static PyObject *__pyx_n_s_HubTracer_kill;
-static PyObject *__pyx_kp_s_Info;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_MaxSwitchTracer;
-static PyObject *__pyx_n_s_MaxSwitchTracer__trace;
-static PyObject *__pyx_n_s_MaxSwitchTracer_did_block_hub;
-static PyObject *__pyx_kp_s_Reported_by_s;
-static PyObject *__pyx_kp_s_Unknown_No_thread_found_for_hub;
-static PyObject *__pyx_kp_s__2;
-static PyObject *__pyx_n_s_active_greenlet;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_kp_s_b;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_current_frames;
-static PyObject *__pyx_n_s_did_block_hub;
-static PyObject *__pyx_n_s_did_block_hub_report;
-static PyObject *__pyx_n_s_event;
-static PyObject *__pyx_n_s_format_kwargs;
-static PyObject *__pyx_n_s_format_run_info;
-static PyObject *__pyx_n_s_format_stack;
-static PyObject *__pyx_n_s_frame;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent___tracer;
-static PyObject *__pyx_n_s_gevent__compat;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_util;
-static PyObject *__pyx_n_s_gmctime;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_hex;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_n_s_ignore_current_greenlet_blocking;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_kill;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_max_blocking_time;
-static PyObject *__pyx_n_s_monitor_current_greenlet_blockin;
-static PyObject *__pyx_n_s_perf_counter;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_report;
-static PyObject *__pyx_kp_s_s_Greenlet_s_appears_to_be_bloc;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_settrace;
-static PyObject *__pyx_kp_s_src_gevent__tracer_py;
-static PyObject *__pyx_n_s_stack;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_thread_ident;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_n_s_trace;
-static PyObject *__pyx_n_s_traceback;
-static int __pyx_pf_6gevent_8__tracer_14GreenletTracer___init__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_2kill(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_4_trace(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_6__call__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_8did_block_hub(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_active_greenlet, PyObject *__pyx_v_format_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_15active_greenlet___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_23previous_trace_function___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8__tracer_10_HubTracer___init__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_2kill(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_3hub___get__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_17max_blocking_time___get__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8__tracer_15HubSwitchTracer___init__(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_2_trace(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub___get__(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer___init__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_2_trace(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking___get__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_11last_switch___get__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_8__tracer_GreenletTracer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_8__tracer__HubTracer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_8__tracer_HubSwitchTracer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_8__tracer_MaxSwitchTracer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_codeobj__4;
-static PyObject *__pyx_codeobj__6;
-static PyObject *__pyx_codeobj__8;
-static PyObject *__pyx_codeobj__10;
-static PyObject *__pyx_codeobj__12;
-static PyObject *__pyx_codeobj__14;
-static PyObject *__pyx_codeobj__16;
-static PyObject *__pyx_codeobj__18;
-static PyObject *__pyx_codeobj__20;
-static PyObject *__pyx_codeobj__22;
-static PyObject *__pyx_codeobj__24;
-/* Late includes */
-
-/* "src/gevent/_tracer.py":28
- *
- * class GreenletTracer(object):
- * def __init__(self): # <<<<<<<<<<<<<<
- * # A counter, incremented by the greenlet trace function
- * # we install on every greenlet switch. This is reset when the
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__tracer_14GreenletTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__tracer_14GreenletTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer___init__(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__tracer_14GreenletTracer___init__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_v_prev_trace = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_tracer.py":33
- * # periodic monitoring thread runs.
- *
- * self.greenlet_switch_counter = 0 # <<<<<<<<<<<<<<
- *
- * # The greenlet last switched to.
- */
- __pyx_v_self->greenlet_switch_counter = 0;
-
- /* "src/gevent/_tracer.py":36
- *
- * # The greenlet last switched to.
- * self.active_greenlet = None # <<<<<<<<<<<<<<
- *
- * # The trace function that was previously installed,
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->active_greenlet);
- __Pyx_DECREF(__pyx_v_self->active_greenlet);
- __pyx_v_self->active_greenlet = Py_None;
-
- /* "src/gevent/_tracer.py":43
- * # calling a bound method (at least when compiled with cython)
- * # even when it redirects to another function.
- * prev_trace = settrace(self) # <<<<<<<<<<<<<<
- *
- * self.previous_trace_function = prev_trace
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_settrace);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_settrace; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_prev_trace = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":45
- * prev_trace = settrace(self)
- *
- * self.previous_trace_function = prev_trace # <<<<<<<<<<<<<<
- *
- * self._killed = False
- */
- __Pyx_INCREF(__pyx_v_prev_trace);
- __Pyx_GIVEREF(__pyx_v_prev_trace);
- __Pyx_GOTREF(__pyx_v_self->previous_trace_function);
- __Pyx_DECREF(__pyx_v_self->previous_trace_function);
- __pyx_v_self->previous_trace_function = __pyx_v_prev_trace;
-
- /* "src/gevent/_tracer.py":47
- * self.previous_trace_function = prev_trace
- *
- * self._killed = False # <<<<<<<<<<<<<<
- *
- * def kill(self):
- */
- __pyx_v_self->_killed = 0;
-
- /* "src/gevent/_tracer.py":28
- *
- * class GreenletTracer(object):
- * def __init__(self): # <<<<<<<<<<<<<<
- * # A counter, incremented by the greenlet trace function
- * # we install on every greenlet switch. This is reset when the
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_prev_trace);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":49
- * self._killed = False
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * # Must be called in the monitored thread.
- * if not self._killed:
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer_kill(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("kill", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_kill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_3kill)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":51
- * def kill(self):
- * # Must be called in the monitored thread.
- * if not self._killed: # <<<<<<<<<<<<<<
- * self._killed = True
- * settrace(self.previous_trace_function)
- */
- __pyx_t_5 = ((!(__pyx_v_self->_killed != 0)) != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/_tracer.py":52
- * # Must be called in the monitored thread.
- * if not self._killed:
- * self._killed = True # <<<<<<<<<<<<<<
- * settrace(self.previous_trace_function)
- * self.previous_trace_function = None
- */
- __pyx_v_self->_killed = 1;
-
- /* "src/gevent/_tracer.py":53
- * if not self._killed:
- * self._killed = True
- * settrace(self.previous_trace_function) # <<<<<<<<<<<<<<
- * self.previous_trace_function = None
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_settrace);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_settrace; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->previous_trace_function); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->previous_trace_function};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->previous_trace_function};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_self->previous_trace_function);
- __Pyx_GIVEREF(__pyx_v_self->previous_trace_function);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->previous_trace_function);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":54
- * self._killed = True
- * settrace(self.previous_trace_function)
- * self.previous_trace_function = None # <<<<<<<<<<<<<<
- *
- * def _trace(self, event, args):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->previous_trace_function);
- __Pyx_DECREF(__pyx_v_self->previous_trace_function);
- __pyx_v_self->previous_trace_function = Py_None;
-
- /* "src/gevent/_tracer.py":51
- * def kill(self):
- * # Must be called in the monitored thread.
- * if not self._killed: # <<<<<<<<<<<<<<
- * self._killed = True
- * settrace(self.previous_trace_function)
- */
- }
-
- /* "src/gevent/_tracer.py":49
- * self._killed = False
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * # Must be called in the monitored thread.
- * if not self._killed:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_2kill[] = "GreenletTracer.kill(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_3kill = {"kill", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_3kill, METH_NOARGS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_2kill};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("kill (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_2kill(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_2kill(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("kill", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer_kill(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":56
- * self.previous_trace_function = None
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer__trace(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- __Pyx_RefNannySetupContext("_trace", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_5_trace)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_event);
- __Pyx_GIVEREF(__pyx_v_event);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_event);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":58
- * def _trace(self, event, args):
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1 # <<<<<<<<<<<<<<
- * if event in ('switch', 'throw'):
- * # args is (origin, target). This is the only defined
- */
- __pyx_v_self->greenlet_switch_counter = (__pyx_v_self->greenlet_switch_counter + 1);
-
- /* "src/gevent/_tracer.py":59
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- * if event in ('switch', 'throw'): # <<<<<<<<<<<<<<
- * # args is (origin, target). This is the only defined
- * # case
- */
- __Pyx_INCREF(__pyx_v_event);
- __pyx_t_7 = __pyx_v_event;
- __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_7, __pyx_n_s_switch, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 59, __pyx_L1_error)
- __pyx_t_10 = (__pyx_t_9 != 0);
- if (!__pyx_t_10) {
- } else {
- __pyx_t_8 = __pyx_t_10;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_7, __pyx_n_s_throw, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 59, __pyx_L1_error)
- __pyx_t_9 = (__pyx_t_10 != 0);
- __pyx_t_8 = __pyx_t_9;
- __pyx_L4_bool_binop_done:;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_9 = (__pyx_t_8 != 0);
- if (__pyx_t_9) {
-
- /* "src/gevent/_tracer.py":62
- * # args is (origin, target). This is the only defined
- * # case
- * self.active_greenlet = args[1] # <<<<<<<<<<<<<<
- * else:
- * self.active_greenlet = None
- */
- if (unlikely(__pyx_v_args == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 62, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->active_greenlet);
- __Pyx_DECREF(__pyx_v_self->active_greenlet);
- __pyx_v_self->active_greenlet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":59
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- * if event in ('switch', 'throw'): # <<<<<<<<<<<<<<
- * # args is (origin, target). This is the only defined
- * # case
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_tracer.py":64
- * self.active_greenlet = args[1]
- * else:
- * self.active_greenlet = None # <<<<<<<<<<<<<<
- * if self.previous_trace_function is not None:
- * self.previous_trace_function(event, args)
- */
- /*else*/ {
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->active_greenlet);
- __Pyx_DECREF(__pyx_v_self->active_greenlet);
- __pyx_v_self->active_greenlet = Py_None;
- }
- __pyx_L3:;
-
- /* "src/gevent/_tracer.py":65
- * else:
- * self.active_greenlet = None
- * if self.previous_trace_function is not None: # <<<<<<<<<<<<<<
- * self.previous_trace_function(event, args)
- *
- */
- __pyx_t_9 = (__pyx_v_self->previous_trace_function != Py_None);
- __pyx_t_8 = (__pyx_t_9 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_tracer.py":66
- * self.active_greenlet = None
- * if self.previous_trace_function is not None:
- * self.previous_trace_function(event, args) # <<<<<<<<<<<<<<
- *
- * def __call__(self, event, args):
- */
- __Pyx_INCREF(__pyx_v_self->previous_trace_function);
- __pyx_t_2 = __pyx_v_self->previous_trace_function; __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_event, __pyx_v_args};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_event, __pyx_v_args};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_event);
- __Pyx_GIVEREF(__pyx_v_event);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_event);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":65
- * else:
- * self.active_greenlet = None
- * if self.previous_trace_function is not None: # <<<<<<<<<<<<<<
- * self.previous_trace_function(event, args)
- *
- */
- }
-
- /* "src/gevent/_tracer.py":56
- * self.previous_trace_function = None
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_4_trace[] = "GreenletTracer._trace(self, str event, tuple args)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_5_trace = {"_trace", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_5_trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_4_trace};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_trace (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 56, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_trace") < 0)) __PYX_ERR(0, 56, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_event = ((PyObject*)values[0]);
- __pyx_v_args = ((PyObject*)values[1]);
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 56, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 56, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 56, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_4_trace(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_4_trace(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_trace", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":68
- * self.previous_trace_function(event, args)
- *
- * def __call__(self, event, args): # <<<<<<<<<<<<<<
- * return self._trace(event, args)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); __PYX_ERR(0, 68, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 68, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_event = values[0];
- __pyx_v_args = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 68, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_6__call__(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_6__call__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/_tracer.py":69
- *
- * def __call__(self, event, args):
- * return self._trace(event, args) # <<<<<<<<<<<<<<
- *
- * def did_block_hub(self, hub):
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(PyString_CheckExact(__pyx_v_event))||((__pyx_v_event) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_event)->tp_name), 0))) __PYX_ERR(0, 69, __pyx_L1_error)
- if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 69, __pyx_L1_error)
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer *)__pyx_v_self->__pyx_vtab)->_trace(__pyx_v_self, ((PyObject*)__pyx_v_event), ((PyObject*)__pyx_v_args), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":68
- * self.previous_trace_function(event, args)
- *
- * def __call__(self, event, args): # <<<<<<<<<<<<<<
- * return self._trace(event, args)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":71
- * return self._trace(event, args)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * # Check to see if we have blocked since the last call to this
- * # method. Returns a true value if we blocked (not in the hub),
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_14GreenletTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, int __pyx_skip_dispatch) {
- int __pyx_v_did_switch;
- PyObject *__pyx_v_active_greenlet = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_9did_block_hub)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_hub);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":82
- * # annoying false positives.
- *
- * active_greenlet = self.active_greenlet # <<<<<<<<<<<<<<
- * did_switch = self.greenlet_switch_counter != 0
- * self.greenlet_switch_counter = 0
- */
- __pyx_t_1 = __pyx_v_self->active_greenlet;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_active_greenlet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":83
- *
- * active_greenlet = self.active_greenlet
- * did_switch = self.greenlet_switch_counter != 0 # <<<<<<<<<<<<<<
- * self.greenlet_switch_counter = 0
- *
- */
- __pyx_v_did_switch = (__pyx_v_self->greenlet_switch_counter != 0);
-
- /* "src/gevent/_tracer.py":84
- * active_greenlet = self.active_greenlet
- * did_switch = self.greenlet_switch_counter != 0
- * self.greenlet_switch_counter = 0 # <<<<<<<<<<<<<<
- *
- * if did_switch or active_greenlet is None or active_greenlet is hub:
- */
- __pyx_v_self->greenlet_switch_counter = 0;
-
- /* "src/gevent/_tracer.py":86
- * self.greenlet_switch_counter = 0
- *
- * if did_switch or active_greenlet is None or active_greenlet is hub: # <<<<<<<<<<<<<<
- * # Either we switched, or nothing is running (we got a
- * # trace event we don't know about or were requested to
- */
- __pyx_t_7 = (__pyx_v_did_switch != 0);
- if (!__pyx_t_7) {
- } else {
- __pyx_t_6 = __pyx_t_7;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_7 = (__pyx_v_active_greenlet == Py_None);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (!__pyx_t_8) {
- } else {
- __pyx_t_6 = __pyx_t_8;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_8 = (__pyx_v_active_greenlet == __pyx_v_hub);
- __pyx_t_7 = (__pyx_t_8 != 0);
- __pyx_t_6 = __pyx_t_7;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_6) {
-
- /* "src/gevent/_tracer.py":91
- * # ignore), or we spent the whole time in the hub, blocked
- * # for IO. Nothing to report.
- * return False # <<<<<<<<<<<<<<
- * return True, active_greenlet
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(Py_False);
- __pyx_r = Py_False;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":86
- * self.greenlet_switch_counter = 0
- *
- * if did_switch or active_greenlet is None or active_greenlet is hub: # <<<<<<<<<<<<<<
- * # Either we switched, or nothing is running (we got a
- * # trace event we don't know about or were requested to
- */
- }
-
- /* "src/gevent/_tracer.py":92
- * # for IO. Nothing to report.
- * return False
- * return True, active_greenlet # <<<<<<<<<<<<<<
- *
- * def ignore_current_greenlet_blocking(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(Py_True);
- __Pyx_GIVEREF(Py_True);
- PyTuple_SET_ITEM(__pyx_t_1, 0, Py_True);
- __Pyx_INCREF(__pyx_v_active_greenlet);
- __Pyx_GIVEREF(__pyx_v_active_greenlet);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_active_greenlet);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":71
- * return self._trace(event, args)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * # Check to see if we have blocked since the last call to this
- * # method. Returns a true value if we blocked (not in the hub),
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_active_greenlet);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_8did_block_hub[] = "GreenletTracer.did_block_hub(self, hub)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_9did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_9did_block_hub, METH_O, __pyx_doc_6gevent_8__tracer_14GreenletTracer_8did_block_hub};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_8did_block_hub(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_8did_block_hub(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":94
- * return True, active_greenlet
- *
- * def ignore_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * # Don't pay attention to the current greenlet.
- * self.active_greenlet = None
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking[] = "GreenletTracer.ignore_current_greenlet_blocking(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking = {"ignore_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ignore_current_greenlet_blocking (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ignore_current_greenlet_blocking", 0);
-
- /* "src/gevent/_tracer.py":96
- * def ignore_current_greenlet_blocking(self):
- * # Don't pay attention to the current greenlet.
- * self.active_greenlet = None # <<<<<<<<<<<<<<
- *
- * def monitor_current_greenlet_blocking(self):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->active_greenlet);
- __Pyx_DECREF(__pyx_v_self->active_greenlet);
- __pyx_v_self->active_greenlet = Py_None;
-
- /* "src/gevent/_tracer.py":94
- * return True, active_greenlet
- *
- * def ignore_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * # Don't pay attention to the current greenlet.
- * self.active_greenlet = None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":98
- * self.active_greenlet = None
- *
- * def monitor_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * self.active_greenlet = getcurrent()
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking[] = "GreenletTracer.monitor_current_greenlet_blocking(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking = {"monitor_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("monitor_current_greenlet_blocking (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("monitor_current_greenlet_blocking", 0);
-
- /* "src/gevent/_tracer.py":99
- *
- * def monitor_current_greenlet_blocking(self):
- * self.active_greenlet = getcurrent() # <<<<<<<<<<<<<<
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs):
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_getcurrent);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_getcurrent; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->active_greenlet);
- __Pyx_DECREF(__pyx_v_self->active_greenlet);
- __pyx_v_self->active_greenlet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":98
- * self.active_greenlet = None
- *
- * def monitor_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * self.active_greenlet = getcurrent()
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.monitor_current_greenlet_blocking", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":101
- * self.active_greenlet = getcurrent()
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs): # <<<<<<<<<<<<<<
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' %
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report[] = "GreenletTracer.did_block_hub_report(self, hub, active_greenlet, format_kwargs)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report = {"did_block_hub_report", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report};
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- PyObject *__pyx_v_active_greenlet = 0;
- PyObject *__pyx_v_format_kwargs = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("did_block_hub_report (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_active_greenlet,&__pyx_n_s_format_kwargs,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_active_greenlet)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, 1); __PYX_ERR(0, 101, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format_kwargs)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, 2); __PYX_ERR(0, 101, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "did_block_hub_report") < 0)) __PYX_ERR(0, 101, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_hub = values[0];
- __pyx_v_active_greenlet = values[1];
- __pyx_v_format_kwargs = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 101, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_active_greenlet, __pyx_v_format_kwargs);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_active_greenlet, PyObject *__pyx_v_format_kwargs) {
- PyObject *__pyx_v_report = NULL;
- PyObject *__pyx_v_frame = NULL;
- PyObject *__pyx_v_stack = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- __Pyx_RefNannySetupContext("did_block_hub_report", 0);
-
- /* "src/gevent/_tracer.py":104
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' %
- * (gmctime(), active_greenlet)] # <<<<<<<<<<<<<<
- * report.append(" Reported by %s" % (self,))
- * try:
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_gmctime);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_gmctime; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_active_greenlet);
- __Pyx_GIVEREF(__pyx_v_active_greenlet);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_active_greenlet);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":103
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs):
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' % # <<<<<<<<<<<<<<
- * (gmctime(), active_greenlet)]
- * report.append(" Reported by %s" % (self,))
- */
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_Greenlet_s_appears_to_be_bloc, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":102
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs):
- * report = ['=' * 80, # <<<<<<<<<<<<<<
- * '\n%s : Greenlet %s appears to be blocked' %
- * (gmctime(), active_greenlet)]
- */
- __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_kp_s_b);
- __Pyx_GIVEREF(__pyx_kp_s_b);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_b);
- __Pyx_GIVEREF(__pyx_t_1);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_v_report = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":105
- * '\n%s : Greenlet %s appears to be blocked' %
- * (gmctime(), active_greenlet)]
- * report.append(" Reported by %s" % (self,)) # <<<<<<<<<<<<<<
- * try:
- * frame = sys._current_frames()[hub.thread_ident]
- */
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Reported_by_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":106
- * (gmctime(), active_greenlet)]
- * report.append(" Reported by %s" % (self,))
- * try: # <<<<<<<<<<<<<<
- * frame = sys._current_frames()[hub.thread_ident]
- * except KeyError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- /*try:*/ {
-
- /* "src/gevent/_tracer.py":107
- * report.append(" Reported by %s" % (self,))
- * try:
- * frame = sys._current_frames()[hub.thread_ident] # <<<<<<<<<<<<<<
- * except KeyError:
- * # The thread holding the hub has died. Perhaps we shouldn't
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_8__tracer_sys, __pyx_n_s_current_frames); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L3_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub, __pyx_n_s_thread_ident); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_frame = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/_tracer.py":106
- * (gmctime(), active_greenlet)]
- * report.append(" Reported by %s" % (self,))
- * try: # <<<<<<<<<<<<<<
- * frame = sys._current_frames()[hub.thread_ident]
- * except KeyError:
- */
- }
-
- /* "src/gevent/_tracer.py":113
- * stack = ["Unknown: No thread found for hub %r\n" % (hub,)]
- * else:
- * stack = traceback.format_stack(frame) # <<<<<<<<<<<<<<
- * report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),))
- * report.append(''.join(stack))
- */
- /*else:*/ {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_8__tracer_traceback, __pyx_n_s_format_stack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_1) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_frame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_frame};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_frame};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
- __Pyx_INCREF(__pyx_v_frame);
- __Pyx_GIVEREF(__pyx_v_frame);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_frame);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_stack = __pyx_t_3;
- __pyx_t_3 = 0;
- }
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_tracer.py":108
- * try:
- * frame = sys._current_frames()[hub.thread_ident]
- * except KeyError: # <<<<<<<<<<<<<<
- * # The thread holding the hub has died. Perhaps we shouldn't
- * # even report this?
- */
- __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_9) {
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_8) < 0) __PYX_ERR(0, 108, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_8);
-
- /* "src/gevent/_tracer.py":111
- * # The thread holding the hub has died. Perhaps we shouldn't
- * # even report this?
- * stack = ["Unknown: No thread found for hub %r\n" % (hub,)] # <<<<<<<<<<<<<<
- * else:
- * stack = traceback.format_stack(frame)
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_hub);
- __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_No_thread_found_for_hub, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 111, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_10);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_10);
- __pyx_t_10 = 0;
- __pyx_v_stack = __pyx_t_1;
- __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/_tracer.py":106
- * (gmctime(), active_greenlet)]
- * report.append(" Reported by %s" % (self,))
- * try: # <<<<<<<<<<<<<<
- * frame = sys._current_frames()[hub.thread_ident]
- * except KeyError:
- */
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/_tracer.py":114
- * else:
- * stack = traceback.format_stack(frame)
- * report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),)) # <<<<<<<<<<<<<<
- * report.append(''.join(stack))
- * report.append("Info:")
- */
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub, __pyx_n_s_thread_ident); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Blocked_Stack_for_thread_id_s, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":115
- * stack = traceback.format_stack(frame)
- * report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),))
- * report.append(''.join(stack)) # <<<<<<<<<<<<<<
- * report.append("Info:")
- * report.extend(format_run_info(**format_kwargs))
- */
- __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_v_stack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":116
- * report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),))
- * report.append(''.join(stack))
- * report.append("Info:") # <<<<<<<<<<<<<<
- * report.extend(format_run_info(**format_kwargs))
- *
- */
- __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_report, __pyx_kp_s_Info); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 116, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":117
- * report.append(''.join(stack))
- * report.append("Info:")
- * report.extend(format_run_info(**format_kwargs)) # <<<<<<<<<<<<<<
- *
- * return report
- */
- if (unlikely(__pyx_v_format_kwargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
- __PYX_ERR(0, 117, __pyx_L1_error)
- }
- if (likely(PyDict_CheckExact(__pyx_v_format_kwargs))) {
- __pyx_t_2 = PyDict_Copy(__pyx_v_format_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- __pyx_t_2 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_format_kwargs, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- }
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_v_6gevent_8__tracer_format_run_info, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyList_Extend(__pyx_v_report, __pyx_t_8); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "src/gevent/_tracer.py":119
- * report.extend(format_run_info(**format_kwargs))
- *
- * return report # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_report);
- __pyx_r = __pyx_v_report;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":101
- * self.active_greenlet = getcurrent()
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs): # <<<<<<<<<<<<<<
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' %
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_report);
- __Pyx_XDECREF(__pyx_v_frame);
- __Pyx_XDECREF(__pyx_v_stack);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":16
- *
- * cdef class GreenletTracer:
- * cpdef readonly object active_greenlet # <<<<<<<<<<<<<<
- * cpdef readonly object previous_trace_function
- * cpdef readonly Py_ssize_t greenlet_switch_counter
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_15active_greenlet_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_15active_greenlet_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_15active_greenlet___get__(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_15active_greenlet___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->active_greenlet);
- __pyx_r = __pyx_v_self->active_greenlet;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":17
- * cdef class GreenletTracer:
- * cpdef readonly object active_greenlet
- * cpdef readonly object previous_trace_function # <<<<<<<<<<<<<<
- * cpdef readonly Py_ssize_t greenlet_switch_counter
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_23previous_trace_function_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_23previous_trace_function_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_23previous_trace_function___get__(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_23previous_trace_function___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->previous_trace_function);
- __pyx_r = __pyx_v_self->previous_trace_function;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":18
- * cpdef readonly object active_greenlet
- * cpdef readonly object previous_trace_function
- * cpdef readonly Py_ssize_t greenlet_switch_counter # <<<<<<<<<<<<<<
- *
- * cdef bint _killed
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter___get__(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter___get__(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->greenlet_switch_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.GreenletTracer.greenlet_switch_counter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":123
- *
- * class _HubTracer(GreenletTracer):
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * GreenletTracer.__init__(self)
- * self.max_blocking_time = max_blocking_time
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__tracer_10_HubTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__tracer_10_HubTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- PyObject *__pyx_v_max_blocking_time = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_blocking_time)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 123, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 123, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_hub = values[0];
- __pyx_v_max_blocking_time = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 123, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer._HubTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__tracer_10_HubTracer___init__(((struct __pyx_obj_6gevent_8__tracer__HubTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__tracer_10_HubTracer___init__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- double __pyx_t_5;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_tracer.py":124
- * class _HubTracer(GreenletTracer):
- * def __init__(self, hub, max_blocking_time):
- * GreenletTracer.__init__(self) # <<<<<<<<<<<<<<
- * self.max_blocking_time = max_blocking_time
- * self.hub = hub
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":125
- * def __init__(self, hub, max_blocking_time):
- * GreenletTracer.__init__(self)
- * self.max_blocking_time = max_blocking_time # <<<<<<<<<<<<<<
- * self.hub = hub
- *
- */
- __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_max_blocking_time); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L1_error)
- __pyx_v_self->max_blocking_time = __pyx_t_5;
-
- /* "src/gevent/_tracer.py":126
- * GreenletTracer.__init__(self)
- * self.max_blocking_time = max_blocking_time
- * self.hub = hub # <<<<<<<<<<<<<<
- *
- * def kill(self):
- */
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(__pyx_v_self->hub);
- __pyx_v_self->hub = __pyx_v_hub;
-
- /* "src/gevent/_tracer.py":123
- *
- * class _HubTracer(GreenletTracer):
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * GreenletTracer.__init__(self)
- * self.max_blocking_time = max_blocking_time
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__tracer._HubTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":128
- * self.hub = hub
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * self.hub = None
- * GreenletTracer.kill(self)
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_10_HubTracer_kill(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("kill", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_kill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_10_HubTracer_3kill)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":129
- *
- * def kill(self):
- * self.hub = None # <<<<<<<<<<<<<<
- * GreenletTracer.kill(self)
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(__pyx_v_self->hub);
- __pyx_v_self->hub = Py_None;
-
- /* "src/gevent/_tracer.py":130
- * def kill(self):
- * self.hub = None
- * GreenletTracer.kill(self) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer_kill(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":128
- * self.hub = hub
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * self.hub = None
- * GreenletTracer.kill(self)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__tracer._HubTracer.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_10_HubTracer_2kill[] = "_HubTracer.kill(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_10_HubTracer_3kill = {"kill", (PyCFunction)__pyx_pw_6gevent_8__tracer_10_HubTracer_3kill, METH_NOARGS, __pyx_doc_6gevent_8__tracer_10_HubTracer_2kill};
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("kill (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_10_HubTracer_2kill(((struct __pyx_obj_6gevent_8__tracer__HubTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_2kill(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("kill", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_10_HubTracer_kill(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer._HubTracer.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":31
- * @cython.internal
- * cdef class _HubTracer(GreenletTracer):
- * cpdef readonly object hub # <<<<<<<<<<<<<<
- * cpdef readonly double max_blocking_time
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_3hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_3hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_10_HubTracer_3hub___get__(((struct __pyx_obj_6gevent_8__tracer__HubTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_3hub___get__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->hub);
- __pyx_r = __pyx_v_self->hub;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":32
- * cdef class _HubTracer(GreenletTracer):
- * cpdef readonly object hub
- * cpdef readonly double max_blocking_time # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_17max_blocking_time_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_10_HubTracer_17max_blocking_time_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_10_HubTracer_17max_blocking_time___get__(((struct __pyx_obj_6gevent_8__tracer__HubTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_10_HubTracer_17max_blocking_time___get__(struct __pyx_obj_6gevent_8__tracer__HubTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->max_blocking_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer._HubTracer.max_blocking_time.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":136
- * # A greenlet tracer that records the last time we switched *into* the hub.
- *
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_entered_hub = 0
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__tracer_15HubSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__tracer_15HubSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- PyObject *__pyx_v_max_blocking_time = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_blocking_time)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 136, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 136, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_hub = values[0];
- __pyx_v_max_blocking_time = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 136, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__tracer_15HubSwitchTracer___init__(((struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__tracer_15HubSwitchTracer___init__(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_tracer.py":137
- *
- * def __init__(self, hub, max_blocking_time):
- * _HubTracer.__init__(self, hub, max_blocking_time) # <<<<<<<<<<<<<<
- * self.last_entered_hub = 0
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__tracer__HubTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_hub);
- __Pyx_INCREF(__pyx_v_max_blocking_time);
- __Pyx_GIVEREF(__pyx_v_max_blocking_time);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_max_blocking_time);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":138
- * def __init__(self, hub, max_blocking_time):
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_entered_hub = 0 # <<<<<<<<<<<<<<
- *
- * def _trace(self, event, args):
- */
- __pyx_v_self->last_entered_hub = 0.0;
-
- /* "src/gevent/_tracer.py":136
- * # A greenlet tracer that records the last time we switched *into* the hub.
- *
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_entered_hub = 0
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":140
- * self.last_entered_hub = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub:
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15HubSwitchTracer__trace(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- double __pyx_t_9;
- __Pyx_RefNannySetupContext("_trace", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_3_trace)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_event);
- __Pyx_GIVEREF(__pyx_v_event);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_event);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":141
- *
- * def _trace(self, event, args):
- * GreenletTracer._trace(self, event, args) # <<<<<<<<<<<<<<
- * if self.active_greenlet is self.hub:
- * self.last_entered_hub = perf_counter()
- */
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer__trace(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":142
- * def _trace(self, event, args):
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub: # <<<<<<<<<<<<<<
- * self.last_entered_hub = perf_counter()
- *
- */
- __pyx_t_7 = (__pyx_v_self->__pyx_base.__pyx_base.active_greenlet == __pyx_v_self->__pyx_base.hub);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/_tracer.py":143
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub:
- * self.last_entered_hub = perf_counter() # <<<<<<<<<<<<<<
- *
- * def did_block_hub(self, hub):
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_perf_counter; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_self->last_entered_hub = __pyx_t_9;
-
- /* "src/gevent/_tracer.py":142
- * def _trace(self, event, args):
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub: # <<<<<<<<<<<<<<
- * self.last_entered_hub = perf_counter()
- *
- */
- }
-
- /* "src/gevent/_tracer.py":140
- * self.last_entered_hub = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_15HubSwitchTracer_2_trace[] = "HubSwitchTracer._trace(self, str event, tuple args)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_15HubSwitchTracer_3_trace = {"_trace", (PyCFunction)__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_3_trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__tracer_15HubSwitchTracer_2_trace};
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_trace (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 140, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_trace") < 0)) __PYX_ERR(0, 140, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_event = ((PyObject*)values[0]);
- __pyx_v_args = ((PyObject*)values[1]);
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 140, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 140, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 140, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_8__tracer_15HubSwitchTracer_2_trace(((struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_2_trace(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_trace", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_15HubSwitchTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":145
- * self.last_entered_hub = perf_counter()
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- * return True, self.active_greenlet
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15HubSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_hub);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":146
- *
- * def did_block_hub(self, hub):
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time: # <<<<<<<<<<<<<<
- * return True, self.active_greenlet
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_perf_counter; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->last_entered_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.max_blocking_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_6) {
-
- /* "src/gevent/_tracer.py":147
- * def did_block_hub(self, hub):
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- * return True, self.active_greenlet # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(Py_True);
- __Pyx_GIVEREF(Py_True);
- PyTuple_SET_ITEM(__pyx_t_1, 0, Py_True);
- __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":146
- *
- * def did_block_hub(self, hub):
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time: # <<<<<<<<<<<<<<
- * return True, self.active_greenlet
- *
- */
- }
-
- /* "src/gevent/_tracer.py":145
- * self.last_entered_hub = perf_counter()
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- * return True, self.active_greenlet
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_15HubSwitchTracer_4did_block_hub[] = "HubSwitchTracer.did_block_hub(self, hub)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub, METH_O, __pyx_doc_6gevent_8__tracer_15HubSwitchTracer_4did_block_hub};
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_15HubSwitchTracer_4did_block_hub(((struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_15HubSwitchTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":36
- *
- * cdef class HubSwitchTracer(_HubTracer):
- * cpdef readonly double last_entered_hub # <<<<<<<<<<<<<<
- *
- * cdef class MaxSwitchTracer(_HubTracer):
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub___get__(((struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub___get__(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->last_entered_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.HubSwitchTracer.last_entered_hub.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":154
- * # not including time spent in the hub.
- *
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_switch = perf_counter()
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- PyObject *__pyx_v_max_blocking_time = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_blocking_time)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 154, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 154, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_hub = values[0];
- __pyx_v_max_blocking_time = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 154, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer___init__(((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer___init__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- double __pyx_t_6;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_tracer.py":155
- *
- * def __init__(self, hub, max_blocking_time):
- * _HubTracer.__init__(self, hub, max_blocking_time) # <<<<<<<<<<<<<<
- * self.last_switch = perf_counter()
- * self.max_blocking = 0
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__tracer__HubTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_hub);
- __Pyx_INCREF(__pyx_v_max_blocking_time);
- __Pyx_GIVEREF(__pyx_v_max_blocking_time);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_max_blocking_time);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":156
- * def __init__(self, hub, max_blocking_time):
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_switch = perf_counter() # <<<<<<<<<<<<<<
- * self.max_blocking = 0
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_perf_counter; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_self->last_switch = __pyx_t_6;
-
- /* "src/gevent/_tracer.py":157
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_switch = perf_counter()
- * self.max_blocking = 0 # <<<<<<<<<<<<<<
- *
- * def _trace(self, event, args):
- */
- __pyx_v_self->max_blocking = 0.0;
-
- /* "src/gevent/_tracer.py":154
- * # not including time spent in the hub.
- *
- * def __init__(self, hub, max_blocking_time): # <<<<<<<<<<<<<<
- * _HubTracer.__init__(self, hub, max_blocking_time)
- * self.last_switch = perf_counter()
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":159
- * self.max_blocking = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15MaxSwitchTracer__trace(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) {
- double __pyx_v_switched_at;
- PyObject *__pyx_v_old_active = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- double __pyx_t_10;
- double __pyx_t_11;
- double __pyx_t_12;
- __Pyx_RefNannySetupContext("_trace", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_3_trace)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_event);
- __Pyx_GIVEREF(__pyx_v_event);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_event);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":160
- *
- * def _trace(self, event, args):
- * old_active = self.active_greenlet # <<<<<<<<<<<<<<
- * GreenletTracer._trace(self, event, args)
- * if old_active is not self.hub and old_active is not None:
- */
- __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.active_greenlet;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_old_active = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":161
- * def _trace(self, event, args):
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args) # <<<<<<<<<<<<<<
- * if old_active is not self.hub and old_active is not None:
- * # If we're switching out of the hub, the blocking
- */
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_14GreenletTracer__trace(((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":162
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- * if old_active is not self.hub and old_active is not None: # <<<<<<<<<<<<<<
- * # If we're switching out of the hub, the blocking
- * # time doesn't count.
- */
- __pyx_t_8 = (__pyx_v_old_active != __pyx_v_self->__pyx_base.hub);
- __pyx_t_9 = (__pyx_t_8 != 0);
- if (__pyx_t_9) {
- } else {
- __pyx_t_7 = __pyx_t_9;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_9 = (__pyx_v_old_active != Py_None);
- __pyx_t_8 = (__pyx_t_9 != 0);
- __pyx_t_7 = __pyx_t_8;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "src/gevent/_tracer.py":165
- * # If we're switching out of the hub, the blocking
- * # time doesn't count.
- * switched_at = perf_counter() # <<<<<<<<<<<<<<
- * self.max_blocking = max(self.max_blocking,
- * switched_at - self.last_switch)
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_perf_counter; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_switched_at = __pyx_t_10;
-
- /* "src/gevent/_tracer.py":167
- * switched_at = perf_counter()
- * self.max_blocking = max(self.max_blocking,
- * switched_at - self.last_switch) # <<<<<<<<<<<<<<
- *
- * def did_block_hub(self, hub):
- */
- __pyx_t_10 = (__pyx_v_switched_at - __pyx_v_self->last_switch);
-
- /* "src/gevent/_tracer.py":166
- * # time doesn't count.
- * switched_at = perf_counter()
- * self.max_blocking = max(self.max_blocking, # <<<<<<<<<<<<<<
- * switched_at - self.last_switch)
- *
- */
- __pyx_t_11 = __pyx_v_self->max_blocking;
-
- /* "src/gevent/_tracer.py":167
- * switched_at = perf_counter()
- * self.max_blocking = max(self.max_blocking,
- * switched_at - self.last_switch) # <<<<<<<<<<<<<<
- *
- * def did_block_hub(self, hub):
- */
- if (((__pyx_t_10 > __pyx_t_11) != 0)) {
- __pyx_t_12 = __pyx_t_10;
- } else {
- __pyx_t_12 = __pyx_t_11;
- }
-
- /* "src/gevent/_tracer.py":166
- * # time doesn't count.
- * switched_at = perf_counter()
- * self.max_blocking = max(self.max_blocking, # <<<<<<<<<<<<<<
- * switched_at - self.last_switch)
- *
- */
- __pyx_v_self->max_blocking = __pyx_t_12;
-
- /* "src/gevent/_tracer.py":162
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- * if old_active is not self.hub and old_active is not None: # <<<<<<<<<<<<<<
- * # If we're switching out of the hub, the blocking
- * # time doesn't count.
- */
- }
-
- /* "src/gevent/_tracer.py":159
- * self.max_blocking = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_old_active);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_15MaxSwitchTracer_2_trace[] = "MaxSwitchTracer._trace(self, str event, tuple args)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_15MaxSwitchTracer_3_trace = {"_trace", (PyCFunction)__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_3_trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__tracer_15MaxSwitchTracer_2_trace};
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_event = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_trace (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 159, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_trace") < 0)) __PYX_ERR(0, 159, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_event = ((PyObject*)values[0]);
- __pyx_v_args = ((PyObject*)values[1]);
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 159, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 159, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 159, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_2_trace(((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_2_trace(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_trace", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_15MaxSwitchTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_tracer.py":169
- * switched_at - self.last_switch)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if self.max_blocking == 0:
- * # We never switched. Check the time now
- */
-
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static PyObject *__pyx_f_6gevent_8__tracer_15MaxSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- double __pyx_t_7;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_hub};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_hub);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_tracer.py":170
- *
- * def did_block_hub(self, hub):
- * if self.max_blocking == 0: # <<<<<<<<<<<<<<
- * # We never switched. Check the time now
- * self.max_blocking = perf_counter() - self.last_switch
- */
- __pyx_t_6 = ((__pyx_v_self->max_blocking == 0.0) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_tracer.py":172
- * if self.max_blocking == 0:
- * # We never switched. Check the time now
- * self.max_blocking = perf_counter() - self.last_switch # <<<<<<<<<<<<<<
- *
- * if self.max_blocking > self.max_blocking_time:
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __pyx_t_2 = __pyx_v_6gevent_8__tracer_perf_counter; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->last_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_self->max_blocking = __pyx_t_7;
-
- /* "src/gevent/_tracer.py":170
- *
- * def did_block_hub(self, hub):
- * if self.max_blocking == 0: # <<<<<<<<<<<<<<
- * # We never switched. Check the time now
- * self.max_blocking = perf_counter() - self.last_switch
- */
- }
-
- /* "src/gevent/_tracer.py":174
- * self.max_blocking = perf_counter() - self.last_switch
- *
- * if self.max_blocking > self.max_blocking_time: # <<<<<<<<<<<<<<
- * return True, self.active_greenlet
- *
- */
- __pyx_t_6 = ((__pyx_v_self->max_blocking > __pyx_v_self->__pyx_base.max_blocking_time) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_tracer.py":175
- *
- * if self.max_blocking > self.max_blocking_time:
- * return True, self.active_greenlet # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(Py_True);
- __Pyx_GIVEREF(Py_True);
- PyTuple_SET_ITEM(__pyx_t_3, 0, Py_True);
- __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->__pyx_base.__pyx_base.active_greenlet);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_tracer.py":174
- * self.max_blocking = perf_counter() - self.last_switch
- *
- * if self.max_blocking > self.max_blocking_time: # <<<<<<<<<<<<<<
- * return True, self.active_greenlet
- *
- */
- }
-
- /* "src/gevent/_tracer.py":169
- * switched_at - self.last_switch)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if self.max_blocking == 0:
- * # We never switched. Check the time now
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/
-static char __pyx_doc_6gevent_8__tracer_15MaxSwitchTracer_4did_block_hub[] = "MaxSwitchTracer.did_block_hub(self, hub)";
-static PyMethodDef __pyx_mdef_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub, METH_O, __pyx_doc_6gevent_8__tracer_15MaxSwitchTracer_4did_block_hub};
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_4did_block_hub(((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("did_block_hub", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__tracer_15MaxSwitchTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":39
- *
- * cdef class MaxSwitchTracer(_HubTracer):
- * cpdef readonly double max_blocking # <<<<<<<<<<<<<<
- * cpdef readonly double last_switch
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking___get__(((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking___get__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->max_blocking); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.max_blocking.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__tracer.pxd":40
- * cdef class MaxSwitchTracer(_HubTracer):
- * cpdef readonly double max_blocking
- * cpdef readonly double last_switch # <<<<<<<<<<<<<<
- *
- * @cython.locals(switched_at=double)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_11last_switch_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_11last_switch_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_11last_switch___get__(((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__tracer_15MaxSwitchTracer_11last_switch___get__(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->last_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__tracer.MaxSwitchTracer.last_switch.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-static struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer __pyx_vtable_6gevent_8__tracer_GreenletTracer;
-
-static PyObject *__pyx_tp_new_6gevent_8__tracer_GreenletTracer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_8__tracer_GreenletTracer *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_8__tracer_GreenletTracer;
- p->active_greenlet = Py_None; Py_INCREF(Py_None);
- p->previous_trace_function = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8__tracer_GreenletTracer(PyObject *o) {
- struct __pyx_obj_6gevent_8__tracer_GreenletTracer *p = (struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->active_greenlet);
- Py_CLEAR(p->previous_trace_function);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8__tracer_GreenletTracer(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8__tracer_GreenletTracer *p = (struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)o;
- if (p->active_greenlet) {
- e = (*v)(p->active_greenlet, a); if (e) return e;
- }
- if (p->previous_trace_function) {
- e = (*v)(p->previous_trace_function, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8__tracer_GreenletTracer(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8__tracer_GreenletTracer *p = (struct __pyx_obj_6gevent_8__tracer_GreenletTracer *)o;
- tmp = ((PyObject*)p->active_greenlet);
- p->active_greenlet = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->previous_trace_function);
- p->previous_trace_function = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_14GreenletTracer_active_greenlet(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_14GreenletTracer_15active_greenlet_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_14GreenletTracer_previous_trace_function(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_14GreenletTracer_23previous_trace_function_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_14GreenletTracer_greenlet_switch_counter(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_14GreenletTracer_23greenlet_switch_counter_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__tracer_GreenletTracer[] = {
- {"ignore_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_10ignore_current_greenlet_blocking},
- {"monitor_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_12monitor_current_greenlet_blocking},
- {"did_block_hub_report", (PyCFunction)__pyx_pw_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__tracer_14GreenletTracer_14did_block_hub_report},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8__tracer_GreenletTracer[] = {
- {(char *)"active_greenlet", __pyx_getprop_6gevent_8__tracer_14GreenletTracer_active_greenlet, 0, (char *)0, 0},
- {(char *)"previous_trace_function", __pyx_getprop_6gevent_8__tracer_14GreenletTracer_previous_trace_function, 0, (char *)0, 0},
- {(char *)"greenlet_switch_counter", __pyx_getprop_6gevent_8__tracer_14GreenletTracer_greenlet_switch_counter, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__tracer_GreenletTracer = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__tracer.GreenletTracer", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__tracer_GreenletTracer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__tracer_GreenletTracer, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "GreenletTracer()", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__tracer_GreenletTracer, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__tracer_GreenletTracer, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__tracer_GreenletTracer, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8__tracer_GreenletTracer, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__tracer_14GreenletTracer_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__tracer_GreenletTracer, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer__HubTracer __pyx_vtable_6gevent_8__tracer__HubTracer;
-
-static PyObject *__pyx_tp_new_6gevent_8__tracer__HubTracer(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_8__tracer__HubTracer *p;
- PyObject *o = __pyx_tp_new_6gevent_8__tracer_GreenletTracer(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__tracer__HubTracer *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer*)__pyx_vtabptr_6gevent_8__tracer__HubTracer;
- p->hub = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8__tracer__HubTracer(PyObject *o) {
- struct __pyx_obj_6gevent_8__tracer__HubTracer *p = (struct __pyx_obj_6gevent_8__tracer__HubTracer *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->hub);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_8__tracer_GreenletTracer(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8__tracer__HubTracer(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8__tracer__HubTracer *p = (struct __pyx_obj_6gevent_8__tracer__HubTracer *)o;
- e = __pyx_tp_traverse_6gevent_8__tracer_GreenletTracer(o, v, a); if (e) return e;
- if (p->hub) {
- e = (*v)(p->hub, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8__tracer__HubTracer(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8__tracer__HubTracer *p = (struct __pyx_obj_6gevent_8__tracer__HubTracer *)o;
- __pyx_tp_clear_6gevent_8__tracer_GreenletTracer(o);
- tmp = ((PyObject*)p->hub);
- p->hub = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_10_HubTracer_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_10_HubTracer_3hub_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_10_HubTracer_max_blocking_time(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_10_HubTracer_17max_blocking_time_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__tracer__HubTracer[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8__tracer__HubTracer[] = {
- {(char *)"hub", __pyx_getprop_6gevent_8__tracer_10_HubTracer_hub, 0, (char *)0, 0},
- {(char *)"max_blocking_time", __pyx_getprop_6gevent_8__tracer_10_HubTracer_max_blocking_time, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__tracer__HubTracer = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__tracer._HubTracer", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__tracer__HubTracer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__tracer__HubTracer, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__, /*tp_call*/
- #else
- 0, /*tp_call*/
- #endif
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_HubTracer(hub, max_blocking_time)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__tracer__HubTracer, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__tracer__HubTracer, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__tracer__HubTracer, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8__tracer__HubTracer, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__tracer_10_HubTracer_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__tracer__HubTracer, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer_HubSwitchTracer __pyx_vtable_6gevent_8__tracer_HubSwitchTracer;
-
-static PyObject *__pyx_tp_new_6gevent_8__tracer_HubSwitchTracer(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *p;
- PyObject *o = __pyx_tp_new_6gevent_8__tracer__HubTracer(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer *)o);
- p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer*)__pyx_vtabptr_6gevent_8__tracer_HubSwitchTracer;
- return o;
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_15HubSwitchTracer_last_entered_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_15HubSwitchTracer_16last_entered_hub_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__tracer_HubSwitchTracer[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8__tracer_HubSwitchTracer[] = {
- {(char *)"last_entered_hub", __pyx_getprop_6gevent_8__tracer_15HubSwitchTracer_last_entered_hub, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__tracer_HubSwitchTracer = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__tracer.HubSwitchTracer", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__tracer_HubSwitchTracer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__tracer__HubTracer, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__, /*tp_call*/
- #else
- 0, /*tp_call*/
- #endif
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "HubSwitchTracer(hub, max_blocking_time)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__tracer__HubTracer, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__tracer__HubTracer, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__tracer_HubSwitchTracer, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8__tracer_HubSwitchTracer, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__tracer_15HubSwitchTracer_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__tracer_HubSwitchTracer, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_8__tracer_MaxSwitchTracer __pyx_vtable_6gevent_8__tracer_MaxSwitchTracer;
-
-static PyObject *__pyx_tp_new_6gevent_8__tracer_MaxSwitchTracer(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *p;
- PyObject *o = __pyx_tp_new_6gevent_8__tracer__HubTracer(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer *)o);
- p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_8__tracer_GreenletTracer*)__pyx_vtabptr_6gevent_8__tracer_MaxSwitchTracer;
- return o;
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_15MaxSwitchTracer_max_blocking(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_12max_blocking_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__tracer_15MaxSwitchTracer_last_switch(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_11last_switch_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__tracer_MaxSwitchTracer[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8__tracer_MaxSwitchTracer[] = {
- {(char *)"max_blocking", __pyx_getprop_6gevent_8__tracer_15MaxSwitchTracer_max_blocking, 0, (char *)0, 0},
- {(char *)"last_switch", __pyx_getprop_6gevent_8__tracer_15MaxSwitchTracer_last_switch, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__tracer_MaxSwitchTracer = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__tracer.MaxSwitchTracer", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__tracer_MaxSwitchTracer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__tracer__HubTracer, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_8__tracer_14GreenletTracer_7__call__, /*tp_call*/
- #else
- 0, /*tp_call*/
- #endif
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "MaxSwitchTracer(hub, max_blocking_time)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__tracer__HubTracer, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__tracer__HubTracer, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__tracer_MaxSwitchTracer, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8__tracer_MaxSwitchTracer, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__tracer_15MaxSwitchTracer_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__tracer_MaxSwitchTracer, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___tracer(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___tracer},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__tracer",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_kp_s_Blocked_Stack_for_thread_id_s, __pyx_k_Blocked_Stack_for_thread_id_s, sizeof(__pyx_k_Blocked_Stack_for_thread_id_s), 0, 0, 1, 0},
- {&__pyx_n_s_GreenletTracer, __pyx_k_GreenletTracer, sizeof(__pyx_k_GreenletTracer), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer__trace, __pyx_k_GreenletTracer__trace, sizeof(__pyx_k_GreenletTracer__trace), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer_did_block_hub, __pyx_k_GreenletTracer_did_block_hub, sizeof(__pyx_k_GreenletTracer_did_block_hub), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer_did_block_hub_rep, __pyx_k_GreenletTracer_did_block_hub_rep, sizeof(__pyx_k_GreenletTracer_did_block_hub_rep), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer_ignore_current_gr, __pyx_k_GreenletTracer_ignore_current_gr, sizeof(__pyx_k_GreenletTracer_ignore_current_gr), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer_kill, __pyx_k_GreenletTracer_kill, sizeof(__pyx_k_GreenletTracer_kill), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletTracer_monitor_current_g, __pyx_k_GreenletTracer_monitor_current_g, sizeof(__pyx_k_GreenletTracer_monitor_current_g), 0, 0, 1, 1},
- {&__pyx_n_s_HubSwitchTracer, __pyx_k_HubSwitchTracer, sizeof(__pyx_k_HubSwitchTracer), 0, 0, 1, 1},
- {&__pyx_n_s_HubSwitchTracer__trace, __pyx_k_HubSwitchTracer__trace, sizeof(__pyx_k_HubSwitchTracer__trace), 0, 0, 1, 1},
- {&__pyx_n_s_HubSwitchTracer_did_block_hub, __pyx_k_HubSwitchTracer_did_block_hub, sizeof(__pyx_k_HubSwitchTracer_did_block_hub), 0, 0, 1, 1},
- {&__pyx_n_s_HubTracer_kill, __pyx_k_HubTracer_kill, sizeof(__pyx_k_HubTracer_kill), 0, 0, 1, 1},
- {&__pyx_kp_s_Info, __pyx_k_Info, sizeof(__pyx_k_Info), 0, 0, 1, 0},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_MaxSwitchTracer, __pyx_k_MaxSwitchTracer, sizeof(__pyx_k_MaxSwitchTracer), 0, 0, 1, 1},
- {&__pyx_n_s_MaxSwitchTracer__trace, __pyx_k_MaxSwitchTracer__trace, sizeof(__pyx_k_MaxSwitchTracer__trace), 0, 0, 1, 1},
- {&__pyx_n_s_MaxSwitchTracer_did_block_hub, __pyx_k_MaxSwitchTracer_did_block_hub, sizeof(__pyx_k_MaxSwitchTracer_did_block_hub), 0, 0, 1, 1},
- {&__pyx_kp_s_Reported_by_s, __pyx_k_Reported_by_s, sizeof(__pyx_k_Reported_by_s), 0, 0, 1, 0},
- {&__pyx_kp_s_Unknown_No_thread_found_for_hub, __pyx_k_Unknown_No_thread_found_for_hub, sizeof(__pyx_k_Unknown_No_thread_found_for_hub), 0, 0, 1, 0},
- {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
- {&__pyx_n_s_active_greenlet, __pyx_k_active_greenlet, sizeof(__pyx_k_active_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- #if PY_MAJOR_VERSION >= 3
- {&__pyx_kp_s_b, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
- #else
- {&__pyx_kp_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 0},
- #endif
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_current_frames, __pyx_k_current_frames, sizeof(__pyx_k_current_frames), 0, 0, 1, 1},
- {&__pyx_n_s_did_block_hub, __pyx_k_did_block_hub, sizeof(__pyx_k_did_block_hub), 0, 0, 1, 1},
- {&__pyx_n_s_did_block_hub_report, __pyx_k_did_block_hub_report, sizeof(__pyx_k_did_block_hub_report), 0, 0, 1, 1},
- {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1},
- {&__pyx_n_s_format_kwargs, __pyx_k_format_kwargs, sizeof(__pyx_k_format_kwargs), 0, 0, 1, 1},
- {&__pyx_n_s_format_run_info, __pyx_k_format_run_info, sizeof(__pyx_k_format_run_info), 0, 0, 1, 1},
- {&__pyx_n_s_format_stack, __pyx_k_format_stack, sizeof(__pyx_k_format_stack), 0, 0, 1, 1},
- {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___tracer, __pyx_k_gevent___tracer, sizeof(__pyx_k_gevent___tracer), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__compat, __pyx_k_gevent__compat, sizeof(__pyx_k_gevent__compat), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_util, __pyx_k_gevent_util, sizeof(__pyx_k_gevent_util), 0, 0, 1, 1},
- {&__pyx_n_s_gmctime, __pyx_k_gmctime, sizeof(__pyx_k_gmctime), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_n_s_ignore_current_greenlet_blocking, __pyx_k_ignore_current_greenlet_blocking, sizeof(__pyx_k_ignore_current_greenlet_blocking), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_kill, __pyx_k_kill, sizeof(__pyx_k_kill), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_max_blocking_time, __pyx_k_max_blocking_time, sizeof(__pyx_k_max_blocking_time), 0, 0, 1, 1},
- {&__pyx_n_s_monitor_current_greenlet_blockin, __pyx_k_monitor_current_greenlet_blockin, sizeof(__pyx_k_monitor_current_greenlet_blockin), 0, 0, 1, 1},
- {&__pyx_n_s_perf_counter, __pyx_k_perf_counter, sizeof(__pyx_k_perf_counter), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_report, __pyx_k_report, sizeof(__pyx_k_report), 0, 0, 1, 1},
- {&__pyx_kp_s_s_Greenlet_s_appears_to_be_bloc, __pyx_k_s_Greenlet_s_appears_to_be_bloc, sizeof(__pyx_k_s_Greenlet_s_appears_to_be_bloc), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_settrace, __pyx_k_settrace, sizeof(__pyx_k_settrace), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__tracer_py, __pyx_k_src_gevent__tracer_py, sizeof(__pyx_k_src_gevent__tracer_py), 0, 0, 1, 0},
- {&__pyx_n_s_stack, __pyx_k_stack, sizeof(__pyx_k_stack), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_thread_ident, __pyx_k_thread_ident, sizeof(__pyx_k_thread_ident), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1},
- {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 108, __pyx_L1_error)
- __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 114, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_tracer.py":49
- * self._killed = False
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * # Must be called in the monitored thread.
- * if not self._killed:
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
- __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_kill, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 49, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":56
- * self.previous_trace_function = None
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- */
- __pyx_tuple__5 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
- __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_trace, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 56, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":71
- * return self._trace(event, args)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * # Check to see if we have blocked since the last call to this
- * # method. Returns a true value if we blocked (not in the hub),
- */
- __pyx_tuple__7 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
- __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_did_block_hub, 71, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 71, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":94
- * return True, active_greenlet
- *
- * def ignore_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * # Don't pay attention to the current greenlet.
- * self.active_greenlet = None
- */
- __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
- __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_ignore_current_greenlet_blocking, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 94, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":98
- * self.active_greenlet = None
- *
- * def monitor_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * self.active_greenlet = getcurrent()
- *
- */
- __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
- __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_monitor_current_greenlet_blockin, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 98, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":101
- * self.active_greenlet = getcurrent()
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs): # <<<<<<<<<<<<<<
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' %
- */
- __pyx_tuple__13 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_hub, __pyx_n_s_active_greenlet, __pyx_n_s_format_kwargs, __pyx_n_s_report, __pyx_n_s_frame, __pyx_n_s_stack); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
- __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_did_block_hub_report, 101, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 101, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":128
- * self.hub = hub
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * self.hub = None
- * GreenletTracer.kill(self)
- */
- __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
- __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_kill, 128, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 128, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":140
- * self.last_entered_hub = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub:
- */
- __pyx_tuple__17 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
- __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_trace, 140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 140, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":145
- * self.last_entered_hub = perf_counter()
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- * return True, self.active_greenlet
- */
- __pyx_tuple__19 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
- __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_did_block_hub, 145, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 145, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":159
- * self.max_blocking = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- */
- __pyx_tuple__21 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_trace, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 159, __pyx_L1_error)
-
- /* "src/gevent/_tracer.py":169
- * switched_at - self.last_switch)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if self.max_blocking == 0:
- * # We never switched. Check the time now
- */
- __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
- __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_did_block_hub, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_8__tracer_sys = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_settrace = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_getcurrent = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_format_run_info = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_perf_counter = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__tracer_gmctime = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_sys, (void *)&__pyx_v_6gevent_8__tracer_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_traceback, (void *)&__pyx_v_6gevent_8__tracer_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_settrace, (void *)&__pyx_v_6gevent_8__tracer_settrace, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_getcurrent, (void *)&__pyx_v_6gevent_8__tracer_getcurrent, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_format_run_info, (void *)&__pyx_v_6gevent_8__tracer_format_run_info, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_perf_counter, (void *)&__pyx_v_6gevent_8__tracer_perf_counter, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_gmctime, (void *)&__pyx_v_6gevent_8__tracer_gmctime, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_vtabptr_6gevent_8__tracer_GreenletTracer = &__pyx_vtable_6gevent_8__tracer_GreenletTracer;
- __pyx_vtable_6gevent_8__tracer_GreenletTracer._trace = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_14GreenletTracer__trace;
- __pyx_vtable_6gevent_8__tracer_GreenletTracer.did_block_hub = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_14GreenletTracer_did_block_hub;
- __pyx_vtable_6gevent_8__tracer_GreenletTracer.kill = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_14GreenletTracer_kill;
- if (PyType_Ready(&__pyx_type_6gevent_8__tracer_GreenletTracer) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- __pyx_type_6gevent_8__tracer_GreenletTracer.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__tracer_GreenletTracer.tp_dictoffset && __pyx_type_6gevent_8__tracer_GreenletTracer.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__tracer_GreenletTracer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__tracer_GreenletTracer.tp_dict, __pyx_vtabptr_6gevent_8__tracer_GreenletTracer) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "GreenletTracer", (PyObject *)&__pyx_type_6gevent_8__tracer_GreenletTracer) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- __pyx_ptype_6gevent_8__tracer_GreenletTracer = &__pyx_type_6gevent_8__tracer_GreenletTracer;
- __pyx_vtabptr_6gevent_8__tracer__HubTracer = &__pyx_vtable_6gevent_8__tracer__HubTracer;
- __pyx_vtable_6gevent_8__tracer__HubTracer.__pyx_base = *__pyx_vtabptr_6gevent_8__tracer_GreenletTracer;
- __pyx_vtable_6gevent_8__tracer__HubTracer.__pyx_base.kill = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_10_HubTracer_kill;
- __pyx_type_6gevent_8__tracer__HubTracer.tp_base = __pyx_ptype_6gevent_8__tracer_GreenletTracer;
- if (PyType_Ready(&__pyx_type_6gevent_8__tracer__HubTracer) < 0) __PYX_ERR(0, 122, __pyx_L1_error)
- __pyx_type_6gevent_8__tracer__HubTracer.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__tracer__HubTracer.tp_dictoffset && __pyx_type_6gevent_8__tracer__HubTracer.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__tracer__HubTracer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__tracer__HubTracer.tp_dict, __pyx_vtabptr_6gevent_8__tracer__HubTracer) < 0) __PYX_ERR(0, 122, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "_HubTracer", (PyObject *)&__pyx_type_6gevent_8__tracer__HubTracer) < 0) __PYX_ERR(0, 122, __pyx_L1_error)
- __pyx_ptype_6gevent_8__tracer__HubTracer = &__pyx_type_6gevent_8__tracer__HubTracer;
- __pyx_vtabptr_6gevent_8__tracer_HubSwitchTracer = &__pyx_vtable_6gevent_8__tracer_HubSwitchTracer;
- __pyx_vtable_6gevent_8__tracer_HubSwitchTracer.__pyx_base = *__pyx_vtabptr_6gevent_8__tracer__HubTracer;
- __pyx_vtable_6gevent_8__tracer_HubSwitchTracer.__pyx_base.__pyx_base._trace = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_15HubSwitchTracer__trace;
- __pyx_vtable_6gevent_8__tracer_HubSwitchTracer.__pyx_base.__pyx_base.did_block_hub = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_15HubSwitchTracer_did_block_hub;
- __pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_base = __pyx_ptype_6gevent_8__tracer__HubTracer;
- if (PyType_Ready(&__pyx_type_6gevent_8__tracer_HubSwitchTracer) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
- __pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_dictoffset && __pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__tracer_HubSwitchTracer.tp_dict, __pyx_vtabptr_6gevent_8__tracer_HubSwitchTracer) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "HubSwitchTracer", (PyObject *)&__pyx_type_6gevent_8__tracer_HubSwitchTracer) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
- __pyx_ptype_6gevent_8__tracer_HubSwitchTracer = &__pyx_type_6gevent_8__tracer_HubSwitchTracer;
- __pyx_vtabptr_6gevent_8__tracer_MaxSwitchTracer = &__pyx_vtable_6gevent_8__tracer_MaxSwitchTracer;
- __pyx_vtable_6gevent_8__tracer_MaxSwitchTracer.__pyx_base = *__pyx_vtabptr_6gevent_8__tracer__HubTracer;
- __pyx_vtable_6gevent_8__tracer_MaxSwitchTracer.__pyx_base.__pyx_base._trace = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_15MaxSwitchTracer__trace;
- __pyx_vtable_6gevent_8__tracer_MaxSwitchTracer.__pyx_base.__pyx_base.did_block_hub = (PyObject *(*)(struct __pyx_obj_6gevent_8__tracer_GreenletTracer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__tracer_15MaxSwitchTracer_did_block_hub;
- __pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_base = __pyx_ptype_6gevent_8__tracer__HubTracer;
- if (PyType_Ready(&__pyx_type_6gevent_8__tracer_MaxSwitchTracer) < 0) __PYX_ERR(0, 150, __pyx_L1_error)
- __pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_dictoffset && __pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__tracer_MaxSwitchTracer.tp_dict, __pyx_vtabptr_6gevent_8__tracer_MaxSwitchTracer) < 0) __PYX_ERR(0, 150, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "MaxSwitchTracer", (PyObject *)&__pyx_type_6gevent_8__tracer_MaxSwitchTracer) < 0) __PYX_ERR(0, 150, __pyx_L1_error)
- __pyx_ptype_6gevent_8__tracer_MaxSwitchTracer = &__pyx_type_6gevent_8__tracer_MaxSwitchTracer;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__tracer(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__tracer(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___tracer(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___tracer(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___tracer(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___tracer(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__tracer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____tracer) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__tracer")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__tracer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_type_import_code();
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_tracer.py":5
- * from __future__ import print_function, absolute_import, division
- *
- * import sys # <<<<<<<<<<<<<<
- * import traceback
- *
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_sys);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_sys, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":6
- *
- * import sys
- * import traceback # <<<<<<<<<<<<<<
- *
- * from greenlet import settrace
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_traceback, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_traceback, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":8
- * import traceback
- *
- * from greenlet import settrace # <<<<<<<<<<<<<<
- * from greenlet import getcurrent
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_settrace);
- __Pyx_GIVEREF(__pyx_n_s_settrace);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_settrace);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_settrace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_settrace);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_settrace, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":9
- *
- * from greenlet import settrace
- * from greenlet import getcurrent # <<<<<<<<<<<<<<
- *
- * from gevent.util import format_run_info
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_getcurrent);
- __Pyx_GIVEREF(__pyx_n_s_getcurrent);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_getcurrent);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_getcurrent);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_getcurrent, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":11
- * from greenlet import getcurrent
- *
- * from gevent.util import format_run_info # <<<<<<<<<<<<<<
- *
- * from gevent._compat import perf_counter
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_format_run_info);
- __Pyx_GIVEREF(__pyx_n_s_format_run_info);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_format_run_info);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_format_run_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_format_run_info);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_format_run_info, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":13
- * from gevent.util import format_run_info
- *
- * from gevent._compat import perf_counter # <<<<<<<<<<<<<<
- * from gevent._util import gmctime
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_perf_counter);
- __Pyx_GIVEREF(__pyx_n_s_perf_counter);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_perf_counter);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_perf_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_perf_counter);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_perf_counter, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":14
- *
- * from gevent._compat import perf_counter
- * from gevent._util import gmctime # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_gmctime);
- __Pyx_GIVEREF(__pyx_n_s_gmctime);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gmctime);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_gmctime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__tracer_gmctime);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__tracer_gmctime, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":17
- *
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'GreenletTracer',
- * 'HubSwitchTracer',
- */
- __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_GreenletTracer);
- __Pyx_GIVEREF(__pyx_n_s_GreenletTracer);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_GreenletTracer);
- __Pyx_INCREF(__pyx_n_s_HubSwitchTracer);
- __Pyx_GIVEREF(__pyx_n_s_HubSwitchTracer);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_HubSwitchTracer);
- __Pyx_INCREF(__pyx_n_s_MaxSwitchTracer);
- __Pyx_GIVEREF(__pyx_n_s_MaxSwitchTracer);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_MaxSwitchTracer);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":49
- * self._killed = False
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * # Must be called in the monitored thread.
- * if not self._killed:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_3kill, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_kill, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_kill, __pyx_t_2) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":56
- * self.previous_trace_function = None
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * # This function runs in the thread we are monitoring.
- * self.greenlet_switch_counter += 1
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_5_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer__trace, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":71
- * return self._trace(event, args)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * # Check to see if we have blocked since the last call to this
- * # method. Returns a true value if we blocked (not in the hub),
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_9did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_did_block_hub, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":94
- * return True, active_greenlet
- *
- * def ignore_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * # Don't pay attention to the current greenlet.
- * self.active_greenlet = None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_11ignore_current_greenlet_blocking, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_ignore_current_gr, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_ignore_current_greenlet_blocking, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":98
- * self.active_greenlet = None
- *
- * def monitor_current_greenlet_blocking(self): # <<<<<<<<<<<<<<
- * self.active_greenlet = getcurrent()
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_13monitor_current_greenlet_blocking, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_monitor_current_g, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_monitor_current_greenlet_blockin, __pyx_t_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":101
- * self.active_greenlet = getcurrent()
- *
- * def did_block_hub_report(self, hub, active_greenlet, format_kwargs): # <<<<<<<<<<<<<<
- * report = ['=' * 80,
- * '\n%s : Greenlet %s appears to be blocked' %
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_14GreenletTracer_15did_block_hub_report, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_did_block_hub_rep, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_GreenletTracer->tp_dict, __pyx_n_s_did_block_hub_report, __pyx_t_2) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_GreenletTracer);
-
- /* "src/gevent/_tracer.py":128
- * self.hub = hub
- *
- * def kill(self): # <<<<<<<<<<<<<<
- * self.hub = None
- * GreenletTracer.kill(self)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_10_HubTracer_3kill, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubTracer_kill, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer__HubTracer->tp_dict, __pyx_n_s_kill, __pyx_t_2) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer__HubTracer);
-
- /* "src/gevent/_tracer.py":140
- * self.last_entered_hub = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * GreenletTracer._trace(self, event, args)
- * if self.active_greenlet is self.hub:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_15HubSwitchTracer_3_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubSwitchTracer__trace, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_HubSwitchTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_HubSwitchTracer);
-
- /* "src/gevent/_tracer.py":145
- * self.last_entered_hub = perf_counter()
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- * return True, self.active_greenlet
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_15HubSwitchTracer_5did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubSwitchTracer_did_block_hub, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_HubSwitchTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_HubSwitchTracer);
-
- /* "src/gevent/_tracer.py":159
- * self.max_blocking = 0
- *
- * def _trace(self, event, args): # <<<<<<<<<<<<<<
- * old_active = self.active_greenlet
- * GreenletTracer._trace(self, event, args)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_15MaxSwitchTracer_3_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MaxSwitchTracer__trace, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_MaxSwitchTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_MaxSwitchTracer);
-
- /* "src/gevent/_tracer.py":169
- * switched_at - self.last_switch)
- *
- * def did_block_hub(self, hub): # <<<<<<<<<<<<<<
- * if self.max_blocking == 0:
- * # We never switched. Check the time now
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__tracer_15MaxSwitchTracer_5did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MaxSwitchTracer_did_block_hub, NULL, __pyx_n_s_gevent___tracer, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__tracer_MaxSwitchTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__tracer_MaxSwitchTracer);
-
- /* "src/gevent/_tracer.py":178
- *
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__tracer')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_tracer.py":179
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__tracer') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent___tracer);
- __Pyx_GIVEREF(__pyx_n_s_gevent___tracer);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___tracer);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_tracer.py":1
- * # Copyright (c) 2018 gevent. See LICENSE for details. # <<<<<<<<<<<<<<
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- * from __future__ import print_function, absolute_import, division
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__tracer", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__tracer");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* KeywordStringCheck */
-static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* BytesEquals */
- static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
- static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* ObjectGetItem */
- #if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* StringJoin */
- #if !CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
- return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
-}
-#endif
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_tracer.py b/python/gevent/_tracer.py
deleted file mode 100644
index 98307ab..0000000
--- a/python/gevent/_tracer.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# Copyright (c) 2018 gevent. See LICENSE for details.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-from __future__ import print_function, absolute_import, division
-
-import sys
-import traceback
-
-from greenlet import settrace
-from greenlet import getcurrent
-
-from gevent.util import format_run_info
-
-from gevent._compat import perf_counter
-from gevent._util import gmctime
-
-
-__all__ = [
- 'GreenletTracer',
- 'HubSwitchTracer',
- 'MaxSwitchTracer',
-]
-
-# Recall these classes are cython compiled, so
-# class variable declarations are bad.
-
-
-class GreenletTracer(object):
- def __init__(self):
- # A counter, incremented by the greenlet trace function
- # we install on every greenlet switch. This is reset when the
- # periodic monitoring thread runs.
-
- self.greenlet_switch_counter = 0
-
- # The greenlet last switched to.
- self.active_greenlet = None
-
- # The trace function that was previously installed,
- # if any.
- # NOTE: Calling a class instance is cheaper than
- # calling a bound method (at least when compiled with cython)
- # even when it redirects to another function.
- prev_trace = settrace(self)
-
- self.previous_trace_function = prev_trace
-
- self._killed = False
-
- def kill(self):
- # Must be called in the monitored thread.
- if not self._killed:
- self._killed = True
- settrace(self.previous_trace_function)
- self.previous_trace_function = None
-
- def _trace(self, event, args):
- # This function runs in the thread we are monitoring.
- self.greenlet_switch_counter += 1
- if event in ('switch', 'throw'):
- # args is (origin, target). This is the only defined
- # case
- self.active_greenlet = args[1]
- else:
- self.active_greenlet = None
- if self.previous_trace_function is not None:
- self.previous_trace_function(event, args)
-
- def __call__(self, event, args):
- return self._trace(event, args)
-
- def did_block_hub(self, hub):
- # Check to see if we have blocked since the last call to this
- # method. Returns a true value if we blocked (not in the hub),
- # a false value if everything is fine.
-
- # This may be called in the same thread being traced or a
- # different thread; if a different thread, there is a race
- # condition with this being incremented in the thread we're
- # monitoring, but probably not often enough to lead to
- # annoying false positives.
-
- active_greenlet = self.active_greenlet
- did_switch = self.greenlet_switch_counter != 0
- self.greenlet_switch_counter = 0
-
- if did_switch or active_greenlet is None or active_greenlet is hub:
- # Either we switched, or nothing is running (we got a
- # trace event we don't know about or were requested to
- # ignore), or we spent the whole time in the hub, blocked
- # for IO. Nothing to report.
- return False
- return True, active_greenlet
-
- def ignore_current_greenlet_blocking(self):
- # Don't pay attention to the current greenlet.
- self.active_greenlet = None
-
- def monitor_current_greenlet_blocking(self):
- self.active_greenlet = getcurrent()
-
- def did_block_hub_report(self, hub, active_greenlet, format_kwargs):
- report = ['=' * 80,
- '\n%s : Greenlet %s appears to be blocked' %
- (gmctime(), active_greenlet)]
- report.append(" Reported by %s" % (self,))
- try:
- frame = sys._current_frames()[hub.thread_ident]
- except KeyError:
- # The thread holding the hub has died. Perhaps we shouldn't
- # even report this?
- stack = ["Unknown: No thread found for hub %r\n" % (hub,)]
- else:
- stack = traceback.format_stack(frame)
- report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),))
- report.append(''.join(stack))
- report.append("Info:")
- report.extend(format_run_info(**format_kwargs))
-
- return report
-
-
-class _HubTracer(GreenletTracer):
- def __init__(self, hub, max_blocking_time):
- GreenletTracer.__init__(self)
- self.max_blocking_time = max_blocking_time
- self.hub = hub
-
- def kill(self):
- self.hub = None
- GreenletTracer.kill(self)
-
-
-class HubSwitchTracer(_HubTracer):
- # A greenlet tracer that records the last time we switched *into* the hub.
-
- def __init__(self, hub, max_blocking_time):
- _HubTracer.__init__(self, hub, max_blocking_time)
- self.last_entered_hub = 0
-
- def _trace(self, event, args):
- GreenletTracer._trace(self, event, args)
- if self.active_greenlet is self.hub:
- self.last_entered_hub = perf_counter()
-
- def did_block_hub(self, hub):
- if perf_counter() - self.last_entered_hub > self.max_blocking_time:
- return True, self.active_greenlet
-
-
-class MaxSwitchTracer(_HubTracer):
- # A greenlet tracer that records the maximum time between switches,
- # not including time spent in the hub.
-
- def __init__(self, hub, max_blocking_time):
- _HubTracer.__init__(self, hub, max_blocking_time)
- self.last_switch = perf_counter()
- self.max_blocking = 0
-
- def _trace(self, event, args):
- old_active = self.active_greenlet
- GreenletTracer._trace(self, event, args)
- if old_active is not self.hub and old_active is not None:
- # If we're switching out of the hub, the blocking
- # time doesn't count.
- switched_at = perf_counter()
- self.max_blocking = max(self.max_blocking,
- switched_at - self.last_switch)
-
- def did_block_hub(self, hub):
- if self.max_blocking == 0:
- # We never switched. Check the time now
- self.max_blocking = perf_counter() - self.last_switch
-
- if self.max_blocking > self.max_blocking_time:
- return True, self.active_greenlet
-
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__tracer')
diff --git a/python/gevent/_util.py b/python/gevent/_util.py
deleted file mode 100644
index 4397aa3..0000000
--- a/python/gevent/_util.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-internal gevent utilities, not for external use.
-"""
-
-from __future__ import print_function, absolute_import, division
-
-from functools import update_wrapper
-
-from gevent._compat import iteritems
-
-
-class _NONE(object):
- """
- A special object you must never pass to any gevent API.
- Used as a marker object for keyword arguments that cannot have the
- builtin None (because that might be a valid value).
- """
- __slots__ = ()
-
- def __repr__(self):
- return '<default value>'
-
-_NONE = _NONE()
-
-def copy_globals(source,
- globs,
- only_names=None,
- ignore_missing_names=False,
- names_to_ignore=(),
- dunder_names_to_keep=('__implements__', '__all__', '__imports__'),
- cleanup_globs=True):
- """
- Copy attributes defined in ``source.__dict__`` to the dictionary
- in globs (which should be the caller's :func:`globals`).
-
- Names that start with ``__`` are ignored (unless they are in
- *dunder_names_to_keep*). Anything found in *names_to_ignore* is
- also ignored.
-
- If *only_names* is given, only those attributes will be
- considered. In this case, *ignore_missing_names* says whether or
- not to raise an :exc:`AttributeError` if one of those names can't
- be found.
-
- If *cleanup_globs* has a true value, then common things imported but
- not used at runtime are removed, including this function.
-
- Returns a list of the names copied; this should be assigned to ``__imports__``.
- """
- if only_names:
- if ignore_missing_names:
- items = ((k, getattr(source, k, _NONE)) for k in only_names)
- else:
- items = ((k, getattr(source, k)) for k in only_names)
- else:
- items = iteritems(source.__dict__)
-
- copied = []
- for key, value in items:
- if value is _NONE:
- continue
- if key in names_to_ignore:
- continue
- if key.startswith("__") and key not in dunder_names_to_keep:
- continue
- globs[key] = value
- copied.append(key)
-
- if cleanup_globs:
- if 'copy_globals' in globs:
- del globs['copy_globals']
-
- return copied
-
-def import_c_accel(globs, cname):
- """
- Import the C-accelerator for the __name__
- and copy its globals.
- """
-
- name = globs.get('__name__')
-
- if not name or name == cname:
- # Do nothing if we're being exec'd as a file (no name)
- # or we're running from the C extension
- return
-
-
- from gevent._compat import PURE_PYTHON
- if PURE_PYTHON:
- return
-
- import importlib
- import warnings
- with warnings.catch_warnings():
- # Python 3.7 likes to produce
- # "ImportWarning: can't resolve
- # package from __spec__ or __package__, falling back on
- # __name__ and __path__"
- # when we load cython compiled files. This is probably a bug in
- # Cython, but it doesn't seem to have any consequences, it's
- # just annoying to see and can mess up our unittests.
- warnings.simplefilter('ignore', ImportWarning)
- mod = importlib.import_module(cname)
-
- # By adopting the entire __dict__, we get a more accurate
- # __file__ and module repr, plus we don't leak any imported
- # things we no longer need.
- globs.clear()
- globs.update(mod.__dict__)
-
- if 'import_c_accel' in globs:
- del globs['import_c_accel']
-
-
-class Lazy(object):
- """
- A non-data descriptor used just like @property. The
- difference is the function value is assigned to the instance
- dict the first time it is accessed and then the function is never
- called agoin.
- """
- def __init__(self, func):
- self.data = (func, func.__name__)
- update_wrapper(self, func)
-
- def __get__(self, inst, class_):
- if inst is None:
- return self
-
- func, name = self.data
- value = func(inst)
- inst.__dict__[name] = value
- return value
-
-class readproperty(object):
- """
- A non-data descriptor like @property. The difference is that
- when the property is assigned to, it is cached in the instance
- and the function is not called on that instance again.
- """
-
- def __init__(self, func):
- self.func = func
- update_wrapper(self, func)
-
- def __get__(self, inst, class_):
- if inst is None:
- return self
-
- return self.func(inst)
-
-def gmctime():
- """
- Returns the current time as a string in RFC3339 format.
- """
- import time
- return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
-
-try:
- from zope.interface import Interface
- from zope.interface import implementer
- from zope.interface import Attribute
-except ImportError:
- class Interface(object):
- pass
- def implementer(_iface):
- def dec(c):
- return c
- return dec
-
- def Attribute(s):
- return s
-
-Interface = Interface
-implementer = implementer
-Attribute = Attribute
diff --git a/python/gevent/_util_py2.py b/python/gevent/_util_py2.py
deleted file mode 100644
index 02332e3..0000000
--- a/python/gevent/_util_py2.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import sys
-
-__all__ = ['reraise']
-
-
-def exec_(_code_, _globs_=None, _locs_=None):
- """Execute code in a namespace."""
- if _globs_ is None:
- frame = sys._getframe(1)
- _globs_ = frame.f_globals
- if _locs_ is None:
- _locs_ = frame.f_locals
- del frame
- elif _locs_ is None:
- _locs_ = _globs_
- exec("""exec _code_ in _globs_, _locs_""")
-
-exec_("""def reraise(tp, value, tb=None):
- try:
- raise tp, value, tb
- finally:
- tb = None
-""")
diff --git a/python/gevent/_waiter.c b/python/gevent/_waiter.c
deleted file mode 100644
index 374a500..0000000
--- a/python/gevent/_waiter.c
+++ /dev/null
@@ -1,8782 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__waiter.pxd",
- "src\\gevent\\__waiter.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent.__waiter",
- "sources": [
- "src/gevent/_waiter.py"
- ]
- },
- "module_name": "gevent.__waiter"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent____waiter
-#define __PYX_HAVE_API__gevent____waiter
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\_waiter.py",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "src/gevent/_waiter.py":27
- *
- *
- * class Waiter(object): # <<<<<<<<<<<<<<
- * """
- * A low level communication utility for greenlets.
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "src/gevent/_waiter.py":166
- *
- *
- * class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * """
- * An internal extension of Waiter that can be used if multiple objects
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyObjectCallMethod1.proto */
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
-static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
-
-/* pop_index.proto */
-static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix);
-static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix);
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix);
-#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ?\
- __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix)))
-#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- __Pyx_fits_Py_ssize_t(ix, type, is_signed) ?\
- __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix)))
-#else
-#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)\
- __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)
-#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix))
-#endif
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_8__waiter_6Waiter_clear(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__waiter_6Waiter_get(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_8__waiter_14MultipleWaiter_get(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject *__pyx_v_6gevent_8__waiter_sys = 0;
-static PyObject *__pyx_v_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-static int __pyx_v_6gevent_8__waiter__greenlet_imported;
-static PyObject *__pyx_v_6gevent_8__waiter__NONE = 0;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.__waiter"
-extern int __pyx_module_is_main_gevent____waiter;
-int __pyx_module_is_main_gevent____waiter = 0;
-
-/* Implementation of 'gevent.__waiter' */
-static PyObject *__pyx_builtin_object;
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_AssertionError;
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_get[] = "get";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_NONE[] = "_NONE";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_clear[] = "clear";
-static const char __pyx_k_ready[] = "ready";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_Waiter[] = "Waiter";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_init_2[] = "_init";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_object[] = "object";
-static const char __pyx_k_source[] = "source";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_values[] = "_values";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_exception[] = "exception";
-static const char __pyx_k_Waiter_get[] = "Waiter.get";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_successful[] = "successful";
-static const char __pyx_k_throw_args[] = "throw_args";
-static const char __pyx_k_exception_2[] = "_exception";
-static const char __pyx_k_switch_args[] = "switch_args";
-static const char __pyx_k_Waiter_clear[] = "Waiter.clear";
-static const char __pyx_k_Waiter_ready[] = "Waiter.ready";
-static const char __pyx_k_Waiter_throw[] = "Waiter.throw";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_s_greenlet_s[] = "<%s greenlet=%s>";
-static const char __pyx_k_Waiter_switch[] = "Waiter.switch";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_AssertionError[] = "AssertionError";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_gevent___waiter[] = "gevent.__waiter";
-static const char __pyx_k_Waiter_successful[] = "Waiter.successful";
-static const char __pyx_k_gevent__hub_local[] = "gevent._hub_local";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_MultipleWaiter_get[] = "MultipleWaiter.get";
-static const char __pyx_k_Waiter_switch_args[] = "Waiter.switch_args";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_s_greenlet_s_value_r[] = "<%s greenlet=%s value=%r>";
-static const char __pyx_k_MultipleWaiter_switch[] = "MultipleWaiter.switch";
-static const char __pyx_k_src_gevent__waiter_py[] = "src\\gevent\\_waiter.py";
-static const char __pyx_k_s_greenlet_s_exc_info_r[] = "<%s greenlet=%s exc_info=%r>";
-static const char __pyx_k_ConcurrentObjectUseError[] = "ConcurrentObjectUseError";
-static const char __pyx_k_Low_level_waiting_primitives[] = "\nLow-level waiting primitives.\n\n";
-static const char __pyx_k_Can_only_use_Waiter_switch_metho[] = "Can only use Waiter.switch method from the Hub greenlet";
-static const char __pyx_k_This_Waiter_is_already_used_by_r[] = "This Waiter is already used by %r";
-static PyObject *__pyx_n_s_AssertionError;
-static PyObject *__pyx_kp_s_Can_only_use_Waiter_switch_metho;
-static PyObject *__pyx_n_s_ConcurrentObjectUseError;
-static PyObject *__pyx_n_s_MultipleWaiter_get;
-static PyObject *__pyx_n_s_MultipleWaiter_switch;
-static PyObject *__pyx_n_s_NONE;
-static PyObject *__pyx_kp_s_This_Waiter_is_already_used_by_r;
-static PyObject *__pyx_n_s_Waiter;
-static PyObject *__pyx_n_s_Waiter_clear;
-static PyObject *__pyx_n_s_Waiter_get;
-static PyObject *__pyx_n_s_Waiter_ready;
-static PyObject *__pyx_n_s_Waiter_successful;
-static PyObject *__pyx_n_s_Waiter_switch;
-static PyObject *__pyx_n_s_Waiter_switch_args;
-static PyObject *__pyx_n_s_Waiter_throw;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_n_s_clear;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_exception;
-static PyObject *__pyx_n_s_exception_2;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent___waiter;
-static PyObject *__pyx_n_s_gevent__hub_local;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_init_2;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_object;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_ready;
-static PyObject *__pyx_kp_s_s_greenlet_s;
-static PyObject *__pyx_kp_s_s_greenlet_s_exc_info_r;
-static PyObject *__pyx_kp_s_s_greenlet_s_value_r;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_n_s_source;
-static PyObject *__pyx_kp_s_src_gevent__waiter_py;
-static PyObject *__pyx_n_s_successful;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_switch_args;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_n_s_throw_args;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_values;
-static PyObject *__pyx_lambda_funcdef_6gevent_8__waiter_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_8__waiter_6Waiter___init__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_2clear(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_4__str__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_6ready(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8successful(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8exc_info___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_10switch(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_12switch_args(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_14throw(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_throw_args); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_16get(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_18__call__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_source); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_3hub___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8greenlet___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_5value___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8__waiter_14MultipleWaiter___init__(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, PyObject *__pyx_v_hub); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_14MultipleWaiter_2switch(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter_14MultipleWaiter_4get(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8__waiter__init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_8__waiter_Waiter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_8__waiter_MultipleWaiter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__12;
-static PyObject *__pyx_tuple__14;
-static PyObject *__pyx_tuple__16;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__20;
-static PyObject *__pyx_codeobj__5;
-static PyObject *__pyx_codeobj__7;
-static PyObject *__pyx_codeobj__9;
-static PyObject *__pyx_codeobj__11;
-static PyObject *__pyx_codeobj__13;
-static PyObject *__pyx_codeobj__15;
-static PyObject *__pyx_codeobj__17;
-static PyObject *__pyx_codeobj__19;
-static PyObject *__pyx_codeobj__21;
-static PyObject *__pyx_codeobj__22;
-/* Late includes */
-
-/* "src/gevent/_waiter.py":24
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_2lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_2lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_8__waiter_2lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_8__waiter_2lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_8__waiter_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_8__waiter_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":70
- * __slots__ = ['hub', 'greenlet', 'value', '_exception']
- *
- * def __init__(self, hub=None): # <<<<<<<<<<<<<<
- * self.hub = get_hub() if hub is None else hub
- * self.greenlet = None
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__waiter_6Waiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__waiter_6Waiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 70, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_hub = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 70, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__waiter.Waiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter___init__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), __pyx_v_hub);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__waiter_6Waiter___init__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_hub) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_waiter.py":71
- *
- * def __init__(self, hub=None):
- * self.hub = get_hub() if hub is None else hub # <<<<<<<<<<<<<<
- * self.greenlet = None
- * self.value = None
- */
- __pyx_t_2 = (__pyx_v_hub == Py_None);
- if ((__pyx_t_2 != 0)) {
- __pyx_t_3 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- } else {
- if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_hub);
- __pyx_t_1 = __pyx_v_hub;
- }
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->hub));
- __pyx_v_self->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":72
- * def __init__(self, hub=None):
- * self.hub = get_hub() if hub is None else hub
- * self.greenlet = None # <<<<<<<<<<<<<<
- * self.value = None
- * self._exception = _NONE
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->greenlet);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_v_self->greenlet = ((PyGreenlet *)Py_None);
-
- /* "src/gevent/_waiter.py":73
- * self.hub = get_hub() if hub is None else hub
- * self.greenlet = None
- * self.value = None # <<<<<<<<<<<<<<
- * self._exception = _NONE
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = Py_None;
-
- /* "src/gevent/_waiter.py":74
- * self.greenlet = None
- * self.value = None
- * self._exception = _NONE # <<<<<<<<<<<<<<
- *
- * def clear(self):
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__waiter__NONE);
- __Pyx_GIVEREF(__pyx_v_6gevent_8__waiter__NONE);
- __Pyx_GOTREF(__pyx_v_self->_exception);
- __Pyx_DECREF(__pyx_v_self->_exception);
- __pyx_v_self->_exception = __pyx_v_6gevent_8__waiter__NONE;
-
- /* "src/gevent/_waiter.py":70
- * __slots__ = ['hub', 'greenlet', 'value', '_exception']
- *
- * def __init__(self, hub=None): # <<<<<<<<<<<<<<
- * self.hub = get_hub() if hub is None else hub
- * self.greenlet = None
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":76
- * self._exception = _NONE
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * self.greenlet = None
- * self.value = None
- */
-
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_8__waiter_6Waiter_clear(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("clear", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_3clear)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_waiter.py":77
- *
- * def clear(self):
- * self.greenlet = None # <<<<<<<<<<<<<<
- * self.value = None
- * self._exception = _NONE
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->greenlet);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_v_self->greenlet = ((PyGreenlet *)Py_None);
-
- /* "src/gevent/_waiter.py":78
- * def clear(self):
- * self.greenlet = None
- * self.value = None # <<<<<<<<<<<<<<
- * self._exception = _NONE
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = Py_None;
-
- /* "src/gevent/_waiter.py":79
- * self.greenlet = None
- * self.value = None
- * self._exception = _NONE # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __Pyx_INCREF(__pyx_v_6gevent_8__waiter__NONE);
- __Pyx_GIVEREF(__pyx_v_6gevent_8__waiter__NONE);
- __Pyx_GOTREF(__pyx_v_self->_exception);
- __Pyx_DECREF(__pyx_v_self->_exception);
- __pyx_v_self->_exception = __pyx_v_6gevent_8__waiter__NONE;
-
- /* "src/gevent/_waiter.py":76
- * self._exception = _NONE
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * self.greenlet = None
- * self.value = None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_2clear[] = "Waiter.clear(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_3clear = {"clear", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_3clear, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_2clear};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("clear (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_2clear(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_2clear(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("clear", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__waiter_6Waiter_clear(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":81
- * self._exception = _NONE
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * if self._exception is _NONE:
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_5__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_5__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_4__str__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_4__str__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/_waiter.py":82
- *
- * def __str__(self):
- * if self._exception is _NONE: # <<<<<<<<<<<<<<
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- * if self._exception is None:
- */
- __pyx_t_1 = (__pyx_v_self->_exception == __pyx_v_6gevent_8__waiter__NONE);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_waiter.py":83
- * def __str__(self):
- * if self._exception is _NONE:
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet) # <<<<<<<<<<<<<<
- * if self._exception is None:
- * return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->greenlet));
- PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->greenlet));
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_greenlet_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":82
- *
- * def __str__(self):
- * if self._exception is _NONE: # <<<<<<<<<<<<<<
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- * if self._exception is None:
- */
- }
-
- /* "src/gevent/_waiter.py":84
- * if self._exception is _NONE:
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- * if self._exception is None: # <<<<<<<<<<<<<<
- * return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- */
- __pyx_t_2 = (__pyx_v_self->_exception == Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/_waiter.py":85
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- * if self._exception is None:
- * return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value) # <<<<<<<<<<<<<<
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->greenlet));
- PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->greenlet));
- __Pyx_INCREF(__pyx_v_self->value);
- __Pyx_GIVEREF(__pyx_v_self->value);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_self->value);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_greenlet_s_value_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":84
- * if self._exception is _NONE:
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- * if self._exception is None: # <<<<<<<<<<<<<<
- * return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- */
- }
-
- /* "src/gevent/_waiter.py":86
- * if self._exception is None:
- * return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info) # <<<<<<<<<<<<<<
- *
- * def ready(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exc_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->greenlet));
- PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_self->greenlet));
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_greenlet_s_exc_info_r, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":81
- * self._exception = _NONE
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * if self._exception is _NONE:
- * return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":88
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exception is not _NONE
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_7ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_6ready[] = "Waiter.ready(self)\nReturn true if and only if it holds a value or an exception";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_7ready = {"ready", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_7ready, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_6ready};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_7ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ready (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_6ready(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_6ready(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("ready", 0);
-
- /* "src/gevent/_waiter.py":90
- * def ready(self):
- * """Return true if and only if it holds a value or an exception"""
- * return self._exception is not _NONE # <<<<<<<<<<<<<<
- *
- * def successful(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = (__pyx_v_self->_exception != __pyx_v_6gevent_8__waiter__NONE);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":88
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exception is not _NONE
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":92
- * return self._exception is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._exception is None
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_9successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_8successful[] = "Waiter.successful(self)\nReturn true if and only if it is ready and holds a value";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_9successful = {"successful", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_9successful, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_8successful};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_9successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("successful (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_8successful(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8successful(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("successful", 0);
-
- /* "src/gevent/_waiter.py":94
- * def successful(self):
- * """Return true if and only if it is ready and holds a value"""
- * return self._exception is None # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = (__pyx_v_self->_exception == Py_None);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":92
- * return self._exception is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._exception is None
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.successful", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":97
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- * if self._exception is not _NONE:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_8exc_info_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_8exc_info_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_8exc_info___get__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8exc_info___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/_waiter.py":99
- * def exc_info(self):
- * "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- * if self._exception is not _NONE: # <<<<<<<<<<<<<<
- * return self._exception
- *
- */
- __pyx_t_1 = (__pyx_v_self->_exception != __pyx_v_6gevent_8__waiter__NONE);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_waiter.py":100
- * "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- * if self._exception is not _NONE:
- * return self._exception # <<<<<<<<<<<<<<
- *
- * def switch(self, value):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_exception);
- __pyx_r = __pyx_v_self->_exception;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":99
- * def exc_info(self):
- * "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- * if self._exception is not _NONE: # <<<<<<<<<<<<<<
- * return self._exception
- *
- */
- }
-
- /* "src/gevent/_waiter.py":97
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- * if self._exception is not _NONE:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":102
- * return self._exception
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * """
- * Switch to the greenlet if one's available. Otherwise store the
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_11switch(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_10switch[] = "Waiter.switch(self, value)\n\n Switch to the greenlet if one's available. Otherwise store the\n *value*.\n\n .. versionchanged:: 1.3b1\n The *value* is no longer optional.\n ";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_11switch = {"switch", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_11switch, METH_O, __pyx_doc_6gevent_8__waiter_6Waiter_10switch};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_11switch(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("switch (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_10switch(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_10switch(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_value) {
- PyGreenlet *__pyx_v_greenlet = NULL;
- PyObject *__pyx_v_switch = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- __Pyx_RefNannySetupContext("switch", 0);
-
- /* "src/gevent/_waiter.py":110
- * The *value* is no longer optional.
- * """
- * greenlet = self.greenlet # <<<<<<<<<<<<<<
- * if greenlet is None:
- * self.value = value
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_self->greenlet);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_greenlet = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":111
- * """
- * greenlet = self.greenlet
- * if greenlet is None: # <<<<<<<<<<<<<<
- * self.value = value
- * self._exception = None
- */
- __pyx_t_2 = (((PyObject *)__pyx_v_greenlet) == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_waiter.py":112
- * greenlet = self.greenlet
- * if greenlet is None:
- * self.value = value # <<<<<<<<<<<<<<
- * self._exception = None
- * else:
- */
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = __pyx_v_value;
-
- /* "src/gevent/_waiter.py":113
- * if greenlet is None:
- * self.value = value
- * self._exception = None # <<<<<<<<<<<<<<
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_exception);
- __Pyx_DECREF(__pyx_v_self->_exception);
- __pyx_v_self->_exception = Py_None;
-
- /* "src/gevent/_waiter.py":111
- * """
- * greenlet = self.greenlet
- * if greenlet is None: # <<<<<<<<<<<<<<
- * self.value = value
- * self._exception = None
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_waiter.py":115
- * self._exception = None
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch
- */
- /*else*/ {
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_8__waiter_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = (__pyx_t_1 != ((PyObject *)__pyx_v_self->hub));
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = (__pyx_t_3 != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/_waiter.py":116
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet") # <<<<<<<<<<<<<<
- * switch = greenlet.switch
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 116, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":115
- * self._exception = None
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch
- */
- }
-
- /* "src/gevent/_waiter.py":117
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch # <<<<<<<<<<<<<<
- * try:
- * switch(value)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_greenlet), __pyx_n_s_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_switch = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":118
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch
- * try: # <<<<<<<<<<<<<<
- * switch(value)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- /* "src/gevent/_waiter.py":119
- * switch = greenlet.switch
- * try:
- * switch(value) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * self.hub.handle_error(switch, *sys.exc_info())
- */
- __Pyx_INCREF(__pyx_v_switch);
- __pyx_t_7 = __pyx_v_switch; __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_value};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L5_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_value};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L5_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 119, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_value);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":118
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch
- * try: # <<<<<<<<<<<<<<
- * switch(value)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L10_try_end;
- __pyx_L5_error:;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":120
- * try:
- * switch(value)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * self.hub.handle_error(switch, *sys.exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__waiter.Waiter.switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_9) < 0) __PYX_ERR(0, 120, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_9);
-
- /* "src/gevent/_waiter.py":121
- * switch(value)
- * except: # pylint:disable=bare-except
- * self.hub.handle_error(switch, *sys.exc_info()) # <<<<<<<<<<<<<<
- *
- * def switch_args(self, *args):
- */
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hub), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_v_switch);
- __Pyx_GIVEREF(__pyx_v_switch);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_switch);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_8__waiter_sys, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_13 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
- __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
- if (likely(__pyx_t_13)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
- __Pyx_INCREF(__pyx_t_13);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_12, function);
- }
- }
- if (__pyx_t_13) {
- __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- } else {
- __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- }
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = PyNumber_Add(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 121, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L6_exception_handled;
- }
- __pyx_L7_except_error:;
-
- /* "src/gevent/_waiter.py":118
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * switch = greenlet.switch
- * try: # <<<<<<<<<<<<<<
- * switch(value)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L6_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- __pyx_L10_try_end:;
- }
- }
- __pyx_L3:;
-
- /* "src/gevent/_waiter.py":102
- * return self._exception
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * """
- * Switch to the greenlet if one's available. Otherwise store the
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_greenlet);
- __Pyx_XDECREF(__pyx_v_switch);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":123
- * self.hub.handle_error(switch, *sys.exc_info())
- *
- * def switch_args(self, *args): # <<<<<<<<<<<<<<
- * return self.switch(args)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_13switch_args(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_12switch_args[] = "Waiter.switch_args(self, *args)";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_13switch_args = {"switch_args", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_13switch_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__waiter_6Waiter_12switch_args};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_13switch_args(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("switch_args (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "switch_args", 0))) return NULL;
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_12switch_args(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_12switch_args(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("switch_args", 0);
-
- /* "src/gevent/_waiter.py":124
- *
- * def switch_args(self, *args):
- * return self.switch(args) # <<<<<<<<<<<<<<
- *
- * def throw(self, *throw_args):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_args};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_args};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_args);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":123
- * self.hub.handle_error(switch, *sys.exc_info())
- *
- * def switch_args(self, *args): # <<<<<<<<<<<<<<
- * return self.switch(args)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.switch_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":126
- * return self.switch(args)
- *
- * def throw(self, *throw_args): # <<<<<<<<<<<<<<
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_15throw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_14throw[] = "Waiter.throw(self, *throw_args)\nSwitch to the greenlet with the exception. If there's no greenlet, store the exception.";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_15throw = {"throw", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_15throw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__waiter_6Waiter_14throw};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_15throw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_throw_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("throw (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "throw", 0))) return NULL;
- __Pyx_INCREF(__pyx_args);
- __pyx_v_throw_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_14throw(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), __pyx_v_throw_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_throw_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_14throw(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_throw_args) {
- PyGreenlet *__pyx_v_greenlet = NULL;
- PyObject *__pyx_v_throw = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- __Pyx_RefNannySetupContext("throw", 0);
-
- /* "src/gevent/_waiter.py":128
- * def throw(self, *throw_args):
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet # <<<<<<<<<<<<<<
- * if greenlet is None:
- * self._exception = throw_args
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_self->greenlet);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_greenlet = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":129
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- * if greenlet is None: # <<<<<<<<<<<<<<
- * self._exception = throw_args
- * else:
- */
- __pyx_t_2 = (((PyObject *)__pyx_v_greenlet) == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_waiter.py":130
- * greenlet = self.greenlet
- * if greenlet is None:
- * self._exception = throw_args # <<<<<<<<<<<<<<
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_v_throw_args);
- __Pyx_GIVEREF(__pyx_v_throw_args);
- __Pyx_GOTREF(__pyx_v_self->_exception);
- __Pyx_DECREF(__pyx_v_self->_exception);
- __pyx_v_self->_exception = __pyx_v_throw_args;
-
- /* "src/gevent/_waiter.py":129
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- * if greenlet is None: # <<<<<<<<<<<<<<
- * self._exception = throw_args
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_waiter.py":132
- * self._exception = throw_args
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw
- */
- /*else*/ {
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_8__waiter_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = (__pyx_t_1 != ((PyObject *)__pyx_v_self->hub));
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = (__pyx_t_3 != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/_waiter.py":133
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet") # <<<<<<<<<<<<<<
- * throw = greenlet.throw
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 133, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":132
- * self._exception = throw_args
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw
- */
- }
-
- /* "src/gevent/_waiter.py":134
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw # <<<<<<<<<<<<<<
- * try:
- * throw(*throw_args)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_greenlet), __pyx_n_s_throw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_throw = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":135
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw
- * try: # <<<<<<<<<<<<<<
- * throw(*throw_args)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- /* "src/gevent/_waiter.py":136
- * throw = greenlet.throw
- * try:
- * throw(*throw_args) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * self.hub.handle_error(throw, *sys.exc_info())
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_throw, __pyx_v_throw_args, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":135
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw
- * try: # <<<<<<<<<<<<<<
- * throw(*throw_args)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L10_try_end;
- __pyx_L5_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":137
- * try:
- * throw(*throw_args)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * self.hub.handle_error(throw, *sys.exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.__waiter.Waiter.throw", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 137, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_8);
-
- /* "src/gevent/_waiter.py":138
- * throw(*throw_args)
- * except: # pylint:disable=bare-except
- * self.hub.handle_error(throw, *sys.exc_info()) # <<<<<<<<<<<<<<
- *
- * def get(self):
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hub), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_v_throw);
- __Pyx_GIVEREF(__pyx_v_throw);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_throw);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_8__waiter_sys, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_13 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
- __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
- if (likely(__pyx_t_13)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
- __Pyx_INCREF(__pyx_t_13);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_12, function);
- }
- }
- if (__pyx_t_13) {
- __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- } else {
- __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- }
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = PyNumber_Add(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 138, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L6_exception_handled;
- }
- __pyx_L7_except_error:;
-
- /* "src/gevent/_waiter.py":135
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- * throw = greenlet.throw
- * try: # <<<<<<<<<<<<<<
- * throw(*throw_args)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L6_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- __pyx_L10_try_end:;
- }
- }
- __pyx_L3:;
-
- /* "src/gevent/_waiter.py":126
- * return self.switch(args)
- *
- * def throw(self, *throw_args): # <<<<<<<<<<<<<<
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.throw", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_greenlet);
- __Pyx_XDECREF(__pyx_v_throw);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":140
- * self.hub.handle_error(throw, *sys.exc_info())
- *
- * def get(self): # <<<<<<<<<<<<<<
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- */
-
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_17get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_8__waiter_6Waiter_get(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- char const *__pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_17get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/_waiter.py":142
- * def get(self):
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE: # <<<<<<<<<<<<<<
- * if self._exception is None:
- * return self.value
- */
- __pyx_t_5 = (__pyx_v_self->_exception != __pyx_v_6gevent_8__waiter__NONE);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/_waiter.py":143
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- * if self._exception is None: # <<<<<<<<<<<<<<
- * return self.value
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- */
- __pyx_t_6 = (__pyx_v_self->_exception == Py_None);
- __pyx_t_5 = (__pyx_t_6 != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/_waiter.py":144
- * if self._exception is not _NONE:
- * if self._exception is None:
- * return self.value # <<<<<<<<<<<<<<
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- * else:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":143
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- * if self._exception is None: # <<<<<<<<<<<<<<
- * return self.value
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- */
- }
-
- /* "src/gevent/_waiter.py":145
- * if self._exception is None:
- * return self.value
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * else:
- * if self.greenlet is not None:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_8__waiter_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_throw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_self->_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_waiter.py":142
- * def get(self):
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE: # <<<<<<<<<<<<<<
- * if self._exception is None:
- * return self.value
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_waiter.py":147
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- * else:
- * if self.greenlet is not None: # <<<<<<<<<<<<<<
- * raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable
- */
- /*else*/ {
- __pyx_t_5 = (((PyObject *)__pyx_v_self->greenlet) != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "src/gevent/_waiter.py":148
- * else:
- * if self.greenlet is not None:
- * raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, )) # <<<<<<<<<<<<<<
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable
- * try:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->greenlet));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->greenlet));
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_This_Waiter_is_already_used_by_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_8__waiter_ConcurrentObjectUseError);
- __pyx_t_1 = __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 148, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":147
- * getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- * else:
- * if self.greenlet is not None: # <<<<<<<<<<<<<<
- * raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable
- */
- }
-
- /* "src/gevent/_waiter.py":149
- * if self.greenlet is not None:
- * raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * try:
- * return self.hub.switch()
- */
- __pyx_t_3 = ((PyObject *)__pyx_f_6gevent_8__waiter_getcurrent()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->greenlet);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_v_self->greenlet = ((PyGreenlet *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/_waiter.py":150
- * raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable
- * try: # <<<<<<<<<<<<<<
- * return self.hub.switch()
- * finally:
- */
- /*try:*/ {
-
- /* "src/gevent/_waiter.py":151
- * self.greenlet = getcurrent() # pylint:disable=undefined-variable
- * try:
- * return self.hub.switch() # <<<<<<<<<<<<<<
- * finally:
- * self.greenlet = None
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self->hub->__pyx_vtab)->__pyx_switch(__pyx_v_self->hub, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L7_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L6_return;
- }
-
- /* "src/gevent/_waiter.py":153
- * return self.hub.switch()
- * finally:
- * self.greenlet = None # <<<<<<<<<<<<<<
- *
- * def __call__(self, source):
- */
- /*finally:*/ {
- __pyx_L7_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __pyx_t_8 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
- {
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->greenlet);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_v_self->greenlet = ((PyGreenlet *)Py_None);
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
- goto __pyx_L1_error;
- }
- __pyx_L6_return: {
- __pyx_t_16 = __pyx_r;
- __pyx_r = 0;
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->greenlet);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_v_self->greenlet = ((PyGreenlet *)Py_None);
- __pyx_r = __pyx_t_16;
- __pyx_t_16 = 0;
- goto __pyx_L0;
- }
- }
- }
- __pyx_L3:;
-
- /* "src/gevent/_waiter.py":140
- * self.hub.handle_error(throw, *sys.exc_info())
- *
- * def get(self): # <<<<<<<<<<<<<<
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_17get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_6Waiter_16get[] = "Waiter.get(self)\nIf a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called.";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_6Waiter_17get = {"get", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_17get, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_16get};
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_17get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_16get(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_16get(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__waiter_6Waiter_get(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":155
- * self.greenlet = None
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.exception is None:
- * self.switch(source.value)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_19__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_19__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_source = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 155, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_source = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 155, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__waiter.Waiter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_18__call__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), __pyx_v_source);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_18__call__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self, PyObject *__pyx_v_source) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/_waiter.py":156
- *
- * def __call__(self, source):
- * if source.exception is None: # <<<<<<<<<<<<<<
- * self.switch(source.value)
- * else:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = (__pyx_t_1 == Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/_waiter.py":157
- * def __call__(self, source):
- * if source.exception is None:
- * self.switch(source.value) # <<<<<<<<<<<<<<
- * else:
- * self.throw(source.exception)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":156
- *
- * def __call__(self, source):
- * if source.exception is None: # <<<<<<<<<<<<<<
- * self.switch(source.value)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/_waiter.py":159
- * self.switch(source.value)
- * else:
- * self.throw(source.exception) # <<<<<<<<<<<<<<
- *
- * # can also have a debugging version, that wraps the value in a tuple (self, value) in switch()
- */
- /*else*/ {
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_throw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_7};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
- __pyx_t_7 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L3:;
-
- /* "src/gevent/_waiter.py":155
- * self.greenlet = None
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.exception is None:
- * self.switch(source.value)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.__waiter.Waiter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":34
- *
- * cdef class Waiter:
- * cdef readonly SwitchOutGreenletWithLoop hub # <<<<<<<<<<<<<<
- * cdef readonly greenlet greenlet
- * cdef readonly value
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_3hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_3hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_3hub___get__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_3hub___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->hub));
- __pyx_r = ((PyObject *)__pyx_v_self->hub);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":35
- * cdef class Waiter:
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet # <<<<<<<<<<<<<<
- * cdef readonly value
- * cdef _exception
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_8greenlet_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_8greenlet_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_8greenlet___get__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_8greenlet___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet));
- __pyx_r = ((PyObject *)__pyx_v_self->greenlet);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":36
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- * cdef readonly value # <<<<<<<<<<<<<<
- * cdef _exception
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8__waiter_6Waiter_5value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_6Waiter_5value___get__(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_6Waiter_5value___get__(struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":177
- * __slots__ = ['_values']
- *
- * def __init__(self, hub=None): # <<<<<<<<<<<<<<
- * Waiter.__init__(self, hub)
- * # we typically expect a relatively small number of these to be outstanding.
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8__waiter_14MultipleWaiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8__waiter_14MultipleWaiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_hub = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hub);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 177, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_hub = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 177, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.__waiter.MultipleWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8__waiter_14MultipleWaiter___init__(((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)__pyx_v_self), __pyx_v_hub);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8__waiter_14MultipleWaiter___init__(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, PyObject *__pyx_v_hub) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/_waiter.py":178
- *
- * def __init__(self, hub=None):
- * Waiter.__init__(self, hub) # <<<<<<<<<<<<<<
- * # we typically expect a relatively small number of these to be outstanding.
- * # since we pop from the left, a deque might be slightly
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_hub);
- __Pyx_GIVEREF(__pyx_v_hub);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_hub);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":184
- * # we can help it to better support monkey-patching, and delaying the import
- * # here can be impractical (see https://github.com/gevent/gevent/issues/652)
- * self._values = list() # <<<<<<<<<<<<<<
- *
- * def switch(self, value):
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_values);
- __Pyx_DECREF(__pyx_v_self->_values);
- __pyx_v_self->_values = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":177
- * __slots__ = ['_values']
- *
- * def __init__(self, hub=None): # <<<<<<<<<<<<<<
- * Waiter.__init__(self, hub)
- * # we typically expect a relatively small number of these to be outstanding.
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.__waiter.MultipleWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":186
- * self._values = list()
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * self._values.append(value)
- * Waiter.switch(self, True)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_14MultipleWaiter_3switch(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_14MultipleWaiter_2switch[] = "MultipleWaiter.switch(self, value)";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_14MultipleWaiter_3switch = {"switch", (PyCFunction)__pyx_pw_6gevent_8__waiter_14MultipleWaiter_3switch, METH_O, __pyx_doc_6gevent_8__waiter_14MultipleWaiter_2switch};
-static PyObject *__pyx_pw_6gevent_8__waiter_14MultipleWaiter_3switch(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("switch (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_14MultipleWaiter_2switch(((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_14MultipleWaiter_2switch(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, PyObject *__pyx_v_value) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("switch", 0);
-
- /* "src/gevent/_waiter.py":187
- *
- * def switch(self, value):
- * self._values.append(value) # <<<<<<<<<<<<<<
- * Waiter.switch(self, True)
- *
- */
- if (unlikely(__pyx_v_self->_values == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
- __PYX_ERR(0, 187, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyList_Append(__pyx_v_self->_values, __pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 187, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":188
- * def switch(self, value):
- * self._values.append(value)
- * Waiter.switch(self, True) # <<<<<<<<<<<<<<
- *
- * def get(self):
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter), __pyx_n_s_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), Py_True};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), Py_True};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(Py_True);
- __Pyx_GIVEREF(Py_True);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, Py_True);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":186
- * self._values = list()
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * self._values.append(value)
- * Waiter.switch(self, True)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.__waiter.MultipleWaiter.switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":190
- * Waiter.switch(self, True)
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if not self._values:
- * Waiter.get(self)
- */
-
-static PyObject *__pyx_pw_6gevent_8__waiter_14MultipleWaiter_5get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_8__waiter_14MultipleWaiter_get(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
-
- /* "src/gevent/_waiter.py":191
- *
- * def get(self):
- * if not self._values: # <<<<<<<<<<<<<<
- * Waiter.get(self)
- * Waiter.clear(self)
- */
- __pyx_t_1 = (__pyx_v_self->_values != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_values) != 0);
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/_waiter.py":192
- * def get(self):
- * if not self._values:
- * Waiter.get(self) # <<<<<<<<<<<<<<
- * Waiter.clear(self)
- *
- */
- __pyx_t_3 = __pyx_f_6gevent_8__waiter_6Waiter_get(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_waiter.py":193
- * if not self._values:
- * Waiter.get(self)
- * Waiter.clear(self) # <<<<<<<<<<<<<<
- *
- * return self._values.pop(0)
- */
- __pyx_t_3 = __pyx_f_6gevent_8__waiter_6Waiter_clear(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_self), 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/_waiter.py":191
- *
- * def get(self):
- * if not self._values: # <<<<<<<<<<<<<<
- * Waiter.get(self)
- * Waiter.clear(self)
- */
- }
-
- /* "src/gevent/_waiter.py":195
- * Waiter.clear(self)
- *
- * return self._values.pop(0) # <<<<<<<<<<<<<<
- *
- * def _init():
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_self->_values == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
- __PYX_ERR(0, 195, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_PyList_PopIndex(__pyx_v_self->_values, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/_waiter.py":190
- * Waiter.switch(self, True)
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if not self._values:
- * Waiter.get(self)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.__waiter.MultipleWaiter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_14MultipleWaiter_5get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter_14MultipleWaiter_4get[] = "MultipleWaiter.get(self)";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_14MultipleWaiter_5get = {"get", (PyCFunction)__pyx_pw_6gevent_8__waiter_14MultipleWaiter_5get, METH_NOARGS, __pyx_doc_6gevent_8__waiter_14MultipleWaiter_4get};
-static PyObject *__pyx_pw_6gevent_8__waiter_14MultipleWaiter_5get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter_14MultipleWaiter_4get(((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter_14MultipleWaiter_4get(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8__waiter_14MultipleWaiter_get(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.MultipleWaiter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/_waiter.py":197
- * return self._values.pop(0)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8__waiter_1_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_8__waiter__init[] = "_init()";
-static PyMethodDef __pyx_mdef_6gevent_8__waiter_1_init = {"_init", (PyCFunction)__pyx_pw_6gevent_8__waiter_1_init, METH_NOARGS, __pyx_doc_6gevent_8__waiter__init};
-static PyObject *__pyx_pw_6gevent_8__waiter_1_init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8__waiter__init(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8__waiter__init(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/_waiter.py":198
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_8__waiter_greenlet_init();
-
- /* "src/gevent/_waiter.py":197
- * return self._values.pop(0)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_vtable_6gevent_8__waiter_Waiter;
-
-static PyObject *__pyx_tp_new_6gevent_8__waiter_Waiter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_8__waiter_Waiter *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_8__waiter_Waiter;
- p->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- p->greenlet = ((PyGreenlet *)Py_None); Py_INCREF(Py_None);
- p->value = Py_None; Py_INCREF(Py_None);
- p->_exception = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8__waiter_Waiter(PyObject *o) {
- struct __pyx_obj_6gevent_8__waiter_Waiter *p = (struct __pyx_obj_6gevent_8__waiter_Waiter *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->hub);
- Py_CLEAR(p->greenlet);
- Py_CLEAR(p->value);
- Py_CLEAR(p->_exception);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8__waiter_Waiter(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8__waiter_Waiter *p = (struct __pyx_obj_6gevent_8__waiter_Waiter *)o;
- if (p->hub) {
- e = (*v)(((PyObject *)p->hub), a); if (e) return e;
- }
- if (p->greenlet) {
- e = (*v)(((PyObject *)p->greenlet), a); if (e) return e;
- }
- if (p->value) {
- e = (*v)(p->value, a); if (e) return e;
- }
- if (p->_exception) {
- e = (*v)(p->_exception, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8__waiter_Waiter(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8__waiter_Waiter *p = (struct __pyx_obj_6gevent_8__waiter_Waiter *)o;
- tmp = ((PyObject*)p->hub);
- p->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->greenlet);
- p->greenlet = ((PyGreenlet *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->value);
- p->value = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_exception);
- p->_exception = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_8__waiter_6Waiter_exc_info(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__waiter_6Waiter_8exc_info_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__waiter_6Waiter_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__waiter_6Waiter_3hub_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__waiter_6Waiter_greenlet(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__waiter_6Waiter_8greenlet_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_8__waiter_6Waiter_value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8__waiter_6Waiter_5value_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__waiter_Waiter[] = {
- {"ready", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_7ready, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_6ready},
- {"successful", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_9successful, METH_NOARGS, __pyx_doc_6gevent_8__waiter_6Waiter_8successful},
- {"switch", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_11switch, METH_O, __pyx_doc_6gevent_8__waiter_6Waiter_10switch},
- {"switch_args", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_13switch_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__waiter_6Waiter_12switch_args},
- {"throw", (PyCFunction)__pyx_pw_6gevent_8__waiter_6Waiter_15throw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_8__waiter_6Waiter_14throw},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8__waiter_Waiter[] = {
- {(char *)"exc_info", __pyx_getprop_6gevent_8__waiter_6Waiter_exc_info, 0, (char *)"Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``.", 0},
- {(char *)"hub", __pyx_getprop_6gevent_8__waiter_6Waiter_hub, 0, (char *)0, 0},
- {(char *)"greenlet", __pyx_getprop_6gevent_8__waiter_6Waiter_greenlet, 0, (char *)0, 0},
- {(char *)"value", __pyx_getprop_6gevent_8__waiter_6Waiter_value, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__waiter_Waiter = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__waiter.Waiter", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__waiter_Waiter, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_8__waiter_6Waiter_19__call__, /*tp_call*/
- __pyx_pw_6gevent_8__waiter_6Waiter_5__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Waiter(hub=None)\n\n A low level communication utility for greenlets.\n\n Waiter is a wrapper around greenlet's ``switch()`` and ``throw()`` calls that makes them somewhat safer:\n\n * switching will occur only if the waiting greenlet is executing :meth:`get` method currently;\n * any error raised in the greenlet is handled inside :meth:`switch` and :meth:`throw`\n * if :meth:`switch`/:meth:`throw` is called before the receiver calls :meth:`get`, then :class:`Waiter`\n will store the value/exception. The following :meth:`get` will return the value/raise the exception.\n\n The :meth:`switch` and :meth:`throw` methods must only be called from the :class:`Hub` greenlet.\n The :meth:`get` method must be called from a greenlet other than :class:`Hub`.\n\n >>> result = Waiter()\n >>> timer = get_hub().loop.timer(0.1)\n >>> timer.start(result.switch, 'hello from Waiter')\n >>> result.get() # blocks for 0.1 seconds\n 'hello from Waiter'\n >>> timer.close()\n\n If switch is called before the greenlet gets a chance to call :meth:`get` then\n :class:`Waiter` stores the value.\n\n >>> result = Waiter()\n >>> timer = get_hub().loop.timer(0.1)\n >>> timer.start(result.switch, 'hi from Waiter')\n >>> sleep(0.2)\n >>> result.get() # returns immediately without blocking\n 'hi from Waiter'\n >>> timer.close()\n\n .. warning::\n\n This a limited and dangerous way to communicate between\n greenlets. It can easily leave a greenlet unscheduled forever\n if used incorrectly. Consider using safer classes such as\n :class:`gevent.event.Event`, :class:`gevent.event.AsyncResult`,\n or :class:`gevent.queue.Queue`.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__waiter_Waiter, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__waiter_Waiter, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__waiter_Waiter, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8__waiter_Waiter, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__waiter_6Waiter_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__waiter_Waiter, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter __pyx_vtable_6gevent_8__waiter_MultipleWaiter;
-
-static PyObject *__pyx_tp_new_6gevent_8__waiter_MultipleWaiter(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *p;
- PyObject *o = __pyx_tp_new_6gevent_8__waiter_Waiter(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
- p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8__waiter_MultipleWaiter(PyObject *o) {
- struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *p = (struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_values);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_8__waiter_Waiter(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8__waiter_MultipleWaiter(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *p = (struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)o;
- e = __pyx_tp_traverse_6gevent_8__waiter_Waiter(o, v, a); if (e) return e;
- if (p->_values) {
- e = (*v)(p->_values, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8__waiter_MultipleWaiter(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *p = (struct __pyx_obj_6gevent_8__waiter_MultipleWaiter *)o;
- __pyx_tp_clear_6gevent_8__waiter_Waiter(o);
- tmp = ((PyObject*)p->_values);
- p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_8__waiter_MultipleWaiter[] = {
- {"switch", (PyCFunction)__pyx_pw_6gevent_8__waiter_14MultipleWaiter_3switch, METH_O, __pyx_doc_6gevent_8__waiter_14MultipleWaiter_2switch},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8__waiter_MultipleWaiter = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.__waiter.MultipleWaiter", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8__waiter_MultipleWaiter, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_8__waiter_6Waiter_19__call__, /*tp_call*/
- #else
- 0, /*tp_call*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_8__waiter_6Waiter_5__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "MultipleWaiter(hub=None)\n\n An internal extension of Waiter that can be used if multiple objects\n must be waited on, and there is a chance that in between waits greenlets\n might be switched out. All greenlets that switch to this waiter\n will have their value returned.\n\n This does not handle exceptions or throw methods.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_8__waiter_MultipleWaiter, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8__waiter_MultipleWaiter, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8__waiter_MultipleWaiter, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8__waiter_14MultipleWaiter_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8__waiter_MultipleWaiter, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec___waiter(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec___waiter},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "__waiter",
- __pyx_k_Low_level_waiting_primitives, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AssertionError, __pyx_k_AssertionError, sizeof(__pyx_k_AssertionError), 0, 0, 1, 1},
- {&__pyx_kp_s_Can_only_use_Waiter_switch_metho, __pyx_k_Can_only_use_Waiter_switch_metho, sizeof(__pyx_k_Can_only_use_Waiter_switch_metho), 0, 0, 1, 0},
- {&__pyx_n_s_ConcurrentObjectUseError, __pyx_k_ConcurrentObjectUseError, sizeof(__pyx_k_ConcurrentObjectUseError), 0, 0, 1, 1},
- {&__pyx_n_s_MultipleWaiter_get, __pyx_k_MultipleWaiter_get, sizeof(__pyx_k_MultipleWaiter_get), 0, 0, 1, 1},
- {&__pyx_n_s_MultipleWaiter_switch, __pyx_k_MultipleWaiter_switch, sizeof(__pyx_k_MultipleWaiter_switch), 0, 0, 1, 1},
- {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1},
- {&__pyx_kp_s_This_Waiter_is_already_used_by_r, __pyx_k_This_Waiter_is_already_used_by_r, sizeof(__pyx_k_This_Waiter_is_already_used_by_r), 0, 0, 1, 0},
- {&__pyx_n_s_Waiter, __pyx_k_Waiter, sizeof(__pyx_k_Waiter), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_clear, __pyx_k_Waiter_clear, sizeof(__pyx_k_Waiter_clear), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_get, __pyx_k_Waiter_get, sizeof(__pyx_k_Waiter_get), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_ready, __pyx_k_Waiter_ready, sizeof(__pyx_k_Waiter_ready), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_successful, __pyx_k_Waiter_successful, sizeof(__pyx_k_Waiter_successful), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_switch, __pyx_k_Waiter_switch, sizeof(__pyx_k_Waiter_switch), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_switch_args, __pyx_k_Waiter_switch_args, sizeof(__pyx_k_Waiter_switch_args), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter_throw, __pyx_k_Waiter_throw, sizeof(__pyx_k_Waiter_throw), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
- {&__pyx_n_s_exception_2, __pyx_k_exception_2, sizeof(__pyx_k_exception_2), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent___waiter, __pyx_k_gevent___waiter, sizeof(__pyx_k_gevent___waiter), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_local, __pyx_k_gevent__hub_local, sizeof(__pyx_k_gevent__hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_init_2, __pyx_k_init_2, sizeof(__pyx_k_init_2), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_ready, __pyx_k_ready, sizeof(__pyx_k_ready), 0, 0, 1, 1},
- {&__pyx_kp_s_s_greenlet_s, __pyx_k_s_greenlet_s, sizeof(__pyx_k_s_greenlet_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_greenlet_s_exc_info_r, __pyx_k_s_greenlet_s_exc_info_r, sizeof(__pyx_k_s_greenlet_s_exc_info_r), 0, 0, 1, 0},
- {&__pyx_kp_s_s_greenlet_s_value_r, __pyx_k_s_greenlet_s_value_r, sizeof(__pyx_k_s_greenlet_s_value_r), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent__waiter_py, __pyx_k_src_gevent__waiter_py, sizeof(__pyx_k_src_gevent__waiter_py), 0, 0, 1, 0},
- {&__pyx_n_s_successful, __pyx_k_successful, sizeof(__pyx_k_successful), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_switch_args, __pyx_k_switch_args, sizeof(__pyx_k_switch_args), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_n_s_throw_args, __pyx_k_throw_args, sizeof(__pyx_k_throw_args), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 21, __pyx_L1_error)
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 23, __pyx_L1_error)
- __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 116, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/_waiter.py":116
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet") # <<<<<<<<<<<<<<
- * switch = greenlet.switch
- * try:
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Can_only_use_Waiter_switch_metho); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 116, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/_waiter.py":133
- * else:
- * if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- * raise AssertionError("Can only use Waiter.switch method from the Hub greenlet") # <<<<<<<<<<<<<<
- * throw = greenlet.throw
- * try:
- */
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Can_only_use_Waiter_switch_metho); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "src/gevent/_waiter.py":23
- * _NONE = object()
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
-
- /* "src/gevent/_waiter.py":76
- * self._exception = _NONE
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * self.greenlet = None
- * self.value = None
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
- __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_clear, 76, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 76, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":88
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exception is not _NONE
- */
- __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
- __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_ready, 88, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 88, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":92
- * return self._exception is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._exception is None
- */
- __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_successful, 92, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 92, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":102
- * return self._exception
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * """
- * Switch to the greenlet if one's available. Otherwise store the
- */
- __pyx_tuple__10 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_value, __pyx_n_s_greenlet, __pyx_n_s_switch); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
- __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_switch, 102, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 102, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":123
- * self.hub.handle_error(switch, *sys.exc_info())
- *
- * def switch_args(self, *args): # <<<<<<<<<<<<<<
- * return self.switch(args)
- *
- */
- __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_args); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 123, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__12);
- __Pyx_GIVEREF(__pyx_tuple__12);
- __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_switch_args, 123, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 123, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":126
- * return self.switch(args)
- *
- * def throw(self, *throw_args): # <<<<<<<<<<<<<<
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- */
- __pyx_tuple__14 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_throw_args, __pyx_n_s_greenlet, __pyx_n_s_throw); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__14);
- __Pyx_GIVEREF(__pyx_tuple__14);
- __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_throw, 126, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 126, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":140
- * self.hub.handle_error(throw, *sys.exc_info())
- *
- * def get(self): # <<<<<<<<<<<<<<
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- */
- __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__16);
- __Pyx_GIVEREF(__pyx_tuple__16);
- __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_get, 140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 140, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":186
- * self._values = list()
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * self._values.append(value)
- * Waiter.switch(self, True)
- */
- __pyx_tuple__18 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_value); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
- __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_switch, 186, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 186, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":190
- * Waiter.switch(self, True)
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if not self._values:
- * Waiter.get(self)
- */
- __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__20);
- __Pyx_GIVEREF(__pyx_tuple__20);
- __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_get, 190, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 190, __pyx_L1_error)
-
- /* "src/gevent/_waiter.py":197
- * return self._values.pop(0)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__waiter_py, __pyx_n_s_init_2, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_8__waiter_sys = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8__waiter__NONE = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_sys, (void *)&__pyx_v_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_ConcurrentObjectUseError, (void *)&__pyx_v_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_NONE, (void *)&__pyx_v_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(2, 15, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = &__pyx_vtable_6gevent_8__waiter_Waiter;
- __pyx_vtable_6gevent_8__waiter_Waiter.get = (PyObject *(*)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__waiter_6Waiter_get;
- __pyx_vtable_6gevent_8__waiter_Waiter.clear = (PyObject *(*)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__waiter_6Waiter_clear;
- if (PyType_Ready(&__pyx_type_6gevent_8__waiter_Waiter) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- __pyx_type_6gevent_8__waiter_Waiter.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__waiter_Waiter.tp_dictoffset && __pyx_type_6gevent_8__waiter_Waiter.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__waiter_Waiter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__waiter_Waiter.tp_dict, __pyx_vtabptr_6gevent_8__waiter_Waiter) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Waiter", (PyObject *)&__pyx_type_6gevent_8__waiter_Waiter) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_Waiter = &__pyx_type_6gevent_8__waiter_Waiter;
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = &__pyx_vtable_6gevent_8__waiter_MultipleWaiter;
- __pyx_vtable_6gevent_8__waiter_MultipleWaiter.__pyx_base = *__pyx_vtabptr_6gevent_8__waiter_Waiter;
- __pyx_vtable_6gevent_8__waiter_MultipleWaiter.__pyx_base.get = (PyObject *(*)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch))__pyx_f_6gevent_8__waiter_14MultipleWaiter_get;
- __pyx_type_6gevent_8__waiter_MultipleWaiter.tp_base = __pyx_ptype_6gevent_8__waiter_Waiter;
- if (PyType_Ready(&__pyx_type_6gevent_8__waiter_MultipleWaiter) < 0) __PYX_ERR(0, 166, __pyx_L1_error)
- __pyx_type_6gevent_8__waiter_MultipleWaiter.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8__waiter_MultipleWaiter.tp_dictoffset && __pyx_type_6gevent_8__waiter_MultipleWaiter.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8__waiter_MultipleWaiter.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8__waiter_MultipleWaiter.tp_dict, __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter) < 0) __PYX_ERR(0, 166, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "MultipleWaiter", (PyObject *)&__pyx_type_6gevent_8__waiter_MultipleWaiter) < 0) __PYX_ERR(0, 166, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = &__pyx_type_6gevent_8__waiter_MultipleWaiter;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(1, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(1, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init__waiter(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init__waiter(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit___waiter(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit___waiter(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec___waiter(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit___waiter(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("__waiter", __pyx_methods, __pyx_k_Low_level_waiting_primitives, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent____waiter) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.__waiter")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.__waiter", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/_waiter.py":12
- * from __future__ import print_function
- *
- * import sys # <<<<<<<<<<<<<<
- *
- * from gevent._hub_local import get_hub_noargs as get_hub
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__waiter_sys);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__waiter_sys, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":14
- * import sys
- *
- * from gevent._hub_local import get_hub_noargs as get_hub # <<<<<<<<<<<<<<
- * from gevent.exceptions import ConcurrentObjectUseError
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_hub_noargs);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":15
- *
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from gevent.exceptions import ConcurrentObjectUseError # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ConcurrentObjectUseError);
- __Pyx_GIVEREF(__pyx_n_s_ConcurrentObjectUseError);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ConcurrentObjectUseError);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ConcurrentObjectUseError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__waiter_ConcurrentObjectUseError);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__waiter_ConcurrentObjectUseError, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":17
- * from gevent.exceptions import ConcurrentObjectUseError
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'Waiter',
- * ]
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Waiter);
- __Pyx_GIVEREF(__pyx_n_s_Waiter);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Waiter);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":21
- * ]
- *
- * _NONE = object() # <<<<<<<<<<<<<<
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_8__waiter__NONE);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8__waiter__NONE, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":23
- * _NONE = object()
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_getcurrent, __pyx_t_2) < 0)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":24
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_2lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent___waiter, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_greenlet_init, __pyx_t_2) < 0)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":68
- * """
- *
- * __slots__ = ['hub', 'greenlet', 'value', '_exception'] # <<<<<<<<<<<<<<
- *
- * def __init__(self, hub=None):
- */
- __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_hub);
- __Pyx_GIVEREF(__pyx_n_s_hub);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_hub);
- __Pyx_INCREF(__pyx_n_s_greenlet);
- __Pyx_GIVEREF(__pyx_n_s_greenlet);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_greenlet);
- __Pyx_INCREF(__pyx_n_s_value);
- __Pyx_GIVEREF(__pyx_n_s_value);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_value);
- __Pyx_INCREF(__pyx_n_s_exception_2);
- __Pyx_GIVEREF(__pyx_n_s_exception_2);
- PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_exception_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":76
- * self._exception = _NONE
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * self.greenlet = None
- * self.value = None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_3clear, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_clear, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_clear, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":88
- * return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exception is not _NONE
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_7ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_ready, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":92
- * return self._exception is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._exception is None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_9successful, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_successful, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_successful, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":102
- * return self._exception
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * """
- * Switch to the greenlet if one's available. Otherwise store the
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_11switch, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_switch, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_switch, __pyx_t_2) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":123
- * self.hub.handle_error(switch, *sys.exc_info())
- *
- * def switch_args(self, *args): # <<<<<<<<<<<<<<
- * return self.switch(args)
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_13switch_args, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_switch_args, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_switch_args, __pyx_t_2) < 0) __PYX_ERR(0, 123, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":126
- * return self.switch(args)
- *
- * def throw(self, *throw_args): # <<<<<<<<<<<<<<
- * """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- * greenlet = self.greenlet
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_15throw, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_throw, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_throw, __pyx_t_2) < 0) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":140
- * self.hub.handle_error(throw, *sys.exc_info())
- *
- * def get(self): # <<<<<<<<<<<<<<
- * """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- * if self._exception is not _NONE:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_6Waiter_17get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Waiter_get, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict, __pyx_n_s_get, __pyx_t_2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_Waiter);
-
- /* "src/gevent/_waiter.py":175
- * This does not handle exceptions or throw methods.
- * """
- * __slots__ = ['_values'] # <<<<<<<<<<<<<<
- *
- * def __init__(self, hub=None):
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_values);
- __Pyx_GIVEREF(__pyx_n_s_values);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_values);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_MultipleWaiter);
-
- /* "src/gevent/_waiter.py":186
- * self._values = list()
- *
- * def switch(self, value): # <<<<<<<<<<<<<<
- * self._values.append(value)
- * Waiter.switch(self, True)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_14MultipleWaiter_3switch, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MultipleWaiter_switch, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict, __pyx_n_s_switch, __pyx_t_2) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_MultipleWaiter);
-
- /* "src/gevent/_waiter.py":190
- * Waiter.switch(self, True)
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if not self._values:
- * Waiter.get(self)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_14MultipleWaiter_5get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MultipleWaiter_get, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict, __pyx_n_s_get, __pyx_t_2) < 0) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_8__waiter_MultipleWaiter);
-
- /* "src/gevent/_waiter.py":197
- * return self._values.pop(0)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8__waiter_1_init, 0, __pyx_n_s_init_2, NULL, __pyx_n_s_gevent___waiter, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_2, __pyx_t_2) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":200
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":203
- *
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent.__waiter')
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_import_c_accel);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_1) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/_waiter.py":204
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent.__waiter') # <<<<<<<<<<<<<<
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_gevent___waiter);
- __Pyx_GIVEREF(__pyx_n_s_gevent___waiter);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___waiter);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/_waiter.py":1
- * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<<
- * # copyright 2018 gevent
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.__waiter", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.__waiter");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* ExtTypeTest */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* PyObjectCallMethod1 */
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = NULL;
-#if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
-#endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- goto done;
-done:
- return result;
-}
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method, *result;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- result = __Pyx__PyObject_CallMethod1(method, arg);
- Py_DECREF(method);
- return result;
-}
-
-/* pop_index */
- static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) {
- PyObject *r;
- if (unlikely(!py_ix)) return NULL;
- r = __Pyx__PyObject_PopIndex(L, py_ix);
- Py_DECREF(py_ix);
- return r;
-}
-static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) {
- return __Pyx_PyObject_CallMethod1(L, __pyx_n_s_pop, py_ix);
-}
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) {
- Py_ssize_t size = PyList_GET_SIZE(L);
- if (likely(size > (((PyListObject*)L)->allocated >> 1))) {
- Py_ssize_t cix = ix;
- if (cix < 0) {
- cix += size;
- }
- if (likely(0 <= cix && cix < size)) {
- PyObject* v = PyList_GET_ITEM(L, cix);
- Py_SIZE(L) -= 1;
- size -= 1;
- memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*));
- return v;
- }
- }
- if (py_ix == Py_None) {
- return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix));
- } else {
- return __Pyx__PyObject_PopIndex(L, py_ix);
- }
-}
-#endif
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/_waiter.py b/python/gevent/_waiter.py
deleted file mode 100644
index b9ba3e8..0000000
--- a/python/gevent/_waiter.py
+++ /dev/null
@@ -1,204 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright 2018 gevent
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-"""
-Low-level waiting primitives.
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-import sys
-
-from gevent._hub_local import get_hub_noargs as get_hub
-from gevent.exceptions import ConcurrentObjectUseError
-
-__all__ = [
- 'Waiter',
-]
-
-_NONE = object()
-
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-
-
-class Waiter(object):
- """
- A low level communication utility for greenlets.
-
- Waiter is a wrapper around greenlet's ``switch()`` and ``throw()`` calls that makes them somewhat safer:
-
- * switching will occur only if the waiting greenlet is executing :meth:`get` method currently;
- * any error raised in the greenlet is handled inside :meth:`switch` and :meth:`throw`
- * if :meth:`switch`/:meth:`throw` is called before the receiver calls :meth:`get`, then :class:`Waiter`
- will store the value/exception. The following :meth:`get` will return the value/raise the exception.
-
- The :meth:`switch` and :meth:`throw` methods must only be called from the :class:`Hub` greenlet.
- The :meth:`get` method must be called from a greenlet other than :class:`Hub`.
-
- >>> result = Waiter()
- >>> timer = get_hub().loop.timer(0.1)
- >>> timer.start(result.switch, 'hello from Waiter')
- >>> result.get() # blocks for 0.1 seconds
- 'hello from Waiter'
- >>> timer.close()
-
- If switch is called before the greenlet gets a chance to call :meth:`get` then
- :class:`Waiter` stores the value.
-
- >>> result = Waiter()
- >>> timer = get_hub().loop.timer(0.1)
- >>> timer.start(result.switch, 'hi from Waiter')
- >>> sleep(0.2)
- >>> result.get() # returns immediately without blocking
- 'hi from Waiter'
- >>> timer.close()
-
- .. warning::
-
- This a limited and dangerous way to communicate between
- greenlets. It can easily leave a greenlet unscheduled forever
- if used incorrectly. Consider using safer classes such as
- :class:`gevent.event.Event`, :class:`gevent.event.AsyncResult`,
- or :class:`gevent.queue.Queue`.
- """
-
- __slots__ = ['hub', 'greenlet', 'value', '_exception']
-
- def __init__(self, hub=None):
- self.hub = get_hub() if hub is None else hub
- self.greenlet = None
- self.value = None
- self._exception = _NONE
-
- def clear(self):
- self.greenlet = None
- self.value = None
- self._exception = _NONE
-
- def __str__(self):
- if self._exception is _NONE:
- return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
- if self._exception is None:
- return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
- return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
-
- def ready(self):
- """Return true if and only if it holds a value or an exception"""
- return self._exception is not _NONE
-
- def successful(self):
- """Return true if and only if it is ready and holds a value"""
- return self._exception is None
-
- @property
- def exc_info(self):
- "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``."
- if self._exception is not _NONE:
- return self._exception
-
- def switch(self, value):
- """
- Switch to the greenlet if one's available. Otherwise store the
- *value*.
-
- .. versionchanged:: 1.3b1
- The *value* is no longer optional.
- """
- greenlet = self.greenlet
- if greenlet is None:
- self.value = value
- self._exception = None
- else:
- if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- switch = greenlet.switch
- try:
- switch(value)
- except: # pylint:disable=bare-except
- self.hub.handle_error(switch, *sys.exc_info())
-
- def switch_args(self, *args):
- return self.switch(args)
-
- def throw(self, *throw_args):
- """Switch to the greenlet with the exception. If there's no greenlet, store the exception."""
- greenlet = self.greenlet
- if greenlet is None:
- self._exception = throw_args
- else:
- if getcurrent() is not self.hub: # pylint:disable=undefined-variable
- raise AssertionError("Can only use Waiter.switch method from the Hub greenlet")
- throw = greenlet.throw
- try:
- throw(*throw_args)
- except: # pylint:disable=bare-except
- self.hub.handle_error(throw, *sys.exc_info())
-
- def get(self):
- """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called."""
- if self._exception is not _NONE:
- if self._exception is None:
- return self.value
- getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
- else:
- if self.greenlet is not None:
- raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
- self.greenlet = getcurrent() # pylint:disable=undefined-variable
- try:
- return self.hub.switch()
- finally:
- self.greenlet = None
-
- def __call__(self, source):
- if source.exception is None:
- self.switch(source.value)
- else:
- self.throw(source.exception)
-
- # can also have a debugging version, that wraps the value in a tuple (self, value) in switch()
- # and unwraps it in wait() thus checking that switch() was indeed called
-
-
-
-class MultipleWaiter(Waiter):
- """
- An internal extension of Waiter that can be used if multiple objects
- must be waited on, and there is a chance that in between waits greenlets
- might be switched out. All greenlets that switch to this waiter
- will have their value returned.
-
- This does not handle exceptions or throw methods.
- """
- __slots__ = ['_values']
-
- def __init__(self, hub=None):
- Waiter.__init__(self, hub)
- # we typically expect a relatively small number of these to be outstanding.
- # since we pop from the left, a deque might be slightly
- # more efficient, but since we're in the hub we avoid imports if
- # we can help it to better support monkey-patching, and delaying the import
- # here can be impractical (see https://github.com/gevent/gevent/issues/652)
- self._values = list()
-
- def switch(self, value):
- self._values.append(value)
- Waiter.switch(self, True)
-
- def get(self):
- if not self._values:
- Waiter.get(self)
- Waiter.clear(self)
-
- return self._values.pop(0)
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent.__waiter')
diff --git a/python/gevent/ares.py b/python/gevent/ares.py
deleted file mode 100644
index 37980b3..0000000
--- a/python/gevent/ares.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Backwards compatibility alias for :mod:`gevent.resolver.cares`.
-
-.. deprecated:: 1.3
- Use :mod:`gevent.resolver.cares`
-"""
-
-from gevent.resolver.cares import * # pylint:disable=wildcard-import,unused-wildcard-import,
-import gevent.resolver.cares as _cares
-__all__ = _cares.__all__ # pylint:disable=c-extension-no-member
-del _cares
diff --git a/python/gevent/backdoor.py b/python/gevent/backdoor.py
deleted file mode 100644
index 8489417..0000000
--- a/python/gevent/backdoor.py
+++ /dev/null
@@ -1,210 +0,0 @@
-# Copyright (c) 2009-2014, gevent contributors
-# Based on eventlet.backdoor Copyright (c) 2005-2006, Bob Ippolito
-"""
-Interactive greenlet-based network console that can be used in any process.
-
-The :class:`BackdoorServer` provides a REPL inside a running process. As
-long as the process is monkey-patched, the ``BackdoorServer`` can coexist
-with other elements of the process.
-
-.. seealso:: :class:`code.InteractiveConsole`
-"""
-from __future__ import print_function, absolute_import
-import sys
-from code import InteractiveConsole
-
-from gevent.greenlet import Greenlet
-from gevent.hub import getcurrent
-from gevent.server import StreamServer
-from gevent.pool import Pool
-
-__all__ = ['BackdoorServer']
-
-try:
- sys.ps1
-except AttributeError:
- sys.ps1 = '>>> '
-try:
- sys.ps2
-except AttributeError:
- sys.ps2 = '... '
-
-class _Greenlet_stdreplace(Greenlet):
- # A greenlet that replaces sys.std[in/out/err] while running.
- _fileobj = None
- saved = None
-
- def switch(self, *args, **kw):
- if self._fileobj is not None:
- self.switch_in()
- Greenlet.switch(self, *args, **kw)
-
- def switch_in(self):
- self.saved = sys.stdin, sys.stderr, sys.stdout
- sys.stdin = sys.stdout = sys.stderr = self._fileobj
-
- def switch_out(self):
- sys.stdin, sys.stderr, sys.stdout = self.saved
- self.saved = None
-
- def throw(self, *args, **kwargs):
- # pylint:disable=arguments-differ
- if self.saved is None and self._fileobj is not None:
- self.switch_in()
- Greenlet.throw(self, *args, **kwargs)
-
- def run(self):
- try:
- return Greenlet.run(self)
- finally:
- # Make sure to restore the originals.
- self.switch_out()
-
-
-class BackdoorServer(StreamServer):
- """
- Provide a backdoor to a program for debugging purposes.
-
- .. warning:: This backdoor provides no authentication and makes no
- attempt to limit what remote users can do. Anyone that
- can access the server can take any action that the running
- python process can. Thus, while you may bind to any interface, for
- security purposes it is recommended that you bind to one
- only accessible to the local machine, e.g.,
- 127.0.0.1/localhost.
-
- Basic usage::
-
- from gevent.backdoor import BackdoorServer
- server = BackdoorServer(('127.0.0.1', 5001),
- banner="Hello from gevent backdoor!",
- locals={'foo': "From defined scope!"})
- server.serve_forever()
-
- In a another terminal, connect with...::
-
- $ telnet 127.0.0.1 5001
- Trying 127.0.0.1...
- Connected to 127.0.0.1.
- Escape character is '^]'.
- Hello from gevent backdoor!
- >> print(foo)
- From defined scope!
-
- .. versionchanged:: 1.2a1
- Spawned greenlets are now tracked in a pool and killed when the server
- is stopped.
- """
-
- def __init__(self, listener, locals=None, banner=None, **server_args):
- """
- :keyword locals: If given, a dictionary of "builtin" values that will be available
- at the top-level.
- :keyword banner: If geven, a string that will be printed to each connecting user.
- """
- group = Pool(greenlet_class=_Greenlet_stdreplace) # no limit on number
- StreamServer.__init__(self, listener, spawn=group, **server_args)
- _locals = {'__doc__': None, '__name__': '__console__'}
- if locals:
- _locals.update(locals)
- self.locals = _locals
-
- self.banner = banner
- self.stderr = sys.stderr
-
- def _create_interactive_locals(self):
- # Create and return a *new* locals dictionary based on self.locals,
- # and set any new entries in it. (InteractiveConsole does not
- # copy its locals value)
- _locals = self.locals.copy()
- # __builtins__ may either be the __builtin__ module or
- # __builtin__.__dict__; in the latter case typing
- # locals() at the backdoor prompt spews out lots of
- # useless stuff
- try:
- import __builtin__
- _locals["__builtins__"] = __builtin__
- except ImportError:
- import builtins # pylint:disable=import-error
- _locals["builtins"] = builtins
- _locals['__builtins__'] = builtins
- return _locals
-
- def handle(self, conn, _address): # pylint: disable=method-hidden
- """
- Interact with one remote user.
-
- .. versionchanged:: 1.1b2 Each connection gets its own
- ``locals`` dictionary. Previously they were shared in a
- potentially unsafe manner.
- """
- fobj = conn.makefile(mode="rw")
- fobj = _fileobject(conn, fobj, self.stderr)
- getcurrent()._fileobj = fobj
-
- getcurrent().switch_in()
- try:
- console = InteractiveConsole(self._create_interactive_locals())
- if sys.version_info[:3] >= (3, 6, 0):
- # Beginning in 3.6, the console likes to print "now exiting <class>"
- # but probably our socket is already closed, so this just causes problems.
- console.interact(banner=self.banner, exitmsg='') # pylint:disable=unexpected-keyword-arg
- else:
- console.interact(banner=self.banner)
- except SystemExit: # raised by quit()
- if hasattr(sys, 'exc_clear'): # py2
- sys.exc_clear()
- finally:
- conn.close()
- fobj.close()
-
-
-class _fileobject(object):
- """
- A file-like object that wraps the result of socket.makefile (composition
- instead of inheritance lets us work identically under CPython and PyPy).
-
- We write directly to the socket, avoiding the buffering that the text-oriented
- makefile would want to do (otherwise we'd be at the mercy of waiting on a
- flush() to get called for the remote user to see data); this beats putting
- the file in binary mode and translating everywhere with a non-default
- encoding.
- """
- def __init__(self, sock, fobj, stderr):
- self._sock = sock
- self._fobj = fobj
- self.stderr = stderr
-
- def __getattr__(self, name):
- return getattr(self._fobj, name)
-
- def close(self):
- self._fobj.close()
- self._sock.close()
-
- def write(self, data):
- if not isinstance(data, bytes):
- data = data.encode('utf-8')
- self._sock.sendall(data)
-
- def isatty(self):
- return True
-
- def flush(self):
- pass
-
- def readline(self, *a):
- try:
- return self._fobj.readline(*a).replace("\r\n", "\n")
- except UnicodeError:
- # Typically, under python 3, a ^C on the other end
- return ''
-
-
-if __name__ == '__main__':
- if not sys.argv[1:]:
- print('USAGE: %s PORT [banner]' % sys.argv[0])
- else:
- BackdoorServer(('127.0.0.1', int(sys.argv[1])),
- banner=(sys.argv[2] if len(sys.argv) > 2 else None),
- locals={'hello': 'world'}).serve_forever()
diff --git a/python/gevent/baseserver.py b/python/gevent/baseserver.py
deleted file mode 100644
index d20d936..0000000
--- a/python/gevent/baseserver.py
+++ /dev/null
@@ -1,404 +0,0 @@
-"""Base class for implementing servers"""
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-import sys
-import _socket
-import errno
-from gevent.greenlet import Greenlet
-from gevent.event import Event
-from gevent.hub import get_hub
-from gevent._compat import string_types, integer_types, xrange
-
-
-__all__ = ['BaseServer']
-
-
-# We define a helper function to handle closing the socket in
-# do_handle; We'd like to bind it to a kwarg to avoid *any* lookups at
-# all, but that's incompatible with the calling convention of
-# do_handle. On CPython, this is ~20% faster than creating and calling
-# a closure and ~10% faster than using a @staticmethod. (In theory, we
-# could create a closure only once in set_handle, to wrap self._handle,
-# but this is safer from a backwards compat standpoint.)
-# we also avoid unpacking the *args tuple when calling/spawning this object
-# for a tiny improvement (benchmark shows a wash)
-def _handle_and_close_when_done(handle, close, args_tuple):
- try:
- return handle(*args_tuple)
- finally:
- close(*args_tuple)
-
-
-class BaseServer(object):
- """
- An abstract base class that implements some common functionality for the servers in gevent.
-
- :param listener: Either be an address that the server should bind
- on or a :class:`gevent.socket.socket` instance that is already
- bound (and put into listening mode in case of TCP socket).
-
- :keyword handle: If given, the request handler. The request
- handler can be defined in a few ways. Most commonly,
- subclasses will implement a ``handle`` method as an
- instance method. Alternatively, a function can be passed
- as the ``handle`` argument to the constructor. In either
- case, the handler can later be changed by calling
- :meth:`set_handle`.
-
- When the request handler returns, the socket used for the
- request will be closed. Therefore, the handler must not return if
- the socket is still in use (for example, by manually spawned greenlets).
-
- :keyword spawn: If provided, is called to create a new
- greenlet to run the handler. By default,
- :func:`gevent.spawn` is used (meaning there is no
- artificial limit on the number of concurrent requests). Possible values for *spawn*:
-
- - a :class:`gevent.pool.Pool` instance -- ``handle`` will be executed
- using :meth:`gevent.pool.Pool.spawn` only if the pool is not full.
- While it is full, no new connections are accepted;
- - :func:`gevent.spawn_raw` -- ``handle`` will be executed in a raw
- greenlet which has a little less overhead then :class:`gevent.Greenlet` instances spawned by default;
- - ``None`` -- ``handle`` will be executed right away, in the :class:`Hub` greenlet.
- ``handle`` cannot use any blocking functions as it would mean switching to the :class:`Hub`.
- - an integer -- a shortcut for ``gevent.pool.Pool(integer)``
-
- .. versionchanged:: 1.1a1
- When the *handle* function returns from processing a connection,
- the client socket will be closed. This resolves the non-deterministic
- closing of the socket, fixing ResourceWarnings under Python 3 and PyPy.
-
- """
- # pylint: disable=too-many-instance-attributes,bare-except,broad-except
-
- #: the number of seconds to sleep in case there was an error in accept() call
- #: for consecutive errors the delay will double until it reaches max_delay
- #: when accept() finally succeeds the delay will be reset to min_delay again
- min_delay = 0.01
- max_delay = 1
-
- #: Sets the maximum number of consecutive accepts that a process may perform on
- #: a single wake up. High values give higher priority to high connection rates,
- #: while lower values give higher priority to already established connections.
- #: Default is 100. Note, that in case of multiple working processes on the same
- #: listening value, it should be set to a lower value. (pywsgi.WSGIServer sets it
- #: to 1 when environ["wsgi.multiprocess"] is true)
- max_accept = 100
-
- _spawn = Greenlet.spawn
-
- #: the default timeout that we wait for the client connections to close in stop()
- stop_timeout = 1
-
- fatal_errors = (errno.EBADF, errno.EINVAL, errno.ENOTSOCK)
-
- def __init__(self, listener, handle=None, spawn='default'):
- self._stop_event = Event()
- self._stop_event.set()
- self._watcher = None
- self._timer = None
- self._handle = None
- # XXX: FIXME: Subclasses rely on the presence or absence of the
- # `socket` attribute to determine whether we are open/should be opened.
- # Instead, have it be None.
- self.pool = None
- try:
- self.set_listener(listener)
- self.set_spawn(spawn)
- self.set_handle(handle)
- self.delay = self.min_delay
- self.loop = get_hub().loop
- if self.max_accept < 1:
- raise ValueError('max_accept must be positive int: %r' % (self.max_accept, ))
- except:
- self.close()
- raise
-
- def set_listener(self, listener):
- if hasattr(listener, 'accept'):
- if hasattr(listener, 'do_handshake'):
- raise TypeError('Expected a regular socket, not SSLSocket: %r' % (listener, ))
- self.family = listener.family
- self.address = listener.getsockname()
- self.socket = listener
- else:
- self.family, self.address = parse_address(listener)
-
- def set_spawn(self, spawn):
- if spawn == 'default':
- self.pool = None
- self._spawn = self._spawn
- elif hasattr(spawn, 'spawn'):
- self.pool = spawn
- self._spawn = spawn.spawn
- elif isinstance(spawn, integer_types):
- from gevent.pool import Pool
- self.pool = Pool(spawn)
- self._spawn = self.pool.spawn
- else:
- self.pool = None
- self._spawn = spawn
- if hasattr(self.pool, 'full'):
- self.full = self.pool.full
- if self.pool is not None:
- self.pool._semaphore.rawlink(self._start_accepting_if_started)
-
- def set_handle(self, handle):
- if handle is not None:
- self.handle = handle
- if hasattr(self, 'handle'):
- self._handle = self.handle
- else:
- raise TypeError("'handle' must be provided")
-
- def _start_accepting_if_started(self, _event=None):
- if self.started:
- self.start_accepting()
-
- def start_accepting(self):
- if self._watcher is None:
- # just stop watcher without creating a new one?
- self._watcher = self.loop.io(self.socket.fileno(), 1)
- self._watcher.start(self._do_read)
-
- def stop_accepting(self):
- if self._watcher is not None:
- self._watcher.stop()
- self._watcher.close()
- self._watcher = None
- if self._timer is not None:
- self._timer.stop()
- self._timer.close()
- self._timer = None
-
- def do_handle(self, *args):
- spawn = self._spawn
- handle = self._handle
- close = self.do_close
-
- try:
- if spawn is None:
- _handle_and_close_when_done(handle, close, args)
- else:
- spawn(_handle_and_close_when_done, handle, close, args)
- except:
- close(*args)
- raise
-
- def do_close(self, *args):
- pass
-
- def do_read(self):
- raise NotImplementedError()
-
- def _do_read(self):
- for _ in xrange(self.max_accept):
- if self.full():
- self.stop_accepting()
- return
- try:
- args = self.do_read()
- self.delay = self.min_delay
- if not args:
- return
- except:
- self.loop.handle_error(self, *sys.exc_info())
- ex = sys.exc_info()[1]
- if self.is_fatal_error(ex):
- self.close()
- sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex)))
- return
- if self.delay >= 0:
- self.stop_accepting()
- self._timer = self.loop.timer(self.delay)
- self._timer.start(self._start_accepting_if_started)
- self.delay = min(self.max_delay, self.delay * 2)
- break
- else:
- try:
- self.do_handle(*args)
- except:
- self.loop.handle_error((args[1:], self), *sys.exc_info())
- if self.delay >= 0:
- self.stop_accepting()
- self._timer = self.loop.timer(self.delay)
- self._timer.start(self._start_accepting_if_started)
- self.delay = min(self.max_delay, self.delay * 2)
- break
-
- def full(self):
- # copied from self.pool
- # pylint: disable=method-hidden
- return False
-
- def __repr__(self):
- return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo())
-
- def __str__(self):
- return '<%s %s>' % (type(self).__name__, self._formatinfo())
-
- def _formatinfo(self):
- if hasattr(self, 'socket'):
- try:
- fileno = self.socket.fileno()
- except Exception as ex:
- fileno = str(ex)
- result = 'fileno=%s ' % fileno
- else:
- result = ''
- try:
- if isinstance(self.address, tuple) and len(self.address) == 2:
- result += 'address=%s:%s' % self.address
- else:
- result += 'address=%s' % (self.address, )
- except Exception as ex:
- result += str(ex) or '<error>'
-
- handle = self.__dict__.get('handle')
- if handle is not None:
- fself = getattr(handle, '__self__', None)
- try:
- if fself is self:
- # Checks the __self__ of the handle in case it is a bound
- # method of self to prevent recursivly defined reprs.
- handle_repr = '<bound method %s.%s of self>' % (
- self.__class__.__name__,
- handle.__name__,
- )
- else:
- handle_repr = repr(handle)
-
- result += ' handle=' + handle_repr
- except Exception as ex:
- result += str(ex) or '<error>'
-
- return result
-
- @property
- def server_host(self):
- """IP address that the server is bound to (string)."""
- if isinstance(self.address, tuple):
- return self.address[0]
-
- @property
- def server_port(self):
- """Port that the server is bound to (an integer)."""
- if isinstance(self.address, tuple):
- return self.address[1]
-
- def init_socket(self):
- """If the user initialized the server with an address rather than socket,
- then this function will create a socket, bind it and put it into listening mode.
-
- It is not supposed to be called by the user, it is called by :meth:`start` before starting
- the accept loop."""
- pass
-
- @property
- def started(self):
- return not self._stop_event.is_set()
-
- def start(self):
- """Start accepting the connections.
-
- If an address was provided in the constructor, then also create a socket,
- bind it and put it into the listening mode.
- """
- self.init_socket()
- self._stop_event.clear()
- try:
- self.start_accepting()
- except:
- self.close()
- raise
-
- def close(self):
- """Close the listener socket and stop accepting."""
- self._stop_event.set()
- try:
- self.stop_accepting()
- finally:
- try:
- self.socket.close()
- except Exception:
- pass
- finally:
- self.__dict__.pop('socket', None)
- self.__dict__.pop('handle', None)
- self.__dict__.pop('_handle', None)
- self.__dict__.pop('_spawn', None)
- self.__dict__.pop('full', None)
- if self.pool is not None:
- self.pool._semaphore.unlink(self._start_accepting_if_started)
-
- @property
- def closed(self):
- return not hasattr(self, 'socket')
-
- def stop(self, timeout=None):
- """
- Stop accepting the connections and close the listening socket.
-
- If the server uses a pool to spawn the requests, then
- :meth:`stop` also waits for all the handlers to exit. If there
- are still handlers executing after *timeout* has expired
- (default 1 second, :attr:`stop_timeout`), then the currently
- running handlers in the pool are killed.
-
- If the server does not use a pool, then this merely stops accepting connections;
- any spawned greenlets that are handling requests continue running until
- they naturally complete.
- """
- self.close()
- if timeout is None:
- timeout = self.stop_timeout
- if self.pool:
- self.pool.join(timeout=timeout)
- self.pool.kill(block=True, timeout=1)
-
- def serve_forever(self, stop_timeout=None):
- """Start the server if it hasn't been already started and wait until it's stopped."""
- # add test that serve_forever exists on stop()
- if not self.started:
- self.start()
- try:
- self._stop_event.wait()
- finally:
- Greenlet.spawn(self.stop, timeout=stop_timeout).join()
-
- def is_fatal_error(self, ex):
- return isinstance(ex, _socket.error) and ex.args[0] in self.fatal_errors
-
-
-def _extract_family(host):
- if host.startswith('[') and host.endswith(']'):
- host = host[1:-1]
- return _socket.AF_INET6, host
- return _socket.AF_INET, host
-
-
-def _parse_address(address):
- if isinstance(address, tuple):
- if not address[0] or ':' in address[0]:
- return _socket.AF_INET6, address
- return _socket.AF_INET, address
-
- if ((isinstance(address, string_types) and ':' not in address)
- or isinstance(address, integer_types)): # noqa (pep8 E129)
- # Just a port
- return _socket.AF_INET6, ('', int(address))
-
- if not isinstance(address, string_types):
- raise TypeError('Expected tuple or string, got %s' % type(address))
-
- host, port = address.rsplit(':', 1)
- family, host = _extract_family(host)
- if host == '*':
- host = ''
- return family, (host, int(port))
-
-
-def parse_address(address):
- try:
- return _parse_address(address)
- except ValueError as ex: # pylint:disable=try-except-raise
- raise ValueError('Failed to parse address %r: %s' % (address, ex))
diff --git a/python/gevent/builtins.py b/python/gevent/builtins.py
deleted file mode 100644
index 389a652..0000000
--- a/python/gevent/builtins.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# Copyright (c) 2015 gevent contributors. See LICENSE for details.
-"""gevent friendly implementations of builtin functions."""
-from __future__ import absolute_import
-
-import sys
-import weakref
-
-from gevent.lock import RLock
-from gevent._compat import imp_acquire_lock
-from gevent._compat import imp_release_lock
-
-
-# Normally we'd have the "expected" case inside the try
-# (Python 3, because Python 3 is the way forward). But
-# under Python 2, the popular `future` library *also* provides
-# a `builtins` module---which lacks the __import__ attribute.
-# So we test for the old, deprecated version first
-
-try: # Py2
- import __builtin__ as __gbuiltins__
- _allowed_module_name_types = (basestring,) # pylint:disable=undefined-variable
- __target__ = '__builtin__'
-except ImportError:
- import builtins as __gbuiltins__ # pylint: disable=import-error
- _allowed_module_name_types = (str,)
- __target__ = 'builtins'
-
-_import = __gbuiltins__.__import__
-
-# We need to protect imports both across threads and across greenlets.
-# And the order matters. Note that under 3.4, the global import lock
-# and imp module are deprecated. It seems that in all Py3 versions, a
-# module lock is used such that this fix is not necessary.
-
-# We emulate the per-module locking system under Python 2 in order to
-# avoid issues acquiring locks in multiple-level-deep imports
-# that attempt to use the gevent blocking API at runtime; using one lock
-# could lead to a LoopExit error as a greenlet attempts to block on it while
-# it's already held by the main greenlet (issue #798).
-
-# We base this approach on a simplification of what `importlib._bootstrap`
-# does; notably, we don't check for deadlocks
-
-_g_import_locks = {} # name -> wref of RLock
-
-__lock_imports = True
-
-
-def __module_lock(name):
- # Return the lock for the given module, creating it if necessary.
- # It will be removed when no longer needed.
- # Nothing in this function yields, so we're multi-greenlet safe
- # (But not multi-threading safe.)
- # XXX: What about on PyPy, where the GC is asynchronous (not ref-counting)?
- # (Does it stop-the-world first?)
- lock = None
- try:
- lock = _g_import_locks[name]()
- except KeyError:
- pass
-
- if lock is None:
- lock = RLock()
-
- def cb(_):
- # We've seen a KeyError on PyPy on RPi2
- _g_import_locks.pop(name, None)
- _g_import_locks[name] = weakref.ref(lock, cb)
- return lock
-
-
-def __import__(*args, **kwargs):
- """
- __import__(name, globals=None, locals=None, fromlist=(), level=0) -> object
-
- Normally python protects imports against concurrency by doing some locking
- at the C level (at least, it does that in CPython). This function just
- wraps the normal __import__ functionality in a recursive lock, ensuring that
- we're protected against greenlet import concurrency as well.
- """
- if args and not issubclass(type(args[0]), _allowed_module_name_types):
- # if a builtin has been acquired as a bound instance method,
- # python knows not to pass 'self' when the method is called.
- # No such protection exists for monkey-patched builtins,
- # however, so this is necessary.
- args = args[1:]
-
- if not __lock_imports:
- return _import(*args, **kwargs)
-
- module_lock = __module_lock(args[0]) # Get a lock for the module name
- imp_acquire_lock()
- try:
- module_lock.acquire()
- try:
- result = _import(*args, **kwargs)
- finally:
- module_lock.release()
- finally:
- imp_release_lock()
- return result
-
-
-def _unlock_imports():
- """
- Internal function, called when gevent needs to perform imports
- lazily, but does not know the state of the system. It may be impossible
- to take the import lock because there are no other running greenlets, for
- example. This causes a monkey-patched __import__ to avoid taking any locks.
- until the corresponding call to lock_imports. This should only be done for limited
- amounts of time and when the set of imports is statically known to be "safe".
- """
- global __lock_imports
- # This could easily become a list that we push/pop from or an integer
- # we increment if we need to do this recursively, but we shouldn't get
- # that complex.
- __lock_imports = False
-
-
-def _lock_imports():
- global __lock_imports
- __lock_imports = True
-
-if sys.version_info[:2] >= (3, 3):
- __implements__ = []
- __import__ = _import
-else:
- __implements__ = ['__import__']
-__all__ = __implements__
-
-
-from gevent._util import copy_globals
-
-__imports__ = copy_globals(__gbuiltins__, globals(),
- names_to_ignore=__implements__)
diff --git a/python/gevent/core.py b/python/gevent/core.py
deleted file mode 100644
index 906e739..0000000
--- a/python/gevent/core.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2009-2015 Denis Bilenko and gevent contributors. See LICENSE for details.
-"""
-Deprecated; this does not reflect all the possible options
-and its interface varies.
-
-.. versionchanged:: 1.3a2
- Deprecated.
-"""
-from __future__ import absolute_import
-
-import sys
-
-from gevent._config import config
-from gevent._util import copy_globals
-
-_core = sys.modules[config.loop.__module__]
-
-copy_globals(_core, globals())
-
-__all__ = _core.__all__ # pylint:disable=no-member
diff --git a/python/gevent/event.c b/python/gevent/event.c
deleted file mode 100644
index 5de3dcf..0000000
--- a/python/gevent/event.c
+++ /dev/null
@@ -1,13439 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/_event.pxd",
- "src\\gevent\\_event.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent._event",
- "sources": [
- "src/gevent/event.py"
- ]
- },
- "module_name": "gevent._event"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 0
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent___event
-#define __PYX_HAVE_API__gevent___event
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\event.py",
- "src\\gevent\\_event.pxd",
- "src\\gevent\\__greenlet_primitives.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_6_event__AbstractLinkable;
-struct __pyx_obj_6gevent_6_event_Event;
-struct __pyx_obj_6gevent_6_event_AsyncResult;
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core;
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait;
-
-/* "gevent/_event.pxd":55
- * @cython.locals(todo=set)
- * cpdef _notify_links(self)
- * cdef _wait_core(self, timeout, catch=*) # <<<<<<<<<<<<<<
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*)
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core {
- int __pyx_n;
- PyObject *catch;
-};
-
-/* "gevent/_event.pxd":57
- * cdef _wait_core(self, timeout, catch=*)
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*) # <<<<<<<<<<<<<<
- *
- *
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":70
- * cdef public int _imap_task_index
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint successful(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":73
- * cpdef bint successful(self)
- *
- * cpdef wait(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint done(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/_event.pxd":38
- * cdef void _init()
- *
- * cdef class _AbstractLinkable: # <<<<<<<<<<<<<<
- * # We declare the __weakref__ here in the base (even though
- * # that's not really what we want) as a workaround for a Cython
- */
-struct __pyx_obj_6gevent_6_event__AbstractLinkable {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *_notifier;
- PyObject *_links;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
-};
-
-
-/* "gevent/_event.pxd":60
- *
- *
- * cdef class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef bint _flag
- *
- */
-struct __pyx_obj_6gevent_6_event_Event {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- int _flag;
-};
-
-
-/* "gevent/_event.pxd":63
- * cdef bint _flag
- *
- * cdef class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef readonly _value
- * cdef readonly tuple _exc_info
- */
-struct __pyx_obj_6gevent_6_event_AsyncResult {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *_value;
- PyObject *_exc_info;
- int _imap_task_index;
-};
-
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "src/gevent/event.py":27
- *
- *
- * class _AbstractLinkable(object): # <<<<<<<<<<<<<<
- * # Encapsulates the standard parts of the linking and notifying protocol
- * # common to both repeatable events and one-time events (AsyncResult).
- */
-
-struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable {
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- int (*ready)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*unlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_check_and_notify)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*_wait_core)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args);
- PyObject *(*_wait_return_value)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *);
- PyObject *(*_wait)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args);
-};
-static struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtabptr_6gevent_6_event__AbstractLinkable;
-
-
-/* "src/gevent/event.py":144
- *
- *
- * class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * """A synchronization primitive that allows one greenlet to wake up one or more others.
- * It has the same interface as :class:`threading.Event` but works across greenlets.
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_Event {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_event_Event *__pyx_vtabptr_6gevent_6_event_Event;
-
-
-/* "src/gevent/event.py":249
- *
- *
- * class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * """A one-time event that stores a value or an exception.
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_AsyncResult {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *(*get)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args);
- int (*successful)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- PyObject *(*wait)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args);
- int (*done)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancel)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancelled)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *__pyx_vtabptr_6gevent_6_event_AsyncResult;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* CallableCheck.proto */
-#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
-#else
-#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
-#endif
-
-/* pyfrozenset_new.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);
-
-/* py_set_remove.proto */
-static CYTHON_INLINE int __Pyx_PySet_Remove(PyObject *set, PyObject *key);
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* set_iter.proto */
-static CYTHON_INLINE PyObject* __Pyx_set_iterator(PyObject* iterable, int is_set,
- Py_ssize_t* p_orig_length, int* p_source_is_set);
-static CYTHON_INLINE int __Pyx_set_iter_next(
- PyObject* iter_obj, Py_ssize_t orig_length,
- Py_ssize_t* ppos, PyObject **value,
- int source_is_set);
-
-/* PySetContains.proto */
-static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* PyObjectLookupSpecial.proto */
-#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
- PyObject *res;
- PyTypeObject *tp = Py_TYPE(obj);
-#if PY_MAJOR_VERSION < 3
- if (unlikely(PyInstance_Check(obj)))
- return __Pyx_PyObject_GetAttrStr(obj, attr_name);
-#endif
- res = _PyType_Lookup(tp, attr_name);
- if (likely(res)) {
- descrgetfunc f = Py_TYPE(res)->tp_descr_get;
- if (!f) {
- Py_INCREF(res);
- } else {
- res = f(res, obj, (PyObject *)tp);
- }
- } else {
- PyErr_SetObject(PyExc_AttributeError, attr_name);
- }
- return res;
-}
-#else
-#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
-#endif
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static int __pyx_f_6gevent_6_event_17_AbstractLinkable_ready(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__check_and_notify(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable_rawlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable_unlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__notify_links(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_core(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_timeout, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_return_value(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_waited, CYTHON_UNUSED PyObject *__pyx_v_wait_success); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args); /* proto*/
-static int __pyx_f_6gevent_6_event_5Event_ready(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_5Event__wait_return_value(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, PyObject *__pyx_v_waited, PyObject *__pyx_v_wait_success); /* proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_ready(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_successful(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult_get(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult__wait_return_value(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_waited, CYTHON_UNUSED PyObject *__pyx_v_wait_success); /* proto*/
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult_wait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args); /* proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_done(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_cancel(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_cancelled(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent._event' */
-static PyTypeObject *__pyx_ptype_6gevent_6_event_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event__AbstractLinkable = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_Event = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_AsyncResult = 0;
-static PyObject *__pyx_v_6gevent_6_event__None = 0;
-static PyObject *__pyx_v_6gevent_6_event_reraise = 0;
-static PyObject *__pyx_v_6gevent_6_event_dump_traceback = 0;
-static PyObject *__pyx_v_6gevent_6_event_load_traceback = 0;
-static PyObject *__pyx_v_6gevent_6_event_InvalidSwitchError = 0;
-static PyObject *__pyx_v_6gevent_6_event_Timeout = 0;
-static int __pyx_v_6gevent_6_event__greenlet_imported;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_event_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_6_event_greenlet_init(void); /*proto*/
-static void __pyx_f_6gevent_6_event__init(void); /*proto*/
-#define __Pyx_MODULE_NAME "gevent._event"
-extern int __pyx_module_is_main_gevent___event;
-int __pyx_module_is_main_gevent___event = 0;
-
-/* Implementation of 'gevent._event' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_NotImplementedError;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_KeyError;
-static const char __pyx_k_s[] = "<%s ";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_get[] = "get";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_set[] = "set";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_NONE[] = "_NONE";
-static const char __pyx_k_None[] = "_None";
-static const char __pyx_k_done[] = "done";
-static const char __pyx_k_exit[] = "__exit__";
-static const char __pyx_k_flag[] = "_flag";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wait[] = "wait";
-static const char __pyx_k_Event[] = "Event";
-static const char __pyx_k_block[] = "block";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_clear[] = "clear";
-static const char __pyx_k_enter[] = "__enter__";
-static const char __pyx_k_isSet[] = "isSet";
-static const char __pyx_k_links[] = "_links";
-static const char __pyx_k_ready[] = "ready";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_unset[] = "unset ";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_cancel[] = "cancel";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_is_set[] = "is_set";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_result[] = "result";
-static const char __pyx_k_source[] = "source";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_unlink[] = "unlink";
-static const char __pyx_k_Timeout[] = "Timeout";
-static const char __pyx_k_links_s[] = " _links[%s]>";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_reraise[] = "reraise";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_value_2[] = "_value";
-static const char __pyx_k_value_r[] = "value=%r ";
-static const char __pyx_k_weakref[] = "__weakref__";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_notifier[] = "_notifier";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_Event_set[] = "Event.set";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_cancelled[] = "cancelled";
-static const char __pyx_k_exception[] = "_exception";
-static const char __pyx_k_Event_wait[] = "Event.wait";
-static const char __pyx_k_exc_info_2[] = "_exc_info";
-static const char __pyx_k_get_nowait[] = "get_nowait";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_set_result[] = "set_result";
-static const char __pyx_k_successful[] = "successful";
-static const char __pyx_k_AsyncResult[] = "AsyncResult";
-static const char __pyx_k_Event_clear[] = "Event.clear";
-static const char __pyx_k_Event_isSet[] = "Event.isSet";
-static const char __pyx_k_Event_ready[] = "Event.ready";
-static const char __pyx_k_auto_unlink[] = "auto_unlink";
-static const char __pyx_k_exception_2[] = "exception";
-static const char __pyx_k_exception_r[] = "exception=%r ";
-static const char __pyx_k_Event_is_set[] = "Event.is_set";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_notify_links[] = "_notify_links";
-static const char __pyx_k_run_callback[] = "run_callback";
-static const char __pyx_k_s_s__links_s[] = "<%s %s _links[%s]>";
-static const char __pyx_k_gevent__event[] = "gevent._event";
-static const char __pyx_k_gevent__tblib[] = "gevent._tblib";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_set_exception[] = "set_exception";
-static const char __pyx_k_dump_traceback[] = "dump_traceback";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_gevent__compat[] = "gevent._compat";
-static const char __pyx_k_gevent_timeout[] = "gevent.timeout";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_load_traceback[] = "load_traceback";
-static const char __pyx_k_AsyncResult_get[] = "AsyncResult.get";
-static const char __pyx_k_AsyncResult_set[] = "AsyncResult.set";
-static const char __pyx_k_imap_task_index[] = "_imap_task_index";
-static const char __pyx_k_raise_exception[] = "_raise_exception";
-static const char __pyx_k_AsyncResult_done[] = "AsyncResult.done";
-static const char __pyx_k_AsyncResult_wait[] = "AsyncResult.wait";
-static const char __pyx_k_AsyncResult_ready[] = "AsyncResult.ready";
-static const char __pyx_k_gevent__hub_local[] = "gevent._hub_local";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_AsyncResult_cancel[] = "AsyncResult.cancel";
-static const char __pyx_k_AsyncResult_result[] = "AsyncResult.result";
-static const char __pyx_k_InvalidSwitchError[] = "InvalidSwitchError";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy";
-static const char __pyx_k_Expected_callable_r[] = "Expected callable: %r";
-static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
-static const char __pyx_k_src_gevent_event_py[] = "src\\gevent\\event.py";
-static const char __pyx_k_reset_internal_locks[] = "_reset_internal_locks";
-static const char __pyx_k_AsyncResult_cancelled[] = "AsyncResult.cancelled";
-static const char __pyx_k_AbstractLinkable_ready[] = "_AbstractLinkable.ready";
-static const char __pyx_k_AsyncResult_get_nowait[] = "AsyncResult.get_nowait";
-static const char __pyx_k_AsyncResult_successful[] = "AsyncResult.successful";
-static const char __pyx_k_AbstractLinkable_unlink[] = "_AbstractLinkable.unlink";
-static const char __pyx_k_AbstractLinkable_rawlink[] = "_AbstractLinkable.rawlink";
-static const char __pyx_k_AsyncResult_set_exception[] = "AsyncResult.set_exception";
-static const char __pyx_k_Event__reset_internal_locks[] = "Event._reset_internal_locks";
-static const char __pyx_k_AsyncResult__raise_exception[] = "AsyncResult._raise_exception";
-static const char __pyx_k_AbstractLinkable__notify_links[] = "_AbstractLinkable._notify_links";
-static const char __pyx_k_Basic_synchronization_primitives[] = "Basic synchronization primitives: Event and AsyncResult";
-static const char __pyx_k_Invalid_switch_into_Event_wait_r[] = "Invalid switch into Event.wait(): %r";
-static const char __pyx_k_if_we_didn_t_wait_we_should_alre[] = "if we didn't wait we should already be set";
-static PyObject *__pyx_n_s_AbstractLinkable__notify_links;
-static PyObject *__pyx_n_s_AbstractLinkable_rawlink;
-static PyObject *__pyx_n_s_AbstractLinkable_ready;
-static PyObject *__pyx_n_s_AbstractLinkable_unlink;
-static PyObject *__pyx_n_s_AsyncResult;
-static PyObject *__pyx_n_s_AsyncResult__raise_exception;
-static PyObject *__pyx_n_s_AsyncResult_cancel;
-static PyObject *__pyx_n_s_AsyncResult_cancelled;
-static PyObject *__pyx_n_s_AsyncResult_done;
-static PyObject *__pyx_n_s_AsyncResult_get;
-static PyObject *__pyx_n_s_AsyncResult_get_nowait;
-static PyObject *__pyx_n_s_AsyncResult_ready;
-static PyObject *__pyx_n_s_AsyncResult_result;
-static PyObject *__pyx_n_s_AsyncResult_set;
-static PyObject *__pyx_n_s_AsyncResult_set_exception;
-static PyObject *__pyx_n_s_AsyncResult_successful;
-static PyObject *__pyx_n_s_AsyncResult_wait;
-static PyObject *__pyx_n_s_Event;
-static PyObject *__pyx_n_s_Event__reset_internal_locks;
-static PyObject *__pyx_n_s_Event_clear;
-static PyObject *__pyx_n_s_Event_isSet;
-static PyObject *__pyx_n_s_Event_is_set;
-static PyObject *__pyx_n_s_Event_ready;
-static PyObject *__pyx_n_s_Event_set;
-static PyObject *__pyx_n_s_Event_wait;
-static PyObject *__pyx_kp_s_Expected_callable_r;
-static PyObject *__pyx_n_s_InvalidSwitchError;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Event_wait_r;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_NONE;
-static PyObject *__pyx_n_s_None;
-static PyObject *__pyx_n_s_NotImplementedError;
-static PyObject *__pyx_n_s_Timeout;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_auto_unlink;
-static PyObject *__pyx_n_s_block;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_n_s_cancel;
-static PyObject *__pyx_n_s_cancelled;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_clear;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_done;
-static PyObject *__pyx_n_s_dump_traceback;
-static PyObject *__pyx_n_s_enter;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_exc_info_2;
-static PyObject *__pyx_n_s_exception;
-static PyObject *__pyx_n_s_exception_2;
-static PyObject *__pyx_kp_s_exception_r;
-static PyObject *__pyx_n_s_exit;
-static PyObject *__pyx_n_s_flag;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_get_nowait;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent__compat;
-static PyObject *__pyx_n_s_gevent__event;
-static PyObject *__pyx_n_s_gevent__hub_local;
-static PyObject *__pyx_n_s_gevent__tblib;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_gevent_timeout;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_kp_s_if_we_didn_t_wait_we_should_alre;
-static PyObject *__pyx_n_s_imap_task_index;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_isSet;
-static PyObject *__pyx_n_s_is_set;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_links;
-static PyObject *__pyx_kp_s_links_s;
-static PyObject *__pyx_n_s_load_traceback;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_notifier;
-static PyObject *__pyx_n_s_notify_links;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_raise_exception;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_ready;
-static PyObject *__pyx_n_s_reraise;
-static PyObject *__pyx_n_s_reset_internal_locks;
-static PyObject *__pyx_n_s_result;
-static PyObject *__pyx_n_s_run_callback;
-static PyObject *__pyx_kp_s_s;
-static PyObject *__pyx_kp_s_s_s__links_s;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_set;
-static PyObject *__pyx_n_s_set_exception;
-static PyObject *__pyx_n_s_set_result;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_n_s_source;
-static PyObject *__pyx_kp_s_src_gevent_event_py;
-static PyObject *__pyx_n_s_start_new_or_dummy;
-static PyObject *__pyx_n_s_successful;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_unlink;
-static PyObject *__pyx_kp_s_unset;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_value_2;
-static PyObject *__pyx_kp_s_value_r;
-static PyObject *__pyx_n_s_wait;
-static PyObject *__pyx_n_s_weakref;
-static PyObject *__pyx_lambda_funcdef_6gevent_6_event_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_6_event_17_AbstractLinkable___init__(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_2ready(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_4rawlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_6unlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_8_notify_links(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_3hub___get__(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_event_5Event___init__(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_2__str__(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_4is_set(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_6isSet(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_8ready(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_10set(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_12clear(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_14wait(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_5Event_16_reset_internal_locks(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_event_11AsyncResult___init__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_10_exception___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_5value___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_8exc_info___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_2__str__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_4ready(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_6successful(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_9exception___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_8set(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_10set_exception(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_exception, PyObject *__pyx_v_exc_info); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_12_raise_exception(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_14get(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_16get_nowait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_18wait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_20__call__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_source); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_22result(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_24done(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_26cancel(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_28cancelled(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_6_value___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_9_exc_info___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index_2__set__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_tp_new_6gevent_6_event__AbstractLinkable(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_event_Event(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_event_AsyncResult(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_k_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__16;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__20;
-static PyObject *__pyx_tuple__22;
-static PyObject *__pyx_tuple__24;
-static PyObject *__pyx_tuple__26;
-static PyObject *__pyx_tuple__28;
-static PyObject *__pyx_tuple__30;
-static PyObject *__pyx_tuple__31;
-static PyObject *__pyx_tuple__33;
-static PyObject *__pyx_tuple__35;
-static PyObject *__pyx_tuple__37;
-static PyObject *__pyx_tuple__39;
-static PyObject *__pyx_tuple__41;
-static PyObject *__pyx_tuple__43;
-static PyObject *__pyx_tuple__45;
-static PyObject *__pyx_tuple__47;
-static PyObject *__pyx_tuple__49;
-static PyObject *__pyx_tuple__51;
-static PyObject *__pyx_tuple__53;
-static PyObject *__pyx_codeobj__8;
-static PyObject *__pyx_codeobj__10;
-static PyObject *__pyx_codeobj__12;
-static PyObject *__pyx_codeobj__14;
-static PyObject *__pyx_codeobj__17;
-static PyObject *__pyx_codeobj__19;
-static PyObject *__pyx_codeobj__21;
-static PyObject *__pyx_codeobj__23;
-static PyObject *__pyx_codeobj__25;
-static PyObject *__pyx_codeobj__27;
-static PyObject *__pyx_codeobj__29;
-static PyObject *__pyx_codeobj__32;
-static PyObject *__pyx_codeobj__34;
-static PyObject *__pyx_codeobj__36;
-static PyObject *__pyx_codeobj__38;
-static PyObject *__pyx_codeobj__40;
-static PyObject *__pyx_codeobj__42;
-static PyObject *__pyx_codeobj__44;
-static PyObject *__pyx_codeobj__46;
-static PyObject *__pyx_codeobj__48;
-static PyObject *__pyx_codeobj__50;
-static PyObject *__pyx_codeobj__52;
-static PyObject *__pyx_codeobj__54;
-/* Late includes */
-
-/* "src/gevent/event.py":24
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_6_event_lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_6_event_lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_6_event_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_6_event_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_6_event_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":33
- * __slots__ = ('_links', 'hub', '_notifier')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Also previously, AsyncResult maintained the order of notifications, but Event
- * # did not; this implementation does not. (Event also only call callbacks one
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_event_17_AbstractLinkable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_event_17_AbstractLinkable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable___init__(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_event_17_AbstractLinkable___init__(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/event.py":44
- * # be an argument to maintain order. (One easy way to do that while guaranteeing
- * # uniqueness would be with a 2.7+ OrderedDict.)
- * self._links = set() # <<<<<<<<<<<<<<
- * self.hub = get_hub()
- * self._notifier = None
- */
- __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_links);
- __Pyx_DECREF(__pyx_v_self->_links);
- __pyx_v_self->_links = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":45
- * # uniqueness would be with a 2.7+ OrderedDict.)
- * self._links = set()
- * self.hub = get_hub() # <<<<<<<<<<<<<<
- * self._notifier = None
- *
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->hub));
- __pyx_v_self->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":46
- * self._links = set()
- * self.hub = get_hub()
- * self._notifier = None # <<<<<<<<<<<<<<
- *
- * def ready(self):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
-
- /* "src/gevent/event.py":33
- * __slots__ = ('_links', 'hub', '_notifier')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * # Also previously, AsyncResult maintained the order of notifications, but Event
- * # did not; this implementation does not. (Event also only call callbacks one
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":48
- * self._notifier = None
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # Instances must define this
- * raise NotImplementedError()
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_3ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_17_AbstractLinkable_ready(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("ready", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_3ready)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":50
- * def ready(self):
- * # Instances must define this
- * raise NotImplementedError() # <<<<<<<<<<<<<<
- *
- * def _check_and_notify(self):
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 50, __pyx_L1_error)
-
- /* "src/gevent/event.py":48
- * self._notifier = None
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # Instances must define this
- * raise NotImplementedError()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event._AbstractLinkable.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_3ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_17_AbstractLinkable_2ready[] = "_AbstractLinkable.ready(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_6_event_17_AbstractLinkable_3ready = {"ready", (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_3ready, METH_NOARGS, __pyx_doc_6gevent_6_event_17_AbstractLinkable_2ready};
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_3ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ready (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable_2ready(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_2ready(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("ready", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_17_AbstractLinkable_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":52
- * raise NotImplementedError()
- *
- * def _check_and_notify(self): # <<<<<<<<<<<<<<
- * # If this object is ready to be notified, begin the process.
- * if self.ready():
- */
-
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__check_and_notify(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("_check_and_notify", 0);
-
- /* "src/gevent/event.py":54
- * def _check_and_notify(self):
- * # If this object is ready to be notified, begin the process.
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self._links and not self._notifier:
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":55
- * # If this object is ready to be notified, begin the process.
- * if self.ready():
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- */
- __pyx_t_2 = (__pyx_v_self->_links != Py_None)&&(PySet_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 55, __pyx_L1_error)
- __pyx_t_3 = ((!__pyx_t_2) != 0);
- __pyx_t_1 = __pyx_t_3;
- __pyx_L5_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":56
- * if self.ready():
- * if self._links and not self._notifier:
- * self._notifier = self.hub.loop.run_callback(self._notify_links) # <<<<<<<<<<<<<<
- *
- * def rawlink(self, callback):
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->hub->loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/event.py":55
- * # If this object is ready to be notified, begin the process.
- * if self.ready():
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- */
- }
-
- /* "src/gevent/event.py":54
- * def _check_and_notify(self):
- * # If this object is ready to be notified, begin the process.
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self._links and not self._notifier:
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- */
- }
-
- /* "src/gevent/event.py":52
- * raise NotImplementedError()
- *
- * def _check_and_notify(self): # <<<<<<<<<<<<<<
- * # If this object is ready to be notified, begin the process.
- * if self.ready():
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._check_and_notify", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":58
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callback to call when this object is ready.
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_5rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable_rawlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("rawlink", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_5rawlink)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":65
- * *callback* will be passed one argument: this instance.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.add(callback)
- */
- __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 65, __pyx_L1_error)
- __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/event.py":66
- * """
- * if not callable(callback):
- * raise TypeError('Expected callable: %r' % (callback, )) # <<<<<<<<<<<<<<
- * self._links.add(callback)
- * self._check_and_notify()
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 66, __pyx_L1_error)
-
- /* "src/gevent/event.py":65
- * *callback* will be passed one argument: this instance.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.add(callback)
- */
- }
-
- /* "src/gevent/event.py":67
- * if not callable(callback):
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.add(callback) # <<<<<<<<<<<<<<
- * self._check_and_notify()
- *
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "add");
- __PYX_ERR(0, 67, __pyx_L1_error)
- }
- __pyx_t_8 = PySet_Add(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 67, __pyx_L1_error)
-
- /* "src/gevent/event.py":68
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.add(callback)
- * self._check_and_notify() # <<<<<<<<<<<<<<
- *
- * def unlink(self, callback):
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_check_and_notify(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":58
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callback to call when this object is ready.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_5rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_6_event_17_AbstractLinkable_4rawlink[] = "_AbstractLinkable.rawlink(self, callback)\n\n Register a callback to call when this object is ready.\n\n *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.\n *callback* will be passed one argument: this instance.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_17_AbstractLinkable_5rawlink = {"rawlink", (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_5rawlink, METH_O, __pyx_doc_6gevent_6_event_17_AbstractLinkable_4rawlink};
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_5rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("rawlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable_4rawlink(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_4rawlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("rawlink", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_event_17_AbstractLinkable_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":70
- * self._check_and_notify()
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`rawlink`"""
- * try:
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_7unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable_unlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- int __pyx_t_10;
- __Pyx_RefNannySetupContext("unlink", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_7unlink)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":72
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * except KeyError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/event.py":73
- * """Remove the callback set by :meth:`rawlink`"""
- * try:
- * self._links.remove(callback) # <<<<<<<<<<<<<<
- * except KeyError:
- * pass
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "remove");
- __PYX_ERR(0, 73, __pyx_L3_error)
- }
- __pyx_t_9 = __Pyx_PySet_Remove(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 73, __pyx_L3_error)
-
- /* "src/gevent/event.py":72
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * except KeyError:
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":74
- * try:
- * self._links.remove(callback)
- * except KeyError: # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_10) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/event.py":72
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback)
- * except KeyError:
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/event.py":70
- * self._check_and_notify()
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`rawlink`"""
- * try:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_7unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_6_event_17_AbstractLinkable_6unlink[] = "_AbstractLinkable.unlink(self, callback)\nRemove the callback set by :meth:`rawlink`";
-static PyMethodDef __pyx_mdef_6gevent_6_event_17_AbstractLinkable_7unlink = {"unlink", (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_7unlink, METH_O, __pyx_doc_6gevent_6_event_17_AbstractLinkable_6unlink};
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_7unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable_6unlink(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_6unlink(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("unlink", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_event_17_AbstractLinkable_unlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":77
- * pass
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Actually call the notification callbacks. Those callbacks in todo that are
- * # still in _links are called. This method is careful to avoid iterating
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_9_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__notify_links(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_todo = 0;
- PyObject *__pyx_v_link = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- Py_ssize_t __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_9_notify_links)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":88
- * # this callback; any links removed between now and then are handled
- * # by the `if` below; any links added are also grabbed
- * todo = set(self._links) # <<<<<<<<<<<<<<
- * for link in todo:
- * # check that link was not notified yet and was not removed by the client
- */
- __pyx_t_1 = PySet_New(__pyx_v_self->_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_todo = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":89
- * # by the `if` below; any links added are also grabbed
- * todo = set(self._links)
- * for link in todo: # <<<<<<<<<<<<<<
- * # check that link was not notified yet and was not removed by the client
- * # We have to do this here, and not as part of the 'for' statement because
- */
- __pyx_t_5 = 0;
- __pyx_t_2 = __Pyx_set_iterator(__pyx_v_todo, 1, (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_1);
- __pyx_t_1 = __pyx_t_2;
- __pyx_t_2 = 0;
- while (1) {
- __pyx_t_8 = __Pyx_set_iter_next(__pyx_t_1, __pyx_t_6, &__pyx_t_5, &__pyx_t_2, __pyx_t_7);
- if (unlikely(__pyx_t_8 == 0)) break;
- if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":93
- * # We have to do this here, and not as part of the 'for' statement because
- * # a previous link(self) call might have altered self._links
- * if link in self._links: # <<<<<<<<<<<<<<
- * try:
- * link(self)
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 93, __pyx_L1_error)
- }
- __pyx_t_9 = (__Pyx_PySet_ContainsTF(__pyx_v_link, __pyx_v_self->_links, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
- __pyx_t_10 = (__pyx_t_9 != 0);
- if (__pyx_t_10) {
-
- /* "src/gevent/event.py":94
- * # a previous link(self) call might have altered self._links
- * if link in self._links:
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- /*try:*/ {
-
- /* "src/gevent/event.py":95
- * if link in self._links:
- * try:
- * link(self) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * self.hub.handle_error((link, self), *sys.exc_info())
- */
- __Pyx_INCREF(__pyx_v_link);
- __pyx_t_3 = __pyx_v_link; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 95, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_14, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":94
- * # a previous link(self) call might have altered self._links
- * if link in self._links:
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- goto __pyx_L13_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":96
- * try:
- * link(self)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * self.hub.handle_error((link, self), *sys.exc_info())
- * if getattr(link, 'auto_unlink', None):
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 96, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_14);
-
- /* "src/gevent/event.py":97
- * link(self)
- * except: # pylint:disable=bare-except
- * self.hub.handle_error((link, self), *sys.exc_info()) # <<<<<<<<<<<<<<
- * if getattr(link, 'auto_unlink', None):
- * # This attribute can avoid having to keep a reference to the function
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hub), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_INCREF(__pyx_v_link);
- __Pyx_GIVEREF(__pyx_v_link);
- PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_link);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_15, 1, ((PyObject *)__pyx_v_self));
- __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_GIVEREF(__pyx_t_15);
- PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15);
- __pyx_t_15 = 0;
- __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_17);
- __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- __pyx_t_17 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
- __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_18);
- if (likely(__pyx_t_17)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
- __Pyx_INCREF(__pyx_t_17);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_18, function);
- }
- }
- if (__pyx_t_17) {
- __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_17); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- } else {
- __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- }
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- __pyx_t_18 = __Pyx_PySequence_Tuple(__pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __pyx_t_15 = PyNumber_Add(__pyx_t_16, __pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_15, NULL); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 97, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- goto __pyx_L7_exception_handled;
- }
- __pyx_L8_except_error:;
-
- /* "src/gevent/event.py":94
- * # a previous link(self) call might have altered self._links
- * if link in self._links:
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- goto __pyx_L1_error;
- __pyx_L7_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_L13_try_end:;
- }
-
- /* "src/gevent/event.py":98
- * except: # pylint:disable=bare-except
- * self.hub.handle_error((link, self), *sys.exc_info())
- * if getattr(link, 'auto_unlink', None): # <<<<<<<<<<<<<<
- * # This attribute can avoid having to keep a reference to the function
- * # *in* the function, which is a cycle
- */
- __pyx_t_14 = __Pyx_GetAttr3(__pyx_v_link, __pyx_n_s_auto_unlink, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_14);
- __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- if (__pyx_t_10) {
-
- /* "src/gevent/event.py":101
- * # This attribute can avoid having to keep a reference to the function
- * # *in* the function, which is a cycle
- * self.unlink(link) # <<<<<<<<<<<<<<
- *
- * # save a tiny bit of memory by letting _notifier be collected
- */
- __pyx_t_14 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_link, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-
- /* "src/gevent/event.py":98
- * except: # pylint:disable=bare-except
- * self.hub.handle_error((link, self), *sys.exc_info())
- * if getattr(link, 'auto_unlink', None): # <<<<<<<<<<<<<<
- * # This attribute can avoid having to keep a reference to the function
- * # *in* the function, which is a cycle
- */
- }
-
- /* "src/gevent/event.py":93
- * # We have to do this here, and not as part of the 'for' statement because
- * # a previous link(self) call might have altered self._links
- * if link in self._links: # <<<<<<<<<<<<<<
- * try:
- * link(self)
- */
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":106
- * # bool(self._notifier) would turn to False as soon as we exit this
- * # method anyway.
- * del todo # <<<<<<<<<<<<<<
- * self._notifier = None
- *
- */
- __Pyx_DECREF(__pyx_v_todo);
- __pyx_v_todo = NULL;
-
- /* "src/gevent/event.py":107
- * # method anyway.
- * del todo
- * self._notifier = None # <<<<<<<<<<<<<<
- *
- * def _wait_core(self, timeout, catch=Timeout):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
-
- /* "src/gevent/event.py":77
- * pass
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Actually call the notification callbacks. Those callbacks in todo that are
- * # still in _links are called. This method is careful to avoid iterating
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_XDECREF(__pyx_t_16);
- __Pyx_XDECREF(__pyx_t_17);
- __Pyx_XDECREF(__pyx_t_18);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_todo);
- __Pyx_XDECREF(__pyx_v_link);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_9_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_17_AbstractLinkable_8_notify_links[] = "_AbstractLinkable._notify_links(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_event_17_AbstractLinkable_9_notify_links = {"_notify_links", (PyCFunction)__pyx_pw_6gevent_6_event_17_AbstractLinkable_9_notify_links, METH_NOARGS, __pyx_doc_6gevent_6_event_17_AbstractLinkable_8_notify_links};
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_9_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable_8_notify_links(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_8_notify_links(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_event_17_AbstractLinkable__notify_links(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":109
- * self._notifier = None
- *
- * def _wait_core(self, timeout, catch=Timeout): # <<<<<<<<<<<<<<
- * # The core of the wait implementation, handling
- * # switching and linking. If *catch* is set to (),
- */
-
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_core(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_timeout, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args) {
- PyObject *__pyx_v_catch = __pyx_k_;
- PyObject *__pyx_v_switch = NULL;
- PyObject *__pyx_v_timer = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_ex = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- int __pyx_t_12;
- int __pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- int __pyx_t_15;
- int __pyx_t_16;
- char const *__pyx_t_17;
- __Pyx_RefNannySetupContext("_wait_core", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_catch = __pyx_optional_args->catch;
- }
- }
-
- /* "src/gevent/event.py":114
- * # a timeout that elapses will be allowed to be raised.
- * # Returns a true value if the wait succeeded without timing out.
- * switch = getcurrent().switch # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.rawlink(switch)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_event_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_switch = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":115
- * # Returns a true value if the wait succeeded without timing out.
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch) # <<<<<<<<<<<<<<
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer:
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":116
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * with Timeout._start_new_or_dummy(timeout) as timer:
- * try:
- */
- /*try:*/ {
-
- /* "src/gevent/event.py":117
- * self.rawlink(switch)
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer: # <<<<<<<<<<<<<<
- * try:
- * result = self.hub.switch()
- */
- /*with:*/ {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_6_event_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L6_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L6_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __pyx_t_1;
- __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- /*try:*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
- __pyx_v_timer = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/event.py":118
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer:
- * try: # <<<<<<<<<<<<<<
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- /*try:*/ {
-
- /* "src/gevent/event.py":119
- * with Timeout._start_new_or_dummy(timeout) as timer:
- * try:
- * result = self.hub.switch() # <<<<<<<<<<<<<<
- * if result is not self: # pragma: no cover
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_self->hub->__pyx_vtab)->__pyx_switch(__pyx_v_self->hub, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L16_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_result = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/event.py":120
- * try:
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- * return True
- */
- __pyx_t_12 = (__pyx_v_result != ((PyObject *)__pyx_v_self));
- __pyx_t_13 = (__pyx_t_12 != 0);
- if (unlikely(__pyx_t_13)) {
-
- /* "src/gevent/event.py":121
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, )) # <<<<<<<<<<<<<<
- * return True
- * except catch as ex:
- */
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_result);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Event_wait_r, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_6_event_InvalidSwitchError);
- __pyx_t_2 = __pyx_v_6gevent_6_event_InvalidSwitchError; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L16_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 121, __pyx_L16_error)
-
- /* "src/gevent/event.py":120
- * try:
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- * return True
- */
- }
-
- /* "src/gevent/event.py":122
- * if result is not self: # pragma: no cover
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- * return True # <<<<<<<<<<<<<<
- * except catch as ex:
- * if ex is not timer:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(Py_True);
- __pyx_r = Py_True;
- goto __pyx_L20_try_return;
-
- /* "src/gevent/event.py":118
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer:
- * try: # <<<<<<<<<<<<<<
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover
- */
- }
- __pyx_L16_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/event.py":123
- * raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- * return True
- * except catch as ex: # <<<<<<<<<<<<<<
- * if ex is not timer:
- * raise
- */
- __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_v_catch);
- if (__pyx_t_15) {
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_14) < 0) __PYX_ERR(0, 123, __pyx_L18_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_INCREF(__pyx_t_2);
- __pyx_v_ex = __pyx_t_2;
-
- /* "src/gevent/event.py":124
- * return True
- * except catch as ex:
- * if ex is not timer: # <<<<<<<<<<<<<<
- * raise
- * # test_set_and_clear and test_timeout in test_threading
- */
- __pyx_t_13 = (__pyx_v_ex != __pyx_v_timer);
- __pyx_t_12 = (__pyx_t_13 != 0);
- if (unlikely(__pyx_t_12)) {
-
- /* "src/gevent/event.py":125
- * except catch as ex:
- * if ex is not timer:
- * raise # <<<<<<<<<<<<<<
- * # test_set_and_clear and test_timeout in test_threading
- * # rely on the exact return values, not just truthish-ness
- */
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_2, __pyx_t_14);
- __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_14 = 0;
- __PYX_ERR(0, 125, __pyx_L18_except_error)
-
- /* "src/gevent/event.py":124
- * return True
- * except catch as ex:
- * if ex is not timer: # <<<<<<<<<<<<<<
- * raise
- * # test_set_and_clear and test_timeout in test_threading
- */
- }
-
- /* "src/gevent/event.py":128
- * # test_set_and_clear and test_timeout in test_threading
- * # rely on the exact return values, not just truthish-ness
- * return False # <<<<<<<<<<<<<<
- * finally:
- * self.unlink(switch)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(Py_False);
- __pyx_r = Py_False;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- goto __pyx_L19_except_return;
- }
- goto __pyx_L18_except_error;
- __pyx_L18_except_error:;
-
- /* "src/gevent/event.py":118
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer:
- * try: # <<<<<<<<<<<<<<
- * result = self.hub.switch()
- * if result is not self: # pragma: no cover
- */
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- goto __pyx_L10_error;
- __pyx_L20_try_return:;
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- goto __pyx_L14_try_return;
- __pyx_L19_except_return:;
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- goto __pyx_L14_try_return;
- }
-
- /* "src/gevent/event.py":117
- * self.rawlink(switch)
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer: # <<<<<<<<<<<<<<
- * try:
- * result = self.hub.switch()
- */
- }
- __pyx_L10_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- /*except:*/ {
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 117, __pyx_L12_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyTuple_Pack(3, __pyx_t_14, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L12_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 117, __pyx_L12_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- if (__pyx_t_12 < 0) __PYX_ERR(0, 117, __pyx_L12_except_error)
- __pyx_t_13 = ((!(__pyx_t_12 != 0)) != 0);
- if (__pyx_t_13) {
- __Pyx_GIVEREF(__pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ErrRestoreWithState(__pyx_t_14, __pyx_t_2, __pyx_t_4);
- __pyx_t_14 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0;
- __PYX_ERR(0, 117, __pyx_L12_except_error)
- }
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L11_exception_handled;
- }
- __pyx_L12_except_error:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L4_error;
- __pyx_L14_try_return:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L7_return;
- __pyx_L11_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- }
- }
- /*finally:*/ {
- /*normal exit:*/{
- if (__pyx_t_5) {
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__2, NULL);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- goto __pyx_L9;
- }
- __pyx_L7_return: {
- __pyx_t_8 = __pyx_r;
- __pyx_r = 0;
- if (__pyx_t_5) {
- __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__3, NULL);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __pyx_r = __pyx_t_8;
- __pyx_t_8 = 0;
- goto __pyx_L3_return;
- }
- __pyx_L9:;
- }
- goto __pyx_L29;
- __pyx_L6_error:;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- goto __pyx_L4_error;
- __pyx_L29:;
- }
- }
-
- /* "src/gevent/event.py":130
- * return False
- * finally:
- * self.unlink(switch) # <<<<<<<<<<<<<<
- *
- * def _wait_return_value(self, waited, wait_success):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_5 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_6, &__pyx_t_11, &__pyx_t_10);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_5, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_8, &__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_10);
- __pyx_t_15 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
- {
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L31_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_11, __pyx_t_10);
- }
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ErrRestore(__pyx_t_5, __pyx_t_8, __pyx_t_7);
- __pyx_t_5 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
- __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
- goto __pyx_L1_error;
- __pyx_L31_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_11, __pyx_t_10);
- }
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_6 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_10 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_10;
- __pyx_t_10 = 0;
- goto __pyx_L0;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/event.py":109
- * self._notifier = None
- *
- * def _wait_core(self, timeout, catch=Timeout): # <<<<<<<<<<<<<<
- * # The core of the wait implementation, handling
- * # switching and linking. If *catch* is set to (),
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_switch);
- __Pyx_XDECREF(__pyx_v_timer);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_ex);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":132
- * self.unlink(switch)
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # pylint:disable=unused-argument
- * return None
- */
-
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_return_value(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_waited, CYTHON_UNUSED PyObject *__pyx_v_wait_success) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_wait_return_value", 0);
-
- /* "src/gevent/event.py":134
- * def _wait_return_value(self, waited, wait_success):
- * # pylint:disable=unused-argument
- * return None # <<<<<<<<<<<<<<
- *
- * def _wait(self, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/event.py":132
- * self.unlink(switch)
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # pylint:disable=unused-argument
- * return None
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":136
- * return None
- *
- * def _wait(self, timeout=None): # <<<<<<<<<<<<<<
- * if self.ready():
- * return self._wait_return_value(False, False)
- */
-
-static PyObject *__pyx_f_6gevent_6_event_17_AbstractLinkable__wait(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_gotit = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_wait", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
-
- /* "src/gevent/event.py":137
- *
- * def _wait(self, timeout=None):
- * if self.ready(): # <<<<<<<<<<<<<<
- * return self._wait_return_value(False, False)
- *
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":138
- * def _wait(self, timeout=None):
- * if self.ready():
- * return self._wait_return_value(False, False) # <<<<<<<<<<<<<<
- *
- * gotit = self._wait_core(timeout)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_return_value(__pyx_v_self, Py_False, Py_False); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":137
- *
- * def _wait(self, timeout=None):
- * if self.ready(): # <<<<<<<<<<<<<<
- * return self._wait_return_value(False, False)
- *
- */
- }
-
- /* "src/gevent/event.py":140
- * return self._wait_return_value(False, False)
- *
- * gotit = self._wait_core(timeout) # <<<<<<<<<<<<<<
- * return self._wait_return_value(True, gotit)
- *
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_core(__pyx_v_self, __pyx_v_timeout, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_gotit = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":141
- *
- * gotit = self._wait_core(timeout)
- * return self._wait_return_value(True, gotit) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_return_value(__pyx_v_self, Py_True, __pyx_v_gotit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":136
- * return None
- *
- * def _wait(self, timeout=None): # <<<<<<<<<<<<<<
- * if self.ready():
- * return self._wait_return_value(False, False)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._event._AbstractLinkable._wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_gotit);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":46
- * cdef _notifier
- * cdef set _links
- * cdef readonly SwitchOutGreenletWithLoop hub # <<<<<<<<<<<<<<
- *
- * cpdef rawlink(self, callback)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_3hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_17_AbstractLinkable_3hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_17_AbstractLinkable_3hub___get__(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_17_AbstractLinkable_3hub___get__(struct __pyx_obj_6gevent_6_event__AbstractLinkable *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->hub));
- __pyx_r = ((PyObject *)__pyx_v_self->hub);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":162
- * __slots__ = ('_flag', '__weakref__')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * _AbstractLinkable.__init__(self)
- * self._flag = False
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_event_5Event_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_event_5Event_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_6_event_5Event___init__(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_event_5Event___init__(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/event.py":163
- *
- * def __init__(self):
- * _AbstractLinkable.__init__(self) # <<<<<<<<<<<<<<
- * self._flag = False
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":164
- * def __init__(self):
- * _AbstractLinkable.__init__(self)
- * self._flag = False # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __pyx_v_self->_flag = 0;
-
- /* "src/gevent/event.py":162
- * __slots__ = ('_flag', '__weakref__')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * _AbstractLinkable.__init__(self)
- * self._flag = False
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._event.Event.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":166
- * self._flag = False
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_3__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_5Event_3__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_2__str__(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_2__str__(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/event.py":167
- *
- * def __str__(self):
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links)) # <<<<<<<<<<<<<<
- *
- * def is_set(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!__pyx_v_self->_flag) {
- goto __pyx_L4_next_or;
- } else {
- }
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_n_s_set); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 167, __pyx_L1_error)
- if (!__pyx_t_3) {
- } else {
- __Pyx_INCREF(__pyx_n_s_set);
- __pyx_t_1 = __pyx_n_s_set;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_L4_next_or:;
- __Pyx_INCREF(__pyx_n_s_clear);
- __pyx_t_1 = __pyx_n_s_clear;
- __pyx_L3_bool_binop_done:;
- __pyx_t_4 = __pyx_v_self->__pyx_base._links;
- __Pyx_INCREF(__pyx_t_4);
- if (unlikely(__pyx_t_4 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 167, __pyx_L1_error)
- }
- __pyx_t_5 = PySet_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_s__links_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":166
- * self._flag = False
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._event.Event.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":169
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- * def is_set(self): # <<<<<<<<<<<<<<
- * """Return true if and only if the internal flag is true."""
- * return self._flag
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_5is_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_4is_set[] = "Event.is_set(self)\nReturn true if and only if the internal flag is true.";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_5is_set = {"is_set", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_5is_set, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_4is_set};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_5is_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("is_set (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_4is_set(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_4is_set(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("is_set", 0);
-
- /* "src/gevent/event.py":171
- * def is_set(self):
- * """Return true if and only if the internal flag is true."""
- * return self._flag # <<<<<<<<<<<<<<
- *
- * def isSet(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":169
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- * def is_set(self): # <<<<<<<<<<<<<<
- * """Return true if and only if the internal flag is true."""
- * return self._flag
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.Event.is_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":173
- * return self._flag
- *
- * def isSet(self): # <<<<<<<<<<<<<<
- * # makes it a better drop-in replacement for threading.Event
- * return self._flag
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_7isSet(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_6isSet[] = "Event.isSet(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_7isSet = {"isSet", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_7isSet, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_6isSet};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_7isSet(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("isSet (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_6isSet(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_6isSet(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("isSet", 0);
-
- /* "src/gevent/event.py":175
- * def isSet(self):
- * # makes it a better drop-in replacement for threading.Event
- * return self._flag # <<<<<<<<<<<<<<
- *
- * def ready(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":173
- * return self._flag
- *
- * def isSet(self): # <<<<<<<<<<<<<<
- * # makes it a better drop-in replacement for threading.Event
- * return self._flag
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.Event.isSet", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":177
- * return self._flag
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # makes it compatible with AsyncResult and Greenlet (for
- * # example in wait())
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_5Event_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_5Event_ready(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("ready", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_5Event_9ready)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":180
- * # makes it compatible with AsyncResult and Greenlet (for
- * # example in wait())
- * return self._flag # <<<<<<<<<<<<<<
- *
- * def set(self):
- */
- __pyx_r = __pyx_v_self->_flag;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":177
- * return self._flag
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # makes it compatible with AsyncResult and Greenlet (for
- * # example in wait())
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.Event.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_8ready[] = "Event.ready(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_9ready = {"ready", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_9ready, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_8ready};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ready (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_8ready(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_8ready(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("ready", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_5Event_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.Event.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":182
- * return self._flag
- *
- * def set(self): # <<<<<<<<<<<<<<
- * """
- * Set the internal flag to true.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_11set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_10set[] = "Event.set(self)\n\n Set the internal flag to true.\n\n All greenlets waiting for it to become true are awakened in\n some order at some time in the future. Greenlets that call\n :meth:`wait` once the flag is true will not block at all\n (until :meth:`clear` is called).\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_11set = {"set", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_11set, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_10set};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_11set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_10set(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_10set(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("set", 0);
-
- /* "src/gevent/event.py":191
- * (until :meth:`clear` is called).
- * """
- * self._flag = True # <<<<<<<<<<<<<<
- * self._check_and_notify()
- *
- */
- __pyx_v_self->_flag = 1;
-
- /* "src/gevent/event.py":192
- * """
- * self._flag = True
- * self._check_and_notify() # <<<<<<<<<<<<<<
- *
- * def clear(self):
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_Event *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._check_and_notify(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":182
- * return self._flag
- *
- * def set(self): # <<<<<<<<<<<<<<
- * """
- * Set the internal flag to true.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.Event.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":194
- * self._check_and_notify()
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * """
- * Reset the internal flag to false.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_12clear[] = "Event.clear(self)\n\n Reset the internal flag to false.\n\n Subsequently, threads calling :meth:`wait` will block until\n :meth:`set` is called to set the internal flag to true again.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_13clear = {"clear", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_13clear, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_12clear};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("clear (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_12clear(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_12clear(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("clear", 0);
-
- /* "src/gevent/event.py":201
- * :meth:`set` is called to set the internal flag to true again.
- * """
- * self._flag = False # <<<<<<<<<<<<<<
- *
- * def _wait_return_value(self, waited, wait_success):
- */
- __pyx_v_self->_flag = 0;
-
- /* "src/gevent/event.py":194
- * self._check_and_notify()
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * """
- * Reset the internal flag to false.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":203
- * self._flag = False
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # To avoid the race condition outlined in http://bugs.python.org/issue13502,
- * # if we had to wait, then we need to return whether or not
- */
-
-static PyObject *__pyx_f_6gevent_6_event_5Event__wait_return_value(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, PyObject *__pyx_v_waited, PyObject *__pyx_v_wait_success) {
- int __pyx_v_flag;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_wait_return_value", 0);
-
- /* "src/gevent/event.py":208
- * # the condition got changed. Otherwise we simply echo
- * # the current state of the flag (which should be true)
- * if not waited: # <<<<<<<<<<<<<<
- * flag = self._flag
- * assert flag, "if we didn't wait we should already be set"
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_waited); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/event.py":209
- * # the current state of the flag (which should be true)
- * if not waited:
- * flag = self._flag # <<<<<<<<<<<<<<
- * assert flag, "if we didn't wait we should already be set"
- * return flag
- */
- __pyx_t_2 = __pyx_v_self->_flag;
- __pyx_v_flag = __pyx_t_2;
-
- /* "src/gevent/event.py":210
- * if not waited:
- * flag = self._flag
- * assert flag, "if we didn't wait we should already be set" # <<<<<<<<<<<<<<
- * return flag
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- if (unlikely(!(__pyx_v_flag != 0))) {
- PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_if_we_didn_t_wait_we_should_alre);
- __PYX_ERR(0, 210, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/event.py":211
- * flag = self._flag
- * assert flag, "if we didn't wait we should already be set"
- * return flag # <<<<<<<<<<<<<<
- *
- * return wait_success
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_flag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":208
- * # the condition got changed. Otherwise we simply echo
- * # the current state of the flag (which should be true)
- * if not waited: # <<<<<<<<<<<<<<
- * flag = self._flag
- * assert flag, "if we didn't wait we should already be set"
- */
- }
-
- /* "src/gevent/event.py":213
- * return flag
- *
- * return wait_success # <<<<<<<<<<<<<<
- *
- * def wait(self, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_wait_success);
- __pyx_r = __pyx_v_wait_success;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":203
- * self._flag = False
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # To avoid the race condition outlined in http://bugs.python.org/issue13502,
- * # if we had to wait, then we need to return whether or not
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._event.Event._wait_return_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":215
- * return wait_success
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Block until the internal flag is true.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_15wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_14wait[] = "Event.wait(self, timeout=None)\n\n Block until the internal flag is true.\n\n If the internal flag is true on entry, return immediately. Otherwise,\n block until another thread (greenlet) calls :meth:`set` to set the flag to true,\n or until the optional timeout occurs.\n\n When the *timeout* argument is present and not ``None``, it should be a\n floating point number specifying a timeout for the operation in seconds\n (or fractions thereof).\n\n :return: This method returns true if and only if the internal flag has been set to\n true, either before the wait call or after the wait starts, so it will\n always return ``True`` except if a timeout is given and the operation\n times out.\n\n .. versionchanged:: 1.1\n The return value represents the flag during the elapsed wait, not\n just after it elapses. This solves a race condition if one greenlet\n sets and then clears the flag without switching, while other greenlets\n are waiting. When the waiters wake up, this will return True; previously,\n they would still wake up, but the return value would be False. This is most\n noticeable when the *timeout* is present.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_15wait = {"wait", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_15wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_5Event_14wait};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_15wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) __PYX_ERR(0, 215, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 215, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.Event.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_14wait(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_14wait(struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait __pyx_t_2;
- __Pyx_RefNannySetupContext("wait", 0);
-
- /* "src/gevent/event.py":240
- * noticeable when the *timeout* is present.
- * """
- * return self._wait(timeout) # <<<<<<<<<<<<<<
- *
- * def _reset_internal_locks(self): # pragma: no cover
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_Event *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._wait(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":215
- * return wait_success
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Block until the internal flag is true.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.Event.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":242
- * return self._wait(timeout)
- *
- * def _reset_internal_locks(self): # pragma: no cover # <<<<<<<<<<<<<<
- * # for compatibility with threading.Event
- * # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_5Event_17_reset_internal_locks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_5Event_16_reset_internal_locks[] = "Event._reset_internal_locks(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_event_5Event_17_reset_internal_locks = {"_reset_internal_locks", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_17_reset_internal_locks, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_16_reset_internal_locks};
-static PyObject *__pyx_pw_6gevent_6_event_5Event_17_reset_internal_locks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_reset_internal_locks (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_5Event_16_reset_internal_locks(((struct __pyx_obj_6gevent_6_event_Event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_5Event_16_reset_internal_locks(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_Event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_reset_internal_locks", 0);
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":301
- * __slots__ = ('_value', '_exc_info', '_imap_task_index')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * _AbstractLinkable.__init__(self)
- * self._value = _NONE
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_event_11AsyncResult_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_event_11AsyncResult_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult___init__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_event_11AsyncResult___init__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/event.py":302
- *
- * def __init__(self):
- * _AbstractLinkable.__init__(self) # <<<<<<<<<<<<<<
- * self._value = _NONE
- * self._exc_info = ()
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":303
- * def __init__(self):
- * _AbstractLinkable.__init__(self)
- * self._value = _NONE # <<<<<<<<<<<<<<
- * self._exc_info = ()
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_value);
- __Pyx_DECREF(__pyx_v_self->_value);
- __pyx_v_self->_value = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":304
- * _AbstractLinkable.__init__(self)
- * self._value = _NONE
- * self._exc_info = () # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = __pyx_empty_tuple;
-
- /* "src/gevent/event.py":301
- * __slots__ = ('_value', '_exc_info', '_imap_task_index')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * _AbstractLinkable.__init__(self)
- * self._value = _NONE
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._event.AsyncResult.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":307
- *
- * @property
- * def _exception(self): # <<<<<<<<<<<<<<
- * return self._exc_info[1] if self._exc_info else _NONE
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_10_exception_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_10_exception_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_10_exception___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_10_exception___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/event.py":308
- * @property
- * def _exception(self):
- * return self._exc_info[1] if self._exc_info else _NONE # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = (__pyx_v_self->_exc_info != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->_exc_info) != 0);
- if (__pyx_t_2) {
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 308, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- } else {
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":307
- *
- * @property
- * def _exception(self): # <<<<<<<<<<<<<<
- * return self._exc_info[1] if self._exc_info else _NONE
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._event.AsyncResult._exception.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":311
- *
- * @property
- * def value(self): # <<<<<<<<<<<<<<
- * """
- * Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise,
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_5value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_5value___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_5value___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/event.py":316
- * ``None``
- * """
- * return self._value if self._value is not _NONE else None # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = (__pyx_v_self->_value != __pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if ((__pyx_t_3 != 0)) {
- __Pyx_INCREF(__pyx_v_self->_value);
- __pyx_t_1 = __pyx_v_self->_value;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_1 = Py_None;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":311
- *
- * @property
- * def value(self): # <<<<<<<<<<<<<<
- * """
- * Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise,
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._event.AsyncResult.value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":319
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * """
- * The three-tuple of exception information if :meth:`set_exception` was called.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_8exc_info_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_8exc_info_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_8exc_info___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_8exc_info___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/event.py":323
- * The three-tuple of exception information if :meth:`set_exception` was called.
- * """
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2]))
- * return ()
- */
- __pyx_t_1 = (__pyx_v_self->_exc_info != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->_exc_info) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":324
- * """
- * if self._exc_info:
- * return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2])) # <<<<<<<<<<<<<<
- * return ()
- *
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 324, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 324, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 324, __pyx_L1_error)
- }
- __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_6gevent_6_event_load_traceback);
- __pyx_t_6 = __pyx_v_6gevent_6_event_load_traceback; __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_6;
- __pyx_t_6 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":323
- * The three-tuple of exception information if :meth:`set_exception` was called.
- * """
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2]))
- * return ()
- */
- }
-
- /* "src/gevent/event.py":325
- * if self._exc_info:
- * return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2]))
- * return () # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_empty_tuple);
- __pyx_r = __pyx_empty_tuple;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":319
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * """
- * The three-tuple of exception information if :meth:`set_exception` was called.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._event.AsyncResult.exc_info.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":327
- * return ()
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * result = '<%s ' % (self.__class__.__name__, )
- * if self.value is not None or self._exception is not _NONE:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_3__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_3__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_2__str__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_2__str__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- int __pyx_t_4;
- int __pyx_t_5;
- Py_ssize_t __pyx_t_6;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/event.py":328
- *
- * def __str__(self):
- * result = '<%s ' % (self.__class__.__name__, ) # <<<<<<<<<<<<<<
- * if self.value is not None or self._exception is not _NONE:
- * result += 'value=%r ' % self.value
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_result = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":329
- * def __str__(self):
- * result = '<%s ' % (self.__class__.__name__, )
- * if self.value is not None or self._exception is not _NONE: # <<<<<<<<<<<<<<
- * result += 'value=%r ' % self.value
- * if self._exception is not None and self._exception is not _NONE:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = (__pyx_t_2 != Py_None);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (!__pyx_t_5) {
- } else {
- __pyx_t_3 = __pyx_t_5;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = (__pyx_t_2 != __pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = (__pyx_t_5 != 0);
- __pyx_t_3 = __pyx_t_4;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_3) {
-
- /* "src/gevent/event.py":330
- * result = '<%s ' % (self.__class__.__name__, )
- * if self.value is not None or self._exception is not _NONE:
- * result += 'value=%r ' % self.value # <<<<<<<<<<<<<<
- * if self._exception is not None and self._exception is not _NONE:
- * result += 'exception=%r ' % self._exception
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_value_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":329
- * def __str__(self):
- * result = '<%s ' % (self.__class__.__name__, )
- * if self.value is not None or self._exception is not _NONE: # <<<<<<<<<<<<<<
- * result += 'value=%r ' % self.value
- * if self._exception is not None and self._exception is not _NONE:
- */
- }
-
- /* "src/gevent/event.py":331
- * if self.value is not None or self._exception is not _NONE:
- * result += 'value=%r ' % self.value
- * if self._exception is not None and self._exception is not _NONE: # <<<<<<<<<<<<<<
- * result += 'exception=%r ' % self._exception
- * if self._exception is _NONE:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = (__pyx_t_1 != Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (__pyx_t_5) {
- } else {
- __pyx_t_3 = __pyx_t_5;
- goto __pyx_L7_bool_binop_done;
- }
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = (__pyx_t_1 != __pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = (__pyx_t_5 != 0);
- __pyx_t_3 = __pyx_t_4;
- __pyx_L7_bool_binop_done:;
- if (__pyx_t_3) {
-
- /* "src/gevent/event.py":332
- * result += 'value=%r ' % self.value
- * if self._exception is not None and self._exception is not _NONE:
- * result += 'exception=%r ' % self._exception # <<<<<<<<<<<<<<
- * if self._exception is _NONE:
- * result += 'unset '
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_exception_r, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":331
- * if self.value is not None or self._exception is not _NONE:
- * result += 'value=%r ' % self.value
- * if self._exception is not None and self._exception is not _NONE: # <<<<<<<<<<<<<<
- * result += 'exception=%r ' % self._exception
- * if self._exception is _NONE:
- */
- }
-
- /* "src/gevent/event.py":333
- * if self._exception is not None and self._exception is not _NONE:
- * result += 'exception=%r ' % self._exception
- * if self._exception is _NONE: # <<<<<<<<<<<<<<
- * result += 'unset '
- * return result + ' _links[%s]>' % len(self._links)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = (__pyx_t_2 == __pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/event.py":334
- * result += 'exception=%r ' % self._exception
- * if self._exception is _NONE:
- * result += 'unset ' # <<<<<<<<<<<<<<
- * return result + ' _links[%s]>' % len(self._links)
- *
- */
- __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_unset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":333
- * if self._exception is not None and self._exception is not _NONE:
- * result += 'exception=%r ' % self._exception
- * if self._exception is _NONE: # <<<<<<<<<<<<<<
- * result += 'unset '
- * return result + ' _links[%s]>' % len(self._links)
- */
- }
-
- /* "src/gevent/event.py":335
- * if self._exception is _NONE:
- * result += 'unset '
- * return result + ' _links[%s]>' % len(self._links) # <<<<<<<<<<<<<<
- *
- * def ready(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_v_self->__pyx_base._links;
- __Pyx_INCREF(__pyx_t_1);
- if (unlikely(__pyx_t_1 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 335, __pyx_L1_error)
- }
- __pyx_t_6 = PySet_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 335, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_links_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyNumber_Add(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":327
- * return ()
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * result = '<%s ' % (self.__class__.__name__, )
- * if self.value is not None or self._exception is not _NONE:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._event.AsyncResult.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":337
- * return result + ' _links[%s]>' % len(self._links)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exc_info or self._value is not _NONE
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_ready(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("ready", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_5ready)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":339
- * def ready(self):
- * """Return true if and only if it holds a value or an exception"""
- * return self._exc_info or self._value is not _NONE # <<<<<<<<<<<<<<
- *
- * def successful(self):
- */
- __pyx_t_6 = (__pyx_v_self->_exc_info != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->_exc_info) != 0);
- if (!__pyx_t_6) {
- } else {
- __pyx_t_5 = __pyx_t_6;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = (__pyx_v_self->_value != __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_7 = (__pyx_t_6 != 0);
- __pyx_t_5 = __pyx_t_7;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":337
- * return result + ' _links[%s]>' % len(self._links)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exc_info or self._value is not _NONE
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.AsyncResult.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_4ready[] = "AsyncResult.ready(self) -> bool\nReturn true if and only if it holds a value or an exception";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_5ready = {"ready", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_5ready, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_4ready};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ready (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_4ready(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_4ready(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("ready", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_11AsyncResult_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":341
- * return self._exc_info or self._value is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._value is not _NONE
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_7successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_successful(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("successful", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_successful); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_7successful)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":343
- * def successful(self):
- * """Return true if and only if it is ready and holds a value"""
- * return self._value is not _NONE # <<<<<<<<<<<<<<
- *
- * @property
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = (__pyx_v_self->_value != __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":341
- * return self._exc_info or self._value is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._value is not _NONE
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.AsyncResult.successful", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_7successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_6successful[] = "AsyncResult.successful(self) -> bool\nReturn true if and only if it is ready and holds a value";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_7successful = {"successful", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_7successful, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_6successful};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_7successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("successful (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_6successful(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_6successful(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("successful", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_11AsyncResult_successful(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.successful", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":346
- *
- * @property
- * def exception(self): # <<<<<<<<<<<<<<
- * """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.
- * Otherwise ``None``."""
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9exception_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_9exception___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_9exception___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/event.py":349
- * """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.
- * Otherwise ``None``."""
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return self._exc_info[1]
- *
- */
- __pyx_t_1 = (__pyx_v_self->_exc_info != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->_exc_info) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":350
- * Otherwise ``None``."""
- * if self._exc_info:
- * return self._exc_info[1] # <<<<<<<<<<<<<<
- *
- * def set(self, value=None):
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 350, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":349
- * """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.
- * Otherwise ``None``."""
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return self._exc_info[1]
- *
- */
- }
-
- /* "src/gevent/event.py":346
- *
- * @property
- * def exception(self): # <<<<<<<<<<<<<<
- * """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.
- * Otherwise ``None``."""
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._event.AsyncResult.exception.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":352
- * return self._exc_info[1]
- *
- * def set(self, value=None): # <<<<<<<<<<<<<<
- * """Store the value and wake up any waiters.
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_8set[] = "AsyncResult.set(self, value=None)\nStore the value and wake up any waiters.\n\n All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.\n Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_9set = {"set", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_9set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_8set};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_value = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set") < 0)) __PYX_ERR(0, 352, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_value = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("set", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 352, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_8set(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_value);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_8set(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_value) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("set", 0);
-
- /* "src/gevent/event.py":358
- * Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.
- * """
- * self._value = value # <<<<<<<<<<<<<<
- * self._check_and_notify()
- *
- */
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->_value);
- __Pyx_DECREF(__pyx_v_self->_value);
- __pyx_v_self->_value = __pyx_v_value;
-
- /* "src/gevent/event.py":359
- * """
- * self._value = value
- * self._check_and_notify() # <<<<<<<<<<<<<<
- *
- * def set_exception(self, exception, exc_info=None):
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._check_and_notify(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":352
- * return self._exc_info[1]
- *
- * def set(self, value=None): # <<<<<<<<<<<<<<
- * """Store the value and wake up any waiters.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":361
- * self._check_and_notify()
- *
- * def set_exception(self, exception, exc_info=None): # <<<<<<<<<<<<<<
- * """Store the exception and wake up any waiters.
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_11set_exception(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_10set_exception[] = "AsyncResult.set_exception(self, exception, exc_info=None)\nStore the exception and wake up any waiters.\n\n All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.\n Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.\n\n :keyword tuple exc_info: If given, a standard three-tuple of type, value, :class:`traceback`\n as returned by :func:`sys.exc_info`. This will be used when the exception\n is re-raised to propagate the correct traceback.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_11set_exception = {"set_exception", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_11set_exception, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_10set_exception};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_11set_exception(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_v_exc_info = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_exception (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exception_2,&__pyx_n_s_exc_info,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception_2)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exc_info);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_exception") < 0)) __PYX_ERR(0, 361, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_exception = values[0];
- __pyx_v_exc_info = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("set_exception", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 361, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.set_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_10set_exception(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_exception, __pyx_v_exc_info);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_10set_exception(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_exception, PyObject *__pyx_v_exc_info) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("set_exception", 0);
-
- /* "src/gevent/event.py":371
- * is re-raised to propagate the correct traceback.
- * """
- * if exc_info: # <<<<<<<<<<<<<<
- * self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2]))
- * else:
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_exc_info); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 371, __pyx_L1_error)
- if (__pyx_t_1) {
-
- /* "src/gevent/event.py":372
- * """
- * if exc_info:
- * self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2])) # <<<<<<<<<<<<<<
- * else:
- * self._exc_info = (type(exception), exception, dump_traceback(None))
- */
- __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_exc_info, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_exc_info, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_6gevent_6_event_dump_traceback);
- __pyx_t_6 = __pyx_v_6gevent_6_event_dump_traceback; __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = ((PyObject*)__pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "src/gevent/event.py":371
- * is re-raised to propagate the correct traceback.
- * """
- * if exc_info: # <<<<<<<<<<<<<<
- * self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2]))
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/event.py":374
- * self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2]))
- * else:
- * self._exc_info = (type(exception), exception, dump_traceback(None)) # <<<<<<<<<<<<<<
- *
- * self._check_and_notify()
- */
- /*else*/ {
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_6gevent_6_event_dump_traceback, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_exception)));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_exception)));
- PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(__pyx_v_exception)));
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_exception);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_6);
- __pyx_t_6 = 0;
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
- }
- __pyx_L3:;
-
- /* "src/gevent/event.py":376
- * self._exc_info = (type(exception), exception, dump_traceback(None))
- *
- * self._check_and_notify() # <<<<<<<<<<<<<<
- *
- * def _raise_exception(self):
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._check_and_notify(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/event.py":361
- * self._check_and_notify()
- *
- * def set_exception(self, exception, exc_info=None): # <<<<<<<<<<<<<<
- * """Store the exception and wake up any waiters.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._event.AsyncResult.set_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":378
- * self._check_and_notify()
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_13_raise_exception(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_12_raise_exception[] = "AsyncResult._raise_exception(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_13_raise_exception = {"_raise_exception", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_13_raise_exception, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_12_raise_exception};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_13_raise_exception(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_raise_exception (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_12_raise_exception(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_12_raise_exception(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_raise_exception", 0);
-
- /* "src/gevent/event.py":379
- *
- * def _raise_exception(self):
- * reraise(*self.exc_info) # <<<<<<<<<<<<<<
- *
- * def get(self, block=True, timeout=None):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exc_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_6gevent_6_event_reraise, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":378
- * self._check_and_notify()
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._event.AsyncResult._raise_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":381
- * reraise(*self.exc_info)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return the stored value or raise the exception.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_15get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult_get(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args) {
- PyObject *__pyx_v_block = ((PyObject *)Py_True);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core __pyx_t_9;
- struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get __pyx_t_10;
- __Pyx_RefNannySetupContext("get", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_block = __pyx_optional_args->block;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_15get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_block);
- __Pyx_GIVEREF(__pyx_v_block);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_block);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":396
- * immediately raise a :class:`Timeout` exception.
- * """
- * if self._value is not _NONE: # <<<<<<<<<<<<<<
- * return self._value
- * if self._exc_info:
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_7 = (__pyx_v_self->_value != __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/event.py":397
- * """
- * if self._value is not _NONE:
- * return self._value # <<<<<<<<<<<<<<
- * if self._exc_info:
- * return self._raise_exception()
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_value);
- __pyx_r = __pyx_v_self->_value;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":396
- * immediately raise a :class:`Timeout` exception.
- * """
- * if self._value is not _NONE: # <<<<<<<<<<<<<<
- * return self._value
- * if self._exc_info:
- */
- }
-
- /* "src/gevent/event.py":398
- * if self._value is not _NONE:
- * return self._value
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return self._raise_exception()
- *
- */
- __pyx_t_8 = (__pyx_v_self->_exc_info != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->_exc_info) != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/event.py":399
- * return self._value
- * if self._exc_info:
- * return self._raise_exception() # <<<<<<<<<<<<<<
- *
- * if not block:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_raise_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":398
- * if self._value is not _NONE:
- * return self._value
- * if self._exc_info: # <<<<<<<<<<<<<<
- * return self._raise_exception()
- *
- */
- }
-
- /* "src/gevent/event.py":401
- * return self._raise_exception()
- *
- * if not block: # <<<<<<<<<<<<<<
- * # Not ready and not blocking, so immediately timeout
- * raise Timeout()
- */
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 401, __pyx_L1_error)
- __pyx_t_7 = ((!__pyx_t_8) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/event.py":403
- * if not block:
- * # Not ready and not blocking, so immediately timeout
- * raise Timeout() # <<<<<<<<<<<<<<
- *
- * # Wait, raising a timeout that elapses
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_event_Timeout);
- __pyx_t_2 = __pyx_v_6gevent_6_event_Timeout; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 403, __pyx_L1_error)
-
- /* "src/gevent/event.py":401
- * return self._raise_exception()
- *
- * if not block: # <<<<<<<<<<<<<<
- * # Not ready and not blocking, so immediately timeout
- * raise Timeout()
- */
- }
-
- /* "src/gevent/event.py":406
- *
- * # Wait, raising a timeout that elapses
- * self._wait_core(timeout, ()) # <<<<<<<<<<<<<<
- *
- * # by definition we are now ready
- */
- __pyx_t_9.__pyx_n = 1;
- __pyx_t_9.catch = __pyx_empty_tuple;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._wait_core(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), __pyx_v_timeout, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":409
- *
- * # by definition we are now ready
- * return self.get(block=False) # <<<<<<<<<<<<<<
- *
- * def get_nowait(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_10.__pyx_n = 1;
- __pyx_t_10.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->get(__pyx_v_self, 0, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":381
- * reraise(*self.exc_info)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return the stored value or raise the exception.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._event.AsyncResult.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_15get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_14get[] = "AsyncResult.get(self, block=True, timeout=None)\nReturn the stored value or raise the exception.\n\n If this instance already holds a value or an exception, return or raise it immediately.\n Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or\n until the optional timeout occurs.\n\n When the *timeout* argument is present and not ``None``, it should be a\n floating point number specifying a timeout for the operation in seconds\n (or fractions thereof). If the *timeout* elapses, the *Timeout* exception will\n be raised.\n\n :keyword bool block: If set to ``False`` and this instance is not ready,\n immediately raise a :class:`Timeout` exception.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_15get = {"get", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_15get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_14get};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_15get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 381, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_block = values[0];
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("get", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 381, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_14get(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_14get(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get __pyx_t_2;
- __Pyx_RefNannySetupContext("get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_event_AsyncResult->get(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":411
- * return self.get(block=False)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """
- * Return the value or raise the exception without blocking.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_17get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_16get_nowait[] = "AsyncResult.get_nowait(self)\n\n Return the value or raise the exception without blocking.\n\n If this object is not yet :meth:`ready <ready>`, raise\n :class:`gevent.Timeout` immediately.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_17get_nowait = {"get_nowait", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_17get_nowait, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_16get_nowait};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_17get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_16get_nowait(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_16get_nowait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get __pyx_t_2;
- __Pyx_RefNannySetupContext("get_nowait", 0);
-
- /* "src/gevent/event.py":418
- * :class:`gevent.Timeout` immediately.
- * """
- * return self.get(block=False) # <<<<<<<<<<<<<<
- *
- * def _wait_return_value(self, waited, wait_success):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->get(__pyx_v_self, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":411
- * return self.get(block=False)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """
- * Return the value or raise the exception without blocking.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.get_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":420
- * return self.get(block=False)
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # pylint:disable=unused-argument
- * # Always return the value. Since this is a one-shot event,
- */
-
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult__wait_return_value(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_waited, CYTHON_UNUSED PyObject *__pyx_v_wait_success) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_wait_return_value", 0);
-
- /* "src/gevent/event.py":424
- * # Always return the value. Since this is a one-shot event,
- * # no race condition should reset it.
- * return self.value # <<<<<<<<<<<<<<
- *
- * def wait(self, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":420
- * return self.get(block=False)
- *
- * def _wait_return_value(self, waited, wait_success): # <<<<<<<<<<<<<<
- * # pylint:disable=unused-argument
- * # Always return the value. Since this is a one-shot event,
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult._wait_return_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":426
- * return self.value
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """Block until the instance is ready.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_19wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_event_11AsyncResult_wait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait __pyx_t_6;
- __Pyx_RefNannySetupContext("wait", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_19wait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":445
- *
- * """
- * return self._wait(timeout) # <<<<<<<<<<<<<<
- *
- * # link protocol
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_6.__pyx_n = 1;
- __pyx_t_6.timeout = __pyx_v_timeout;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._wait(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":426
- * return self.value
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """Block until the instance is ready.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._event.AsyncResult.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_19wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_18wait[] = "AsyncResult.wait(self, timeout=None)\nBlock until the instance is ready.\n\n If this instance already holds a value, it is returned immediately. If this\n instance already holds an exception, ``None`` is returned immediately.\n\n Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception`\n (at which point either the value or ``None`` will be returned, respectively),\n or until the optional timeout expires (at which point ``None`` will also be\n returned).\n\n When the *timeout* argument is present and not ``None``, it should be a\n floating point number specifying a timeout for the operation in seconds\n (or fractions thereof).\n\n .. note:: If a timeout is given and expires, ``None`` will be returned\n (no timeout exception will be raised).\n\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_19wait = {"wait", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_19wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_18wait};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_19wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wait (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) __PYX_ERR(0, 426, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 426, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_18wait(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_18wait(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait __pyx_t_2;
- __Pyx_RefNannySetupContext("wait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_event_AsyncResult->wait(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":448
- *
- * # link protocol
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.successful():
- * self.set(source.value)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_21__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_21__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_source = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 448, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_source = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 448, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_20__call__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_source);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_20__call__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_source) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/event.py":449
- * # link protocol
- * def __call__(self, source):
- * if source.successful(): # <<<<<<<<<<<<<<
- * self.set(source.value)
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_4) {
-
- /* "src/gevent/event.py":450
- * def __call__(self, source):
- * if source.successful():
- * self.set(source.value) # <<<<<<<<<<<<<<
- * else:
- * self.set_exception(source.exception, getattr(source, 'exc_info', None))
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":449
- * # link protocol
- * def __call__(self, source):
- * if source.successful(): # <<<<<<<<<<<<<<
- * self.set(source.value)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/event.py":452
- * self.set(source.value)
- * else:
- * self.set_exception(source.exception, getattr(source, 'exc_info', None)) # <<<<<<<<<<<<<<
- *
- * # Methods to make us more like concurrent.futures.Future
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_exception_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_3 = __Pyx_GetAttr3(__pyx_v_source, __pyx_n_s_exc_info, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
- __pyx_t_6 = 0;
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L3:;
-
- /* "src/gevent/event.py":448
- *
- * # link protocol
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.successful():
- * self.set(source.value)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._event.AsyncResult.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":456
- * # Methods to make us more like concurrent.futures.Future
- *
- * def result(self, timeout=None): # <<<<<<<<<<<<<<
- * return self.get(timeout=timeout)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_23result(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_22result[] = "AsyncResult.result(self, timeout=None)";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_23result = {"result", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_23result, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_22result};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_23result(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("result (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "result") < 0)) __PYX_ERR(0, 456, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("result", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 456, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult.result", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_22result(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_22result(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("result", 0);
-
- /* "src/gevent/event.py":457
- *
- * def result(self, timeout=None):
- * return self.get(timeout=timeout) # <<<<<<<<<<<<<<
- *
- * set_result = set
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 457, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":456
- * # Methods to make us more like concurrent.futures.Future
- *
- * def result(self, timeout=None): # <<<<<<<<<<<<<<
- * return self.get(timeout=timeout)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._event.AsyncResult.result", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":461
- * set_result = set
- *
- * def done(self): # <<<<<<<<<<<<<<
- * return self.ready()
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_25done(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_done(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("done", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_done); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_25done)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":462
- *
- * def done(self):
- * return self.ready() # <<<<<<<<<<<<<<
- *
- * # we don't support cancelling
- */
- __pyx_r = ((struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.ready(((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)__pyx_v_self), 0);
- goto __pyx_L0;
-
- /* "src/gevent/event.py":461
- * set_result = set
- *
- * def done(self): # <<<<<<<<<<<<<<
- * return self.ready()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.AsyncResult.done", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_25done(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_24done[] = "AsyncResult.done(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_25done = {"done", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_25done, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_24done};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_25done(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("done (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_24done(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_24done(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("done", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_11AsyncResult_done(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.done", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":466
- * # we don't support cancelling
- *
- * def cancel(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_27cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_cancel(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("cancel", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cancel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_27cancel)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":467
- *
- * def cancel(self):
- * return False # <<<<<<<<<<<<<<
- *
- * def cancelled(self):
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":466
- * # we don't support cancelling
- *
- * def cancel(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.AsyncResult.cancel", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_27cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_26cancel[] = "AsyncResult.cancel(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_27cancel = {"cancel", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_27cancel, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_26cancel};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_27cancel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("cancel (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_26cancel(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_26cancel(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("cancel", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_11AsyncResult_cancel(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.cancel", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":469
- * return False
- *
- * def cancelled(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_29cancelled(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_event_11AsyncResult_cancelled(CYTHON_UNUSED struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("cancelled", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cancelled); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_29cancelled)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/event.py":470
- *
- * def cancelled(self):
- * return False # <<<<<<<<<<<<<<
- *
- * # exception is a method, we use it as a property
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/event.py":469
- * return False
- *
- * def cancelled(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._event.AsyncResult.cancelled", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_29cancelled(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_event_11AsyncResult_28cancelled[] = "AsyncResult.cancelled(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_6_event_11AsyncResult_29cancelled = {"cancelled", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_29cancelled, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_28cancelled};
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_29cancelled(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("cancelled (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_28cancelled(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_28cancelled(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("cancelled", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_event_11AsyncResult_cancelled(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult.cancelled", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":64
- *
- * cdef class AsyncResult(_AbstractLinkable):
- * cdef readonly _value # <<<<<<<<<<<<<<
- * cdef readonly tuple _exc_info
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_6_value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_6_value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_6_value___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_6_value___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_value);
- __pyx_r = __pyx_v_self->_value;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":65
- * cdef class AsyncResult(_AbstractLinkable):
- * cdef readonly _value
- * cdef readonly tuple _exc_info # <<<<<<<<<<<<<<
- *
- * # For the use of _imap.py
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9_exc_info_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_9_exc_info_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_9_exc_info___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_9_exc_info___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_exc_info);
- __pyx_r = __pyx_v_self->_exc_info;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":68
- *
- * # For the use of _imap.py
- * cdef public int _imap_task_index # <<<<<<<<<<<<<<
- *
- * cpdef get(self, block=*, timeout=*)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index___get__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index___get__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_imap_task_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.AsyncResult._imap_task_index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index_2__set__(((struct __pyx_obj_6gevent_6_event_AsyncResult *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_event_11AsyncResult_16_imap_task_index_2__set__(struct __pyx_obj_6gevent_6_event_AsyncResult *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 68, __pyx_L1_error)
- __pyx_v_self->_imap_task_index = __pyx_t_1;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent._event.AsyncResult._imap_task_index.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/event.py":474
- * # exception is a method, we use it as a property
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-static void __pyx_f_6gevent_6_event__init(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/event.py":475
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_6_event_greenlet_init();
-
- /* "src/gevent/event.py":474
- * # exception is a method, we use it as a property
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_event_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_event.pxd":28
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_6_event_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_6_event__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_event.pxd":33
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_event.pxd":34
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef void _init()
- */
- __pyx_v_6gevent_6_event__greenlet_imported = 1;
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-static struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_vtable_6gevent_6_event__AbstractLinkable;
-
-static PyObject *__pyx_tp_new_6gevent_6_event__AbstractLinkable(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_event__AbstractLinkable *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_6_event__AbstractLinkable;
- p->_notifier = Py_None; Py_INCREF(Py_None);
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_event__AbstractLinkable(PyObject *o) {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable *p = (struct __pyx_obj_6gevent_6_event__AbstractLinkable *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- Py_CLEAR(p->_notifier);
- Py_CLEAR(p->_links);
- Py_CLEAR(p->hub);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_event__AbstractLinkable(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_event__AbstractLinkable *p = (struct __pyx_obj_6gevent_6_event__AbstractLinkable *)o;
- if (p->_notifier) {
- e = (*v)(p->_notifier, a); if (e) return e;
- }
- if (p->_links) {
- e = (*v)(p->_links, a); if (e) return e;
- }
- if (p->hub) {
- e = (*v)(((PyObject *)p->hub), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_event__AbstractLinkable(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_event__AbstractLinkable *p = (struct __pyx_obj_6gevent_6_event__AbstractLinkable *)o;
- tmp = ((PyObject*)p->_notifier);
- p->_notifier = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_links);
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->hub);
- p->hub = ((struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_17_AbstractLinkable_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_17_AbstractLinkable_3hub_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_event__AbstractLinkable[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_event__AbstractLinkable[] = {
- {(char *)"hub", __pyx_getprop_6gevent_6_event_17_AbstractLinkable_hub, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_event__AbstractLinkable = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._event._AbstractLinkable", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_event__AbstractLinkable), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_event__AbstractLinkable, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_AbstractLinkable()", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_event__AbstractLinkable, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_event__AbstractLinkable, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_event__AbstractLinkable, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_event__AbstractLinkable, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_event_17_AbstractLinkable_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_event__AbstractLinkable, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_event_Event __pyx_vtable_6gevent_6_event_Event;
-
-static PyObject *__pyx_tp_new_6gevent_6_event_Event(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_event_Event *p;
- PyObject *o = __pyx_tp_new_6gevent_6_event__AbstractLinkable(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_event_Event *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable*)__pyx_vtabptr_6gevent_6_event_Event;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_event_Event[] = {
- {"is_set", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_5is_set, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_4is_set},
- {"isSet", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_7isSet, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_6isSet},
- {"set", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_11set, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_10set},
- {"clear", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_13clear, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_12clear},
- {"wait", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_15wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_5Event_14wait},
- {"_reset_internal_locks", (PyCFunction)__pyx_pw_6gevent_6_event_5Event_17_reset_internal_locks, METH_NOARGS, __pyx_doc_6gevent_6_event_5Event_16_reset_internal_locks},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_event_Event = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._event.Event", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_event_Event), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_event__AbstractLinkable, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_pw_6gevent_6_event_5Event_3__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Event()\nA synchronization primitive that allows one greenlet to wake up one or more others.\n It has the same interface as :class:`threading.Event` but works across greenlets.\n\n An event object manages an internal flag that can be set to true with the\n :meth:`set` method and reset to false with the :meth:`clear` method. The :meth:`wait` method\n blocks until the flag is true.\n\n .. note::\n The order and timing in which waiting greenlets are awakened is not determined.\n As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a\n undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets\n (those not waiting to be awakened) may run between the current greenlet yielding and\n the waiting greenlets being awakened. These details may change in the future.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_event__AbstractLinkable, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_event__AbstractLinkable, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_event_Event, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_event_5Event_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_event_Event, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_event_AsyncResult __pyx_vtable_6gevent_6_event_AsyncResult;
-
-static PyObject *__pyx_tp_new_6gevent_6_event_AsyncResult(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_event_AsyncResult *p;
- PyObject *o = __pyx_tp_new_6gevent_6_event__AbstractLinkable(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_event_AsyncResult *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable*)__pyx_vtabptr_6gevent_6_event_AsyncResult;
- p->_value = Py_None; Py_INCREF(Py_None);
- p->_exc_info = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_event_AsyncResult(PyObject *o) {
- struct __pyx_obj_6gevent_6_event_AsyncResult *p = (struct __pyx_obj_6gevent_6_event_AsyncResult *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_value);
- Py_CLEAR(p->_exc_info);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_6_event__AbstractLinkable(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_event_AsyncResult(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_event_AsyncResult *p = (struct __pyx_obj_6gevent_6_event_AsyncResult *)o;
- e = __pyx_tp_traverse_6gevent_6_event__AbstractLinkable(o, v, a); if (e) return e;
- if (p->_value) {
- e = (*v)(p->_value, a); if (e) return e;
- }
- if (p->_exc_info) {
- e = (*v)(p->_exc_info, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_event_AsyncResult(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_event_AsyncResult *p = (struct __pyx_obj_6gevent_6_event_AsyncResult *)o;
- __pyx_tp_clear_6gevent_6_event__AbstractLinkable(o);
- tmp = ((PyObject*)p->_value);
- p->_value = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_exc_info);
- p->_exc_info = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult__exception(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_10_exception_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult_value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_5value_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult_exc_info(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_8exc_info_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult_exception(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_9exception_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult__value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_6_value_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult__exc_info(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_9_exc_info_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_event_11AsyncResult__imap_task_index(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_6_event_11AsyncResult__imap_task_index(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_6_event_11AsyncResult_16_imap_task_index_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_event_AsyncResult[] = {
- {"set", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_9set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_8set},
- {"set_exception", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_11set_exception, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_10set_exception},
- {"_raise_exception", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_13_raise_exception, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_12_raise_exception},
- {"get_nowait", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_17get_nowait, METH_NOARGS, __pyx_doc_6gevent_6_event_11AsyncResult_16get_nowait},
- {"result", (PyCFunction)__pyx_pw_6gevent_6_event_11AsyncResult_23result, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_event_11AsyncResult_22result},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_event_AsyncResult[] = {
- {(char *)"_exception", __pyx_getprop_6gevent_6_event_11AsyncResult__exception, 0, (char *)0, 0},
- {(char *)"value", __pyx_getprop_6gevent_6_event_11AsyncResult_value, 0, (char *)"\n Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise,\n ``None``\n ", 0},
- {(char *)"exc_info", __pyx_getprop_6gevent_6_event_11AsyncResult_exc_info, 0, (char *)"\n The three-tuple of exception information if :meth:`set_exception` was called.\n ", 0},
- {(char *)"exception", __pyx_getprop_6gevent_6_event_11AsyncResult_exception, 0, (char *)"Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.\n Otherwise ``None``.", 0},
- {(char *)"_value", __pyx_getprop_6gevent_6_event_11AsyncResult__value, 0, (char *)0, 0},
- {(char *)"_exc_info", __pyx_getprop_6gevent_6_event_11AsyncResult__exc_info, 0, (char *)0, 0},
- {(char *)"_imap_task_index", __pyx_getprop_6gevent_6_event_11AsyncResult__imap_task_index, __pyx_setprop_6gevent_6_event_11AsyncResult__imap_task_index, (char *)"_imap_task_index: 'int'", 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_event_AsyncResult = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._event.AsyncResult", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_event_AsyncResult), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_event_AsyncResult, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_6_event_11AsyncResult_21__call__, /*tp_call*/
- __pyx_pw_6gevent_6_event_11AsyncResult_3__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "AsyncResult()\nA one-time event that stores a value or an exception.\n\n Like :class:`Event` it wakes up all the waiters when :meth:`set` or :meth:`set_exception`\n is called. Waiters may receive the passed value or exception by calling :meth:`get`\n instead of :meth:`wait`. An :class:`AsyncResult` instance cannot be reset.\n\n To pass a value call :meth:`set`. Calls to :meth:`get` (those that are currently blocking as well as\n those made in the future) will return the value:\n\n >>> result = AsyncResult()\n >>> result.set(100)\n >>> result.get()\n 100\n\n To pass an exception call :meth:`set_exception`. This will cause :meth:`get` to raise that exception:\n\n >>> result = AsyncResult()\n >>> result.set_exception(RuntimeError('failure'))\n >>> result.get()\n Traceback (most recent call last):\n ...\n RuntimeError: failure\n\n :class:`AsyncResult` implements :meth:`__call__` and thus can be used as :meth:`link` target:\n\n >>> import gevent\n >>> result = AsyncResult()\n >>> gevent.spawn(lambda : 1/0).link(result)\n >>> try:\n ... result.get()\n ... except ZeroDivisionError:\n ... print('ZeroDivisionError')\n ZeroDivisionError\n\n .. note::\n The order and timing in which waiting greenlets are awakened is not determined.\n As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a\n undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets\n (those not waiting to be awakened) may run between the current greenlet yielding and\n the waiting greenlets being awakened. These details may change in the future.\n\n .. versionchanged:: 1.1\n The exact order in which waiting greenlets are awakened is not the same\n as in 1.0.\n .. versionchanged:: 1.1\n Callbacks :meth:`linked <rawlink>` to this"" object are required to be hashable, and duplicates are\n merged.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_event_AsyncResult, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_event_AsyncResult, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_event_AsyncResult, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_event_AsyncResult, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_event_11AsyncResult_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_event_AsyncResult, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec__event(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec__event},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "_event",
- __pyx_k_Basic_synchronization_primitives, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AbstractLinkable__notify_links, __pyx_k_AbstractLinkable__notify_links, sizeof(__pyx_k_AbstractLinkable__notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_AbstractLinkable_rawlink, __pyx_k_AbstractLinkable_rawlink, sizeof(__pyx_k_AbstractLinkable_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_AbstractLinkable_ready, __pyx_k_AbstractLinkable_ready, sizeof(__pyx_k_AbstractLinkable_ready), 0, 0, 1, 1},
- {&__pyx_n_s_AbstractLinkable_unlink, __pyx_k_AbstractLinkable_unlink, sizeof(__pyx_k_AbstractLinkable_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult, __pyx_k_AsyncResult, sizeof(__pyx_k_AsyncResult), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult__raise_exception, __pyx_k_AsyncResult__raise_exception, sizeof(__pyx_k_AsyncResult__raise_exception), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_cancel, __pyx_k_AsyncResult_cancel, sizeof(__pyx_k_AsyncResult_cancel), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_cancelled, __pyx_k_AsyncResult_cancelled, sizeof(__pyx_k_AsyncResult_cancelled), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_done, __pyx_k_AsyncResult_done, sizeof(__pyx_k_AsyncResult_done), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_get, __pyx_k_AsyncResult_get, sizeof(__pyx_k_AsyncResult_get), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_get_nowait, __pyx_k_AsyncResult_get_nowait, sizeof(__pyx_k_AsyncResult_get_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_ready, __pyx_k_AsyncResult_ready, sizeof(__pyx_k_AsyncResult_ready), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_result, __pyx_k_AsyncResult_result, sizeof(__pyx_k_AsyncResult_result), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_set, __pyx_k_AsyncResult_set, sizeof(__pyx_k_AsyncResult_set), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_set_exception, __pyx_k_AsyncResult_set_exception, sizeof(__pyx_k_AsyncResult_set_exception), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_successful, __pyx_k_AsyncResult_successful, sizeof(__pyx_k_AsyncResult_successful), 0, 0, 1, 1},
- {&__pyx_n_s_AsyncResult_wait, __pyx_k_AsyncResult_wait, sizeof(__pyx_k_AsyncResult_wait), 0, 0, 1, 1},
- {&__pyx_n_s_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
- {&__pyx_n_s_Event__reset_internal_locks, __pyx_k_Event__reset_internal_locks, sizeof(__pyx_k_Event__reset_internal_locks), 0, 0, 1, 1},
- {&__pyx_n_s_Event_clear, __pyx_k_Event_clear, sizeof(__pyx_k_Event_clear), 0, 0, 1, 1},
- {&__pyx_n_s_Event_isSet, __pyx_k_Event_isSet, sizeof(__pyx_k_Event_isSet), 0, 0, 1, 1},
- {&__pyx_n_s_Event_is_set, __pyx_k_Event_is_set, sizeof(__pyx_k_Event_is_set), 0, 0, 1, 1},
- {&__pyx_n_s_Event_ready, __pyx_k_Event_ready, sizeof(__pyx_k_Event_ready), 0, 0, 1, 1},
- {&__pyx_n_s_Event_set, __pyx_k_Event_set, sizeof(__pyx_k_Event_set), 0, 0, 1, 1},
- {&__pyx_n_s_Event_wait, __pyx_k_Event_wait, sizeof(__pyx_k_Event_wait), 0, 0, 1, 1},
- {&__pyx_kp_s_Expected_callable_r, __pyx_k_Expected_callable_r, sizeof(__pyx_k_Expected_callable_r), 0, 0, 1, 0},
- {&__pyx_n_s_InvalidSwitchError, __pyx_k_InvalidSwitchError, sizeof(__pyx_k_InvalidSwitchError), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_switch_into_Event_wait_r, __pyx_k_Invalid_switch_into_Event_wait_r, sizeof(__pyx_k_Invalid_switch_into_Event_wait_r), 0, 0, 1, 0},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1},
- {&__pyx_n_s_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 0, 1, 1},
- {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
- {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_auto_unlink, __pyx_k_auto_unlink, sizeof(__pyx_k_auto_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_block, __pyx_k_block, sizeof(__pyx_k_block), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
- {&__pyx_n_s_cancelled, __pyx_k_cancelled, sizeof(__pyx_k_cancelled), 0, 0, 1, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_done, __pyx_k_done, sizeof(__pyx_k_done), 0, 0, 1, 1},
- {&__pyx_n_s_dump_traceback, __pyx_k_dump_traceback, sizeof(__pyx_k_dump_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info_2, __pyx_k_exc_info_2, sizeof(__pyx_k_exc_info_2), 0, 0, 1, 1},
- {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
- {&__pyx_n_s_exception_2, __pyx_k_exception_2, sizeof(__pyx_k_exception_2), 0, 0, 1, 1},
- {&__pyx_kp_s_exception_r, __pyx_k_exception_r, sizeof(__pyx_k_exception_r), 0, 0, 1, 0},
- {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
- {&__pyx_n_s_flag, __pyx_k_flag, sizeof(__pyx_k_flag), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_get_nowait, __pyx_k_get_nowait, sizeof(__pyx_k_get_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__compat, __pyx_k_gevent__compat, sizeof(__pyx_k_gevent__compat), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__event, __pyx_k_gevent__event, sizeof(__pyx_k_gevent__event), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_local, __pyx_k_gevent__hub_local, sizeof(__pyx_k_gevent__hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__tblib, __pyx_k_gevent__tblib, sizeof(__pyx_k_gevent__tblib), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_kp_s_if_we_didn_t_wait_we_should_alre, __pyx_k_if_we_didn_t_wait_we_should_alre, sizeof(__pyx_k_if_we_didn_t_wait_we_should_alre), 0, 0, 1, 0},
- {&__pyx_n_s_imap_task_index, __pyx_k_imap_task_index, sizeof(__pyx_k_imap_task_index), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_isSet, __pyx_k_isSet, sizeof(__pyx_k_isSet), 0, 0, 1, 1},
- {&__pyx_n_s_is_set, __pyx_k_is_set, sizeof(__pyx_k_is_set), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_links, __pyx_k_links, sizeof(__pyx_k_links), 0, 0, 1, 1},
- {&__pyx_kp_s_links_s, __pyx_k_links_s, sizeof(__pyx_k_links_s), 0, 0, 1, 0},
- {&__pyx_n_s_load_traceback, __pyx_k_load_traceback, sizeof(__pyx_k_load_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_notifier, __pyx_k_notifier, sizeof(__pyx_k_notifier), 0, 0, 1, 1},
- {&__pyx_n_s_notify_links, __pyx_k_notify_links, sizeof(__pyx_k_notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_raise_exception, __pyx_k_raise_exception, sizeof(__pyx_k_raise_exception), 0, 0, 1, 1},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_ready, __pyx_k_ready, sizeof(__pyx_k_ready), 0, 0, 1, 1},
- {&__pyx_n_s_reraise, __pyx_k_reraise, sizeof(__pyx_k_reraise), 0, 0, 1, 1},
- {&__pyx_n_s_reset_internal_locks, __pyx_k_reset_internal_locks, sizeof(__pyx_k_reset_internal_locks), 0, 0, 1, 1},
- {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
- {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1},
- {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_s__links_s, __pyx_k_s_s__links_s, sizeof(__pyx_k_s_s__links_s), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
- {&__pyx_n_s_set_exception, __pyx_k_set_exception, sizeof(__pyx_k_set_exception), 0, 0, 1, 1},
- {&__pyx_n_s_set_result, __pyx_k_set_result, sizeof(__pyx_k_set_result), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_event_py, __pyx_k_src_gevent_event_py, sizeof(__pyx_k_src_gevent_event_py), 0, 0, 1, 0},
- {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1},
- {&__pyx_n_s_successful, __pyx_k_successful, sizeof(__pyx_k_successful), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
- {&__pyx_kp_s_unset, __pyx_k_unset, sizeof(__pyx_k_unset), 0, 0, 1, 0},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_value_2, __pyx_k_value_2, sizeof(__pyx_k_value_2), 0, 0, 1, 1},
- {&__pyx_kp_s_value_r, __pyx_k_value_r, sizeof(__pyx_k_value_r), 0, 0, 1, 0},
- {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 23, __pyx_L1_error)
- __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 50, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 66, __pyx_L1_error)
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 74, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/event.py":117
- * self.rawlink(switch)
- * try:
- * with Timeout._start_new_or_dummy(timeout) as timer: # <<<<<<<<<<<<<<
- * try:
- * result = self.hub.switch()
- */
- __pyx_tuple__2 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
- __pyx_tuple__3 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
-
- /* "src/gevent/event.py":374
- * self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2]))
- * else:
- * self._exc_info = (type(exception), exception, dump_traceback(None)) # <<<<<<<<<<<<<<
- *
- * self._check_and_notify()
- */
- __pyx_tuple__4 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 374, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "src/gevent/event.py":23
- * ]
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
-
- /* "src/gevent/event.py":31
- * # common to both repeatable events and one-time events (AsyncResult).
- *
- * __slots__ = ('_links', 'hub', '_notifier') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_links, __pyx_n_s_hub, __pyx_n_s_notifier); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
-
- /* "src/gevent/event.py":48
- * self._notifier = None
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # Instances must define this
- * raise NotImplementedError()
- */
- __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
- __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_ready, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 48, __pyx_L1_error)
-
- /* "src/gevent/event.py":58
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callback to call when this object is ready.
- */
- __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
- __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_rawlink, 58, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 58, __pyx_L1_error)
-
- /* "src/gevent/event.py":70
- * self._check_and_notify()
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`rawlink`"""
- * try:
- */
- __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
- __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_unlink, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 70, __pyx_L1_error)
-
- /* "src/gevent/event.py":77
- * pass
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Actually call the notification callbacks. Those callbacks in todo that are
- * # still in _links are called. This method is careful to avoid iterating
- */
- __pyx_tuple__13 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
- __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_notify_links, 77, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 77, __pyx_L1_error)
-
- /* "src/gevent/event.py":160
- * """
- *
- * __slots__ = ('_flag', '__weakref__') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_s_flag, __pyx_n_s_weakref); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
-
- /* "src/gevent/event.py":169
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- * def is_set(self): # <<<<<<<<<<<<<<
- * """Return true if and only if the internal flag is true."""
- * return self._flag
- */
- __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__16);
- __Pyx_GIVEREF(__pyx_tuple__16);
- __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_is_set, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 169, __pyx_L1_error)
-
- /* "src/gevent/event.py":173
- * return self._flag
- *
- * def isSet(self): # <<<<<<<<<<<<<<
- * # makes it a better drop-in replacement for threading.Event
- * return self._flag
- */
- __pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
- __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_isSet, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 173, __pyx_L1_error)
-
- /* "src/gevent/event.py":177
- * return self._flag
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # makes it compatible with AsyncResult and Greenlet (for
- * # example in wait())
- */
- __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__20);
- __Pyx_GIVEREF(__pyx_tuple__20);
- __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_ready, 177, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 177, __pyx_L1_error)
-
- /* "src/gevent/event.py":182
- * return self._flag
- *
- * def set(self): # <<<<<<<<<<<<<<
- * """
- * Set the internal flag to true.
- */
- __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 182, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__22);
- __Pyx_GIVEREF(__pyx_tuple__22);
- __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_set, 182, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 182, __pyx_L1_error)
-
- /* "src/gevent/event.py":194
- * self._check_and_notify()
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * """
- * Reset the internal flag to false.
- */
- __pyx_tuple__24 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__24);
- __Pyx_GIVEREF(__pyx_tuple__24);
- __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_clear, 194, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 194, __pyx_L1_error)
-
- /* "src/gevent/event.py":215
- * return wait_success
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Block until the internal flag is true.
- */
- __pyx_tuple__26 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__26);
- __Pyx_GIVEREF(__pyx_tuple__26);
- __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_wait, 215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 215, __pyx_L1_error)
-
- /* "src/gevent/event.py":242
- * return self._wait(timeout)
- *
- * def _reset_internal_locks(self): # pragma: no cover # <<<<<<<<<<<<<<
- * # for compatibility with threading.Event
- * # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",)
- */
- __pyx_tuple__28 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__28);
- __Pyx_GIVEREF(__pyx_tuple__28);
- __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_reset_internal_locks, 242, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 242, __pyx_L1_error)
-
- /* "src/gevent/event.py":299
- * """
- *
- * __slots__ = ('_value', '_exc_info', '_imap_task_index') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_tuple__30 = PyTuple_Pack(3, __pyx_n_s_value_2, __pyx_n_s_exc_info_2, __pyx_n_s_imap_task_index); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__30);
- __Pyx_GIVEREF(__pyx_tuple__30);
-
- /* "src/gevent/event.py":337
- * return result + ' _links[%s]>' % len(self._links)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exc_info or self._value is not _NONE
- */
- __pyx_tuple__31 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__31);
- __Pyx_GIVEREF(__pyx_tuple__31);
- __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_ready, 337, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 337, __pyx_L1_error)
-
- /* "src/gevent/event.py":341
- * return self._exc_info or self._value is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._value is not _NONE
- */
- __pyx_tuple__33 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__33);
- __Pyx_GIVEREF(__pyx_tuple__33);
- __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_successful, 341, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 341, __pyx_L1_error)
-
- /* "src/gevent/event.py":352
- * return self._exc_info[1]
- *
- * def set(self, value=None): # <<<<<<<<<<<<<<
- * """Store the value and wake up any waiters.
- *
- */
- __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_value); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__35);
- __Pyx_GIVEREF(__pyx_tuple__35);
- __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_set, 352, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 352, __pyx_L1_error)
-
- /* "src/gevent/event.py":361
- * self._check_and_notify()
- *
- * def set_exception(self, exception, exc_info=None): # <<<<<<<<<<<<<<
- * """Store the exception and wake up any waiters.
- *
- */
- __pyx_tuple__37 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_exception_2, __pyx_n_s_exc_info); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 361, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__37);
- __Pyx_GIVEREF(__pyx_tuple__37);
- __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_set_exception, 361, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 361, __pyx_L1_error)
-
- /* "src/gevent/event.py":378
- * self._check_and_notify()
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
- __pyx_tuple__39 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__39);
- __Pyx_GIVEREF(__pyx_tuple__39);
- __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_raise_exception, 378, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 378, __pyx_L1_error)
-
- /* "src/gevent/event.py":381
- * reraise(*self.exc_info)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return the stored value or raise the exception.
- *
- */
- __pyx_tuple__41 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__41);
- __Pyx_GIVEREF(__pyx_tuple__41);
- __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_get, 381, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 381, __pyx_L1_error)
-
- /* "src/gevent/event.py":411
- * return self.get(block=False)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """
- * Return the value or raise the exception without blocking.
- */
- __pyx_tuple__43 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 411, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__43);
- __Pyx_GIVEREF(__pyx_tuple__43);
- __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_get_nowait, 411, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 411, __pyx_L1_error)
-
- /* "src/gevent/event.py":426
- * return self.value
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """Block until the instance is ready.
- *
- */
- __pyx_tuple__45 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__45);
- __Pyx_GIVEREF(__pyx_tuple__45);
- __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_wait, 426, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 426, __pyx_L1_error)
-
- /* "src/gevent/event.py":456
- * # Methods to make us more like concurrent.futures.Future
- *
- * def result(self, timeout=None): # <<<<<<<<<<<<<<
- * return self.get(timeout=timeout)
- *
- */
- __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__47);
- __Pyx_GIVEREF(__pyx_tuple__47);
- __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_result, 456, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 456, __pyx_L1_error)
-
- /* "src/gevent/event.py":461
- * set_result = set
- *
- * def done(self): # <<<<<<<<<<<<<<
- * return self.ready()
- *
- */
- __pyx_tuple__49 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__49);
- __Pyx_GIVEREF(__pyx_tuple__49);
- __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_done, 461, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 461, __pyx_L1_error)
-
- /* "src/gevent/event.py":466
- * # we don't support cancelling
- *
- * def cancel(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
- __pyx_tuple__51 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__51);
- __Pyx_GIVEREF(__pyx_tuple__51);
- __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_cancel, 466, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 466, __pyx_L1_error)
-
- /* "src/gevent/event.py":469
- * return False
- *
- * def cancelled(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
- __pyx_tuple__53 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__53);
- __Pyx_GIVEREF(__pyx_tuple__53);
- __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_event_py, __pyx_n_s_cancelled, 469, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_6_event__None = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_event_reraise = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_event_dump_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_event_load_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_event_InvalidSwitchError = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_event_Timeout = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_None, (void *)&__pyx_v_6gevent_6_event__None, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_reraise, (void *)&__pyx_v_6gevent_6_event_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_dump_traceback, (void *)&__pyx_v_6gevent_6_event_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_load_traceback, (void *)&__pyx_v_6gevent_6_event_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_InvalidSwitchError, (void *)&__pyx_v_6gevent_6_event_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_Timeout, (void *)&__pyx_v_6gevent_6_event_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_6_event__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_init", (void (*)(void))__pyx_f_6gevent_6_event__init, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_6_event_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_6_event_greenlet)) __PYX_ERR(1, 18, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event__AbstractLinkable = &__pyx_vtable_6gevent_6_event__AbstractLinkable;
- __pyx_vtable_6gevent_6_event__AbstractLinkable.rawlink = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_17_AbstractLinkable_rawlink;
- __pyx_vtable_6gevent_6_event__AbstractLinkable.ready = (int (*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_17_AbstractLinkable_ready;
- __pyx_vtable_6gevent_6_event__AbstractLinkable.unlink = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_17_AbstractLinkable_unlink;
- __pyx_vtable_6gevent_6_event__AbstractLinkable._check_and_notify = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *))__pyx_f_6gevent_6_event_17_AbstractLinkable__check_and_notify;
- __pyx_vtable_6gevent_6_event__AbstractLinkable._notify_links = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_17_AbstractLinkable__notify_links;
- __pyx_vtable_6gevent_6_event__AbstractLinkable._wait_core = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args))__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_core;
- __pyx_vtable_6gevent_6_event__AbstractLinkable._wait_return_value = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *))__pyx_f_6gevent_6_event_17_AbstractLinkable__wait_return_value;
- __pyx_vtable_6gevent_6_event__AbstractLinkable._wait = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args))__pyx_f_6gevent_6_event_17_AbstractLinkable__wait;
- if (PyType_Ready(&__pyx_type_6gevent_6_event__AbstractLinkable) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- __pyx_type_6gevent_6_event__AbstractLinkable.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_event__AbstractLinkable.tp_dictoffset && __pyx_type_6gevent_6_event__AbstractLinkable.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_event__AbstractLinkable.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_event__AbstractLinkable.tp_dict, __pyx_vtabptr_6gevent_6_event__AbstractLinkable) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "_AbstractLinkable", (PyObject *)&__pyx_type_6gevent_6_event__AbstractLinkable) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
- if (__pyx_type_6gevent_6_event__AbstractLinkable.tp_weaklistoffset == 0) __pyx_type_6gevent_6_event__AbstractLinkable.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_event__AbstractLinkable, __weakref__);
- __pyx_ptype_6gevent_6_event__AbstractLinkable = &__pyx_type_6gevent_6_event__AbstractLinkable;
- __pyx_vtabptr_6gevent_6_event_Event = &__pyx_vtable_6gevent_6_event_Event;
- __pyx_vtable_6gevent_6_event_Event.__pyx_base = *__pyx_vtabptr_6gevent_6_event__AbstractLinkable;
- __pyx_vtable_6gevent_6_event_Event.__pyx_base.ready = (int (*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_5Event_ready;
- __pyx_vtable_6gevent_6_event_Event.__pyx_base._wait_return_value = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *))__pyx_f_6gevent_6_event_5Event__wait_return_value;
- __pyx_type_6gevent_6_event_Event.tp_base = __pyx_ptype_6gevent_6_event__AbstractLinkable;
- if (PyType_Ready(&__pyx_type_6gevent_6_event_Event) < 0) __PYX_ERR(0, 144, __pyx_L1_error)
- __pyx_type_6gevent_6_event_Event.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_event_Event.tp_dictoffset && __pyx_type_6gevent_6_event_Event.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_event_Event.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_event_Event.tp_dict, __pyx_vtabptr_6gevent_6_event_Event) < 0) __PYX_ERR(0, 144, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Event", (PyObject *)&__pyx_type_6gevent_6_event_Event) < 0) __PYX_ERR(0, 144, __pyx_L1_error)
- if (__pyx_type_6gevent_6_event_Event.tp_weaklistoffset == 0) __pyx_type_6gevent_6_event_Event.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_event_Event, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_event_Event = &__pyx_type_6gevent_6_event_Event;
- __pyx_vtabptr_6gevent_6_event_AsyncResult = &__pyx_vtable_6gevent_6_event_AsyncResult;
- __pyx_vtable_6gevent_6_event_AsyncResult.__pyx_base = *__pyx_vtabptr_6gevent_6_event__AbstractLinkable;
- __pyx_vtable_6gevent_6_event_AsyncResult.__pyx_base.ready = (int (*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_11AsyncResult_ready;
- __pyx_vtable_6gevent_6_event_AsyncResult.__pyx_base._wait_return_value = (PyObject *(*)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *))__pyx_f_6gevent_6_event_11AsyncResult__wait_return_value;
- __pyx_vtable_6gevent_6_event_AsyncResult.get = (PyObject *(*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args))__pyx_f_6gevent_6_event_11AsyncResult_get;
- __pyx_vtable_6gevent_6_event_AsyncResult.successful = (int (*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_11AsyncResult_successful;
- __pyx_vtable_6gevent_6_event_AsyncResult.wait = (PyObject *(*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args))__pyx_f_6gevent_6_event_11AsyncResult_wait;
- __pyx_vtable_6gevent_6_event_AsyncResult.done = (int (*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_11AsyncResult_done;
- __pyx_vtable_6gevent_6_event_AsyncResult.cancel = (int (*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_11AsyncResult_cancel;
- __pyx_vtable_6gevent_6_event_AsyncResult.cancelled = (int (*)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_event_11AsyncResult_cancelled;
- __pyx_type_6gevent_6_event_AsyncResult.tp_base = __pyx_ptype_6gevent_6_event__AbstractLinkable;
- if (PyType_Ready(&__pyx_type_6gevent_6_event_AsyncResult) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
- __pyx_type_6gevent_6_event_AsyncResult.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_event_AsyncResult.tp_dictoffset && __pyx_type_6gevent_6_event_AsyncResult.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_event_AsyncResult.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_event_AsyncResult.tp_dict, __pyx_vtabptr_6gevent_6_event_AsyncResult) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "AsyncResult", (PyObject *)&__pyx_type_6gevent_6_event_AsyncResult) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
- if (__pyx_type_6gevent_6_event_AsyncResult.tp_weaklistoffset == 0) __pyx_type_6gevent_6_event_AsyncResult.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_event_AsyncResult, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_event_AsyncResult = &__pyx_type_6gevent_6_event_AsyncResult;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(2, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(2, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init_event(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init_event(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit__event(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit__event(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec__event(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__event(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("_event", __pyx_methods, __pyx_k_Basic_synchronization_primitives, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent___event) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent._event")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent._event", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/event.py":6
- * """Basic synchronization primitives: Event and AsyncResult"""
- * from __future__ import print_function
- * import sys # <<<<<<<<<<<<<<
- *
- * from gevent._util import _NONE
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":8
- * import sys
- *
- * from gevent._util import _NONE # <<<<<<<<<<<<<<
- * from gevent._compat import reraise
- * from gevent._tblib import dump_traceback, load_traceback
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_NONE);
- __Pyx_GIVEREF(__pyx_n_s_NONE);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_NONE);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONE, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":9
- *
- * from gevent._util import _NONE
- * from gevent._compat import reraise # <<<<<<<<<<<<<<
- * from gevent._tblib import dump_traceback, load_traceback
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_reraise);
- __Pyx_GIVEREF(__pyx_n_s_reraise);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_reraise);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_reraise); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_event_reraise);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_event_reraise, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":10
- * from gevent._util import _NONE
- * from gevent._compat import reraise
- * from gevent._tblib import dump_traceback, load_traceback # <<<<<<<<<<<<<<
- *
- * from gevent._hub_local import get_hub_noargs as get_hub
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_dump_traceback);
- __Pyx_GIVEREF(__pyx_n_s_dump_traceback);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_dump_traceback);
- __Pyx_INCREF(__pyx_n_s_load_traceback);
- __Pyx_GIVEREF(__pyx_n_s_load_traceback);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_load_traceback);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__tblib, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_dump_traceback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_event_dump_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_event_dump_traceback, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_load_traceback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_event_load_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_event_load_traceback, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":12
- * from gevent._tblib import dump_traceback, load_traceback
- *
- * from gevent._hub_local import get_hub_noargs as get_hub # <<<<<<<<<<<<<<
- *
- * from gevent.exceptions import InvalidSwitchError
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_hub_noargs);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":14
- * from gevent._hub_local import get_hub_noargs as get_hub
- *
- * from gevent.exceptions import InvalidSwitchError # <<<<<<<<<<<<<<
- * from gevent.timeout import Timeout
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_InvalidSwitchError);
- __Pyx_GIVEREF(__pyx_n_s_InvalidSwitchError);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_InvalidSwitchError);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_event_InvalidSwitchError);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_event_InvalidSwitchError, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":15
- *
- * from gevent.exceptions import InvalidSwitchError
- * from gevent.timeout import Timeout # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_Timeout);
- __Pyx_GIVEREF(__pyx_n_s_Timeout);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Timeout);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_event_Timeout);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_event_Timeout, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":18
- *
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'Event',
- * 'AsyncResult',
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Event);
- __Pyx_GIVEREF(__pyx_n_s_Event);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Event);
- __Pyx_INCREF(__pyx_n_s_AsyncResult);
- __Pyx_GIVEREF(__pyx_n_s_AsyncResult);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_AsyncResult);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":23
- * ]
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_getcurrent, __pyx_t_2) < 0)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":24
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent__event, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_greenlet_init, __pyx_t_2) < 0)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":31
- * # common to both repeatable events and one-time events (AsyncResult).
- *
- * __slots__ = ('_links', 'hub', '_notifier') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict, __pyx_n_s_slots, __pyx_tuple__6) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_event__AbstractLinkable);
-
- /* "src/gevent/event.py":48
- * self._notifier = None
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # Instances must define this
- * raise NotImplementedError()
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_17_AbstractLinkable_3ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_ready, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event__AbstractLinkable);
-
- /* "src/gevent/event.py":58
- * self._notifier = self.hub.loop.run_callback(self._notify_links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callback to call when this object is ready.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_17_AbstractLinkable_5rawlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_rawlink, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict, __pyx_n_s_rawlink, __pyx_t_2) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event__AbstractLinkable);
-
- /* "src/gevent/event.py":70
- * self._check_and_notify()
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`rawlink`"""
- * try:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_17_AbstractLinkable_7unlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_unlink, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict, __pyx_n_s_unlink, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event__AbstractLinkable);
-
- /* "src/gevent/event.py":77
- * pass
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * # Actually call the notification callbacks. Those callbacks in todo that are
- * # still in _links are called. This method is careful to avoid iterating
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_17_AbstractLinkable_9_notify_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable__notify_links, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict, __pyx_n_s_notify_links, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event__AbstractLinkable);
-
- /* "src/gevent/event.py":109
- * self._notifier = None
- *
- * def _wait_core(self, timeout, catch=Timeout): # <<<<<<<<<<<<<<
- * # The core of the wait implementation, handling
- * # switching and linking. If *catch* is set to (),
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_event_Timeout);
- __pyx_k_ = __pyx_v_6gevent_6_event_Timeout;
- __Pyx_GIVEREF(__pyx_v_6gevent_6_event_Timeout);
-
- /* "src/gevent/event.py":160
- * """
- *
- * __slots__ = ('_flag', '__weakref__') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_slots, __pyx_tuple__15) < 0) __PYX_ERR(0, 160, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":169
- * return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
- *
- * def is_set(self): # <<<<<<<<<<<<<<
- * """Return true if and only if the internal flag is true."""
- * return self._flag
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_5is_set, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_is_set, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_is_set, __pyx_t_2) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":173
- * return self._flag
- *
- * def isSet(self): # <<<<<<<<<<<<<<
- * # makes it a better drop-in replacement for threading.Event
- * return self._flag
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_7isSet, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_isSet, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_isSet, __pyx_t_2) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":177
- * return self._flag
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * # makes it compatible with AsyncResult and Greenlet (for
- * # example in wait())
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_9ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_ready, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":182
- * return self._flag
- *
- * def set(self): # <<<<<<<<<<<<<<
- * """
- * Set the internal flag to true.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_11set, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_set, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_set, __pyx_t_2) < 0) __PYX_ERR(0, 182, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":194
- * self._check_and_notify()
- *
- * def clear(self): # <<<<<<<<<<<<<<
- * """
- * Reset the internal flag to false.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_13clear, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_clear, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_clear, __pyx_t_2) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":215
- * return wait_success
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Block until the internal flag is true.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_15wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event_wait, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 215, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":242
- * return self._wait(timeout)
- *
- * def _reset_internal_locks(self): # pragma: no cover # <<<<<<<<<<<<<<
- * # for compatibility with threading.Event
- * # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_5Event_17_reset_internal_locks, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Event__reset_internal_locks, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_Event->tp_dict, __pyx_n_s_reset_internal_locks, __pyx_t_2) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_Event);
-
- /* "src/gevent/event.py":299
- * """
- *
- * __slots__ = ('_value', '_exc_info', '_imap_task_index') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_slots, __pyx_tuple__30) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":337
- * return result + ' _links[%s]>' % len(self._links)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it holds a value or an exception"""
- * return self._exc_info or self._value is not _NONE
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_5ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_ready, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":341
- * return self._exc_info or self._value is not _NONE
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """Return true if and only if it is ready and holds a value"""
- * return self._value is not _NONE
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_7successful, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_successful, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_successful, __pyx_t_2) < 0) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":352
- * return self._exc_info[1]
- *
- * def set(self, value=None): # <<<<<<<<<<<<<<
- * """Store the value and wake up any waiters.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_9set, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_set, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_set, __pyx_t_2) < 0) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":361
- * self._check_and_notify()
- *
- * def set_exception(self, exception, exc_info=None): # <<<<<<<<<<<<<<
- * """Store the exception and wake up any waiters.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_11set_exception, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_set_exception, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_set_exception, __pyx_t_2) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":378
- * self._check_and_notify()
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_13_raise_exception, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult__raise_exception, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_raise_exception, __pyx_t_2) < 0) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":381
- * reraise(*self.exc_info)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return the stored value or raise the exception.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_15get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_get, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_get, __pyx_t_2) < 0) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":411
- * return self.get(block=False)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """
- * Return the value or raise the exception without blocking.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_17get_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_get_nowait, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_get_nowait, __pyx_t_2) < 0) __PYX_ERR(0, 411, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":426
- * return self.value
- *
- * def wait(self, timeout=None): # <<<<<<<<<<<<<<
- * """Block until the instance is ready.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_19wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_wait, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":456
- * # Methods to make us more like concurrent.futures.Future
- *
- * def result(self, timeout=None): # <<<<<<<<<<<<<<
- * return self.get(timeout=timeout)
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_23result, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_result, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_result, __pyx_t_2) < 0) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":459
- * return self.get(timeout=timeout)
- *
- * set_result = set # <<<<<<<<<<<<<<
- *
- * def done(self):
- */
- __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult, __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_set_result, __pyx_t_2) < 0) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":461
- * set_result = set
- *
- * def done(self): # <<<<<<<<<<<<<<
- * return self.ready()
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_25done, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_done, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_done, __pyx_t_2) < 0) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":466
- * # we don't support cancelling
- *
- * def cancel(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_27cancel, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_cancel, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_cancel, __pyx_t_2) < 0) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":469
- * return False
- *
- * def cancelled(self): # <<<<<<<<<<<<<<
- * return False
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_event_11AsyncResult_29cancelled, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AsyncResult_cancelled, NULL, __pyx_n_s_gevent__event, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict, __pyx_n_s_cancelled, __pyx_t_2) < 0) __PYX_ERR(0, 469, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_event_AsyncResult);
-
- /* "src/gevent/event.py":477
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_f_6gevent_6_event__init();
-
- /* "src/gevent/event.py":480
- *
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent._event')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 480, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 480, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 480, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/event.py":481
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent._event') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 481, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent__event);
- __Pyx_GIVEREF(__pyx_n_s_gevent__event);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent__event);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/event.py":1
- * # Copyright (c) 2009-2016 Denis Bilenko, gevent contributors. See LICENSE for details. # <<<<<<<<<<<<<<
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
- *
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent._event", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent._event");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* KeywordStringCheck */
-static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* pyfrozenset_new */
- static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
- if (it) {
- PyObject* result;
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* args;
- args = PyTuple_Pack(1, it);
- if (unlikely(!args))
- return NULL;
- result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
- Py_DECREF(args);
- return result;
-#else
- if (PyFrozenSet_CheckExact(it)) {
- Py_INCREF(it);
- return it;
- }
- result = PyFrozenSet_New(it);
- if (unlikely(!result))
- return NULL;
- if (likely(PySet_GET_SIZE(result)))
- return result;
- Py_DECREF(result);
-#endif
- }
-#if CYTHON_USE_TYPE_SLOTS
- return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
-#else
- return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
-#endif
-}
-
-/* py_set_discard_unhashable */
- static int __Pyx_PySet_DiscardUnhashable(PyObject *set, PyObject *key) {
- PyObject *tmpkey;
- int rv;
- if (likely(!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)))
- return -1;
- PyErr_Clear();
- tmpkey = __Pyx_PyFrozenSet_New(key);
- if (tmpkey == NULL)
- return -1;
- rv = PySet_Discard(set, tmpkey);
- Py_DECREF(tmpkey);
- return rv;
-}
-
-/* py_set_remove */
- static int __Pyx_PySet_RemoveNotFound(PyObject *set, PyObject *key, int found) {
- if (unlikely(found < 0)) {
- found = __Pyx_PySet_DiscardUnhashable(set, key);
- }
- if (likely(found == 0)) {
- PyObject *tup;
- tup = PyTuple_Pack(1, key);
- if (!tup)
- return -1;
- PyErr_SetObject(PyExc_KeyError, tup);
- Py_DECREF(tup);
- return -1;
- }
- return found;
-}
-static CYTHON_INLINE int __Pyx_PySet_Remove(PyObject *set, PyObject *key) {
- int found = PySet_Discard(set, key);
- if (unlikely(found != 1)) {
- return __Pyx_PySet_RemoveNotFound(set, key, found);
- }
- return 0;
-}
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* set_iter */
- static CYTHON_INLINE PyObject* __Pyx_set_iterator(PyObject* iterable, int is_set,
- Py_ssize_t* p_orig_length, int* p_source_is_set) {
-#if CYTHON_COMPILING_IN_CPYTHON
- is_set = is_set || likely(PySet_CheckExact(iterable) || PyFrozenSet_CheckExact(iterable));
- *p_source_is_set = is_set;
- if (likely(is_set)) {
- *p_orig_length = PySet_Size(iterable);
- Py_INCREF(iterable);
- return iterable;
- }
-#else
- (void)is_set;
- *p_source_is_set = 0;
-#endif
- *p_orig_length = 0;
- return PyObject_GetIter(iterable);
-}
-static CYTHON_INLINE int __Pyx_set_iter_next(
- PyObject* iter_obj, Py_ssize_t orig_length,
- Py_ssize_t* ppos, PyObject **value,
- int source_is_set) {
- if (!CYTHON_COMPILING_IN_CPYTHON || unlikely(!source_is_set)) {
- *value = PyIter_Next(iter_obj);
- if (unlikely(!*value)) {
- return __Pyx_IterFinish();
- }
- (void)orig_length;
- (void)ppos;
- return 1;
- }
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(PySet_GET_SIZE(iter_obj) != orig_length)) {
- PyErr_SetString(
- PyExc_RuntimeError,
- "set changed size during iteration");
- return -1;
- }
- {
- Py_hash_t hash;
- int ret = _PySet_NextEntry(iter_obj, ppos, value, &hash);
- assert (ret != -1);
- if (likely(ret)) {
- Py_INCREF(*value);
- return 1;
- }
- }
-#endif
- return 0;
-}
-
-/* PySetContains */
- static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
- int result = -1;
- if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
- PyObject *tmpkey;
- PyErr_Clear();
- tmpkey = __Pyx_PyFrozenSet_New(key);
- if (tmpkey != NULL) {
- result = PySet_Contains(set, tmpkey);
- Py_DECREF(tmpkey);
- }
- }
- return result;
-}
-static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
- int result = PySet_Contains(set, key);
- if (unlikely(result < 0)) {
- result = __Pyx_PySet_ContainsUnhashable(set, key);
- }
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/event.py b/python/gevent/event.py
deleted file mode 100644
index 06fe82a..0000000
--- a/python/gevent/event.py
+++ /dev/null
@@ -1,481 +0,0 @@
-# Copyright (c) 2009-2016 Denis Bilenko, gevent contributors. See LICENSE for details.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False,infer_types=True
-
-"""Basic synchronization primitives: Event and AsyncResult"""
-from __future__ import print_function
-import sys
-
-from gevent._util import _NONE
-from gevent._compat import reraise
-from gevent._tblib import dump_traceback, load_traceback
-
-from gevent._hub_local import get_hub_noargs as get_hub
-
-from gevent.exceptions import InvalidSwitchError
-from gevent.timeout import Timeout
-
-
-__all__ = [
- 'Event',
- 'AsyncResult',
-]
-
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-
-
-class _AbstractLinkable(object):
- # Encapsulates the standard parts of the linking and notifying protocol
- # common to both repeatable events and one-time events (AsyncResult).
-
- __slots__ = ('_links', 'hub', '_notifier')
-
- def __init__(self):
- # Also previously, AsyncResult maintained the order of notifications, but Event
- # did not; this implementation does not. (Event also only call callbacks one
- # time (set), but AsyncResult permitted duplicates.)
-
- # HOWEVER, gevent.queue.Queue does guarantee the order of getters relative
- # to putters. Some existing documentation out on the net likes to refer to
- # gevent as "deterministic", such that running the same program twice will
- # produce results in the same order (so long as I/O isn't involved). This could
- # be an argument to maintain order. (One easy way to do that while guaranteeing
- # uniqueness would be with a 2.7+ OrderedDict.)
- self._links = set()
- self.hub = get_hub()
- self._notifier = None
-
- def ready(self):
- # Instances must define this
- raise NotImplementedError()
-
- def _check_and_notify(self):
- # If this object is ready to be notified, begin the process.
- if self.ready():
- if self._links and not self._notifier:
- self._notifier = self.hub.loop.run_callback(self._notify_links)
-
- def rawlink(self, callback):
- """
- Register a callback to call when this object is ready.
-
- *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.
- *callback* will be passed one argument: this instance.
- """
- if not callable(callback):
- raise TypeError('Expected callable: %r' % (callback, ))
- self._links.add(callback)
- self._check_and_notify()
-
- def unlink(self, callback):
- """Remove the callback set by :meth:`rawlink`"""
- try:
- self._links.remove(callback)
- except KeyError:
- pass
-
- def _notify_links(self):
- # Actually call the notification callbacks. Those callbacks in todo that are
- # still in _links are called. This method is careful to avoid iterating
- # over self._links, because links could be added or removed while this
- # method runs. Only links present when this method begins running
- # will be called; if a callback adds a new link, it will not run
- # until the next time notify_links is activated
-
- # We don't need to capture self._links as todo when establishing
- # this callback; any links removed between now and then are handled
- # by the `if` below; any links added are also grabbed
- todo = set(self._links)
- for link in todo:
- # check that link was not notified yet and was not removed by the client
- # We have to do this here, and not as part of the 'for' statement because
- # a previous link(self) call might have altered self._links
- if link in self._links:
- try:
- link(self)
- except: # pylint:disable=bare-except
- self.hub.handle_error((link, self), *sys.exc_info())
- if getattr(link, 'auto_unlink', None):
- # This attribute can avoid having to keep a reference to the function
- # *in* the function, which is a cycle
- self.unlink(link)
-
- # save a tiny bit of memory by letting _notifier be collected
- # bool(self._notifier) would turn to False as soon as we exit this
- # method anyway.
- del todo
- self._notifier = None
-
- def _wait_core(self, timeout, catch=Timeout):
- # The core of the wait implementation, handling
- # switching and linking. If *catch* is set to (),
- # a timeout that elapses will be allowed to be raised.
- # Returns a true value if the wait succeeded without timing out.
- switch = getcurrent().switch # pylint:disable=undefined-variable
- self.rawlink(switch)
- try:
- with Timeout._start_new_or_dummy(timeout) as timer:
- try:
- result = self.hub.switch()
- if result is not self: # pragma: no cover
- raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, ))
- return True
- except catch as ex:
- if ex is not timer:
- raise
- # test_set_and_clear and test_timeout in test_threading
- # rely on the exact return values, not just truthish-ness
- return False
- finally:
- self.unlink(switch)
-
- def _wait_return_value(self, waited, wait_success):
- # pylint:disable=unused-argument
- return None
-
- def _wait(self, timeout=None):
- if self.ready():
- return self._wait_return_value(False, False)
-
- gotit = self._wait_core(timeout)
- return self._wait_return_value(True, gotit)
-
-
-class Event(_AbstractLinkable):
- """A synchronization primitive that allows one greenlet to wake up one or more others.
- It has the same interface as :class:`threading.Event` but works across greenlets.
-
- An event object manages an internal flag that can be set to true with the
- :meth:`set` method and reset to false with the :meth:`clear` method. The :meth:`wait` method
- blocks until the flag is true.
-
- .. note::
- The order and timing in which waiting greenlets are awakened is not determined.
- As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a
- undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets
- (those not waiting to be awakened) may run between the current greenlet yielding and
- the waiting greenlets being awakened. These details may change in the future.
- """
-
- __slots__ = ('_flag', '__weakref__')
-
- def __init__(self):
- _AbstractLinkable.__init__(self)
- self._flag = False
-
- def __str__(self):
- return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links))
-
- def is_set(self):
- """Return true if and only if the internal flag is true."""
- return self._flag
-
- def isSet(self):
- # makes it a better drop-in replacement for threading.Event
- return self._flag
-
- def ready(self):
- # makes it compatible with AsyncResult and Greenlet (for
- # example in wait())
- return self._flag
-
- def set(self):
- """
- Set the internal flag to true.
-
- All greenlets waiting for it to become true are awakened in
- some order at some time in the future. Greenlets that call
- :meth:`wait` once the flag is true will not block at all
- (until :meth:`clear` is called).
- """
- self._flag = True
- self._check_and_notify()
-
- def clear(self):
- """
- Reset the internal flag to false.
-
- Subsequently, threads calling :meth:`wait` will block until
- :meth:`set` is called to set the internal flag to true again.
- """
- self._flag = False
-
- def _wait_return_value(self, waited, wait_success):
- # To avoid the race condition outlined in http://bugs.python.org/issue13502,
- # if we had to wait, then we need to return whether or not
- # the condition got changed. Otherwise we simply echo
- # the current state of the flag (which should be true)
- if not waited:
- flag = self._flag
- assert flag, "if we didn't wait we should already be set"
- return flag
-
- return wait_success
-
- def wait(self, timeout=None):
- """
- Block until the internal flag is true.
-
- If the internal flag is true on entry, return immediately. Otherwise,
- block until another thread (greenlet) calls :meth:`set` to set the flag to true,
- or until the optional timeout occurs.
-
- When the *timeout* argument is present and not ``None``, it should be a
- floating point number specifying a timeout for the operation in seconds
- (or fractions thereof).
-
- :return: This method returns true if and only if the internal flag has been set to
- true, either before the wait call or after the wait starts, so it will
- always return ``True`` except if a timeout is given and the operation
- times out.
-
- .. versionchanged:: 1.1
- The return value represents the flag during the elapsed wait, not
- just after it elapses. This solves a race condition if one greenlet
- sets and then clears the flag without switching, while other greenlets
- are waiting. When the waiters wake up, this will return True; previously,
- they would still wake up, but the return value would be False. This is most
- noticeable when the *timeout* is present.
- """
- return self._wait(timeout)
-
- def _reset_internal_locks(self): # pragma: no cover
- # for compatibility with threading.Event
- # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",)
- # in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
- pass
-
-
-class AsyncResult(_AbstractLinkable):
- """A one-time event that stores a value or an exception.
-
- Like :class:`Event` it wakes up all the waiters when :meth:`set` or :meth:`set_exception`
- is called. Waiters may receive the passed value or exception by calling :meth:`get`
- instead of :meth:`wait`. An :class:`AsyncResult` instance cannot be reset.
-
- To pass a value call :meth:`set`. Calls to :meth:`get` (those that are currently blocking as well as
- those made in the future) will return the value:
-
- >>> result = AsyncResult()
- >>> result.set(100)
- >>> result.get()
- 100
-
- To pass an exception call :meth:`set_exception`. This will cause :meth:`get` to raise that exception:
-
- >>> result = AsyncResult()
- >>> result.set_exception(RuntimeError('failure'))
- >>> result.get()
- Traceback (most recent call last):
- ...
- RuntimeError: failure
-
- :class:`AsyncResult` implements :meth:`__call__` and thus can be used as :meth:`link` target:
-
- >>> import gevent
- >>> result = AsyncResult()
- >>> gevent.spawn(lambda : 1/0).link(result)
- >>> try:
- ... result.get()
- ... except ZeroDivisionError:
- ... print('ZeroDivisionError')
- ZeroDivisionError
-
- .. note::
- The order and timing in which waiting greenlets are awakened is not determined.
- As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a
- undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets
- (those not waiting to be awakened) may run between the current greenlet yielding and
- the waiting greenlets being awakened. These details may change in the future.
-
- .. versionchanged:: 1.1
- The exact order in which waiting greenlets are awakened is not the same
- as in 1.0.
- .. versionchanged:: 1.1
- Callbacks :meth:`linked <rawlink>` to this object are required to be hashable, and duplicates are
- merged.
- """
-
- __slots__ = ('_value', '_exc_info', '_imap_task_index')
-
- def __init__(self):
- _AbstractLinkable.__init__(self)
- self._value = _NONE
- self._exc_info = ()
-
- @property
- def _exception(self):
- return self._exc_info[1] if self._exc_info else _NONE
-
- @property
- def value(self):
- """
- Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise,
- ``None``
- """
- return self._value if self._value is not _NONE else None
-
- @property
- def exc_info(self):
- """
- The three-tuple of exception information if :meth:`set_exception` was called.
- """
- if self._exc_info:
- return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2]))
- return ()
-
- def __str__(self):
- result = '<%s ' % (self.__class__.__name__, )
- if self.value is not None or self._exception is not _NONE:
- result += 'value=%r ' % self.value
- if self._exception is not None and self._exception is not _NONE:
- result += 'exception=%r ' % self._exception
- if self._exception is _NONE:
- result += 'unset '
- return result + ' _links[%s]>' % len(self._links)
-
- def ready(self):
- """Return true if and only if it holds a value or an exception"""
- return self._exc_info or self._value is not _NONE
-
- def successful(self):
- """Return true if and only if it is ready and holds a value"""
- return self._value is not _NONE
-
- @property
- def exception(self):
- """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called.
- Otherwise ``None``."""
- if self._exc_info:
- return self._exc_info[1]
-
- def set(self, value=None):
- """Store the value and wake up any waiters.
-
- All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.
- Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.
- """
- self._value = value
- self._check_and_notify()
-
- def set_exception(self, exception, exc_info=None):
- """Store the exception and wake up any waiters.
-
- All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.
- Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.
-
- :keyword tuple exc_info: If given, a standard three-tuple of type, value, :class:`traceback`
- as returned by :func:`sys.exc_info`. This will be used when the exception
- is re-raised to propagate the correct traceback.
- """
- if exc_info:
- self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2]))
- else:
- self._exc_info = (type(exception), exception, dump_traceback(None))
-
- self._check_and_notify()
-
- def _raise_exception(self):
- reraise(*self.exc_info)
-
- def get(self, block=True, timeout=None):
- """Return the stored value or raise the exception.
-
- If this instance already holds a value or an exception, return or raise it immediately.
- Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or
- until the optional timeout occurs.
-
- When the *timeout* argument is present and not ``None``, it should be a
- floating point number specifying a timeout for the operation in seconds
- (or fractions thereof). If the *timeout* elapses, the *Timeout* exception will
- be raised.
-
- :keyword bool block: If set to ``False`` and this instance is not ready,
- immediately raise a :class:`Timeout` exception.
- """
- if self._value is not _NONE:
- return self._value
- if self._exc_info:
- return self._raise_exception()
-
- if not block:
- # Not ready and not blocking, so immediately timeout
- raise Timeout()
-
- # Wait, raising a timeout that elapses
- self._wait_core(timeout, ())
-
- # by definition we are now ready
- return self.get(block=False)
-
- def get_nowait(self):
- """
- Return the value or raise the exception without blocking.
-
- If this object is not yet :meth:`ready <ready>`, raise
- :class:`gevent.Timeout` immediately.
- """
- return self.get(block=False)
-
- def _wait_return_value(self, waited, wait_success):
- # pylint:disable=unused-argument
- # Always return the value. Since this is a one-shot event,
- # no race condition should reset it.
- return self.value
-
- def wait(self, timeout=None):
- """Block until the instance is ready.
-
- If this instance already holds a value, it is returned immediately. If this
- instance already holds an exception, ``None`` is returned immediately.
-
- Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception`
- (at which point either the value or ``None`` will be returned, respectively),
- or until the optional timeout expires (at which point ``None`` will also be
- returned).
-
- When the *timeout* argument is present and not ``None``, it should be a
- floating point number specifying a timeout for the operation in seconds
- (or fractions thereof).
-
- .. note:: If a timeout is given and expires, ``None`` will be returned
- (no timeout exception will be raised).
-
- """
- return self._wait(timeout)
-
- # link protocol
- def __call__(self, source):
- if source.successful():
- self.set(source.value)
- else:
- self.set_exception(source.exception, getattr(source, 'exc_info', None))
-
- # Methods to make us more like concurrent.futures.Future
-
- def result(self, timeout=None):
- return self.get(timeout=timeout)
-
- set_result = set
-
- def done(self):
- return self.ready()
-
- # we don't support cancelling
-
- def cancel(self):
- return False
-
- def cancelled(self):
- return False
-
- # exception is a method, we use it as a property
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent._event')
diff --git a/python/gevent/events.py b/python/gevent/events.py
deleted file mode 100644
index 12c02ec..0000000
--- a/python/gevent/events.py
+++ /dev/null
@@ -1,480 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2018 gevent. See LICENSE for details.
-"""
-Publish/subscribe event infrastructure.
-
-When certain "interesting" things happen during the lifetime of the
-process, gevent will "publish" an event (an object). That event is
-delivered to interested "subscribers" (functions that take one
-parameter, the event object).
-
-Higher level frameworks may take this foundation and build richer
-models on it.
-
-If :mod:`zope.event` is installed, then it will be used to provide the
-functionality of `notify` and `subscribers`. See
-:mod:`zope.event.classhandler` for a simple class-based approach to
-subscribing to a filtered list of events, and see `zope.component
-<https://zopecomponent.readthedocs.io/en/latest/event.html>`_ for a
-much higher-level, flexible system. If you are using one of these systems,
-you generally will not want to directly modify `subscribers`.
-
-.. versionadded:: 1.3b1
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-__all__ = [
- 'subscribers',
-
- # monitor thread
- 'IEventLoopBlocked',
- 'EventLoopBlocked',
- 'IMemoryUsageThresholdExceeded',
- 'MemoryUsageThresholdExceeded',
- 'IMemoryUsageUnderThreshold',
- 'MemoryUsageUnderThreshold',
-
- # Hub
- 'IPeriodicMonitorThread',
- 'IPeriodicMonitorThreadStartedEvent',
- 'PeriodicMonitorThreadStartedEvent',
-
- # monkey
- 'IGeventPatchEvent',
- 'GeventPatchEvent',
- 'IGeventWillPatchEvent',
- 'DoNotPatch',
- 'GeventWillPatchEvent',
- 'IGeventDidPatchEvent',
- 'IGeventWillPatchModuleEvent',
- 'GeventWillPatchModuleEvent',
- 'IGeventDidPatchModuleEvent',
- 'GeventDidPatchModuleEvent',
- 'IGeventWillPatchAllEvent',
- 'GeventWillPatchAllEvent',
- 'IGeventDidPatchBuiltinModulesEvent',
- 'GeventDidPatchBuiltinModulesEvent',
- 'IGeventDidPatchAllEvent',
- 'GeventDidPatchAllEvent',
-]
-
-# pylint:disable=no-self-argument
-
-try:
- from zope.event import subscribers
- from zope.event import notify
-except ImportError:
- #: Applications may register for notification of events by appending a
- #: callable to the ``subscribers`` list.
- #:
- #: Each subscriber takes a single argument, which is the event object
- #: being published.
- #:
- #: Exceptions raised by subscribers will be propagated *without* running
- #: any remaining subscribers.
- subscribers = []
-
- def notify(event):
- """
- Notify all subscribers of ``event``.
- """
- for subscriber in subscribers:
- subscriber(event)
-
-notify = notify # export
-try:
- # pkg_resources is technically optional, we don't
- # list a hard dependency on it.
- __import__('pkg_resources')
-except ImportError:
- notify_and_call_entry_points = notify
-else:
- from pkg_resources import iter_entry_points
- import platform
- try:
- # Cache the platform info. pkg_resources uses
- # platform.machine() for environment markers, and
- # platform.machine() wants to call os.popen('uname'), which is
- # broken on Py2 when the gevent child signal handler is
- # installed. (see test__monkey_sigchild_2.py)
- platform.uname()
- except: # pylint:disable=bare-except
- pass
- finally:
- del platform
-
- def notify_and_call_entry_points(event):
- notify(event)
- for plugin in iter_entry_points(event.ENTRY_POINT_NAME):
- subscriber = plugin.load()
- subscriber(event)
-
-from gevent._util import Interface
-from gevent._util import implementer
-from gevent._util import Attribute
-
-
-class IPeriodicMonitorThread(Interface):
- """
- The contract for the periodic monitoring thread that is started
- by the hub.
- """
-
- def add_monitoring_function(function, period):
- """
- Schedule the *function* to be called approximately every *period* fractional seconds.
-
- The *function* receives one argument, the hub being monitored. It is called
- in the monitoring thread, *not* the hub thread. It **must not** attempt to
- use the gevent asynchronous API.
-
- If the *function* is already a monitoring function, then its *period*
- will be updated for future runs.
-
- If the *period* is ``None``, then the function will be removed.
-
- A *period* less than or equal to zero is not allowed.
- """
-
-class IPeriodicMonitorThreadStartedEvent(Interface):
- """
- The event emitted when a hub starts a periodic monitoring thread.
-
- You can use this event to add additional monitoring functions.
- """
-
- monitor = Attribute("The instance of `IPeriodicMonitorThread` that was started.")
-
-class PeriodicMonitorThreadStartedEvent(object):
- """
- The implementation of :class:`IPeriodicMonitorThreadStartedEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.hub.periodic_monitor_thread_started'
-
- def __init__(self, monitor):
- self.monitor = monitor
-
-class IEventLoopBlocked(Interface):
- """
- The event emitted when the event loop is blocked.
-
- This event is emitted in the monitor thread.
- """
-
- greenlet = Attribute("The greenlet that appeared to be blocking the loop.")
- blocking_time = Attribute("The approximate time in seconds the loop has been blocked.")
- info = Attribute("A sequence of string lines providing extra info.")
-
-@implementer(IEventLoopBlocked)
-class EventLoopBlocked(object):
- """
- The event emitted when the event loop is blocked.
-
- Implements `IEventLoopBlocked`.
- """
-
- def __init__(self, greenlet, blocking_time, info):
- self.greenlet = greenlet
- self.blocking_time = blocking_time
- self.info = info
-
-class IMemoryUsageThresholdExceeded(Interface):
- """
- The event emitted when the memory usage threshold is exceeded.
-
- This event is emitted only while memory continues to grow
- above the threshold. Only if the condition or stabilized is corrected (memory
- usage drops) will the event be emitted in the future.
-
- This event is emitted in the monitor thread.
- """
-
- mem_usage = Attribute("The current process memory usage, in bytes.")
- max_allowed = Attribute("The maximum allowed memory usage, in bytes.")
- memory_info = Attribute("The tuple of memory usage stats return by psutil.")
-
-class _AbstractMemoryEvent(object):
-
- def __init__(self, mem_usage, max_allowed, memory_info):
- self.mem_usage = mem_usage
- self.max_allowed = max_allowed
- self.memory_info = memory_info
-
- def __repr__(self):
- return "<%s used=%d max=%d details=%r>" % (
- self.__class__.__name__,
- self.mem_usage,
- self.max_allowed,
- self.memory_info,
- )
-
-@implementer(IMemoryUsageThresholdExceeded)
-class MemoryUsageThresholdExceeded(_AbstractMemoryEvent):
- """
- Implementation of `IMemoryUsageThresholdExceeded`.
- """
-
-
-class IMemoryUsageUnderThreshold(Interface):
- """
- The event emitted when the memory usage drops below the
- threshold after having previously been above it.
-
- This event is emitted only the first time memory usage is detected
- to be below the threshold after having previously been above it.
- If memory usage climbs again, a `IMemoryUsageThresholdExceeded`
- event will be broadcast, and then this event could be broadcast again.
-
- This event is emitted in the monitor thread.
- """
-
- mem_usage = Attribute("The current process memory usage, in bytes.")
- max_allowed = Attribute("The maximum allowed memory usage, in bytes.")
- max_memory_usage = Attribute("The memory usage that caused the previous "
- "IMemoryUsageThresholdExceeded event.")
- memory_info = Attribute("The tuple of memory usage stats return by psutil.")
-
-
-@implementer(IMemoryUsageUnderThreshold)
-class MemoryUsageUnderThreshold(_AbstractMemoryEvent):
- """
- Implementation of `IMemoryUsageUnderThreshold`.
- """
-
- def __init__(self, mem_usage, max_allowed, memory_info, max_usage):
- super(MemoryUsageUnderThreshold, self).__init__(mem_usage, max_allowed, memory_info)
- self.max_memory_usage = max_usage
-
-
-class IGeventPatchEvent(Interface):
- """
- The root for all monkey-patch events gevent emits.
- """
-
- source = Attribute("The source object containing the patches.")
- target = Attribute("The destination object to be patched.")
-
-@implementer(IGeventPatchEvent)
-class GeventPatchEvent(object):
- """
- Implementation of `IGeventPatchEvent`.
- """
-
- def __init__(self, source, target):
- self.source = source
- self.target = target
-
- def __repr__(self):
- return '<%s source=%r target=%r at %x>' % (self.__class__.__name__,
- self.source,
- self.target,
- id(self))
-
-class IGeventWillPatchEvent(IGeventPatchEvent):
- """
- An event emitted *before* gevent monkey-patches something.
-
- If a subscriber raises `DoNotPatch`, then patching this particular
- item will not take place.
- """
-
-
-class DoNotPatch(BaseException):
- """
- Subscribers to will-patch events can raise instances
- of this class to tell gevent not to patch that particular item.
- """
-
-
-@implementer(IGeventWillPatchEvent)
-class GeventWillPatchEvent(GeventPatchEvent):
- """
- Implementation of `IGeventWillPatchEvent`.
- """
-
-class IGeventDidPatchEvent(IGeventPatchEvent):
- """
- An event emitted *after* gevent has patched something.
- """
-
-@implementer(IGeventDidPatchEvent)
-class GeventDidPatchEvent(GeventPatchEvent):
- """
- Implementation of `IGeventDidPatchEvent`.
- """
-
-class IGeventWillPatchModuleEvent(IGeventWillPatchEvent):
- """
- An event emitted *before* gevent begins patching a specific module.
-
- Both *source* and *target* attributes are module objects.
- """
-
- module_name = Attribute("The name of the module being patched. "
- "This is the same as ``target.__name__``.")
-
- target_item_names = Attribute("The list of item names to patch. "
- "This can be modified in place with caution.")
-
-@implementer(IGeventWillPatchModuleEvent)
-class GeventWillPatchModuleEvent(GeventWillPatchEvent):
- """
- Implementation of `IGeventWillPatchModuleEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.monkey.will_patch_module'
-
- def __init__(self, module_name, source, target, items):
- super(GeventWillPatchModuleEvent, self).__init__(source, target)
- self.module_name = module_name
- self.target_item_names = items
-
-
-class IGeventDidPatchModuleEvent(IGeventDidPatchEvent):
- """
- An event emitted *after* gevent has completed patching a specific
- module.
- """
-
- module_name = Attribute("The name of the module being patched. "
- "This is the same as ``target.__name__``.")
-
-
-@implementer(IGeventDidPatchModuleEvent)
-class GeventDidPatchModuleEvent(GeventDidPatchEvent):
- """
- Implementation of `IGeventDidPatchModuleEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.monkey.did_patch_module'
-
- def __init__(self, module_name, source, target):
- super(GeventDidPatchModuleEvent, self).__init__(source, target)
- self.module_name = module_name
-
-# TODO: Maybe it would be useful for the the module patch events
-# to have an attribute telling if they're being done during patch_all?
-
-class IGeventWillPatchAllEvent(IGeventWillPatchEvent):
- """
- An event emitted *before* gevent begins patching the system.
-
- Following this event will be a series of
- `IGeventWillPatchModuleEvent` and `IGeventDidPatchModuleEvent` for
- each patched module.
-
- Once the gevent builtin modules have been processed,
- `IGeventDidPatchBuiltinModulesEvent` will be emitted. Processing
- this event is an ideal time for third-party modules to be imported
- and patched (which may trigger its own will/did patch module
- events).
-
- Finally, a `IGeventDidPatchAllEvent` will be sent.
-
- If a subscriber to this event raises `DoNotPatch`, no patching
- will be done.
-
- The *source* and *target* attributes have undefined values.
- """
-
- patch_all_arguments = Attribute(
- "A dictionary of all the arguments to `gevent.monkey.patch_all`. "
- "This dictionary should not be modified. "
- )
-
- patch_all_kwargs = Attribute(
- "A dictionary of the extra arguments to `gevent.monkey.patch_all`. "
- "This dictionary should not be modified. "
- )
-
- def will_patch_module(module_name):
- """
- Return whether the module named *module_name* will be patched.
- """
-
-class _PatchAllMixin(object):
- def __init__(self, patch_all_arguments, patch_all_kwargs):
- super(_PatchAllMixin, self).__init__(None, None)
- self._patch_all_arguments = patch_all_arguments
- self._patch_all_kwargs = patch_all_kwargs
-
- @property
- def patch_all_arguments(self):
- return self._patch_all_arguments.copy()
-
- @property
- def patch_all_kwargs(self):
- return self._patch_all_kwargs.copy()
-
- def __repr__(self):
- return '<%s %r at %x>' % (self.__class__.__name__,
- self._patch_all_arguments,
- id(self))
-
-@implementer(IGeventWillPatchAllEvent)
-class GeventWillPatchAllEvent(_PatchAllMixin, GeventWillPatchEvent):
- """
- Implementation of `IGeventWillPatchAllEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.monkey.will_patch_all'
-
- def will_patch_module(self, module_name):
- return self.patch_all_arguments.get(module_name)
-
-class IGeventDidPatchBuiltinModulesEvent(IGeventDidPatchEvent):
- """
- Event emitted *after* the builtin modules have been patched.
-
- The values of the *source* and *target* attributes are undefined.
- """
-
- patch_all_arguments = Attribute(
- "A dictionary of all the arguments to `gevent.monkey.patch_all`. "
- "This dictionary should not be modified. "
- )
-
- patch_all_kwargs = Attribute(
- "A dictionary of the extra arguments to `gevent.monkey.patch_all`. "
- "This dictionary should not be modified. "
- )
-
-@implementer(IGeventDidPatchBuiltinModulesEvent)
-class GeventDidPatchBuiltinModulesEvent(_PatchAllMixin, GeventDidPatchEvent):
- """
- Implementation of `IGeventDidPatchBuiltinModulesEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.monkey.did_patch_builtins'
-
-class IGeventDidPatchAllEvent(IGeventDidPatchEvent):
- """
- Event emitted after gevent has patched all modules, both builtin
- and those provided by plugins/subscribers.
-
- The values of the *source* and *target* attributes are undefined.
- """
-
-@implementer(IGeventDidPatchAllEvent)
-class GeventDidPatchAllEvent(_PatchAllMixin, GeventDidPatchEvent):
- """
- Implementation of `IGeventDidPatchAllEvent`.
- """
-
- #: The name of the setuptools entry point that is called when this
- #: event is emitted.
- ENTRY_POINT_NAME = 'gevent.plugins.monkey.did_patch_all'
diff --git a/python/gevent/exceptions.py b/python/gevent/exceptions.py
deleted file mode 100644
index 2c779ce..0000000
--- a/python/gevent/exceptions.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright 2018 gevent
-"""
-Exceptions.
-
-.. versionadded:: 1.3b1
-
-"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-__all__ = [
- 'LoopExit',
-]
-
-
-class LoopExit(Exception):
- """
- Exception thrown when the hub finishes running (`gevent.hub.Hub.run`
- would return).
-
- In a normal application, this is never thrown or caught
- explicitly. The internal implementation of functions like
- :meth:`gevent.hub.Hub.join` and :func:`gevent.joinall` may catch it, but user code
- generally should not.
-
- .. caution::
- Errors in application programming can also lead to this exception being
- raised. Some examples include (but are not limited too):
-
- - greenlets deadlocking on a lock;
- - using a socket or other gevent object with native thread
- affinity from a different thread
-
- """
-
- def __repr__(self):
- # pylint:disable=unsubscriptable-object
- if len(self.args) == 3: # From the hub
- import pprint
- return "%s\n\tHub: %s\n\tHandles:\n%s" % (
- self.args[0], self.args[1],
- pprint.pformat(self.args[2])
- )
- return Exception.__repr__(self)
-
- def __str__(self):
- return repr(self)
-
-class BlockingSwitchOutError(AssertionError):
- """
- Raised when a gevent synchronous function is called from a
- low-level event loop callback.
-
- This is usually a programming error.
- """
-
-
-class InvalidSwitchError(AssertionError):
- """
- Raised when the event loop returns control to a greenlet in an
- unexpected way.
-
- This is usually a bug in gevent, greenlet, or the event loop.
- """
-
-class ConcurrentObjectUseError(AssertionError):
- """
- Raised when an object is used (waited on) by two greenlets
- independently, meaning the object was entered into a blocking
- state by one greenlet and then another while still blocking in the
- first one.
-
- This is usually a programming error.
-
- .. seealso:: `gevent.socket.wait`
- """
diff --git a/python/gevent/fileobject.py b/python/gevent/fileobject.py
deleted file mode 100644
index 598f882..0000000
--- a/python/gevent/fileobject.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Wrappers to make file-like objects cooperative.
-
-.. class:: FileObject
-
- The main entry point to the file-like gevent-compatible behaviour. It will be defined
- to be the best available implementation.
-
-There are two main implementations of ``FileObject``. On all systems,
-there is :class:`FileObjectThread` which uses the built-in native
-threadpool to avoid blocking the entire interpreter. On UNIX systems
-(those that support the :mod:`fcntl` module), there is also
-:class:`FileObjectPosix` which uses native non-blocking semantics.
-
-A third class, :class:`FileObjectBlock`, is simply a wrapper that executes everything
-synchronously (and so is not gevent-compatible). It is provided for testing and debugging
-purposes.
-
-Configuration
-=============
-
-You may change the default value for ``FileObject`` using the
-``GEVENT_FILE`` environment variable. Set it to ``posix``, ``thread``,
-or ``block`` to choose from :class:`FileObjectPosix`,
-:class:`FileObjectThread` and :class:`FileObjectBlock`, respectively.
-You may also set it to the fully qualified class name of another
-object that implements the file interface to use one of your own
-objects.
-
-.. note:: The environment variable must be set at the time this module
- is first imported.
-
-Classes
-=======
-"""
-from __future__ import absolute_import
-
-from gevent._config import config
-
-__all__ = [
- 'FileObjectPosix',
- 'FileObjectThread',
- 'FileObjectBlock',
- 'FileObject',
-]
-
-try:
- from fcntl import fcntl
-except ImportError:
- __all__.remove("FileObjectPosix")
-else:
- del fcntl
- from gevent._fileobjectposix import FileObjectPosix
-
-from gevent._fileobjectcommon import FileObjectThread
-from gevent._fileobjectcommon import FileObjectBlock
-
-
-# None of the possible objects can live in this module because
-# we would get an import cycle and the config couldn't be set from code.
-FileObject = config.fileobject
diff --git a/python/gevent/greenlet.c b/python/gevent/greenlet.c
deleted file mode 100644
index eb4280a..0000000
--- a/python/gevent/greenlet.c
+++ /dev/null
@@ -1,24050 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/__ident.pxd",
- "src/gevent/_greenlet.pxd",
- "src/gevent/_ident.py",
- "src\\gevent\\__ident.pxd",
- "src\\gevent\\_greenlet.pxd",
- "src\\gevent\\_ident.py"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent._greenlet",
- "sources": [
- "src/gevent/greenlet.py"
- ]
- },
- "module_name": "gevent._greenlet"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 1
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent___greenlet
-#define __PYX_HAVE_API__gevent___greenlet
-/* Early includes */
-#include "greenlet/greenlet.h"
-#include "frameobject.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\greenlet.py",
- "src\\gevent\\_greenlet.pxd",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
- "stringsource",
- "src\\gevent\\__ident.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef;
-struct __pyx_obj_6gevent_7__ident_IdentRegistry;
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet__Frame;
-struct __pyx_obj_6gevent_9_greenlet_Greenlet;
-struct __pyx_obj_6gevent_9_greenlet__dummy_event;
-struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py;
-struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py;
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join;
-struct __pyx_opt_args_6gevent_9_greenlet_joinall;
-struct __pyx_defaults;
-typedef struct __pyx_defaults __pyx_defaults;
-
-/* "gevent/_greenlet.pxd":105
- *
- * cpdef bint has_links(self)
- * cpdef join(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint ready(self)
- * cpdef bint successful(self)
- */
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_greenlet.pxd":174
- *
- * @cython.locals(done=list)
- * cpdef joinall(greenlets, timeout=*, raise_error=*, count=*) # <<<<<<<<<<<<<<
- */
-struct __pyx_opt_args_6gevent_9_greenlet_joinall {
- int __pyx_n;
- PyObject *timeout;
- PyObject *raise_error;
- PyObject *count;
-};
-struct __pyx_defaults {
- PyObject *__pyx_arg_exception;
-};
-
-/* "gevent/__ident.pxd":15
- * @cython.internal
- * @cython.final
- * cdef class ValuedWeakRef(ref): # <<<<<<<<<<<<<<
- * cdef object value
- *
- */
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef {
- PyWeakReference __pyx_base;
- PyObject *value;
-};
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-struct __pyx_obj_6gevent_7__ident_IdentRegistry {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtab;
- PyObject *_registry;
- PyObject *_available_idents;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-/* "gevent/_greenlet.pxd":56
- * cdef void _init()
- *
- * cdef class SpawnedLink: # <<<<<<<<<<<<<<
- * cdef public object callback
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink {
- PyObject_HEAD
- PyObject *callback;
-};
-
-
-/* "gevent/_greenlet.pxd":61
- *
- * @cython.final
- * cdef class SuccessSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":65
- *
- * @cython.final
- * cdef class FailureSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":71
- * @cython.internal
- * @cython.freelist(1000)
- * cdef class _Frame: # <<<<<<<<<<<<<<
- * cdef readonly CodeType f_code
- * cdef readonly int f_lineno
- */
-struct __pyx_obj_6gevent_9_greenlet__Frame {
- PyObject_HEAD
- PyCodeObject *f_code;
- int f_lineno;
- struct __pyx_obj_6gevent_9_greenlet__Frame *f_back;
-};
-
-
-/* "gevent/_greenlet.pxd":86
- *
- *
- * cdef class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * cdef readonly object value
- * cdef readonly tuple args
- */
-struct __pyx_obj_6gevent_9_greenlet_Greenlet {
- PyGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtab;
- PyObject *value;
- PyObject *args;
- PyObject *kwargs;
- PyObject *spawning_greenlet;
- PyObject *spawn_tree_locals;
- PyObject *_spawning_stack_frames;
- PyObject *_links;
- PyObject *_exc_info;
- PyObject *_notifier;
- PyObject *_start_event;
- PyObject *_formatted_info;
- PyObject *_ident;
-};
-
-
-/* "gevent/_greenlet.pxd":157
- * @cython.final
- * @cython.internal
- * cdef class _dummy_event: # <<<<<<<<<<<<<<
- * cdef readonly bint pending
- * cdef readonly bint active
- */
-struct __pyx_obj_6gevent_9_greenlet__dummy_event {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtab;
- int pending;
- int active;
-};
-
-
-/* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception, object waiter):
- * """wrap(greenlets: list, exception, waiter)"""
- */
-struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py {
- PyObject_HEAD
- PyObject *(*__pyx_v_f)(PyObject *, PyObject *, PyObject *);
-};
-
-struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py {
- PyObject_HEAD
- PyObject *(*__pyx_v_f)(PyObject *, PyObject *);
-};
-
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-
-struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry {
- PyObject *(*get_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_return_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtabptr_6gevent_7__ident_IdentRegistry;
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-
-/* "src/gevent/greenlet.py":157
- * _greenlet__init__ = greenlet.__init__
- *
- * class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * """
- * A light-weight cooperatively-scheduled execution unit.
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet {
- int (*has_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*join)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args);
- int (*ready)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- int (*successful)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_formatinfo)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*_get_minimal_ident)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___started_but_aborted)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_cancelled_by_kill)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_pending)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___never_started_or_killed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_completed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*__pyx___handle_death_before_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*__pyx___cancel_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*_report_result)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_report_error)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtabptr_6gevent_9_greenlet_Greenlet;
-
-
-/* "src/gevent/greenlet.py":820
- *
- *
- * class _dummy_event(object): # <<<<<<<<<<<<<<
- * __slots__ = ('pending', 'active')
- *
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event {
- PyObject *(*stop)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
- PyObject *(*start)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*close)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtabptr_6gevent_9_greenlet__dummy_event;
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_stop(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_start(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, PyObject *, int __pyx_skip_dispatch);
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_close(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* CallableCheck.proto */
-#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
-#else
-#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* IncludeStringH.proto */
-#include <string.h>
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* StrEquals.proto */
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
-#else
-#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
-#endif
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* ListExtend.proto */
-static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject* none = _PyList_Extend((PyListObject*)L, v);
- if (unlikely(!none))
- return -1;
- Py_DECREF(none);
- return 0;
-#else
- return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
-#endif
-}
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* ListCompAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len)) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* py_dict_items.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod0.proto */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_CallUnboundCMethod0(cfunc, self)\
- (likely((cfunc)->func) ?\
- (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\
- (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
- (PY_VERSION_HEX >= 0x030700A0 ?\
- (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
- (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
- (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
- ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\
- __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
- __Pyx__CallUnboundCMethod0(cfunc, self))
-#else
-#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
-#endif
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* StringJoin.proto */
-#if PY_MAJOR_VERSION < 3
-#define __Pyx_PyString_Join __Pyx_PyBytes_Join
-#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
-#else
-#define __Pyx_PyString_Join PyUnicode_Join
-#define __Pyx_PyBaseString_Join PyUnicode_Join
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION < 3
- #define __Pyx_PyBytes_Join _PyString_Join
- #else
- #define __Pyx_PyBytes_Join _PyBytes_Join
- #endif
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* PyDictContains.proto */
-static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
- int result = PyDict_Contains(dict, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* None.proto */
-static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
-
-/* py_dict_clear.proto */
-#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0)
-
-/* SliceObject.proto */
-#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\
- __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
-static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
- PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
- int has_cstart, int has_cstop, int wraparound);
-
-/* PyObjectCallMethod1.proto */
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
-static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
-
-/* pop_index.proto */
-static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix);
-static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix);
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix);
-#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ?\
- __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix)))
-#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- __Pyx_fits_Py_ssize_t(ix, type, is_signed) ?\
- __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix)))
-#else
-#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)\
- __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)
-#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
- (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
- __Pyx__PyObject_PopIndex(L, py_ix))
-#endif
-
-/* HasAttr.proto */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* ClassMethod.proto */
-#include "descrobject.h"
-static PyObject* __Pyx_Method_ClassMethod(PyObject *method);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__get_minimal_ident(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___never_started_or_killed(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_pending(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_cancelled_by_kill(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_completed(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___started_but_aborted(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet___cancel_start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet___handle_death_before_start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_args); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_ready(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_successful(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__formatinfo(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet_join(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__report_result(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_result); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__report_error(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_exc_info); /* proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_has_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet_rawlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__notify_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_stop(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_start(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_cb, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_close(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'weakref' */
-
-/* Module declarations from 'gevent.__ident' */
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ref = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ValuedWeakRef = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_IdentRegistry = 0;
-static PyObject **__pyx_vp_6gevent_7__ident_heappop = 0;
-#define __pyx_v_6gevent_7__ident_heappop (*__pyx_vp_6gevent_7__ident_heappop)
-static PyObject **__pyx_vp_6gevent_7__ident_heappush = 0;
-#define __pyx_v_6gevent_7__ident_heappush (*__pyx_vp_6gevent_7__ident_heappush)
-static PyObject **__pyx_vp_6gevent_7__ident_WeakKeyDictionary = 0;
-#define __pyx_v_6gevent_7__ident_WeakKeyDictionary (*__pyx_vp_6gevent_7__ident_WeakKeyDictionary)
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject **__pyx_vp_6gevent_8__waiter_sys = 0;
-#define __pyx_v_6gevent_8__waiter_sys (*__pyx_vp_6gevent_8__waiter_sys)
-static PyObject **__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-#define __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError (*__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError)
-static int *__pyx_vp_6gevent_8__waiter__greenlet_imported = 0;
-#define __pyx_v_6gevent_8__waiter__greenlet_imported (*__pyx_vp_6gevent_8__waiter__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_8__waiter__NONE = 0;
-#define __pyx_v_6gevent_8__waiter__NONE (*__pyx_vp_6gevent_8__waiter__NONE)
-
-/* Module declarations from 'types' */
-
-/* Module declarations from 'gevent._greenlet' */
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_CodeType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FrameType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__Frame = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_Greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__dummy_event = 0;
-static PyTypeObject *__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py = 0;
-static PyTypeObject *__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py = 0;
-static int __pyx_v_6gevent_9_greenlet__PYPY;
-static PyObject *__pyx_v_6gevent_9_greenlet_sys_getframe = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_sys_exc_info = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_Timeout = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_GreenletExit = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_InvalidSwitchError = 0;
-static int __pyx_v_6gevent_9_greenlet__greenlet_imported;
-static PyObject *__pyx_v_6gevent_9_greenlet__greenlet__init__ = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet__threadlocal = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_get_hub_class = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_wref = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_dump_traceback = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_load_traceback = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_wait = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_iwait = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_reraise = 0;
-static PyObject *__pyx_v_6gevent_9_greenlet_GEVENT_CONFIG = 0;
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_6gevent_9_greenlet__cancelled_start_event = 0;
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_6gevent_9_greenlet__start_completed_event = 0;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_9_greenlet_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_9_greenlet_greenlet_init(void); /*proto*/
-static void __pyx_f_6gevent_9_greenlet__init(void); /*proto*/
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_9_greenlet__extract_stack(int); /*proto*/
-static struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_f_6gevent_9_greenlet__Frame_from_list(PyObject *); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet__killall3(PyObject *, PyObject *, PyObject *); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet__killall(PyObject *, PyObject *); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_joinall(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_joinall *__pyx_optional_args); /*proto*/
-static PyObject *__Pyx_CFunc_object____list____object____object___to_py(PyObject *(*)(PyObject *, PyObject *, PyObject *)); /*proto*/
-static PyObject *__Pyx_CFunc_object____list____object___to_py(PyObject *(*)(PyObject *, PyObject *)); /*proto*/
-#define __Pyx_MODULE_NAME "gevent._greenlet"
-extern int __pyx_module_is_main_gevent___greenlet;
-int __pyx_module_is_main_gevent___greenlet = 0;
-
-/* Implementation of 'gevent._greenlet' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_NameError;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_reversed;
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_AttributeError;
-static PyObject *__pyx_builtin_hex;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_AssertionError;
-static const char __pyx_k_g[] = "g";
-static const char __pyx_k_t[] = "t";
-static const char __pyx_k__2[] = ": ";
-static const char __pyx_k__3[] = ">";
-static const char __pyx_k__4[] = "";
-static const char __pyx_k__5[] = "(";
-static const char __pyx_k__6[] = ", ";
-static const char __pyx_k__7[] = ")";
-static const char __pyx_k_cb[] = "cb";
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_cls[] = "cls";
-static const char __pyx_k_get[] = "__get__";
-static const char __pyx_k_hex[] = "hex";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_ref[] = "ref";
-static const char __pyx_k_run[] = "run";
-static const char __pyx_k_s_s[] = "%s=%s";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_Lazy[] = "Lazy";
-static const char __pyx_k_PYPY[] = "_PYPY";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_bool[] = "__bool__";
-static const char __pyx_k_call[] = "__call__";
-static const char __pyx_k_dead[] = "dead";
-static const char __pyx_k_dict[] = "__dict__";
-static const char __pyx_k_glet[] = "glet";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_kill[] = "_kill";
-static const char __pyx_k_link[] = "link";
-static const char __pyx_k_loop[] = "loop";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "__self__";
-static const char __pyx_k_stop[] = "stop";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wait[] = "wait";
-static const char __pyx_k_wrap[] = "wrap";
-static const char __pyx_k_wref[] = "wref";
-static const char __pyx_k_alive[] = "alive";
-static const char __pyx_k_block[] = "block";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_count[] = "count";
-static const char __pyx_k_get_2[] = "get";
-static const char __pyx_k_items[] = "items";
-static const char __pyx_k_iwait[] = "iwait";
-static const char __pyx_k_ready[] = "ready";
-static const char __pyx_k_run_2[] = "_run";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_spawn[] = "spawn";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_timer[] = "timer";
-static const char __pyx_k_PYPY_2[] = "PYPY";
-static const char __pyx_k_Waiter[] = "Waiter";
-static const char __pyx_k_active[] = "active";
-static const char __pyx_k_cancel[] = "cancel";
-static const char __pyx_k_config[] = "config";
-static const char __pyx_k_f_back[] = "f_back";
-static const char __pyx_k_f_code[] = "f_code";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_kill_2[] = "kill";
-static const char __pyx_k_kwargs[] = "kwargs";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_name_2[] = "name";
-static const char __pyx_k_parent[] = "parent";
-static const char __pyx_k_remove[] = "remove";
-static const char __pyx_k_result[] = "result";
-static const char __pyx_k_self_2[] = "self";
-static const char __pyx_k_source[] = "source";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_unlink[] = "unlink";
-static const char __pyx_k_waiter[] = "waiter";
-static const char __pyx_k_Timeout[] = "Timeout";
-static const char __pyx_k_joinall[] = "joinall";
-static const char __pyx_k_killall[] = "killall";
-static const char __pyx_k_nonzero[] = "__nonzero__";
-static const char __pyx_k_pending[] = "pending";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_reraise[] = "reraise";
-static const char __pyx_k_seconds[] = "seconds";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_weakref[] = "weakref";
-static const char __pyx_k_Greenlet[] = "Greenlet";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_f_lineno[] = "f_lineno";
-static const char __pyx_k_getframe[] = "_getframe";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_reversed[] = "reversed";
-static const char __pyx_k_s_s_at_s[] = "<%s \"%s\" at %s";
-static const char __pyx_k_waiter_2[] = "_waiter";
-static const char __pyx_k_NameError[] = "NameError";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_exception[] = "exception";
-static const char __pyx_k_greenlets[] = "greenlets";
-static const char __pyx_k_has_links[] = "has_links";
-static const char __pyx_k_Greenlet_d[] = "Greenlet-%d";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_continulet[] = "continulet";
-static const char __pyx_k_formatinfo[] = "_formatinfo";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_link_value[] = "link_value";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_successful[] = "successful";
-static const char __pyx_k_unlink_all[] = "unlink_all";
-static const char __pyx_k_SpawnedLink[] = "SpawnedLink";
-static const char __pyx_k_cfunc_to_py[] = "cfunc.to_py";
-static const char __pyx_k_raise_error[] = "raise_error";
-static const char __pyx_k_spawn_later[] = "spawn_later";
-static const char __pyx_k_start_later[] = "start_later";
-static const char __pyx_k_threadlocal[] = "_threadlocal";
-static const char __pyx_k_GreenletExit[] = "GreenletExit";
-static const char __pyx_k_Greenlet_get[] = "Greenlet.get";
-static const char __pyx_k_Greenlet_run[] = "Greenlet.run";
-static const char __pyx_k_continuation[] = "_continuation";
-static const char __pyx_k_continulet_2[] = "_continulet";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_notify_links[] = "_notify_links";
-static const char __pyx_k_readproperty[] = "readproperty";
-static const char __pyx_k_run_callback[] = "run_callback";
-static const char __pyx_k_stringsource[] = "stringsource";
-static const char __pyx_k_sys_exc_info[] = "sys_exc_info";
-static const char __pyx_k_sys_getframe[] = "sys_getframe";
-static const char __pyx_k_GEVENT_CONFIG[] = "GEVENT_CONFIG";
-static const char __pyx_k_Greenlet__run[] = "Greenlet._run";
-static const char __pyx_k_Greenlet_join[] = "Greenlet.join";
-static const char __pyx_k_Greenlet_kill[] = "Greenlet.kill";
-static const char __pyx_k_Greenlet_link[] = "Greenlet.link";
-static const char __pyx_k_Greenlet_name[] = "Greenlet.name";
-static const char __pyx_k_get_hub_class[] = "get_hub_class";
-static const char __pyx_k_gevent__tblib[] = "gevent._tblib";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_minimal_ident[] = "minimal_ident";
-static const char __pyx_k_AssertionError[] = "AssertionError";
-static const char __pyx_k_AttributeError[] = "AttributeError";
-static const char __pyx_k_Greenlet_ready[] = "Greenlet.ready";
-static const char __pyx_k_Greenlet_spawn[] = "Greenlet.spawn";
-static const char __pyx_k_Greenlet_start[] = "Greenlet.start";
-static const char __pyx_k_Greenlet_throw[] = "Greenlet.throw";
-static const char __pyx_k_dump_traceback[] = "dump_traceback";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_gevent__compat[] = "gevent._compat";
-static const char __pyx_k_gevent__config[] = "gevent._config";
-static const char __pyx_k_gevent_timeout[] = "gevent.timeout";
-static const char __pyx_k_greenlet__init[] = "_greenlet__init__";
-static const char __pyx_k_ident_registry[] = "ident_registry";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_link_exception[] = "link_exception";
-static const char __pyx_k_load_traceback[] = "load_traceback";
-static const char __pyx_k_spawning_stack[] = "spawning_stack";
-static const char __pyx_k_Greenlet_unlink[] = "Greenlet.unlink";
-static const char __pyx_k_raise_exception[] = "_raise_exception";
-static const char __pyx_k_wait_on_objects[] = "wait_on_objects";
-static const char __pyx_k_Greenlet_rawlink[] = "Greenlet.rawlink";
-static const char __pyx_k_dummy_event_stop[] = "_dummy_event.stop";
-static const char __pyx_k_gevent__greenlet[] = "gevent._greenlet";
-static const char __pyx_k_iwait_on_objects[] = "iwait_on_objects";
-static const char __pyx_k_dummy_event_close[] = "_dummy_event.close";
-static const char __pyx_k_dummy_event_start[] = "_dummy_event.start";
-static const char __pyx_k_gevent__hub_local[] = "gevent._hub_local";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_spawn_tree_locals[] = "spawn_tree_locals";
-static const char __pyx_k_Greenlet_has_links[] = "Greenlet.has_links";
-static const char __pyx_k_InvalidSwitchError[] = "InvalidSwitchError";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy";
-static const char __pyx_k_Expected_callable_r[] = "Expected callable: %r";
-static const char __pyx_k_Greenlet_link_value[] = "Greenlet.link_value";
-static const char __pyx_k_Greenlet_successful[] = "Greenlet.successful";
-static const char __pyx_k_Greenlet_unlink_all[] = "Greenlet.unlink_all";
-static const char __pyx_k_track_greenlet_tree[] = "track_greenlet_tree";
-static const char __pyx_k_Greenlet__formatinfo[] = "Greenlet._formatinfo";
-static const char __pyx_k_Greenlet_spawn_later[] = "Greenlet.spawn_later";
-static const char __pyx_k_Greenlet_start_later[] = "Greenlet.start_later";
-static const char __pyx_k_spawning_stack_limit[] = "spawning_stack_limit";
-static const char __pyx_k_cancelled_start_event[] = "_cancelled_start_event";
-static const char __pyx_k_spawning_stack_frames[] = "_spawning_stack_frames";
-static const char __pyx_k_start_completed_event[] = "_start_completed_event";
-static const char __pyx_k_Greenlet__notify_links[] = "Greenlet._notify_links";
-static const char __pyx_k_gevent__hub_primitives[] = "gevent._hub_primitives";
-static const char __pyx_k_src_gevent_greenlet_py[] = "src\\gevent\\greenlet.py";
-static const char __pyx_k_Greenlet_link_exception[] = "Greenlet.link_exception";
-static const char __pyx_k_Greenlet_spawning_stack[] = "Greenlet.spawning_stack";
-static const char __pyx_k_Greenlet__raise_exception[] = "Greenlet._raise_exception";
-static const char __pyx_k_Cannot_start_the_dummy_event[] = "Cannot start the dummy event";
-static const char __pyx_k_Pyx_CFunc_object____list____ob[] = "__Pyx_CFunc_object____list____object____object___to_py.<locals>.wrap";
-static const char __pyx_k_Invalid_switch_into_Greenlet_get[] = "Invalid switch into Greenlet.get(): %r";
-static const char __pyx_k_Invalid_switch_into_Greenlet_joi[] = "Invalid switch into Greenlet.join(): %r";
-static const char __pyx_k_Pyx_CFunc_object____list____ob_2[] = "__Pyx_CFunc_object____list____object___to_py.<locals>.wrap";
-static const char __pyx_k_The_run_argument_or_self__run_mu[] = "The run argument or self._run must be callable";
-static PyObject *__pyx_n_s_AssertionError;
-static PyObject *__pyx_n_s_AttributeError;
-static PyObject *__pyx_kp_s_Cannot_start_the_dummy_event;
-static PyObject *__pyx_kp_s_Expected_callable_r;
-static PyObject *__pyx_n_s_GEVENT_CONFIG;
-static PyObject *__pyx_n_s_Greenlet;
-static PyObject *__pyx_n_s_GreenletExit;
-static PyObject *__pyx_n_s_Greenlet__formatinfo;
-static PyObject *__pyx_n_s_Greenlet__notify_links;
-static PyObject *__pyx_n_s_Greenlet__raise_exception;
-static PyObject *__pyx_n_s_Greenlet__run;
-static PyObject *__pyx_kp_s_Greenlet_d;
-static PyObject *__pyx_n_s_Greenlet_get;
-static PyObject *__pyx_n_s_Greenlet_has_links;
-static PyObject *__pyx_n_s_Greenlet_join;
-static PyObject *__pyx_n_s_Greenlet_kill;
-static PyObject *__pyx_n_s_Greenlet_link;
-static PyObject *__pyx_n_s_Greenlet_link_exception;
-static PyObject *__pyx_n_s_Greenlet_link_value;
-static PyObject *__pyx_n_s_Greenlet_name;
-static PyObject *__pyx_n_s_Greenlet_rawlink;
-static PyObject *__pyx_n_s_Greenlet_ready;
-static PyObject *__pyx_n_s_Greenlet_run;
-static PyObject *__pyx_n_s_Greenlet_spawn;
-static PyObject *__pyx_n_s_Greenlet_spawn_later;
-static PyObject *__pyx_n_s_Greenlet_spawning_stack;
-static PyObject *__pyx_n_s_Greenlet_start;
-static PyObject *__pyx_n_s_Greenlet_start_later;
-static PyObject *__pyx_n_s_Greenlet_successful;
-static PyObject *__pyx_n_s_Greenlet_throw;
-static PyObject *__pyx_n_s_Greenlet_unlink;
-static PyObject *__pyx_n_s_Greenlet_unlink_all;
-static PyObject *__pyx_n_s_InvalidSwitchError;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Greenlet_get;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Greenlet_joi;
-static PyObject *__pyx_n_s_Lazy;
-static PyObject *__pyx_n_s_NameError;
-static PyObject *__pyx_n_s_PYPY;
-static PyObject *__pyx_n_s_PYPY_2;
-static PyObject *__pyx_n_s_Pyx_CFunc_object____list____ob;
-static PyObject *__pyx_n_s_Pyx_CFunc_object____list____ob_2;
-static PyObject *__pyx_n_s_SpawnedLink;
-static PyObject *__pyx_kp_s_The_run_argument_or_self__run_mu;
-static PyObject *__pyx_n_s_Timeout;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_n_s_Waiter;
-static PyObject *__pyx_kp_s__2;
-static PyObject *__pyx_kp_s__3;
-static PyObject *__pyx_kp_s__4;
-static PyObject *__pyx_kp_s__5;
-static PyObject *__pyx_kp_s__6;
-static PyObject *__pyx_kp_s__7;
-static PyObject *__pyx_n_s_active;
-static PyObject *__pyx_n_s_alive;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_n_s_block;
-static PyObject *__pyx_n_s_bool;
-static PyObject *__pyx_n_s_call;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_n_s_cancel;
-static PyObject *__pyx_n_s_cancelled_start_event;
-static PyObject *__pyx_n_s_cb;
-static PyObject *__pyx_n_s_cfunc_to_py;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_cls;
-static PyObject *__pyx_n_s_config;
-static PyObject *__pyx_n_s_continuation;
-static PyObject *__pyx_n_s_continulet;
-static PyObject *__pyx_n_s_continulet_2;
-static PyObject *__pyx_n_s_count;
-static PyObject *__pyx_n_s_dead;
-static PyObject *__pyx_n_s_dict;
-static PyObject *__pyx_n_s_dummy_event_close;
-static PyObject *__pyx_n_s_dummy_event_start;
-static PyObject *__pyx_n_s_dummy_event_stop;
-static PyObject *__pyx_n_s_dump_traceback;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_exception;
-static PyObject *__pyx_n_s_f_back;
-static PyObject *__pyx_n_s_f_code;
-static PyObject *__pyx_n_s_f_lineno;
-static PyObject *__pyx_n_s_formatinfo;
-static PyObject *__pyx_n_s_g;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_get_2;
-static PyObject *__pyx_n_s_get_hub_class;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_getframe;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_n_s_gevent__compat;
-static PyObject *__pyx_n_s_gevent__config;
-static PyObject *__pyx_n_s_gevent__greenlet;
-static PyObject *__pyx_n_s_gevent__hub_local;
-static PyObject *__pyx_n_s_gevent__hub_primitives;
-static PyObject *__pyx_n_s_gevent__tblib;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_gevent_timeout;
-static PyObject *__pyx_n_s_glet;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet__init;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_greenlets;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_has_links;
-static PyObject *__pyx_n_s_hex;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_n_s_ident_registry;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_items;
-static PyObject *__pyx_n_s_iwait;
-static PyObject *__pyx_n_s_iwait_on_objects;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_joinall;
-static PyObject *__pyx_n_s_kill;
-static PyObject *__pyx_n_s_kill_2;
-static PyObject *__pyx_n_s_killall;
-static PyObject *__pyx_n_s_kwargs;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_link;
-static PyObject *__pyx_n_s_link_exception;
-static PyObject *__pyx_n_s_link_value;
-static PyObject *__pyx_n_s_load_traceback;
-static PyObject *__pyx_n_s_loop;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_minimal_ident;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_name_2;
-static PyObject *__pyx_n_s_nonzero;
-static PyObject *__pyx_n_s_notify_links;
-static PyObject *__pyx_n_s_parent;
-static PyObject *__pyx_n_s_pending;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_raise_error;
-static PyObject *__pyx_n_s_raise_exception;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_readproperty;
-static PyObject *__pyx_n_s_ready;
-static PyObject *__pyx_n_s_ref;
-static PyObject *__pyx_n_s_remove;
-static PyObject *__pyx_n_s_reraise;
-static PyObject *__pyx_n_s_result;
-static PyObject *__pyx_n_s_reversed;
-static PyObject *__pyx_n_s_run;
-static PyObject *__pyx_n_s_run_2;
-static PyObject *__pyx_n_s_run_callback;
-static PyObject *__pyx_kp_s_s_s;
-static PyObject *__pyx_kp_s_s_s_at_s;
-static PyObject *__pyx_n_s_seconds;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_self_2;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_n_s_source;
-static PyObject *__pyx_n_s_spawn;
-static PyObject *__pyx_n_s_spawn_later;
-static PyObject *__pyx_n_s_spawn_tree_locals;
-static PyObject *__pyx_n_s_spawning_stack;
-static PyObject *__pyx_n_s_spawning_stack_frames;
-static PyObject *__pyx_n_s_spawning_stack_limit;
-static PyObject *__pyx_kp_s_src_gevent_greenlet_py;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_start_completed_event;
-static PyObject *__pyx_n_s_start_later;
-static PyObject *__pyx_n_s_start_new_or_dummy;
-static PyObject *__pyx_n_s_stop;
-static PyObject *__pyx_kp_s_stringsource;
-static PyObject *__pyx_n_s_successful;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_sys_exc_info;
-static PyObject *__pyx_n_s_sys_getframe;
-static PyObject *__pyx_n_s_t;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_threadlocal;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_timer;
-static PyObject *__pyx_n_s_track_greenlet_tree;
-static PyObject *__pyx_n_s_unlink;
-static PyObject *__pyx_n_s_unlink_all;
-static PyObject *__pyx_n_s_wait;
-static PyObject *__pyx_n_s_wait_on_objects;
-static PyObject *__pyx_n_s_waiter;
-static PyObject *__pyx_n_s_waiter_2;
-static PyObject *__pyx_n_s_weakref;
-static PyObject *__pyx_n_s_wrap;
-static PyObject *__pyx_n_s_wref;
-static PyObject *__pyx_lambda_funcdef_6gevent_9_greenlet_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink___init__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_2__call__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_source); /* proto */
-static Py_hash_t __pyx_pf_6gevent_9_greenlet_11SpawnedLink_4__hash__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_6__eq__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_8__str__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_10__repr__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_12__getattr__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback___get__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_2__set__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_4__del__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_18SuccessSpawnedLink___call__(struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink *__pyx_v_self, PyObject *__pyx_v_source); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_18FailureSpawnedLink___call__(struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink *__pyx_v_self, PyObject *__pyx_v_source); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_6_Frame___init__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self, PyObject *__pyx_v_f_code, PyObject *__pyx_v_f_lineno, PyObject *__pyx_v_f_back); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_9f_globals___get__(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_6f_code___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_8f_lineno___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_6f_back___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet___init__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_run, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_2spawning_stack(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_13minimal_ident___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4name(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_6_raise_exception(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4loop___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_8__nonzero__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4dead___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_7started___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_10ready(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_12successful(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_14__repr__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_16_formatinfo(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_9exception___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_8exc_info___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_18throw(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_20start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_22start_later(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_seconds); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_24spawn(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_26spawn_later(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_seconds, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_28kill(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_exception, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_30get(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_32join(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_34run(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_36_run(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_38has_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_40rawlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_42link(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_44unlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_46unlink_all(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_48link_value(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_50link_exception(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_52_notify_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_5value___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4args___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_6kwargs___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_17spawning_greenlet___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_2__set__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_4__del__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_9_greenlet_12_dummy_event___init__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_2stop(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_4start(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, PyObject *__pyx_v_cb); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_6close(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_7pending___get__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_6active___get__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet__kill(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_glet, PyObject *__pyx_v_exception, PyObject *__pyx_v_waiter); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_2joinall(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_timeout, PyObject *__pyx_v_raise_error, PyObject *__pyx_v_count); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_7__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_9_greenlet_4killall(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception, PyObject *__pyx_v_waiter); /* proto */
-static PyObject *__pyx_pf_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception); /* proto */
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_SpawnedLink(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_SuccessSpawnedLink(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_FailureSpawnedLink(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_9_greenlet__Frame(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_Greenlet(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_9_greenlet__dummy_event(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_10;
-static PyObject *__pyx_k__9;
-static PyObject *__pyx_k__14;
-static PyObject *__pyx_k__15;
-static PyObject *__pyx_k__16;
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__12;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_tuple__24;
-static PyObject *__pyx_tuple__25;
-static PyObject *__pyx_tuple__27;
-static PyObject *__pyx_tuple__29;
-static PyObject *__pyx_tuple__31;
-static PyObject *__pyx_tuple__33;
-static PyObject *__pyx_tuple__35;
-static PyObject *__pyx_tuple__37;
-static PyObject *__pyx_tuple__39;
-static PyObject *__pyx_tuple__41;
-static PyObject *__pyx_tuple__43;
-static PyObject *__pyx_tuple__45;
-static PyObject *__pyx_tuple__47;
-static PyObject *__pyx_tuple__49;
-static PyObject *__pyx_tuple__51;
-static PyObject *__pyx_tuple__53;
-static PyObject *__pyx_tuple__55;
-static PyObject *__pyx_tuple__57;
-static PyObject *__pyx_tuple__59;
-static PyObject *__pyx_tuple__61;
-static PyObject *__pyx_tuple__63;
-static PyObject *__pyx_tuple__65;
-static PyObject *__pyx_tuple__67;
-static PyObject *__pyx_tuple__69;
-static PyObject *__pyx_tuple__71;
-static PyObject *__pyx_tuple__73;
-static PyObject *__pyx_tuple__74;
-static PyObject *__pyx_tuple__76;
-static PyObject *__pyx_tuple__78;
-static PyObject *__pyx_tuple__80;
-static PyObject *__pyx_tuple__82;
-static PyObject *__pyx_tuple__84;
-static PyObject *__pyx_codeobj__20;
-static PyObject *__pyx_codeobj__22;
-static PyObject *__pyx_codeobj__26;
-static PyObject *__pyx_codeobj__28;
-static PyObject *__pyx_codeobj__30;
-static PyObject *__pyx_codeobj__32;
-static PyObject *__pyx_codeobj__34;
-static PyObject *__pyx_codeobj__36;
-static PyObject *__pyx_codeobj__38;
-static PyObject *__pyx_codeobj__40;
-static PyObject *__pyx_codeobj__42;
-static PyObject *__pyx_codeobj__44;
-static PyObject *__pyx_codeobj__46;
-static PyObject *__pyx_codeobj__48;
-static PyObject *__pyx_codeobj__50;
-static PyObject *__pyx_codeobj__52;
-static PyObject *__pyx_codeobj__54;
-static PyObject *__pyx_codeobj__56;
-static PyObject *__pyx_codeobj__58;
-static PyObject *__pyx_codeobj__60;
-static PyObject *__pyx_codeobj__62;
-static PyObject *__pyx_codeobj__64;
-static PyObject *__pyx_codeobj__66;
-static PyObject *__pyx_codeobj__68;
-static PyObject *__pyx_codeobj__70;
-static PyObject *__pyx_codeobj__72;
-static PyObject *__pyx_codeobj__75;
-static PyObject *__pyx_codeobj__77;
-static PyObject *__pyx_codeobj__79;
-static PyObject *__pyx_codeobj__81;
-static PyObject *__pyx_codeobj__83;
-static PyObject *__pyx_codeobj__85;
-/* Late includes */
-
-/* "src/gevent/greenlet.py":46
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['Waiter'] = _waiter.Waiter
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_6lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_6lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_9_greenlet_6lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_9_greenlet_6lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_9_greenlet_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_9_greenlet_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":63
- * __slots__ = ['callback']
- *
- * def __init__(self, callback): # <<<<<<<<<<<<<<
- * if not callable(callback):
- * raise TypeError("Expected callable: %r" % (callback, ))
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 63, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_callback = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 63, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink___init__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self), __pyx_v_callback);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink___init__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_callback) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/greenlet.py":64
- *
- * def __init__(self, callback):
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError("Expected callable: %r" % (callback, ))
- * self.callback = callback
- */
- __pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 64, __pyx_L1_error)
- __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/greenlet.py":65
- * def __init__(self, callback):
- * if not callable(callback):
- * raise TypeError("Expected callable: %r" % (callback, )) # <<<<<<<<<<<<<<
- * self.callback = callback
- *
- */
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 65, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":64
- *
- * def __init__(self, callback):
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError("Expected callable: %r" % (callback, ))
- * self.callback = callback
- */
- }
-
- /* "src/gevent/greenlet.py":66
- * if not callable(callback):
- * raise TypeError("Expected callable: %r" % (callback, ))
- * self.callback = callback # <<<<<<<<<<<<<<
- *
- * def __call__(self, source):
- */
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = __pyx_v_callback;
-
- /* "src/gevent/greenlet.py":63
- * __slots__ = ['callback']
- *
- * def __init__(self, callback): # <<<<<<<<<<<<<<
- * if not callable(callback):
- * raise TypeError("Expected callable: %r" % (callback, ))
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":68
- * self.callback = callback
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * g = greenlet(self.callback, get_hub())
- * g.switch(source)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_source = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 68, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_source = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 68, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_2__call__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self), __pyx_v_source);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_2__call__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_source) {
- PyGreenlet *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/greenlet.py":69
- *
- * def __call__(self, source):
- * g = greenlet(self.callback, get_hub()) # <<<<<<<<<<<<<<
- * g.switch(source)
- *
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_self->callback);
- __Pyx_GIVEREF(__pyx_v_self->callback);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->callback);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_9_greenlet_greenlet), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_g = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":70
- * def __call__(self, source):
- * g = greenlet(self.callback, get_hub())
- * g.switch(source) # <<<<<<<<<<<<<<
- *
- * def __hash__(self):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_g), __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_source); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_source};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_source};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_source);
- __Pyx_GIVEREF(__pyx_v_source);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_source);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":68
- * self.callback = callback
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * g = greenlet(self.callback, get_hub())
- * g.switch(source)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":72
- * g.switch(source)
- *
- * def __hash__(self): # <<<<<<<<<<<<<<
- * return hash(self.callback)
- *
- */
-
-/* Python wrapper */
-static Py_hash_t __pyx_pw_6gevent_9_greenlet_11SpawnedLink_5__hash__(PyObject *__pyx_v_self); /*proto*/
-static Py_hash_t __pyx_pw_6gevent_9_greenlet_11SpawnedLink_5__hash__(PyObject *__pyx_v_self) {
- Py_hash_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_4__hash__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_hash_t __pyx_pf_6gevent_9_greenlet_11SpawnedLink_4__hash__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self) {
- Py_hash_t __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_hash_t __pyx_t_2;
- __Pyx_RefNannySetupContext("__hash__", 0);
-
- /* "src/gevent/greenlet.py":73
- *
- * def __hash__(self):
- * return hash(self.callback) # <<<<<<<<<<<<<<
- *
- * def __eq__(self, other):
- */
- __pyx_t_1 = __pyx_v_self->callback;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Hash(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_hash_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":72
- * g.switch(source)
- *
- * def __hash__(self): # <<<<<<<<<<<<<<
- * return hash(self.callback)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__hash__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":75
- * return hash(self.callback)
- *
- * def __eq__(self, other): # <<<<<<<<<<<<<<
- * return self.callback == getattr(other, 'callback', other)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_7__eq__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_7__eq__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__eq__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_6__eq__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self), ((PyObject *)__pyx_v_other));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_6__eq__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_other) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__eq__", 0);
-
- /* "src/gevent/greenlet.py":76
- *
- * def __eq__(self, other):
- * return self.callback == getattr(other, 'callback', other) # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_other, __pyx_n_s_callback, __pyx_v_other); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_RichCompare(__pyx_v_self->callback, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":75
- * return hash(self.callback)
- *
- * def __eq__(self, other): # <<<<<<<<<<<<<<
- * return self.callback == getattr(other, 'callback', other)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__eq__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":78
- * return self.callback == getattr(other, 'callback', other)
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return str(self.callback)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_9__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_9__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8__str__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_8__str__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/greenlet.py":79
- *
- * def __str__(self):
- * return str(self.callback) # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_self->callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":78
- * return self.callback == getattr(other, 'callback', other)
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return str(self.callback)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":81
- * return str(self.callback)
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return repr(self.callback)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_11__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_11__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_10__repr__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_10__repr__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "src/gevent/greenlet.py":82
- *
- * def __repr__(self):
- * return repr(self.callback) # <<<<<<<<<<<<<<
- *
- * def __getattr__(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_v_self->callback;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":81
- * return str(self.callback)
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return repr(self.callback)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":84
- * return repr(self.callback)
- *
- * def __getattr__(self, item): # <<<<<<<<<<<<<<
- * assert item != 'callback'
- * return getattr(self.callback, item)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_13__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_13__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_12__getattr__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_12__getattr__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__getattr__", 0);
-
- /* "src/gevent/greenlet.py":85
- *
- * def __getattr__(self, item):
- * assert item != 'callback' # <<<<<<<<<<<<<<
- * return getattr(self.callback, item)
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_item, __pyx_n_s_callback, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
- if (unlikely(!__pyx_t_1)) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 85, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/greenlet.py":86
- * def __getattr__(self, item):
- * assert item != 'callback'
- * return getattr(self.callback, item) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_v_self->callback;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_GetAttr(__pyx_t_2, __pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":84
- * return repr(self.callback)
- *
- * def __getattr__(self, item): # <<<<<<<<<<<<<<
- * assert item != 'callback'
- * return getattr(self.callback, item)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.SpawnedLink.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":57
- *
- * cdef class SpawnedLink:
- * cdef public object callback # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback___get__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback___get__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->callback);
- __pyx_r = __pyx_v_self->callback;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_2__set__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_2__set__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_4__del__(((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_11SpawnedLink_8callback_4__del__(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":96
- * __slots__ = []
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.successful():
- * return SpawnedLink.__call__(self, source)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_18SuccessSpawnedLink_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_18SuccessSpawnedLink_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_source = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 96, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_source = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 96, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.SuccessSpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_18SuccessSpawnedLink___call__(((struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink *)__pyx_v_self), __pyx_v_source);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_18SuccessSpawnedLink___call__(struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink *__pyx_v_self, PyObject *__pyx_v_source) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/greenlet.py":97
- *
- * def __call__(self, source):
- * if source.successful(): # <<<<<<<<<<<<<<
- * return SpawnedLink.__call__(self, source)
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_4) {
-
- /* "src/gevent/greenlet.py":98
- * def __call__(self, source):
- * if source.successful():
- * return SpawnedLink.__call__(self, source) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_SpawnedLink), __pyx_n_s_call); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_source};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_source};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_source);
- __Pyx_GIVEREF(__pyx_v_source);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_source);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":97
- *
- * def __call__(self, source):
- * if source.successful(): # <<<<<<<<<<<<<<
- * return SpawnedLink.__call__(self, source)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":96
- * __slots__ = []
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if source.successful():
- * return SpawnedLink.__call__(self, source)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._greenlet.SuccessSpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":108
- * __slots__ = []
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if not source.successful():
- * return SpawnedLink.__call__(self, source)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_18FailureSpawnedLink_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_18FailureSpawnedLink_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_source = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 108, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_source = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 108, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.FailureSpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_18FailureSpawnedLink___call__(((struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink *)__pyx_v_self), __pyx_v_source);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_18FailureSpawnedLink___call__(struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink *__pyx_v_self, PyObject *__pyx_v_source) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/greenlet.py":109
- *
- * def __call__(self, source):
- * if not source.successful(): # <<<<<<<<<<<<<<
- * return SpawnedLink.__call__(self, source)
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = ((!__pyx_t_4) != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/greenlet.py":110
- * def __call__(self, source):
- * if not source.successful():
- * return SpawnedLink.__call__(self, source) # <<<<<<<<<<<<<<
- *
- * class _Frame(object):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_SpawnedLink), __pyx_n_s_call); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_source};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_source};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_source);
- __Pyx_GIVEREF(__pyx_v_source);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_source);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":109
- *
- * def __call__(self, source):
- * if not source.successful(): # <<<<<<<<<<<<<<
- * return SpawnedLink.__call__(self, source)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":108
- * __slots__ = []
- *
- * def __call__(self, source): # <<<<<<<<<<<<<<
- * if not source.successful():
- * return SpawnedLink.__call__(self, source)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.FailureSpawnedLink.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":116
- * __slots__ = ('f_code', 'f_lineno', 'f_back')
- *
- * def __init__(self, f_code, f_lineno, f_back): # <<<<<<<<<<<<<<
- * self.f_code = f_code
- * self.f_lineno = f_lineno
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_6_Frame_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_6_Frame_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_f_code = 0;
- PyObject *__pyx_v_f_lineno = 0;
- PyObject *__pyx_v_f_back = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_f_code,&__pyx_n_s_f_lineno,&__pyx_n_s_f_back,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_f_code)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_f_lineno)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 116, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_f_back)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 116, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 116, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_f_code = values[0];
- __pyx_v_f_lineno = values[1];
- __pyx_v_f_back = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 116, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet._Frame.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_6_Frame___init__(((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_v_self), __pyx_v_f_code, __pyx_v_f_lineno, __pyx_v_f_back);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_6_Frame___init__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self, PyObject *__pyx_v_f_code, PyObject *__pyx_v_f_lineno, PyObject *__pyx_v_f_back) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/greenlet.py":117
- *
- * def __init__(self, f_code, f_lineno, f_back):
- * self.f_code = f_code # <<<<<<<<<<<<<<
- * self.f_lineno = f_lineno
- * self.f_back = f_back
- */
- if (!(likely(((__pyx_v_f_code) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_f_code, __pyx_ptype_6gevent_9_greenlet_CodeType))))) __PYX_ERR(0, 117, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_f_code;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->f_code);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->f_code));
- __pyx_v_self->f_code = ((PyCodeObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":118
- * def __init__(self, f_code, f_lineno, f_back):
- * self.f_code = f_code
- * self.f_lineno = f_lineno # <<<<<<<<<<<<<<
- * self.f_back = f_back
- *
- */
- __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_f_lineno); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L1_error)
- __pyx_v_self->f_lineno = __pyx_t_2;
-
- /* "src/gevent/greenlet.py":119
- * self.f_code = f_code
- * self.f_lineno = f_lineno
- * self.f_back = f_back # <<<<<<<<<<<<<<
- *
- * @property
- */
- if (!(likely(((__pyx_v_f_back) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_f_back, __pyx_ptype_6gevent_9_greenlet__Frame))))) __PYX_ERR(0, 119, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_f_back;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->f_back);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->f_back));
- __pyx_v_self->f_back = ((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":116
- * __slots__ = ('f_code', 'f_lineno', 'f_back')
- *
- * def __init__(self, f_code, f_lineno, f_back): # <<<<<<<<<<<<<<
- * self.f_code = f_code
- * self.f_lineno = f_lineno
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._Frame.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":122
- *
- * @property
- * def f_globals(self): # <<<<<<<<<<<<<<
- * return None
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_9f_globals_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_9f_globals_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_6_Frame_9f_globals___get__(((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_9f_globals___get__(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":123
- * @property
- * def f_globals(self):
- * return None # <<<<<<<<<<<<<<
- *
- * def _Frame_from_list(frames):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":122
- *
- * @property
- * def f_globals(self): # <<<<<<<<<<<<<<
- * return None
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":72
- * @cython.freelist(1000)
- * cdef class _Frame:
- * cdef readonly CodeType f_code # <<<<<<<<<<<<<<
- * cdef readonly int f_lineno
- * cdef readonly _Frame f_back
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_6f_code_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_6f_code_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_6_Frame_6f_code___get__(((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_6f_code___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->f_code));
- __pyx_r = ((PyObject *)__pyx_v_self->f_code);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":73
- * cdef class _Frame:
- * cdef readonly CodeType f_code
- * cdef readonly int f_lineno # <<<<<<<<<<<<<<
- * cdef readonly _Frame f_back
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_8f_lineno_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_8f_lineno_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_6_Frame_8f_lineno___get__(((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_8f_lineno___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->f_lineno); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._Frame.f_lineno.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":74
- * cdef readonly CodeType f_code
- * cdef readonly int f_lineno
- * cdef readonly _Frame f_back # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_6f_back_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_6_Frame_6f_back_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_6_Frame_6f_back___get__(((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_6_Frame_6f_back___get__(struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->f_back));
- __pyx_r = ((PyObject *)__pyx_v_self->f_back);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":125
- * return None
- *
- * def _Frame_from_list(frames): # <<<<<<<<<<<<<<
- * previous = None
- * for frame in reversed(frames):
- */
-
-static struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_f_6gevent_9_greenlet__Frame_from_list(PyObject *__pyx_v_frames) {
- struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_previous = 0;
- PyObject *__pyx_v_frame = 0;
- struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_v_f = 0;
- struct __pyx_obj_6gevent_9_greenlet__Frame *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("_Frame_from_list", 0);
-
- /* "src/gevent/greenlet.py":126
- *
- * def _Frame_from_list(frames):
- * previous = None # <<<<<<<<<<<<<<
- * for frame in reversed(frames):
- * f = _Frame(frame[0], frame[1], previous)
- */
- __Pyx_INCREF(Py_None);
- __pyx_v_previous = ((struct __pyx_obj_6gevent_9_greenlet__Frame *)Py_None);
-
- /* "src/gevent/greenlet.py":127
- * def _Frame_from_list(frames):
- * previous = None
- * for frame in reversed(frames): # <<<<<<<<<<<<<<
- * f = _Frame(frame[0], frame[1], previous)
- * previous = f
- */
- if (unlikely(__pyx_v_frames == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 127, __pyx_L1_error)
- }
- __pyx_t_1 = __pyx_v_frames; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1) - 1;
- for (;;) {
- if (__pyx_t_2 < 0) break;
- if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2--; if (unlikely(0 < 0)) __PYX_ERR(0, 127, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2--; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_XDECREF_SET(__pyx_v_frame, ((PyObject*)__pyx_t_3));
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":128
- * previous = None
- * for frame in reversed(frames):
- * f = _Frame(frame[0], frame[1], previous) # <<<<<<<<<<<<<<
- * previous = f
- * return previous
- */
- if (unlikely(__pyx_v_frame == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 128, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_frame, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (unlikely(__pyx_v_frame == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 128, __pyx_L1_error)
- }
- __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_frame, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
- __Pyx_INCREF(((PyObject *)__pyx_v_previous));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_previous));
- PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_previous));
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_9_greenlet__Frame), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF_SET(__pyx_v_f, ((struct __pyx_obj_6gevent_9_greenlet__Frame *)__pyx_t_4));
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":129
- * for frame in reversed(frames):
- * f = _Frame(frame[0], frame[1], previous)
- * previous = f # <<<<<<<<<<<<<<
- * return previous
- *
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_f));
- __Pyx_DECREF_SET(__pyx_v_previous, __pyx_v_f);
-
- /* "src/gevent/greenlet.py":127
- * def _Frame_from_list(frames):
- * previous = None
- * for frame in reversed(frames): # <<<<<<<<<<<<<<
- * f = _Frame(frame[0], frame[1], previous)
- * previous = f
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":130
- * f = _Frame(frame[0], frame[1], previous)
- * previous = f
- * return previous # <<<<<<<<<<<<<<
- *
- * def _extract_stack(limit):
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __Pyx_INCREF(((PyObject *)__pyx_v_previous));
- __pyx_r = __pyx_v_previous;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":125
- * return None
- *
- * def _Frame_from_list(frames): # <<<<<<<<<<<<<<
- * previous = None
- * for frame in reversed(frames):
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._greenlet._Frame_from_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_previous);
- __Pyx_XDECREF(__pyx_v_frame);
- __Pyx_XDECREF((PyObject *)__pyx_v_f);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":132
- * return previous
- *
- * def _extract_stack(limit): # <<<<<<<<<<<<<<
- * try:
- * frame = sys_getframe()
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_9_greenlet__extract_stack(int __pyx_v_limit) {
- PyObject *__pyx_v_frames = 0;
- PyFrameObject *__pyx_v_frame = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- int __pyx_t_11;
- __Pyx_RefNannySetupContext("_extract_stack", 0);
-
- /* "src/gevent/greenlet.py":133
- *
- * def _extract_stack(limit):
- * try: # <<<<<<<<<<<<<<
- * frame = sys_getframe()
- * except ValueError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":134
- * def _extract_stack(limit):
- * try:
- * frame = sys_getframe() # <<<<<<<<<<<<<<
- * except ValueError:
- * # In certain embedded cases that directly use the Python C api
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_getframe);
- __pyx_t_5 = __pyx_v_6gevent_9_greenlet_sys_getframe; __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L3_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6gevent_9_greenlet_FrameType))))) __PYX_ERR(0, 134, __pyx_L3_error)
- __pyx_v_frame = ((PyFrameObject *)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":133
- *
- * def _extract_stack(limit):
- * try: # <<<<<<<<<<<<<<
- * frame = sys_getframe()
- * except ValueError:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":135
- * try:
- * frame = sys_getframe()
- * except ValueError: # <<<<<<<<<<<<<<
- * # In certain embedded cases that directly use the Python C api
- * # to call Greenlet.spawn (e.g., uwsgi) this can raise
- */
- __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
- if (__pyx_t_7) {
- __Pyx_AddTraceback("gevent._greenlet._extract_stack", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 135, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_6);
-
- /* "src/gevent/greenlet.py":143
- * # not the Python level.
- * # See https://github.com/gevent/gevent/issues/1212
- * frame = None # <<<<<<<<<<<<<<
- *
- * frames = []
- */
- __Pyx_INCREF(Py_None);
- __Pyx_XDECREF_SET(__pyx_v_frame, ((PyFrameObject *)Py_None));
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/greenlet.py":133
- *
- * def _extract_stack(limit):
- * try: # <<<<<<<<<<<<<<
- * frame = sys_getframe()
- * except ValueError:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/greenlet.py":145
- * frame = None
- *
- * frames = [] # <<<<<<<<<<<<<<
- *
- * while limit and frame is not None:
- */
- __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_v_frames = ((PyObject*)__pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":147
- * frames = []
- *
- * while limit and frame is not None: # <<<<<<<<<<<<<<
- * limit -= 1
- * frames.append((frame.f_code, frame.f_lineno))
- */
- while (1) {
- __pyx_t_9 = (__pyx_v_limit != 0);
- if (__pyx_t_9) {
- } else {
- __pyx_t_8 = __pyx_t_9;
- goto __pyx_L13_bool_binop_done;
- }
- __pyx_t_9 = (((PyObject *)__pyx_v_frame) != Py_None);
- __pyx_t_10 = (__pyx_t_9 != 0);
- __pyx_t_8 = __pyx_t_10;
- __pyx_L13_bool_binop_done:;
- if (!__pyx_t_8) break;
-
- /* "src/gevent/greenlet.py":148
- *
- * while limit and frame is not None:
- * limit -= 1 # <<<<<<<<<<<<<<
- * frames.append((frame.f_code, frame.f_lineno))
- * frame = frame.f_back
- */
- __pyx_v_limit = (__pyx_v_limit - 1);
-
- /* "src/gevent/greenlet.py":149
- * while limit and frame is not None:
- * limit -= 1
- * frames.append((frame.f_code, frame.f_lineno)) # <<<<<<<<<<<<<<
- * frame = frame.f_back
- *
- */
- __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_frame->f_lineno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(((PyObject *)__pyx_v_frame->f_code));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_frame->f_code));
- PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_frame->f_code));
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_frames, __pyx_t_5); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/greenlet.py":150
- * limit -= 1
- * frames.append((frame.f_code, frame.f_lineno))
- * frame = frame.f_back # <<<<<<<<<<<<<<
- *
- * return frames
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_frame), __pyx_n_s_f_back); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_6gevent_9_greenlet_FrameType))))) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_DECREF_SET(__pyx_v_frame, ((PyFrameObject *)__pyx_t_5));
- __pyx_t_5 = 0;
- }
-
- /* "src/gevent/greenlet.py":152
- * frame = frame.f_back
- *
- * return frames # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_frames);
- __pyx_r = __pyx_v_frames;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":132
- * return previous
- *
- * def _extract_stack(limit): # <<<<<<<<<<<<<<
- * try:
- * frame = sys_getframe()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._greenlet._extract_stack", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_frames);
- __Pyx_XDECREF((PyObject *)__pyx_v_frame);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":166
- *
- * # pylint:disable=keyword-arg-before-vararg,super-init-not-called
- * def __init__(self, run=None, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * :param args: The arguments passed to the ``run`` function.
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet___init__[] = "\n :param args: The arguments passed to the ``run`` function.\n :param kwargs: The keyword arguments passed to the ``run`` function.\n :keyword callable run: The callable object to run. If not given, this object's\n `_run` method will be invoked (typically defined by subclasses).\n\n .. versionchanged:: 1.1b1\n The ``run`` argument to the constructor is now verified to be a callable\n object. Previously, passing a non-callable object would fail after the greenlet\n was spawned.\n\n .. versionchanged:: 1.3b1\n The ``GEVENT_TRACK_GREENLET_TREE`` configuration value may be set to\n a false value to disable ``spawn_tree_locals``, ``spawning_greenlet``,\n and ``spawning_stack``. The first two will be None in that case, and the\n latter will be empty.\n ";
-#if CYTHON_COMPILING_IN_CPYTHON
-struct wrapperbase __pyx_wrapperbase_6gevent_9_greenlet_8Greenlet___init__;
-#endif
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_run = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
- __Pyx_GOTREF(__pyx_v_kwargs);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
- __Pyx_RefNannyFinishContext();
- return -1;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_run,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_run);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__init__") < 0)) __PYX_ERR(0, 166, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- }
- __pyx_v_run = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet___init__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_run, __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet___init__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_run, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- PyGreenlet *__pyx_v_spawner = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- int __pyx_t_12;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/greenlet.py":213
- *
- *
- * _greenlet__init__(self, None, get_hub()) # <<<<<<<<<<<<<<
- *
- * if run is not None:
- */
- __pyx_t_2 = ((PyObject *)__pyx_f_6gevent_11__hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet__greenlet__init__);
- __pyx_t_3 = __pyx_v_6gevent_9_greenlet__greenlet__init__; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, ((PyObject *)__pyx_v_self), Py_None, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, ((PyObject *)__pyx_v_self), Py_None, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, Py_None);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":215
- * _greenlet__init__(self, None, get_hub())
- *
- * if run is not None: # <<<<<<<<<<<<<<
- * self._run = run
- *
- */
- __pyx_t_7 = (__pyx_v_run != Py_None);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/greenlet.py":216
- *
- * if run is not None:
- * self._run = run # <<<<<<<<<<<<<<
- *
- * # If they didn't pass a callable at all, then they must
- */
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_run_2, __pyx_v_run) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":215
- * _greenlet__init__(self, None, get_hub())
- *
- * if run is not None: # <<<<<<<<<<<<<<
- * self._run = run
- *
- */
- }
-
- /* "src/gevent/greenlet.py":221
- * # already have one. Note that subclassing to override the run() method
- * # itself has never been documented or supported.
- * if not callable(self._run): # <<<<<<<<<<<<<<
- * raise TypeError("The run argument or self._run must be callable")
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_run_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = __Pyx_PyCallable_Check(__pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/greenlet.py":222
- * # itself has never been documented or supported.
- * if not callable(self._run):
- * raise TypeError("The run argument or self._run must be callable") # <<<<<<<<<<<<<<
- *
- * self.args = args
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 222, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":221
- * # already have one. Note that subclassing to override the run() method
- * # itself has never been documented or supported.
- * if not callable(self._run): # <<<<<<<<<<<<<<
- * raise TypeError("The run argument or self._run must be callable")
- *
- */
- }
-
- /* "src/gevent/greenlet.py":224
- * raise TypeError("The run argument or self._run must be callable")
- *
- * self.args = args # <<<<<<<<<<<<<<
- * self.kwargs = kwargs
- * self.value = None
- */
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_v_args;
-
- /* "src/gevent/greenlet.py":225
- *
- * self.args = args
- * self.kwargs = kwargs # <<<<<<<<<<<<<<
- * self.value = None
- *
- */
- __Pyx_INCREF(__pyx_v_kwargs);
- __Pyx_GIVEREF(__pyx_v_kwargs);
- __Pyx_GOTREF(__pyx_v_self->kwargs);
- __Pyx_DECREF(__pyx_v_self->kwargs);
- __pyx_v_self->kwargs = __pyx_v_kwargs;
-
- /* "src/gevent/greenlet.py":226
- * self.args = args
- * self.kwargs = kwargs
- * self.value = None # <<<<<<<<<<<<<<
- *
- * #: An event, such as a timer or a callback that fires. It is established in
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = Py_None;
-
- /* "src/gevent/greenlet.py":234
- * #: scheduled for starting. A placeholder _dummy_event is assigned by them to prevent
- * #: the greenlet from being started in the future, if necessary.
- * self._start_event = None # <<<<<<<<<<<<<<
- *
- * self._notifier = None
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_start_event);
- __Pyx_DECREF(__pyx_v_self->_start_event);
- __pyx_v_self->_start_event = Py_None;
-
- /* "src/gevent/greenlet.py":236
- * self._start_event = None
- *
- * self._notifier = None # <<<<<<<<<<<<<<
- * self._formatted_info = None
- * self._links = []
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = Py_None;
-
- /* "src/gevent/greenlet.py":237
- *
- * self._notifier = None
- * self._formatted_info = None # <<<<<<<<<<<<<<
- * self._links = []
- * self._ident = None
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_formatted_info);
- __Pyx_DECREF(__pyx_v_self->_formatted_info);
- __pyx_v_self->_formatted_info = ((PyObject*)Py_None);
-
- /* "src/gevent/greenlet.py":238
- * self._notifier = None
- * self._formatted_info = None
- * self._links = [] # <<<<<<<<<<<<<<
- * self._ident = None
- *
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_links);
- __Pyx_DECREF(__pyx_v_self->_links);
- __pyx_v_self->_links = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":239
- * self._formatted_info = None
- * self._links = []
- * self._ident = None # <<<<<<<<<<<<<<
- *
- * # Initial state: None.
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_ident);
- __Pyx_DECREF(__pyx_v_self->_ident);
- __pyx_v_self->_ident = Py_None;
-
- /* "src/gevent/greenlet.py":244
- * # Completed successfully: (None, None, None)
- * # Failed with exception: (t, v, dump_traceback(tb)))
- * self._exc_info = None # <<<<<<<<<<<<<<
- *
- * if GEVENT_CONFIG.track_greenlet_tree:
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = ((PyObject*)Py_None);
-
- /* "src/gevent/greenlet.py":246
- * self._exc_info = None
- *
- * if GEVENT_CONFIG.track_greenlet_tree: # <<<<<<<<<<<<<<
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_9_greenlet_GEVENT_CONFIG, __pyx_n_s_track_greenlet_tree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_7) {
-
- /* "src/gevent/greenlet.py":247
- *
- * if GEVENT_CONFIG.track_greenlet_tree:
- * spawner = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.spawning_greenlet = wref(spawner)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_9_greenlet_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_spawner = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":248
- * if GEVENT_CONFIG.track_greenlet_tree:
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner) # <<<<<<<<<<<<<<
- * try:
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_wref);
- __pyx_t_3 = __pyx_v_6gevent_9_greenlet_wref; __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_spawner)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_spawner)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_spawner)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_spawner));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_spawner));
- PyTuple_SET_ITEM(__pyx_t_2, 0+1, ((PyObject *)__pyx_v_spawner));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->spawning_greenlet);
- __Pyx_DECREF(__pyx_v_self->spawning_greenlet);
- __pyx_v_self->spawning_greenlet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":249
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner)
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- * except AttributeError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":250
- * self.spawning_greenlet = wref(spawner)
- * try:
- * self.spawn_tree_locals = spawner.spawn_tree_locals # <<<<<<<<<<<<<<
- * except AttributeError:
- * self.spawn_tree_locals = {}
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_spawner), __pyx_n_s_spawn_tree_locals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 250, __pyx_L6_error)
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->spawn_tree_locals);
- __Pyx_DECREF(__pyx_v_self->spawn_tree_locals);
- __pyx_v_self->spawn_tree_locals = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":249
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner)
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- * except AttributeError:
- */
- }
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L11_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":251
- * try:
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- * except AttributeError: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = {}
- * if spawner.parent is not None:
- */
- __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_5) {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 251, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "src/gevent/greenlet.py":252
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- * except AttributeError:
- * self.spawn_tree_locals = {} # <<<<<<<<<<<<<<
- * if spawner.parent is not None:
- * # The main greenlet has no parent.
- */
- __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->spawn_tree_locals);
- __Pyx_DECREF(__pyx_v_self->spawn_tree_locals);
- __pyx_v_self->spawn_tree_locals = ((PyObject*)__pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":253
- * except AttributeError:
- * self.spawn_tree_locals = {}
- * if spawner.parent is not None: # <<<<<<<<<<<<<<
- * # The main greenlet has no parent.
- * # Its children get separate locals.
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_spawner), __pyx_n_s_parent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 253, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = (__pyx_t_6 != Py_None);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/greenlet.py":256
- * # The main greenlet has no parent.
- * # Its children get separate locals.
- * spawner.spawn_tree_locals = self.spawn_tree_locals # <<<<<<<<<<<<<<
- *
- * self._spawning_stack_frames = _extract_stack(self.spawning_stack_limit)
- */
- __pyx_t_6 = __pyx_v_self->spawn_tree_locals;
- __Pyx_INCREF(__pyx_t_6);
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_spawner), __pyx_n_s_spawn_tree_locals, __pyx_t_6) < 0) __PYX_ERR(0, 256, __pyx_L8_except_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":253
- * except AttributeError:
- * self.spawn_tree_locals = {}
- * if spawner.parent is not None: # <<<<<<<<<<<<<<
- * # The main greenlet has no parent.
- * # Its children get separate locals.
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- goto __pyx_L7_exception_handled;
- }
- goto __pyx_L8_except_error;
- __pyx_L8_except_error:;
-
- /* "src/gevent/greenlet.py":249
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner)
- * try: # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = spawner.spawn_tree_locals
- * except AttributeError:
- */
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- goto __pyx_L1_error;
- __pyx_L7_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_L11_try_end:;
- }
-
- /* "src/gevent/greenlet.py":258
- * spawner.spawn_tree_locals = self.spawn_tree_locals
- *
- * self._spawning_stack_frames = _extract_stack(self.spawning_stack_limit) # <<<<<<<<<<<<<<
- * self._spawning_stack_frames.extend(getattr(spawner, '_spawning_stack_frames', []))
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_spawning_stack_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __pyx_f_6gevent_9_greenlet__extract_stack(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_v_self->_spawning_stack_frames);
- __Pyx_DECREF(__pyx_v_self->_spawning_stack_frames);
- __pyx_v_self->_spawning_stack_frames = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":259
- *
- * self._spawning_stack_frames = _extract_stack(self.spawning_stack_limit)
- * self._spawning_stack_frames.extend(getattr(spawner, '_spawning_stack_frames', [])) # <<<<<<<<<<<<<<
- * else:
- * # None is the default for all of these in Cython, but we
- */
- if (unlikely(__pyx_v_self->_spawning_stack_frames == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend");
- __PYX_ERR(0, 259, __pyx_L1_error)
- }
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_spawner), __pyx_n_s_spawning_stack_frames, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_self->_spawning_stack_frames, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":246
- * self._exc_info = None
- *
- * if GEVENT_CONFIG.track_greenlet_tree: # <<<<<<<<<<<<<<
- * spawner = getcurrent() # pylint:disable=undefined-variable
- * self.spawning_greenlet = wref(spawner)
- */
- goto __pyx_L5;
- }
-
- /* "src/gevent/greenlet.py":263
- * # None is the default for all of these in Cython, but we
- * # need to declare them for pure-Python mode.
- * self.spawning_greenlet = None # <<<<<<<<<<<<<<
- * self.spawn_tree_locals = None
- * self._spawning_stack_frames = None
- */
- /*else*/ {
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->spawning_greenlet);
- __Pyx_DECREF(__pyx_v_self->spawning_greenlet);
- __pyx_v_self->spawning_greenlet = Py_None;
-
- /* "src/gevent/greenlet.py":264
- * # need to declare them for pure-Python mode.
- * self.spawning_greenlet = None
- * self.spawn_tree_locals = None # <<<<<<<<<<<<<<
- * self._spawning_stack_frames = None
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->spawn_tree_locals);
- __Pyx_DECREF(__pyx_v_self->spawn_tree_locals);
- __pyx_v_self->spawn_tree_locals = ((PyObject*)Py_None);
-
- /* "src/gevent/greenlet.py":265
- * self.spawning_greenlet = None
- * self.spawn_tree_locals = None
- * self._spawning_stack_frames = None # <<<<<<<<<<<<<<
- *
- * @Lazy
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_spawning_stack_frames);
- __Pyx_DECREF(__pyx_v_self->_spawning_stack_frames);
- __pyx_v_self->_spawning_stack_frames = ((PyObject*)Py_None);
- }
- __pyx_L5:;
-
- /* "src/gevent/greenlet.py":166
- *
- * # pylint:disable=keyword-arg-before-vararg,super-init-not-called
- * def __init__(self, run=None, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * :param args: The arguments passed to the ``run`` function.
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_spawner);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":268
- *
- * @Lazy
- * def spawning_stack(self): # <<<<<<<<<<<<<<
- * # Store this in the __dict__. We don't use it from the C
- * # code. It's tempting to discard _spawning_stack_frames
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_3spawning_stack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_2spawning_stack[] = "Greenlet.spawning_stack(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_3spawning_stack = {"spawning_stack", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_3spawning_stack, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_2spawning_stack};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_3spawning_stack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("spawning_stack (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_2spawning_stack(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_2spawning_stack(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("spawning_stack", 0);
-
- /* "src/gevent/greenlet.py":273
- * # after this, but child greenlets may still be created
- * # that need it.
- * return _Frame_from_list(self._spawning_stack_frames or []) # <<<<<<<<<<<<<<
- *
- * def _get_minimal_ident(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_spawning_stack_frames); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 273, __pyx_L1_error)
- if (!__pyx_t_2) {
- } else {
- __Pyx_INCREF(__pyx_v_self->_spawning_stack_frames);
- __pyx_t_1 = __pyx_v_self->_spawning_stack_frames;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_L3_bool_binop_done:;
- __pyx_t_3 = ((PyObject *)__pyx_f_6gevent_9_greenlet__Frame_from_list(((PyObject*)__pyx_t_1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":268
- *
- * @Lazy
- * def spawning_stack(self): # <<<<<<<<<<<<<<
- * # Store this in the __dict__. We don't use it from the C
- * # code. It's tempting to discard _spawning_stack_frames
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.spawning_stack", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":275
- * return _Frame_from_list(self._spawning_stack_frames or [])
- *
- * def _get_minimal_ident(self): # <<<<<<<<<<<<<<
- * reg = self.parent.ident_registry
- * return reg.get_ident(self)
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__get_minimal_ident(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- struct __pyx_obj_6gevent_7__ident_IdentRegistry *__pyx_v_reg = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_get_minimal_ident", 0);
-
- /* "src/gevent/greenlet.py":276
- *
- * def _get_minimal_ident(self):
- * reg = self.parent.ident_registry # <<<<<<<<<<<<<<
- * return reg.get_ident(self)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ident_registry); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_7__ident_IdentRegistry))))) __PYX_ERR(0, 276, __pyx_L1_error)
- __pyx_v_reg = ((struct __pyx_obj_6gevent_7__ident_IdentRegistry *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":277
- * def _get_minimal_ident(self):
- * reg = self.parent.ident_registry
- * return reg.get_ident(self) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *)__pyx_v_reg->__pyx_vtab)->get_ident(__pyx_v_reg, ((PyObject *)__pyx_v_self), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":275
- * return _Frame_from_list(self._spawning_stack_frames or [])
- *
- * def _get_minimal_ident(self): # <<<<<<<<<<<<<<
- * reg = self.parent.ident_registry
- * return reg.get_ident(self)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._get_minimal_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_reg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":280
- *
- * @property
- * def minimal_ident(self): # <<<<<<<<<<<<<<
- * """
- * A small, unique integer that identifies this object.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_13minimal_ident_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_13minimal_ident_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_13minimal_ident___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_13minimal_ident___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":296
- * .. versionadded:: 1.3a2
- * """
- * if self._ident is None: # <<<<<<<<<<<<<<
- * self._ident = self._get_minimal_ident()
- * return self._ident
- */
- __pyx_t_1 = (__pyx_v_self->_ident == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":297
- * """
- * if self._ident is None:
- * self._ident = self._get_minimal_ident() # <<<<<<<<<<<<<<
- * return self._ident
- *
- */
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_get_minimal_ident(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_ident);
- __Pyx_DECREF(__pyx_v_self->_ident);
- __pyx_v_self->_ident = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":296
- * .. versionadded:: 1.3a2
- * """
- * if self._ident is None: # <<<<<<<<<<<<<<
- * self._ident = self._get_minimal_ident()
- * return self._ident
- */
- }
-
- /* "src/gevent/greenlet.py":298
- * if self._ident is None:
- * self._ident = self._get_minimal_ident()
- * return self._ident # <<<<<<<<<<<<<<
- *
- * @readproperty
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_ident);
- __pyx_r = __pyx_v_self->_ident;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":280
- *
- * @property
- * def minimal_ident(self): # <<<<<<<<<<<<<<
- * """
- * A small, unique integer that identifies this object.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.minimal_ident.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":301
- *
- * @readproperty
- * def name(self): # <<<<<<<<<<<<<<
- * """
- * The greenlet name. By default, a unique name is constructed using
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_5name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_4name[] = "Greenlet.name(self)\n\n The greenlet name. By default, a unique name is constructed using\n the :attr:`minimal_ident`. You can assign a string to this\n value to change it. It is shown in the `repr` of this object.\n\n .. versionadded:: 1.3a2\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_5name = {"name", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_5name, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_4name};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_5name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("name (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_4name(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4name(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("name", 0);
-
- /* "src/gevent/greenlet.py":309
- * .. versionadded:: 1.3a2
- * """
- * return 'Greenlet-%d' % (self.minimal_ident) # <<<<<<<<<<<<<<
- *
- * def _raise_exception(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_minimal_ident); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Greenlet_d, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":301
- *
- * @readproperty
- * def name(self): # <<<<<<<<<<<<<<
- * """
- * The greenlet name. By default, a unique name is constructed using
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.name", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":311
- * return 'Greenlet-%d' % (self.minimal_ident)
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_7_raise_exception(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_6_raise_exception[] = "Greenlet._raise_exception(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_7_raise_exception = {"_raise_exception", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_7_raise_exception, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_6_raise_exception};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_7_raise_exception(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_raise_exception (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_6_raise_exception(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_6_raise_exception(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_raise_exception", 0);
-
- /* "src/gevent/greenlet.py":312
- *
- * def _raise_exception(self):
- * reraise(*self.exc_info) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exc_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_6gevent_9_greenlet_reraise, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":311
- * return 'Greenlet-%d' % (self.minimal_ident)
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._raise_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":315
- *
- * @property
- * def loop(self): # <<<<<<<<<<<<<<
- * # needed by killall
- * return self.parent.loop
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4loop_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_4loop___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4loop___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":317
- * def loop(self):
- * # needed by killall
- * return self.parent.loop # <<<<<<<<<<<<<<
- *
- * def __nonzero__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_loop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":315
- *
- * @property
- * def loop(self): # <<<<<<<<<<<<<<
- * # needed by killall
- * return self.parent.loop
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.loop.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":319
- * return self.parent.loop
- *
- * def __nonzero__(self): # <<<<<<<<<<<<<<
- * return self._start_event is not None and self._exc_info is None
- * try:
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_9__nonzero__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_9__nonzero__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_8__nonzero__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_8__nonzero__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("__nonzero__", 0);
-
- /* "src/gevent/greenlet.py":320
- *
- * def __nonzero__(self):
- * return self._start_event is not None and self._exc_info is None # <<<<<<<<<<<<<<
- * try:
- * __bool__ = __nonzero__ # Python 3
- */
- __pyx_t_2 = (__pyx_v_self->_start_event != Py_None);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_2 = (__pyx_v_self->_exc_info == ((PyObject*)Py_None));
- __pyx_t_1 = __pyx_t_2;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":319
- * return self.parent.loop
- *
- * def __nonzero__(self): # <<<<<<<<<<<<<<
- * return self._start_event is not None and self._exc_info is None
- * try:
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":343
- * else:
- * @property
- * def dead(self): # <<<<<<<<<<<<<<
- * "Boolean indicating that the greenlet is dead and will not run again."
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4dead_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4dead_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_4dead___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4dead___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":345
- * def dead(self):
- * "Boolean indicating that the greenlet is dead and will not run again."
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self) # <<<<<<<<<<<<<<
- *
- * def __never_started_or_killed(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___start_cancelled_by_kill(__pyx_v_self);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___started_but_aborted(__pyx_v_self);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_greenlet), __pyx_n_s_dead); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":343
- * else:
- * @property
- * def dead(self): # <<<<<<<<<<<<<<
- * "Boolean indicating that the greenlet is dead and will not run again."
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.dead.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":347
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
- *
- * def __never_started_or_killed(self): # <<<<<<<<<<<<<<
- * return self._start_event is None
- *
- */
-
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___never_started_or_killed(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__never_started_or_killed", 0);
-
- /* "src/gevent/greenlet.py":348
- *
- * def __never_started_or_killed(self):
- * return self._start_event is None # <<<<<<<<<<<<<<
- *
- * def __start_pending(self):
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == Py_None);
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":347
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
- *
- * def __never_started_or_killed(self): # <<<<<<<<<<<<<<
- * return self._start_event is None
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":350
- * return self._start_event is None
- *
- * def __start_pending(self): # <<<<<<<<<<<<<<
- * return (self._start_event is not None
- * and (self._start_event.pending or getattr(self._start_event, 'active', False)))
- */
-
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_pending(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__start_pending", 0);
-
- /* "src/gevent/greenlet.py":351
- *
- * def __start_pending(self):
- * return (self._start_event is not None # <<<<<<<<<<<<<<
- * and (self._start_event.pending or getattr(self._start_event, 'active', False)))
- *
- */
- __pyx_t_2 = (__pyx_v_self->_start_event != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L3_bool_binop_done;
- }
-
- /* "src/gevent/greenlet.py":352
- * def __start_pending(self):
- * return (self._start_event is not None
- * and (self._start_event.pending or getattr(self._start_event, 'active', False))) # <<<<<<<<<<<<<<
- *
- * def __start_cancelled_by_kill(self):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_start_event, __pyx_n_s_pending); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (!__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_4 = __pyx_v_self->_start_event;
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_4, __pyx_n_s_active, Py_False); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_1 = __pyx_t_3;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":350
- * return self._start_event is None
- *
- * def __start_pending(self): # <<<<<<<<<<<<<<
- * return (self._start_event is not None
- * and (self._start_event.pending or getattr(self._start_event, 'active', False)))
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_WriteUnraisable("gevent._greenlet.Greenlet.__start_pending", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":354
- * and (self._start_event.pending or getattr(self._start_event, 'active', False)))
- *
- * def __start_cancelled_by_kill(self): # <<<<<<<<<<<<<<
- * return self._start_event is _cancelled_start_event
- *
- */
-
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_cancelled_by_kill(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__start_cancelled_by_kill", 0);
-
- /* "src/gevent/greenlet.py":355
- *
- * def __start_cancelled_by_kill(self):
- * return self._start_event is _cancelled_start_event # <<<<<<<<<<<<<<
- *
- * def __start_completed(self):
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == ((PyObject *)__pyx_v_6gevent_9_greenlet__cancelled_start_event));
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":354
- * and (self._start_event.pending or getattr(self._start_event, 'active', False)))
- *
- * def __start_cancelled_by_kill(self): # <<<<<<<<<<<<<<
- * return self._start_event is _cancelled_start_event
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":357
- * return self._start_event is _cancelled_start_event
- *
- * def __start_completed(self): # <<<<<<<<<<<<<<
- * return self._start_event is _start_completed_event
- *
- */
-
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___start_completed(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__start_completed", 0);
-
- /* "src/gevent/greenlet.py":358
- *
- * def __start_completed(self):
- * return self._start_event is _start_completed_event # <<<<<<<<<<<<<<
- *
- * def __started_but_aborted(self):
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == ((PyObject *)__pyx_v_6gevent_9_greenlet__start_completed_event));
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":357
- * return self._start_event is _cancelled_start_event
- *
- * def __start_completed(self): # <<<<<<<<<<<<<<
- * return self._start_event is _start_completed_event
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":360
- * return self._start_event is _start_completed_event
- *
- * def __started_but_aborted(self): # <<<<<<<<<<<<<<
- * return (not self.__never_started_or_killed() # we have been started or killed
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- */
-
-static int __pyx_f_6gevent_9_greenlet_8Greenlet___started_but_aborted(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("__started_but_aborted", 0);
-
- /* "src/gevent/greenlet.py":361
- *
- * def __started_but_aborted(self):
- * return (not self.__never_started_or_killed() # we have been started or killed # <<<<<<<<<<<<<<
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- * and not self.__start_completed() # the start never completed
- */
- __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___never_started_or_killed(__pyx_v_self) != 0)) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L3_bool_binop_done;
- }
-
- /* "src/gevent/greenlet.py":362
- * def __started_but_aborted(self):
- * return (not self.__never_started_or_killed() # we have been started or killed
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started # <<<<<<<<<<<<<<
- * and not self.__start_completed() # the start never completed
- * and not self.__start_pending()) # and we're not pending, so we must have been aborted
- */
- __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___start_cancelled_by_kill(__pyx_v_self) != 0)) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L3_bool_binop_done;
- }
-
- /* "src/gevent/greenlet.py":363
- * return (not self.__never_started_or_killed() # we have been started or killed
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- * and not self.__start_completed() # the start never completed # <<<<<<<<<<<<<<
- * and not self.__start_pending()) # and we're not pending, so we must have been aborted
- *
- */
- __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___start_completed(__pyx_v_self) != 0)) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L3_bool_binop_done;
- }
-
- /* "src/gevent/greenlet.py":364
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- * and not self.__start_completed() # the start never completed
- * and not self.__start_pending()) # and we're not pending, so we must have been aborted # <<<<<<<<<<<<<<
- *
- * def __cancel_start(self):
- */
- __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___start_pending(__pyx_v_self) != 0)) != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":360
- * return self._start_event is _start_completed_event
- *
- * def __started_but_aborted(self): # <<<<<<<<<<<<<<
- * return (not self.__never_started_or_killed() # we have been started or killed
- * and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":366
- * and not self.__start_pending()) # and we're not pending, so we must have been aborted
- *
- * def __cancel_start(self): # <<<<<<<<<<<<<<
- * if self._start_event is None:
- * # prevent self from ever being started in the future
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet___cancel_start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__cancel_start", 0);
-
- /* "src/gevent/greenlet.py":367
- *
- * def __cancel_start(self):
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * # prevent self from ever being started in the future
- * self._start_event = _cancelled_start_event
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":369
- * if self._start_event is None:
- * # prevent self from ever being started in the future
- * self._start_event = _cancelled_start_event # <<<<<<<<<<<<<<
- * # cancel any pending start event
- * # NOTE: If this was a real pending start event, this will leave a
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_6gevent_9_greenlet__cancelled_start_event));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_6gevent_9_greenlet__cancelled_start_event));
- __Pyx_GOTREF(__pyx_v_self->_start_event);
- __Pyx_DECREF(__pyx_v_self->_start_event);
- __pyx_v_self->_start_event = ((PyObject *)__pyx_v_6gevent_9_greenlet__cancelled_start_event);
-
- /* "src/gevent/greenlet.py":367
- *
- * def __cancel_start(self):
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * # prevent self from ever being started in the future
- * self._start_event = _cancelled_start_event
- */
- }
-
- /* "src/gevent/greenlet.py":376
- * # variable copy of that list (in _run_callbacks). This isn't a problem,
- * # except for the leak-tests.
- * self._start_event.stop() # <<<<<<<<<<<<<<
- * self._start_event.close()
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_start_event, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":377
- * # except for the leak-tests.
- * self._start_event.stop()
- * self._start_event.close() # <<<<<<<<<<<<<<
- *
- * def __handle_death_before_start(self, args):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_start_event, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":366
- * and not self.__start_pending()) # and we're not pending, so we must have been aborted
- *
- * def __cancel_start(self): # <<<<<<<<<<<<<<
- * if self._start_event is None:
- * # prevent self from ever being started in the future
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__cancel_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":379
- * self._start_event.close()
- *
- * def __handle_death_before_start(self, args): # <<<<<<<<<<<<<<
- * # args is (t, v, tb) or simply t or v
- * if self._exc_info is None and self.dead:
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet___handle_death_before_start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_args) {
- PyObject *__pyx_v_arg = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__handle_death_before_start", 0);
- __Pyx_INCREF(__pyx_v_args);
-
- /* "src/gevent/greenlet.py":381
- * def __handle_death_before_start(self, args):
- * # args is (t, v, tb) or simply t or v
- * if self._exc_info is None and self.dead: # <<<<<<<<<<<<<<
- * # the greenlet was never switched to before and it will never be, _report_error was not called
- * # the result was not set and the links weren't notified. let's do it here.
- */
- __pyx_t_2 = (__pyx_v_self->_exc_info == ((PyObject*)Py_None));
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dead); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":386
- * # checking that self.dead is true is essential, because throw() does not necessarily kill the greenlet
- * # (if the exception raised by throw() is caught somewhere inside the greenlet).
- * if len(args) == 1: # <<<<<<<<<<<<<<
- * arg = args[0]
- * #if isinstance(arg, type):
- */
- if (unlikely(__pyx_v_args == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 386, __pyx_L1_error)
- }
- __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 386, __pyx_L1_error)
- __pyx_t_1 = ((__pyx_t_5 == 1) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":387
- * # (if the exception raised by throw() is caught somewhere inside the greenlet).
- * if len(args) == 1:
- * arg = args[0] # <<<<<<<<<<<<<<
- * #if isinstance(arg, type):
- * if type(arg) is type(Exception):
- */
- if (unlikely(__pyx_v_args == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 387, __pyx_L1_error)
- }
- __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_arg = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":389
- * arg = args[0]
- * #if isinstance(arg, type):
- * if type(arg) is type(Exception): # <<<<<<<<<<<<<<
- * args = (arg, arg(), None)
- * else:
- */
- __pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_arg)) == ((PyObject *)Py_TYPE(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])))));
- __pyx_t_3 = (__pyx_t_1 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":390
- * #if isinstance(arg, type):
- * if type(arg) is type(Exception):
- * args = (arg, arg(), None) # <<<<<<<<<<<<<<
- * else:
- * args = (type(arg), arg, None)
- */
- __Pyx_INCREF(__pyx_v_arg);
- __pyx_t_6 = __pyx_v_arg; __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_7) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 390, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_v_arg);
- __Pyx_GIVEREF(__pyx_v_arg);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_arg);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_6, 2, Py_None);
- __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_6));
- __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":389
- * arg = args[0]
- * #if isinstance(arg, type):
- * if type(arg) is type(Exception): # <<<<<<<<<<<<<<
- * args = (arg, arg(), None)
- * else:
- */
- goto __pyx_L7;
- }
-
- /* "src/gevent/greenlet.py":392
- * args = (arg, arg(), None)
- * else:
- * args = (type(arg), arg, None) # <<<<<<<<<<<<<<
- * elif not args:
- * args = (GreenletExit, GreenletExit(), None)
- */
- /*else*/ {
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 392, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
- PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)Py_TYPE(__pyx_v_arg)));
- __Pyx_INCREF(__pyx_v_arg);
- __Pyx_GIVEREF(__pyx_v_arg);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_arg);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_6, 2, Py_None);
- __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_6));
- __pyx_t_6 = 0;
- }
- __pyx_L7:;
-
- /* "src/gevent/greenlet.py":386
- * # checking that self.dead is true is essential, because throw() does not necessarily kill the greenlet
- * # (if the exception raised by throw() is caught somewhere inside the greenlet).
- * if len(args) == 1: # <<<<<<<<<<<<<<
- * arg = args[0]
- * #if isinstance(arg, type):
- */
- goto __pyx_L6;
- }
-
- /* "src/gevent/greenlet.py":393
- * else:
- * args = (type(arg), arg, None)
- * elif not args: # <<<<<<<<<<<<<<
- * args = (GreenletExit, GreenletExit(), None)
- * self._report_error(args)
- */
- __pyx_t_3 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
- __pyx_t_1 = ((!__pyx_t_3) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":394
- * args = (type(arg), arg, None)
- * elif not args:
- * args = (GreenletExit, GreenletExit(), None) # <<<<<<<<<<<<<<
- * self._report_error(args)
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __pyx_t_4 = __pyx_v_6gevent_9_greenlet_GreenletExit; __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_7) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __Pyx_GIVEREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_6gevent_9_greenlet_GreenletExit);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
- __pyx_t_6 = 0;
- __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_4));
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":393
- * else:
- * args = (type(arg), arg, None)
- * elif not args: # <<<<<<<<<<<<<<
- * args = (GreenletExit, GreenletExit(), None)
- * self._report_error(args)
- */
- }
- __pyx_L6:;
-
- /* "src/gevent/greenlet.py":395
- * elif not args:
- * args = (GreenletExit, GreenletExit(), None)
- * self._report_error(args) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_report_error(__pyx_v_self, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":381
- * def __handle_death_before_start(self, args):
- * # args is (t, v, tb) or simply t or v
- * if self._exc_info is None and self.dead: # <<<<<<<<<<<<<<
- * # the greenlet was never switched to before and it will never be, _report_error was not called
- * # the result was not set and the links weren't notified. let's do it here.
- */
- }
-
- /* "src/gevent/greenlet.py":379
- * self._start_event.close()
- *
- * def __handle_death_before_start(self, args): # <<<<<<<<<<<<<<
- * # args is (t, v, tb) or simply t or v
- * if self._exc_info is None and self.dead:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__handle_death_before_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_arg);
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":398
- *
- * @property
- * def started(self): # <<<<<<<<<<<<<<
- * # DEPRECATED
- * return bool(self)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_7started_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_7started_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_7started___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_7started___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":400
- * def started(self):
- * # DEPRECATED
- * return bool(self) # <<<<<<<<<<<<<<
- *
- * def ready(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 400, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":398
- *
- * @property
- * def started(self): # <<<<<<<<<<<<<<
- * # DEPRECATED
- * return bool(self)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.started.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":402
- * return bool(self)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_11ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_ready(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("ready", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_11ready)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":411
- * necessarily the literal constants ``True`` or ``False``.
- * """
- * return self.dead or self._exc_info is not None # <<<<<<<<<<<<<<
- *
- * def successful(self):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dead); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 411, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!__pyx_t_6) {
- } else {
- __pyx_t_5 = __pyx_t_6;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_6 = (__pyx_v_self->_exc_info != ((PyObject*)Py_None));
- __pyx_t_7 = (__pyx_t_6 != 0);
- __pyx_t_5 = __pyx_t_7;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":402
- * return bool(self)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._greenlet.Greenlet.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_11ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_10ready[] = "Greenlet.ready(self) -> bool\n\n Return a true value if and only if the greenlet has finished\n execution.\n\n .. versionchanged:: 1.1\n This function is only guaranteed to return true or false *values*, not\n necessarily the literal constants ``True`` or ``False``.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_11ready = {"ready", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_11ready, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_10ready};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_11ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ready (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_10ready(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_10ready(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("ready", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_9_greenlet_8Greenlet_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":413
- * return self.dead or self._exc_info is not None
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished execution
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_13successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_successful(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("successful", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_successful); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_13successful)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":425
- * not necessarily the literal constants ``True`` or ``False``.
- * """
- * return self._exc_info is not None and self._exc_info[1] is None # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __pyx_t_6 = (__pyx_v_self->_exc_info != ((PyObject*)Py_None));
- __pyx_t_7 = (__pyx_t_6 != 0);
- if (__pyx_t_7) {
- } else {
- __pyx_t_5 = __pyx_t_7;
- goto __pyx_L3_bool_binop_done;
- }
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 425, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_7 = (__pyx_t_1 == Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = (__pyx_t_7 != 0);
- __pyx_t_5 = __pyx_t_6;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":413
- * return self.dead or self._exc_info is not None
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished execution
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._greenlet.Greenlet.successful", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_13successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_12successful[] = "Greenlet.successful(self) -> bool\n\n Return a true value if and only if the greenlet has finished execution\n successfully, that is, without raising an error.\n\n .. tip:: A greenlet that has been killed with the default\n :class:`GreenletExit` exception is considered successful.\n That is, ``GreenletExit`` is not considered an error.\n\n .. note:: This function is only guaranteed to return true or false *values*,\n not necessarily the literal constants ``True`` or ``False``.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_13successful = {"successful", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_13successful, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_12successful};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_13successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("successful (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_12successful(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_12successful(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("successful", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_9_greenlet_8Greenlet_successful(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.successful", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":427
- * return self._exc_info is not None and self._exc_info[1] is None
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * classname = self.__class__.__name__
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_15__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_15__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_14__repr__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_14__repr__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_v_classname = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_formatted = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "src/gevent/greenlet.py":428
- *
- * def __repr__(self):
- * classname = self.__class__.__name__ # <<<<<<<<<<<<<<
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- * formatted = self._formatinfo()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 428, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_classname = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":429
- * def __repr__(self):
- * classname = self.__class__.__name__
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self))) # <<<<<<<<<<<<<<
- * formatted = self._formatinfo()
- * if formatted:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_classname);
- __Pyx_GIVEREF(__pyx_v_classname);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_classname);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_at_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_result = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":430
- * classname = self.__class__.__name__
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- * formatted = self._formatinfo() # <<<<<<<<<<<<<<
- * if formatted:
- * result += ': ' + formatted
- */
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_formatinfo(__pyx_v_self, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_formatted = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":431
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- * formatted = self._formatinfo()
- * if formatted: # <<<<<<<<<<<<<<
- * result += ': ' + formatted
- * return result + '>'
- */
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_formatted); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 431, __pyx_L1_error)
- if (__pyx_t_4) {
-
- /* "src/gevent/greenlet.py":432
- * formatted = self._formatinfo()
- * if formatted:
- * result += ': ' + formatted # <<<<<<<<<<<<<<
- * return result + '>'
- *
- */
- __pyx_t_3 = PyNumber_Add(__pyx_kp_s__2, __pyx_v_formatted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":431
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- * formatted = self._formatinfo()
- * if formatted: # <<<<<<<<<<<<<<
- * result += ': ' + formatted
- * return result + '>'
- */
- }
-
- /* "src/gevent/greenlet.py":433
- * if formatted:
- * result += ': ' + formatted
- * return result + '>' # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":427
- * return self._exc_info is not None and self._exc_info[1] is None
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * classname = self.__class__.__name__
- * result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_classname);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_formatted);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":436
- *
- *
- * def _formatinfo(self): # <<<<<<<<<<<<<<
- * info = self._formatted_info
- * if info is not None:
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17_formatinfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__formatinfo(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_info = NULL;
- PyObject *__pyx_v_func = NULL;
- PyObject *__pyx_v_im_self = NULL;
- PyObject *__pyx_v_funcname = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_args = NULL;
- PyObject *__pyx_v_x = NULL;
- PyObject *__pyx_v_key = NULL;
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- Py_ssize_t __pyx_t_7;
- PyObject *(*__pyx_t_8)(PyObject *);
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *(*__pyx_t_11)(PyObject *);
- int __pyx_t_12;
- __Pyx_RefNannySetupContext("_formatinfo", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_formatinfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_17_formatinfo)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 436, __pyx_L1_error)
- __pyx_r = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":437
- *
- * def _formatinfo(self):
- * info = self._formatted_info # <<<<<<<<<<<<<<
- * if info is not None:
- * return info
- */
- __pyx_t_1 = __pyx_v_self->_formatted_info;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_info = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":438
- * def _formatinfo(self):
- * info = self._formatted_info
- * if info is not None: # <<<<<<<<<<<<<<
- * return info
- *
- */
- __pyx_t_5 = (__pyx_v_info != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":439
- * info = self._formatted_info
- * if info is not None:
- * return info # <<<<<<<<<<<<<<
- *
- * # Are we running an arbitrary function provided to the constructor,
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(PyString_CheckExact(__pyx_v_info))||((__pyx_v_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_info)->tp_name), 0))) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_info);
- __pyx_r = ((PyObject*)__pyx_v_info);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":438
- * def _formatinfo(self):
- * info = self._formatted_info
- * if info is not None: # <<<<<<<<<<<<<<
- * return info
- *
- */
- }
-
- /* "src/gevent/greenlet.py":443
- * # Are we running an arbitrary function provided to the constructor,
- * # or did a subclass override _run?
- * func = self._run # <<<<<<<<<<<<<<
- * im_self = getattr(func, '__self__', None)
- * if im_self is self:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_run_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 443, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_func = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":444
- * # or did a subclass override _run?
- * func = self._run
- * im_self = getattr(func, '__self__', None) # <<<<<<<<<<<<<<
- * if im_self is self:
- * funcname = '_run'
- */
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_func, __pyx_n_s_self, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_im_self = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":445
- * func = self._run
- * im_self = getattr(func, '__self__', None)
- * if im_self is self: # <<<<<<<<<<<<<<
- * funcname = '_run'
- * elif im_self is not None:
- */
- __pyx_t_6 = (__pyx_v_im_self == ((PyObject *)__pyx_v_self));
- __pyx_t_5 = (__pyx_t_6 != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/greenlet.py":446
- * im_self = getattr(func, '__self__', None)
- * if im_self is self:
- * funcname = '_run' # <<<<<<<<<<<<<<
- * elif im_self is not None:
- * funcname = repr(func)
- */
- __Pyx_INCREF(__pyx_n_s_run_2);
- __pyx_v_funcname = __pyx_n_s_run_2;
-
- /* "src/gevent/greenlet.py":445
- * func = self._run
- * im_self = getattr(func, '__self__', None)
- * if im_self is self: # <<<<<<<<<<<<<<
- * funcname = '_run'
- * elif im_self is not None:
- */
- goto __pyx_L4;
- }
-
- /* "src/gevent/greenlet.py":447
- * if im_self is self:
- * funcname = '_run'
- * elif im_self is not None: # <<<<<<<<<<<<<<
- * funcname = repr(func)
- * else:
- */
- __pyx_t_5 = (__pyx_v_im_self != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":448
- * funcname = '_run'
- * elif im_self is not None:
- * funcname = repr(func) # <<<<<<<<<<<<<<
- * else:
- * funcname = getattr(func, '__name__', '') or repr(func)
- */
- __pyx_t_1 = PyObject_Repr(__pyx_v_func); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_funcname = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":447
- * if im_self is self:
- * funcname = '_run'
- * elif im_self is not None: # <<<<<<<<<<<<<<
- * funcname = repr(func)
- * else:
- */
- goto __pyx_L4;
- }
-
- /* "src/gevent/greenlet.py":450
- * funcname = repr(func)
- * else:
- * funcname = getattr(func, '__name__', '') or repr(func) # <<<<<<<<<<<<<<
- *
- * result = funcname
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_GetAttr3(__pyx_v_func, __pyx_n_s_name, __pyx_kp_s__4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 450, __pyx_L1_error)
- if (!__pyx_t_6) {
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_1 = __pyx_t_2;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_2 = PyObject_Repr(__pyx_v_func); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_1 = __pyx_t_2;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_L5_bool_binop_done:;
- __pyx_v_funcname = __pyx_t_1;
- __pyx_t_1 = 0;
- }
- __pyx_L4:;
-
- /* "src/gevent/greenlet.py":452
- * funcname = getattr(func, '__name__', '') or repr(func)
- *
- * result = funcname # <<<<<<<<<<<<<<
- * args = []
- * if self.args:
- */
- __Pyx_INCREF(__pyx_v_funcname);
- __pyx_v_result = __pyx_v_funcname;
-
- /* "src/gevent/greenlet.py":453
- *
- * result = funcname
- * args = [] # <<<<<<<<<<<<<<
- * if self.args:
- * args = [repr(x)[:50] for x in self.args]
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_args = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":454
- * result = funcname
- * args = []
- * if self.args: # <<<<<<<<<<<<<<
- * args = [repr(x)[:50] for x in self.args]
- * if self.kwargs:
- */
- __pyx_t_6 = (__pyx_v_self->args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->args) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":455
- * args = []
- * if self.args:
- * args = [repr(x)[:50] for x in self.args] # <<<<<<<<<<<<<<
- * if self.kwargs:
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(__pyx_v_self->args == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 455, __pyx_L1_error)
- }
- __pyx_t_2 = __pyx_v_self->args; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
- for (;;) {
- if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 455, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Repr(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (unlikely(__pyx_t_3 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 455, __pyx_L1_error)
- }
- __pyx_t_4 = PySequence_GetSlice(__pyx_t_3, 0, 50); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":454
- * result = funcname
- * args = []
- * if self.args: # <<<<<<<<<<<<<<
- * args = [repr(x)[:50] for x in self.args]
- * if self.kwargs:
- */
- }
-
- /* "src/gevent/greenlet.py":456
- * if self.args:
- * args = [repr(x)[:50] for x in self.args]
- * if self.kwargs: # <<<<<<<<<<<<<<
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- * if args:
- */
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->kwargs); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 456, __pyx_L1_error)
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":457
- * args = [repr(x)[:50] for x in self.args]
- * if self.kwargs:
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()]) # <<<<<<<<<<<<<<
- * if args:
- * result += '(' + ', '.join(args) + ')'
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(__pyx_v_self->kwargs == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
- __PYX_ERR(0, 457, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_self->kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
- __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- } else {
- __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 457, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- for (;;) {
- if (likely(!__pyx_t_8)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- } else {
- if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- }
- } else {
- __pyx_t_2 = __pyx_t_8(__pyx_t_4);
- if (unlikely(!__pyx_t_2)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 457, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_2);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
- PyObject* sequence = __pyx_t_2;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 457, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_9 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_9);
- #else
- __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- #endif
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
- index = 0; __pyx_t_3 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_3);
- index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 457, __pyx_L1_error)
- __pyx_t_11 = NULL;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L14_unpacking_done;
- __pyx_L13_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_11 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 457, __pyx_L1_error)
- __pyx_L14_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
- __pyx_t_3 = 0;
- __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_9);
- __pyx_t_9 = 0;
- __pyx_t_2 = PyObject_Repr(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(__pyx_t_2 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 457, __pyx_L1_error)
- }
- __pyx_t_9 = PySequence_GetSlice(__pyx_t_2, 0, 50); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_key);
- __Pyx_GIVEREF(__pyx_v_key);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
- __Pyx_GIVEREF(__pyx_t_9);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
- __pyx_t_9 = 0;
- __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_args, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 457, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":456
- * if self.args:
- * args = [repr(x)[:50] for x in self.args]
- * if self.kwargs: # <<<<<<<<<<<<<<
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- * if args:
- */
- }
-
- /* "src/gevent/greenlet.py":458
- * if self.kwargs:
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- * if args: # <<<<<<<<<<<<<<
- * result += '(' + ', '.join(args) + ')'
- * # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- */
- __pyx_t_6 = (PyList_GET_SIZE(__pyx_v_args) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":459
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- * if args:
- * result += '(' + ', '.join(args) + ')' # <<<<<<<<<<<<<<
- * # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- * self._formatted_info = result
- */
- __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyNumber_Add(__pyx_kp_s__5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 459, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":458
- * if self.kwargs:
- * args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- * if args: # <<<<<<<<<<<<<<
- * result += '(' + ', '.join(args) + ')'
- * # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- */
- }
-
- /* "src/gevent/greenlet.py":461
- * result += '(' + ', '.join(args) + ')'
- * # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- * self._formatted_info = result # <<<<<<<<<<<<<<
- * return result
- *
- */
- if (!(likely(PyString_CheckExact(__pyx_v_result))||((__pyx_v_result) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_result)->tp_name), 0))) __PYX_ERR(0, 461, __pyx_L1_error)
- __pyx_t_4 = __pyx_v_result;
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_formatted_info);
- __Pyx_DECREF(__pyx_v_self->_formatted_info);
- __pyx_v_self->_formatted_info = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":462
- * # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- * self._formatted_info = result
- * return result # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- if (!(likely(PyString_CheckExact(__pyx_v_result))||((__pyx_v_result) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_result)->tp_name), 0))) __PYX_ERR(0, 462, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = ((PyObject*)__pyx_v_result);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":436
- *
- *
- * def _formatinfo(self): # <<<<<<<<<<<<<<
- * info = self._formatted_info
- * if info is not None:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._formatinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_info);
- __Pyx_XDECREF(__pyx_v_func);
- __Pyx_XDECREF(__pyx_v_im_self);
- __Pyx_XDECREF(__pyx_v_funcname);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_x);
- __Pyx_XDECREF(__pyx_v_key);
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17_formatinfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_16_formatinfo[] = "Greenlet._formatinfo(self) -> str";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_17_formatinfo = {"_formatinfo", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_17_formatinfo, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_16_formatinfo};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17_formatinfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_formatinfo (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_16_formatinfo(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_16_formatinfo(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_formatinfo", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_8Greenlet__formatinfo(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._formatinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":465
- *
- * @property
- * def exception(self): # <<<<<<<<<<<<<<
- * """
- * Holds the exception instance raised by the function if the
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_9exception_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_9exception___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_9exception___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":470
- * greenlet has finished with an error. Otherwise ``None``.
- * """
- * return self._exc_info[1] if self._exc_info is not None else None # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = (__pyx_v_self->_exc_info != ((PyObject*)Py_None));
- if ((__pyx_t_2 != 0)) {
- if (unlikely(__pyx_v_self->_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 470, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_1 = Py_None;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":465
- *
- * @property
- * def exception(self): # <<<<<<<<<<<<<<
- * """
- * Holds the exception instance raised by the function if the
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.exception.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":473
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * """
- * Holds the exc_info three-tuple raised by the function if the
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_8exc_info_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_8exc_info_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_8exc_info___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_8exc_info___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_v_ei = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/greenlet.py":482
- * .. versionadded:: 1.1
- * """
- * ei = self._exc_info # <<<<<<<<<<<<<<
- * if ei is not None and ei[0] is not None:
- * return (ei[0], ei[1], load_traceback(ei[2]))
- */
- __pyx_t_1 = __pyx_v_self->_exc_info;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_ei = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":483
- * """
- * ei = self._exc_info
- * if ei is not None and ei[0] is not None: # <<<<<<<<<<<<<<
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- */
- __pyx_t_3 = (__pyx_v_ei != ((PyObject*)Py_None));
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L4_bool_binop_done;
- }
- if (unlikely(__pyx_v_ei == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 483, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_ei, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = (__pyx_t_1 != Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_4 != 0);
- __pyx_t_2 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":484
- * ei = self._exc_info
- * if ei is not None and ei[0] is not None:
- * return (ei[0], ei[1], load_traceback(ei[2])) # <<<<<<<<<<<<<<
- *
- * def throw(self, *args):
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_ei == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 484, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_ei, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(__pyx_v_ei == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 484, __pyx_L1_error)
- }
- __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_ei, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (unlikely(__pyx_v_ei == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 484, __pyx_L1_error)
- }
- __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_ei, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_load_traceback);
- __pyx_t_8 = __pyx_v_6gevent_9_greenlet_load_traceback; __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- if (!__pyx_t_9) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
- __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
- __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
- __pyx_t_7 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 484, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6);
- __pyx_t_1 = 0;
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_r = __pyx_t_8;
- __pyx_t_8 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":483
- * """
- * ei = self._exc_info
- * if ei is not None and ei[0] is not None: # <<<<<<<<<<<<<<
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- */
- }
-
- /* "src/gevent/greenlet.py":473
- *
- * @property
- * def exc_info(self): # <<<<<<<<<<<<<<
- * """
- * Holds the exc_info three-tuple raised by the function if the
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.exc_info.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_ei);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":486
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- * def throw(self, *args): # <<<<<<<<<<<<<<
- * """Immediately switch into the greenlet and raise an exception in it.
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_19throw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_18throw[] = "Greenlet.throw(self, *args)\nImmediately switch into the greenlet and raise an exception in it.\n\n Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever.\n To raise an exception in a safe manner from any greenlet, use :meth:`kill`.\n\n If a greenlet was started but never switched to yet, then also\n a) cancel the event that will start it\n b) fire the notifications as if an exception was raised in a greenlet\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_19throw = {"throw", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_19throw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_18throw};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_19throw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("throw (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "throw", 0))) return NULL;
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_18throw(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_18throw(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- char const *__pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("throw", 0);
-
- /* "src/gevent/greenlet.py":496
- * b) fire the notifications as if an exception was raised in a greenlet
- * """
- * self.__cancel_start() # <<<<<<<<<<<<<<
- *
- * try:
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___cancel_start(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":498
- * self.__cancel_start()
- *
- * try: # <<<<<<<<<<<<<<
- * if not self.dead:
- * # Prevent switching into a greenlet *at all* if we had never
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":499
- *
- * try:
- * if not self.dead: # <<<<<<<<<<<<<<
- * # Prevent switching into a greenlet *at all* if we had never
- * # started it. Usually this is the same thing that happens by throwing,
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dead); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 499, __pyx_L4_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = ((!__pyx_t_2) != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":504
- * # but if this is done from the hub with nothing else running, prevents a
- * # LoopExit.
- * greenlet.throw(self, *args) # <<<<<<<<<<<<<<
- * finally:
- * self.__handle_death_before_start(args)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_greenlet), __pyx_n_s_throw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
- __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":499
- *
- * try:
- * if not self.dead: # <<<<<<<<<<<<<<
- * # Prevent switching into a greenlet *at all* if we had never
- * # started it. Usually this is the same thing that happens by throwing,
- */
- }
- }
-
- /* "src/gevent/greenlet.py":506
- * greenlet.throw(self, *args)
- * finally:
- * self.__handle_death_before_start(args) # <<<<<<<<<<<<<<
- *
- * def start(self):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___handle_death_before_start(__pyx_v_self, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 506, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
- {
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___handle_death_before_start(__pyx_v_self, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 506, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
- goto __pyx_L1_error;
- __pyx_L8_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/greenlet.py":486
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- * def throw(self, *args): # <<<<<<<<<<<<<<
- * """Immediately switch into the greenlet and raise an exception in it.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.throw", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":508
- * self.__handle_death_before_start(args)
- *
- * def start(self): # <<<<<<<<<<<<<<
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_21start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_20start[] = "Greenlet.start(self)\nSchedule the greenlet to run in this loop iteration";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_21start = {"start", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_21start, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_20start};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_21start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_20start(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_20start(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("start", 0);
-
- /* "src/gevent/greenlet.py":510
- * def start(self):
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":511
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None:
- * self._start_event = self.parent.loop.run_callback(self.switch) # <<<<<<<<<<<<<<
- *
- * def start_later(self, seconds):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_loop); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_start_event);
- __Pyx_DECREF(__pyx_v_self->_start_event);
- __pyx_v_self->_start_event = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":510
- * def start(self):
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":508
- * self.__handle_death_before_start(args)
- *
- * def start(self): # <<<<<<<<<<<<<<
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":513
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- * def start_later(self, seconds): # <<<<<<<<<<<<<<
- * """
- * start_later(seconds) -> None
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_23start_later(PyObject *__pyx_v_self, PyObject *__pyx_v_seconds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_22start_later[] = "Greenlet.start_later(self, seconds)\n\n start_later(seconds) -> None\n\n Schedule the greenlet to run in the future loop iteration\n *seconds* later\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_23start_later = {"start_later", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_23start_later, METH_O, __pyx_doc_6gevent_9_greenlet_8Greenlet_22start_later};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_23start_later(PyObject *__pyx_v_self, PyObject *__pyx_v_seconds) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start_later (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_22start_later(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), ((PyObject *)__pyx_v_seconds));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_22start_later(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_seconds) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("start_later", 0);
-
- /* "src/gevent/greenlet.py":520
- * *seconds* later
- * """
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * self._start_event = self.parent.loop.timer(seconds)
- * self._start_event.start(self.switch)
- */
- __pyx_t_1 = (__pyx_v_self->_start_event == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":521
- * """
- * if self._start_event is None:
- * self._start_event = self.parent.loop.timer(seconds) # <<<<<<<<<<<<<<
- * self._start_event.start(self.switch)
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_loop); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_timer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_seconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_seconds};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_seconds};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_INCREF(__pyx_v_seconds);
- __Pyx_GIVEREF(__pyx_v_seconds);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_seconds);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_start_event);
- __Pyx_DECREF(__pyx_v_self->_start_event);
- __pyx_v_self->_start_event = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":522
- * if self._start_event is None:
- * self._start_event = self.parent.loop.timer(seconds)
- * self._start_event.start(self.switch) # <<<<<<<<<<<<<<
- *
- * @classmethod
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_start_event, __pyx_n_s_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":520
- * *seconds* later
- * """
- * if self._start_event is None: # <<<<<<<<<<<<<<
- * self._start_event = self.parent.loop.timer(seconds)
- * self._start_event.start(self.switch)
- */
- }
-
- /* "src/gevent/greenlet.py":513
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- * def start_later(self, seconds): # <<<<<<<<<<<<<<
- * """
- * start_later(seconds) -> None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.start_later", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":525
- *
- * @classmethod
- * def spawn(cls, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn(function, *args, **kwargs) -> Greenlet
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_25spawn(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_24spawn[] = "Greenlet.spawn(type cls, *args, **kwargs)\n\n spawn(function, *args, **kwargs) -> Greenlet\n\n Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.\n This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.\n\n The arguments are passed to :meth:`Greenlet.__init__`.\n\n .. versionchanged:: 1.1b1\n If a *function* is given that is not callable, immediately raise a :exc:`TypeError`\n instead of spawning a greenlet that will raise an uncaught TypeError.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_25spawn = {"spawn", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_25spawn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_24spawn};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_25spawn(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("spawn (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "spawn", 1))) return NULL;
- if (unlikely(__pyx_kwds)) {
- __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
- __Pyx_GOTREF(__pyx_v_kwargs);
- } else {
- __pyx_v_kwargs = NULL;
- }
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_24spawn(((PyTypeObject*)__pyx_v_cls), __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_24spawn(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- PyObject *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("spawn", 0);
-
- /* "src/gevent/greenlet.py":538
- * instead of spawning a greenlet that will raise an uncaught TypeError.
- * """
- * g = cls(*args, **kwargs) # <<<<<<<<<<<<<<
- * g.start()
- * return g
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_g = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":539
- * """
- * g = cls(*args, **kwargs)
- * g.start() # <<<<<<<<<<<<<<
- * return g
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":540
- * g = cls(*args, **kwargs)
- * g.start()
- * return g # <<<<<<<<<<<<<<
- *
- * @classmethod
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_g);
- __pyx_r = __pyx_v_g;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":525
- *
- * @classmethod
- * def spawn(cls, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn(function, *args, **kwargs) -> Greenlet
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.spawn", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":543
- *
- * @classmethod
- * def spawn_later(cls, seconds, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn_later(seconds, function, *args, **kwargs) -> Greenlet
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_27spawn_later(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_26spawn_later[] = "Greenlet.spawn_later(type cls, seconds, *args, **kwargs)\n\n spawn_later(seconds, function, *args, **kwargs) -> Greenlet\n\n Create and return a new `Greenlet` object scheduled to run ``function(*args, **kwargs)``\n in a future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``\n or ``gevent.spawn_later``.\n\n The arguments are passed to :meth:`Greenlet.__init__`.\n\n .. versionchanged:: 1.1b1\n If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword )\n is given to this classmethod (and not a classmethod of a subclass),\n it is verified to be callable. Previously, the spawned greenlet would have failed\n when it started running.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_27spawn_later = {"spawn_later", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_27spawn_later, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_26spawn_later};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_27spawn_later(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_seconds = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("spawn_later (wrapper)", 0);
- __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
- __Pyx_GOTREF(__pyx_v_kwargs);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seconds,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seconds)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "spawn_later") < 0)) __PYX_ERR(0, 543, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_seconds = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("spawn_later", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 543, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.spawn_later", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_26spawn_later(((PyTypeObject*)__pyx_v_cls), __pyx_v_seconds, __pyx_v_args, __pyx_v_kwargs);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kwargs);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_26spawn_later(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_seconds, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
- PyObject *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("spawn_later", 0);
-
- /* "src/gevent/greenlet.py":559
- * when it started running.
- * """
- * if cls is Greenlet and not args and 'run' not in kwargs: # <<<<<<<<<<<<<<
- * raise TypeError("")
- * g = cls(*args, **kwargs)
- */
- __pyx_t_2 = (__pyx_v_cls == __pyx_ptype_6gevent_9_greenlet_Greenlet);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_3 = (PyTuple_GET_SIZE(__pyx_v_args) != 0);
- __pyx_t_2 = ((!__pyx_t_3) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_run, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 559, __pyx_L1_error)
- __pyx_t_3 = (__pyx_t_2 != 0);
- __pyx_t_1 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/greenlet.py":560
- * """
- * if cls is Greenlet and not args and 'run' not in kwargs:
- * raise TypeError("") # <<<<<<<<<<<<<<
- * g = cls(*args, **kwargs)
- * g.start_later(seconds)
- */
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 560, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 560, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":559
- * when it started running.
- * """
- * if cls is Greenlet and not args and 'run' not in kwargs: # <<<<<<<<<<<<<<
- * raise TypeError("")
- * g = cls(*args, **kwargs)
- */
- }
-
- /* "src/gevent/greenlet.py":561
- * if cls is Greenlet and not args and 'run' not in kwargs:
- * raise TypeError("")
- * g = cls(*args, **kwargs) # <<<<<<<<<<<<<<
- * g.start_later(seconds)
- * return g
- */
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 561, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_g = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":562
- * raise TypeError("")
- * g = cls(*args, **kwargs)
- * g.start_later(seconds) # <<<<<<<<<<<<<<
- * return g
- *
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_start_later); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_seconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_seconds};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_seconds};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(__pyx_v_seconds);
- __Pyx_GIVEREF(__pyx_v_seconds);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_seconds);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 562, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":563
- * g = cls(*args, **kwargs)
- * g.start_later(seconds)
- * return g # <<<<<<<<<<<<<<
- *
- * def kill(self, exception=GreenletExit, block=True, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_g);
- __pyx_r = __pyx_v_g;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":543
- *
- * @classmethod
- * def spawn_later(cls, seconds, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn_later(seconds, function, *args, **kwargs) -> Greenlet
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.spawn_later", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":565
- * return g
- *
- * def kill(self, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Raise the ``exception`` in the greenlet.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_29kill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_28kill[] = "Greenlet.kill(self, exception=GreenletExit, block=True, timeout=None)\n\n Raise the ``exception`` in the greenlet.\n\n If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires.\n If block is ``False``, the current greenlet is not unscheduled.\n\n The function always returns ``None`` and never raises an error.\n\n .. note::\n\n Depending on what this greenlet is executing and the state\n of the event loop, the exception may or may not be raised\n immediately when this greenlet resumes execution. It may\n be raised on a subsequent green call, or, if this greenlet\n exits before making such a call, it may not be raised at\n all. As of 1.1, an example where the exception is raised\n later is if this greenlet had called :func:`sleep(0)\n <gevent.sleep>`; an example where the exception is raised\n immediately is if this greenlet had called\n :func:`sleep(0.1) <gevent.sleep>`.\n\n .. caution::\n\n Use care when killing greenlets. If the code executing is not\n exception safe (e.g., makes proper use of ``finally``) then an\n unexpected exception could result in corrupted state.\n\n See also :func:`gevent.kill`.\n\n :keyword type exception: The type of exception to raise in the greenlet. The default\n is :class:`GreenletExit`, which indicates a :meth:`successful` completion\n of the greenlet.\n\n .. versionchanged:: 0.13.0\n *block* is now ``True`` by default.\n .. versionchanged:: 1.1a2\n If this greenlet had never been switched to, killing it will prevent it from ever being switched to.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_29kill = {"kill", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_29kill, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_28kill};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_29kill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("kill (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exception,&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[3] = {0,0,0};
- values[0] = __pyx_k__9;
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "kill") < 0)) __PYX_ERR(0, 565, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_exception = values[0];
- __pyx_v_block = values[1];
- __pyx_v_timeout = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("kill", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 565, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_28kill(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_exception, __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_28kill(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_exception, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_v_waiter = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join __pyx_t_8;
- __Pyx_RefNannySetupContext("kill", 0);
-
- /* "src/gevent/greenlet.py":604
- * If this greenlet had never been switched to, killing it will prevent it from ever being switched to.
- * """
- * self.__cancel_start() # <<<<<<<<<<<<<<
- *
- * if self.dead:
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___cancel_start(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":606
- * self.__cancel_start()
- *
- * if self.dead: # <<<<<<<<<<<<<<
- * self.__handle_death_before_start((exception,))
- * else:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dead); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 606, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 606, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":607
- *
- * if self.dead:
- * self.__handle_death_before_start((exception,)) # <<<<<<<<<<<<<<
- * else:
- * waiter = Waiter() if block else None # pylint:disable=undefined-variable
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_exception);
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___handle_death_before_start(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 607, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":606
- * self.__cancel_start()
- *
- * if self.dead: # <<<<<<<<<<<<<<
- * self.__handle_death_before_start((exception,))
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/greenlet.py":609
- * self.__handle_death_before_start((exception,))
- * else:
- * waiter = Waiter() if block else None # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.parent.loop.run_callback(_kill, self, exception, waiter)
- * if block:
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 609, __pyx_L1_error)
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1;
- __pyx_t_1 = 0;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_3 = Py_None;
- }
- __pyx_v_waiter = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":610
- * else:
- * waiter = Waiter() if block else None # pylint:disable=undefined-variable
- * self.parent.loop.run_callback(_kill, self, exception, waiter) # <<<<<<<<<<<<<<
- * if block:
- * waiter.get()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_loop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_kill); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_exception, __pyx_v_waiter};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_exception, __pyx_v_waiter};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_exception);
- __Pyx_INCREF(__pyx_v_waiter);
- __Pyx_GIVEREF(__pyx_v_waiter);
- PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_waiter);
- __pyx_t_4 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":611
- * waiter = Waiter() if block else None # pylint:disable=undefined-variable
- * self.parent.loop.run_callback(_kill, self, exception, waiter)
- * if block: # <<<<<<<<<<<<<<
- * waiter.get()
- * self.join(timeout)
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 611, __pyx_L1_error)
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":612
- * self.parent.loop.run_callback(_kill, self, exception, waiter)
- * if block:
- * waiter.get() # <<<<<<<<<<<<<<
- * self.join(timeout)
- * # it should be OK to use kill() in finally or kill a greenlet from more than one place;
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_get_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_7) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":613
- * if block:
- * waiter.get()
- * self.join(timeout) # <<<<<<<<<<<<<<
- * # it should be OK to use kill() in finally or kill a greenlet from more than one place;
- * # thus it should not raise when the greenlet is already killed (= not started)
- */
- __pyx_t_8.__pyx_n = 1;
- __pyx_t_8.timeout = __pyx_v_timeout;
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->join(__pyx_v_self, 0, &__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 613, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":611
- * waiter = Waiter() if block else None # pylint:disable=undefined-variable
- * self.parent.loop.run_callback(_kill, self, exception, waiter)
- * if block: # <<<<<<<<<<<<<<
- * waiter.get()
- * self.join(timeout)
- */
- }
- }
- __pyx_L3:;
-
- /* "src/gevent/greenlet.py":565
- * return g
- *
- * def kill(self, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Raise the ``exception`` in the greenlet.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_waiter);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":617
- * # thus it should not raise when the greenlet is already killed (= not started)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * get(block=True, timeout=None) -> object
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_31get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_30get[] = "Greenlet.get(self, block=True, timeout=None)\n\n get(block=True, timeout=None) -> object\n\n Return the result the greenlet has returned or re-raise the\n exception it has raised.\n\n If block is ``False``, raise :class:`gevent.Timeout` if the\n greenlet is still alive. If block is ``True``, unschedule the\n current greenlet until the result is available or the timeout\n expires. In the latter case, :class:`gevent.Timeout` is\n raised.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_31get = {"get", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_31get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_30get};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_31get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 617, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_block = values[0];
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("get", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 617, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_30get(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_30get(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_v_switch = NULL;
- PyObject *__pyx_v_t = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- int __pyx_t_11;
- int __pyx_t_12;
- char const *__pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- PyObject *__pyx_t_21 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
-
- /* "src/gevent/greenlet.py":630
- * raised.
- * """
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self.successful():
- * return self.value
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":631
- * """
- * if self.ready():
- * if self.successful(): # <<<<<<<<<<<<<<
- * return self.value
- * self._raise_exception()
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->successful(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":632
- * if self.ready():
- * if self.successful():
- * return self.value # <<<<<<<<<<<<<<
- * self._raise_exception()
- * if not block:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":631
- * """
- * if self.ready():
- * if self.successful(): # <<<<<<<<<<<<<<
- * return self.value
- * self._raise_exception()
- */
- }
-
- /* "src/gevent/greenlet.py":633
- * if self.successful():
- * return self.value
- * self._raise_exception() # <<<<<<<<<<<<<<
- * if not block:
- * raise Timeout()
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_raise_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":630
- * raised.
- * """
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self.successful():
- * return self.value
- */
- }
-
- /* "src/gevent/greenlet.py":634
- * return self.value
- * self._raise_exception()
- * if not block: # <<<<<<<<<<<<<<
- * raise Timeout()
- *
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 634, __pyx_L1_error)
- __pyx_t_5 = ((!__pyx_t_1) != 0);
- if (unlikely(__pyx_t_5)) {
-
- /* "src/gevent/greenlet.py":635
- * self._raise_exception()
- * if not block:
- * raise Timeout() # <<<<<<<<<<<<<<
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_Timeout);
- __pyx_t_3 = __pyx_v_6gevent_9_greenlet_Timeout; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 635, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 635, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 635, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":634
- * return self.value
- * self._raise_exception()
- * if not block: # <<<<<<<<<<<<<<
- * raise Timeout()
- *
- */
- }
-
- /* "src/gevent/greenlet.py":637
- * raise Timeout()
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.rawlink(switch)
- * try:
- */
- __pyx_t_2 = ((PyObject *)__pyx_f_6gevent_9_greenlet_getcurrent()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_switch = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":638
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch) # <<<<<<<<<<<<<<
- * try:
- * t = Timeout._start_new_or_dummy(timeout)
- */
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 638, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":639
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":640
- * self.rawlink(switch)
- * try:
- * t = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<<
- * try:
- * result = self.parent.switch()
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_9_greenlet_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_timeout);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_t = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":641
- * try:
- * t = Timeout._start_new_or_dummy(timeout)
- * try: # <<<<<<<<<<<<<<
- * result = self.parent.switch()
- * if result is not self:
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":642
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- * result = self.parent.switch() # <<<<<<<<<<<<<<
- * if result is not self:
- * raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, ))
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 642, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_switch); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 642, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 642, __pyx_L13_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 642, __pyx_L13_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_v_result = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":643
- * try:
- * result = self.parent.switch()
- * if result is not self: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, ))
- * finally:
- */
- __pyx_t_5 = (__pyx_v_result != ((PyObject *)__pyx_v_self));
- __pyx_t_1 = (__pyx_t_5 != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/greenlet.py":644
- * result = self.parent.switch()
- * if result is not self:
- * raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, )) # <<<<<<<<<<<<<<
- * finally:
- * t.cancel()
- */
- __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_result);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Greenlet_get, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_InvalidSwitchError);
- __pyx_t_9 = __pyx_v_6gevent_9_greenlet_InvalidSwitchError; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L13_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 644, __pyx_L13_error)
-
- /* "src/gevent/greenlet.py":643
- * try:
- * result = self.parent.switch()
- * if result is not self: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, ))
- * finally:
- */
- }
- }
-
- /* "src/gevent/greenlet.py":646
- * raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, ))
- * finally:
- * t.cancel() # <<<<<<<<<<<<<<
- * except:
- * # unlinking in 'except' instead of finally is an optimization:
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 646, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_10) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L6_error)
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L6_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L14;
- }
- __pyx_L13_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __Pyx_XGOTREF(__pyx_t_18);
- __Pyx_XGOTREF(__pyx_t_19);
- __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
- {
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 646, __pyx_L17_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_10) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L17_error)
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L17_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
- }
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
- goto __pyx_L6_error;
- __pyx_L17_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
- }
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- goto __pyx_L6_error;
- }
- __pyx_L14:;
- }
-
- /* "src/gevent/greenlet.py":639
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L11_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":647
- * finally:
- * t.cancel()
- * except: # <<<<<<<<<<<<<<
- * # unlinking in 'except' instead of finally is an optimization:
- * # if switch occurred normally then link was already removed in _notify_links
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 647, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GOTREF(__pyx_t_10);
-
- /* "src/gevent/greenlet.py":653
- * # Note, however, that if "Invalid switch" assert was removed and invalid switch
- * # did happen, the link would remain, causing another invalid switch later in this greenlet.
- * self.unlink(switch) # <<<<<<<<<<<<<<
- * raise
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_20 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_20)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_20);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_20) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_v_switch};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_v_switch};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_21 = PyTuple_New(1+1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_21);
- __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL;
- __Pyx_INCREF(__pyx_v_switch);
- __Pyx_GIVEREF(__pyx_v_switch);
- PyTuple_SET_ITEM(__pyx_t_21, 0+1, __pyx_v_switch);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_21, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":654
- * # did happen, the link would remain, causing another invalid switch later in this greenlet.
- * self.unlink(switch)
- * raise # <<<<<<<<<<<<<<
- *
- * if self.ready():
- */
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_9, __pyx_t_10);
- __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
- __PYX_ERR(0, 654, __pyx_L8_except_error)
- }
- __pyx_L8_except_error:;
-
- /* "src/gevent/greenlet.py":639
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L11_try_end:;
- }
-
- /* "src/gevent/greenlet.py":656
- * raise
- *
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self.successful():
- * return self.value
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":657
- *
- * if self.ready():
- * if self.successful(): # <<<<<<<<<<<<<<
- * return self.value
- * self._raise_exception()
- */
- __pyx_t_1 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->successful(__pyx_v_self, 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":658
- * if self.ready():
- * if self.successful():
- * return self.value # <<<<<<<<<<<<<<
- * self._raise_exception()
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":657
- *
- * if self.ready():
- * if self.successful(): # <<<<<<<<<<<<<<
- * return self.value
- * self._raise_exception()
- */
- }
-
- /* "src/gevent/greenlet.py":659
- * if self.successful():
- * return self.value
- * self._raise_exception() # <<<<<<<<<<<<<<
- *
- * def join(self, timeout=None):
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_raise_exception); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 659, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-
- /* "src/gevent/greenlet.py":656
- * raise
- *
- * if self.ready(): # <<<<<<<<<<<<<<
- * if self.successful():
- * return self.value
- */
- }
-
- /* "src/gevent/greenlet.py":617
- * # thus it should not raise when the greenlet is already killed (= not started)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * get(block=True, timeout=None) -> object
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_20);
- __Pyx_XDECREF(__pyx_t_21);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_switch);
- __Pyx_XDECREF(__pyx_v_t);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":661
- * self._raise_exception()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * join(timeout=None) -> None
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_33join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet_join(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_switch = NULL;
- PyObject *__pyx_v_t = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_ex = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_t_10;
- int __pyx_t_11;
- int __pyx_t_12;
- char const *__pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- PyObject *__pyx_t_21 = NULL;
- __Pyx_RefNannySetupContext("join", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_join); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_33join)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":668
- * ``None`` regardless.
- * """
- * if self.ready(): # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_6 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/greenlet.py":669
- * """
- * if self.ready():
- * return # <<<<<<<<<<<<<<
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":668
- * ``None`` regardless.
- * """
- * if self.ready(): # <<<<<<<<<<<<<<
- * return
- *
- */
- }
-
- /* "src/gevent/greenlet.py":671
- * return
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.rawlink(switch)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_9_greenlet_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_switch = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":672
- *
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch) # <<<<<<<<<<<<<<
- * try:
- * t = Timeout._start_new_or_dummy(timeout)
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":673
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":674
- * self.rawlink(switch)
- * try:
- * t = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<<
- * try:
- * result = self.parent.switch()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_9_greenlet_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_t = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":675
- * try:
- * t = Timeout._start_new_or_dummy(timeout)
- * try: # <<<<<<<<<<<<<<
- * result = self.parent.switch()
- * if result is not self:
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":676
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- * result = self.parent.switch() # <<<<<<<<<<<<<<
- * if result is not self:
- * raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, ))
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 676, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L11_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L11_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_result = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":677
- * try:
- * result = self.parent.switch()
- * if result is not self: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, ))
- * finally:
- */
- __pyx_t_6 = (__pyx_v_result != ((PyObject *)__pyx_v_self));
- __pyx_t_10 = (__pyx_t_6 != 0);
- if (unlikely(__pyx_t_10)) {
-
- /* "src/gevent/greenlet.py":678
- * result = self.parent.switch()
- * if result is not self:
- * raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, )) # <<<<<<<<<<<<<<
- * finally:
- * t.cancel()
- */
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_result);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Greenlet_joi, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_InvalidSwitchError);
- __pyx_t_5 = __pyx_v_6gevent_9_greenlet_InvalidSwitchError; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 678, __pyx_L11_error)
-
- /* "src/gevent/greenlet.py":677
- * try:
- * result = self.parent.switch()
- * if result is not self: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, ))
- * finally:
- */
- }
- }
-
- /* "src/gevent/greenlet.py":680
- * raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, ))
- * finally:
- * t.cancel() # <<<<<<<<<<<<<<
- * except Timeout as ex:
- * self.unlink(switch)
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 680, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L4_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L4_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- goto __pyx_L12;
- }
- __pyx_L11_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __Pyx_XGOTREF(__pyx_t_18);
- __Pyx_XGOTREF(__pyx_t_19);
- __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
- {
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 680, __pyx_L15_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L15_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L15_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
- }
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
- goto __pyx_L4_error;
- __pyx_L15_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
- }
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- goto __pyx_L4_error;
- }
- __pyx_L12:;
- }
-
- /* "src/gevent/greenlet.py":673
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- }
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L9_try_end;
- __pyx_L4_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":681
- * finally:
- * t.cancel()
- * except Timeout as ex: # <<<<<<<<<<<<<<
- * self.unlink(switch)
- * if ex is not t:
- */
- __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_v_6gevent_9_greenlet_Timeout);
- if (__pyx_t_12) {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 681, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __pyx_v_ex = __pyx_t_5;
-
- /* "src/gevent/greenlet.py":682
- * t.cancel()
- * except Timeout as ex:
- * self.unlink(switch) # <<<<<<<<<<<<<<
- * if ex is not t:
- * raise
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_20 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_20)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_20);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_20) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_v_switch};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_v_switch};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_21 = PyTuple_New(1+1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_21);
- __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL;
- __Pyx_INCREF(__pyx_v_switch);
- __Pyx_GIVEREF(__pyx_v_switch);
- PyTuple_SET_ITEM(__pyx_t_21, 0+1, __pyx_v_switch);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":683
- * except Timeout as ex:
- * self.unlink(switch)
- * if ex is not t: # <<<<<<<<<<<<<<
- * raise
- * except:
- */
- if (unlikely(!__pyx_v_t)) { __Pyx_RaiseUnboundLocalError("t"); __PYX_ERR(0, 683, __pyx_L6_except_error) }
- __pyx_t_10 = (__pyx_v_ex != __pyx_v_t);
- __pyx_t_6 = (__pyx_t_10 != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "src/gevent/greenlet.py":684
- * self.unlink(switch)
- * if ex is not t:
- * raise # <<<<<<<<<<<<<<
- * except:
- * self.unlink(switch)
- */
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_5, __pyx_t_4);
- __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
- __PYX_ERR(0, 684, __pyx_L6_except_error)
-
- /* "src/gevent/greenlet.py":683
- * except Timeout as ex:
- * self.unlink(switch)
- * if ex is not t: # <<<<<<<<<<<<<<
- * raise
- * except:
- */
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L5_exception_handled;
- }
-
- /* "src/gevent/greenlet.py":685
- * if ex is not t:
- * raise
- * except: # <<<<<<<<<<<<<<
- * self.unlink(switch)
- * raise
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 685, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "src/gevent/greenlet.py":686
- * raise
- * except:
- * self.unlink(switch) # <<<<<<<<<<<<<<
- * raise
- *
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_21 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_21)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_21);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_21) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_switch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_v_switch};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_v_switch};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_20 = PyTuple_New(1+1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_20);
- __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_21); __pyx_t_21 = NULL;
- __Pyx_INCREF(__pyx_v_switch);
- __Pyx_GIVEREF(__pyx_v_switch);
- PyTuple_SET_ITEM(__pyx_t_20, 0+1, __pyx_v_switch);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":687
- * except:
- * self.unlink(switch)
- * raise # <<<<<<<<<<<<<<
- *
- * def _report_result(self, result):
- */
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_5, __pyx_t_2);
- __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0;
- __PYX_ERR(0, 687, __pyx_L6_except_error)
- }
- __pyx_L6_except_error:;
-
- /* "src/gevent/greenlet.py":673
- * switch = getcurrent().switch # pylint:disable=undefined-variable
- * self.rawlink(switch)
- * try: # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
- goto __pyx_L1_error;
- __pyx_L5_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
- __pyx_L9_try_end:;
- }
-
- /* "src/gevent/greenlet.py":661
- * self._raise_exception()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * join(timeout=None) -> None
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_20);
- __Pyx_XDECREF(__pyx_t_21);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_switch);
- __Pyx_XDECREF(__pyx_v_t);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_ex);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_33join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_32join[] = "Greenlet.join(self, timeout=None)\n\n join(timeout=None) -> None\n\n Wait until the greenlet finishes or *timeout* expires. Return\n ``None`` regardless.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_33join = {"join", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_33join, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_32join};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_33join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("join (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "join") < 0)) __PYX_ERR(0, 661, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("join", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 661, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_32join(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_32join(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join __pyx_t_2;
- __Pyx_RefNannySetupContext("join", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_9_greenlet_Greenlet->join(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":689
- * raise
- *
- * def _report_result(self, result): # <<<<<<<<<<<<<<
- * self._exc_info = (None, None, None)
- * self.value = result
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__report_result(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_result) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("_report_result", 0);
-
- /* "src/gevent/greenlet.py":690
- *
- * def _report_result(self, result):
- * self._exc_info = (None, None, None) # <<<<<<<<<<<<<<
- * self.value = result
- * if self._links and not self._notifier:
- */
- __Pyx_INCREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = __pyx_tuple__10;
-
- /* "src/gevent/greenlet.py":691
- * def _report_result(self, result):
- * self._exc_info = (None, None, None)
- * self.value = result # <<<<<<<<<<<<<<
- * if self._links and not self._notifier:
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- */
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = __pyx_v_result;
-
- /* "src/gevent/greenlet.py":692
- * self._exc_info = (None, None, None)
- * self.value = result
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- __pyx_t_2 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 692, __pyx_L1_error)
- __pyx_t_3 = ((!__pyx_t_2) != 0);
- __pyx_t_1 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":693
- * self.value = result
- * if self._links and not self._notifier:
- * self._notifier = self.parent.loop.run_callback(self._notify_links) # <<<<<<<<<<<<<<
- *
- * def _report_error(self, exc_info):
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_loop); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":692
- * self._exc_info = (None, None, None)
- * self.value = result
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":689
- * raise
- *
- * def _report_result(self, result): # <<<<<<<<<<<<<<
- * self._exc_info = (None, None, None)
- * self.value = result
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._report_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":695
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def _report_error(self, exc_info): # <<<<<<<<<<<<<<
- * if isinstance(exc_info[1], GreenletExit):
- * self._report_result(exc_info[1])
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__report_error(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_exc_info) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_t_10;
- int __pyx_t_11;
- int __pyx_t_12;
- char const *__pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- __Pyx_RefNannySetupContext("_report_error", 0);
- __Pyx_INCREF(__pyx_v_exc_info);
-
- /* "src/gevent/greenlet.py":696
- *
- * def _report_error(self, exc_info):
- * if isinstance(exc_info[1], GreenletExit): # <<<<<<<<<<<<<<
- * self._report_result(exc_info[1])
- * return
- */
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 696, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_v_6gevent_9_greenlet_GreenletExit;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_3 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 696, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/greenlet.py":697
- * def _report_error(self, exc_info):
- * if isinstance(exc_info[1], GreenletExit):
- * self._report_result(exc_info[1]) # <<<<<<<<<<<<<<
- * return
- *
- */
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 697, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_report_result(__pyx_v_self, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":698
- * if isinstance(exc_info[1], GreenletExit):
- * self._report_result(exc_info[1])
- * return # <<<<<<<<<<<<<<
- *
- * self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2])
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":696
- *
- * def _report_error(self, exc_info):
- * if isinstance(exc_info[1], GreenletExit): # <<<<<<<<<<<<<<
- * self._report_result(exc_info[1])
- * return
- */
- }
-
- /* "src/gevent/greenlet.py":700
- * return
- *
- * self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2]) # <<<<<<<<<<<<<<
- *
- * if self._links and not self._notifier:
- */
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 700, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_exc_info, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 700, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_exc_info, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 700, __pyx_L1_error)
- }
- __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v_exc_info, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_dump_traceback);
- __pyx_t_7 = __pyx_v_6gevent_9_greenlet_dump_traceback; __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
- __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
- __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 700, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_v_self->_exc_info);
- __Pyx_DECREF(__pyx_v_self->_exc_info);
- __pyx_v_self->_exc_info = ((PyObject*)__pyx_t_7);
- __pyx_t_7 = 0;
-
- /* "src/gevent/greenlet.py":702
- * self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2])
- *
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- __pyx_t_3 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_4 = __pyx_t_3;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 702, __pyx_L1_error)
- __pyx_t_10 = ((!__pyx_t_3) != 0);
- __pyx_t_4 = __pyx_t_10;
- __pyx_L5_bool_binop_done:;
- if (__pyx_t_4) {
-
- /* "src/gevent/greenlet.py":703
- *
- * if self._links and not self._notifier:
- * self._notifier = self.parent.loop.run_callback(self._notify_links) # <<<<<<<<<<<<<<
- *
- * try:
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_loop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_1) {
- __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
- __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
- __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = __pyx_t_7;
- __pyx_t_7 = 0;
-
- /* "src/gevent/greenlet.py":702
- * self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2])
- *
- * if self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":705
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * try: # <<<<<<<<<<<<<<
- * self.parent.handle_error(self, *exc_info)
- * finally:
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":706
- *
- * try:
- * self.parent.handle_error(self, *exc_info) # <<<<<<<<<<<<<<
- * finally:
- * del exc_info
- */
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 706, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 706, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
- if (unlikely(__pyx_v_exc_info == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 706, __pyx_L8_error)
- }
- __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_v_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 706, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 706, __pyx_L8_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
-
- /* "src/gevent/greenlet.py":708
- * self.parent.handle_error(self, *exc_info)
- * finally:
- * del exc_info # <<<<<<<<<<<<<<
- *
- * def run(self):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __Pyx_DECREF(__pyx_v_exc_info);
- __pyx_v_exc_info = NULL;
- goto __pyx_L9;
- }
- __pyx_L8_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __Pyx_XGOTREF(__pyx_t_18);
- __Pyx_XGOTREF(__pyx_t_19);
- __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
- {
- __Pyx_DECREF(__pyx_v_exc_info);
- __pyx_v_exc_info = NULL;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
- }
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
- goto __pyx_L1_error;
- }
- __pyx_L9:;
- }
-
- /* "src/gevent/greenlet.py":695
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def _report_error(self, exc_info): # <<<<<<<<<<<<<<
- * if isinstance(exc_info[1], GreenletExit):
- * self._report_result(exc_info[1])
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._report_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_exc_info);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":710
- * del exc_info
- *
- * def run(self): # <<<<<<<<<<<<<<
- * try:
- * self.__cancel_start()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_35run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_34run[] = "Greenlet.run(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_35run = {"run", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_35run, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_34run};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_35run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("run (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_34run(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_34run(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_t_10;
- int __pyx_t_11;
- int __pyx_t_12;
- char const *__pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- __Pyx_RefNannySetupContext("run", 0);
-
- /* "src/gevent/greenlet.py":711
- *
- * def run(self):
- * try: # <<<<<<<<<<<<<<
- * self.__cancel_start()
- * self._start_event = _start_completed_event
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":712
- * def run(self):
- * try:
- * self.__cancel_start() # <<<<<<<<<<<<<<
- * self._start_event = _start_completed_event
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->__pyx___cancel_start(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":713
- * try:
- * self.__cancel_start()
- * self._start_event = _start_completed_event # <<<<<<<<<<<<<<
- *
- * try:
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_6gevent_9_greenlet__start_completed_event));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_6gevent_9_greenlet__start_completed_event));
- __Pyx_GOTREF(__pyx_v_self->_start_event);
- __Pyx_DECREF(__pyx_v_self->_start_event);
- __pyx_v_self->_start_event = ((PyObject *)__pyx_v_6gevent_9_greenlet__start_completed_event);
-
- /* "src/gevent/greenlet.py":715
- * self._start_event = _start_completed_event
- *
- * try: # <<<<<<<<<<<<<<
- * result = self._run(*self.args, **self.kwargs)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":716
- *
- * try:
- * result = self._run(*self.args, **self.kwargs) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * self._report_error(sys_exc_info())
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_run_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(__pyx_v_self->args == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 716, __pyx_L6_error)
- }
- if (unlikely(__pyx_v_self->kwargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
- __PYX_ERR(0, 716, __pyx_L6_error)
- }
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_self->args, __pyx_v_self->kwargs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 716, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_result = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "src/gevent/greenlet.py":715
- * self._start_event = _start_completed_event
- *
- * try: # <<<<<<<<<<<<<<
- * result = self._run(*self.args, **self.kwargs)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L11_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/greenlet.py":717
- * try:
- * result = self._run(*self.args, **self.kwargs)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * self._report_error(sys_exc_info())
- * return
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 717, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_6);
-
- /* "src/gevent/greenlet.py":718
- * result = self._run(*self.args, **self.kwargs)
- * except: # pylint:disable=bare-except
- * self._report_error(sys_exc_info()) # <<<<<<<<<<<<<<
- * return
- * self._report_result(result)
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __pyx_t_8 = __pyx_v_6gevent_9_greenlet_sys_exc_info; __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- if (__pyx_t_9) {
- __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 718, __pyx_L8_except_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 718, __pyx_L8_except_error)
- }
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (!(likely(PyTuple_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 718, __pyx_L8_except_error)
- __pyx_t_8 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_report_error(__pyx_v_self, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 718, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "src/gevent/greenlet.py":719
- * except: # pylint:disable=bare-except
- * self._report_error(sys_exc_info())
- * return # <<<<<<<<<<<<<<
- * self._report_result(result)
- * finally:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L9_except_return;
- }
- __pyx_L8_except_error:;
-
- /* "src/gevent/greenlet.py":715
- * self._start_event = _start_completed_event
- *
- * try: # <<<<<<<<<<<<<<
- * result = self._run(*self.args, **self.kwargs)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- goto __pyx_L4_error;
- __pyx_L9_except_return:;
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- goto __pyx_L3_return;
- __pyx_L11_try_end:;
- }
-
- /* "src/gevent/greenlet.py":720
- * self._report_error(sys_exc_info())
- * return
- * self._report_result(result) # <<<<<<<<<<<<<<
- * finally:
- * self.__dict__.pop('_run', None)
- */
- __pyx_t_6 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->_report_result(__pyx_v_self, __pyx_v_result); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 720, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
-
- /* "src/gevent/greenlet.py":722
- * self._report_result(result)
- * finally:
- * self.__dict__.pop('_run', None) # <<<<<<<<<<<<<<
- * self.args = ()
- * self.kwargs.clear()
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":723
- * finally:
- * self.__dict__.pop('_run', None)
- * self.args = () # <<<<<<<<<<<<<<
- * self.kwargs.clear()
- *
- */
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_empty_tuple;
-
- /* "src/gevent/greenlet.py":724
- * self.__dict__.pop('_run', None)
- * self.args = ()
- * self.kwargs.clear() # <<<<<<<<<<<<<<
- *
- * def _run(self):
- */
- if (unlikely(__pyx_v_self->kwargs == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
- __PYX_ERR(0, 724, __pyx_L1_error)
- }
- __pyx_t_10 = __Pyx_PyDict_Clear(__pyx_v_self->kwargs); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 724, __pyx_L1_error)
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0)) __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
- {
-
- /* "src/gevent/greenlet.py":722
- * self._report_result(result)
- * finally:
- * self.__dict__.pop('_run', None) # <<<<<<<<<<<<<<
- * self.args = ()
- * self.kwargs.clear()
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L15_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L15_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L15_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":723
- * finally:
- * self.__dict__.pop('_run', None)
- * self.args = () # <<<<<<<<<<<<<<
- * self.kwargs.clear()
- *
- */
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_empty_tuple;
-
- /* "src/gevent/greenlet.py":724
- * self.__dict__.pop('_run', None)
- * self.args = ()
- * self.kwargs.clear() # <<<<<<<<<<<<<<
- *
- * def _run(self):
- */
- if (unlikely(__pyx_v_self->kwargs == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
- __PYX_ERR(0, 724, __pyx_L15_error)
- }
- __pyx_t_10 = __Pyx_PyDict_Clear(__pyx_v_self->kwargs); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 724, __pyx_L15_error)
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_ErrRestore(__pyx_t_4, __pyx_t_3, __pyx_t_2);
- __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
- goto __pyx_L1_error;
- __pyx_L15_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L3_return: {
- __pyx_t_16 = __pyx_r;
- __pyx_r = 0;
-
- /* "src/gevent/greenlet.py":722
- * self._report_result(result)
- * finally:
- * self.__dict__.pop('_run', None) # <<<<<<<<<<<<<<
- * self.args = ()
- * self.kwargs.clear()
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/greenlet.py":723
- * finally:
- * self.__dict__.pop('_run', None)
- * self.args = () # <<<<<<<<<<<<<<
- * self.kwargs.clear()
- *
- */
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_empty_tuple;
-
- /* "src/gevent/greenlet.py":724
- * self.__dict__.pop('_run', None)
- * self.args = ()
- * self.kwargs.clear() # <<<<<<<<<<<<<<
- *
- * def _run(self):
- */
- if (unlikely(__pyx_v_self->kwargs == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
- __PYX_ERR(0, 724, __pyx_L1_error)
- }
- __pyx_t_10 = __Pyx_PyDict_Clear(__pyx_v_self->kwargs); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 724, __pyx_L1_error)
- __pyx_r = __pyx_t_16;
- __pyx_t_16 = 0;
- goto __pyx_L0;
- }
- __pyx_L5:;
- }
-
- /* "src/gevent/greenlet.py":710
- * del exc_info
- *
- * def run(self): # <<<<<<<<<<<<<<
- * try:
- * self.__cancel_start()
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":726
- * self.kwargs.clear()
- *
- * def _run(self): # <<<<<<<<<<<<<<
- * """
- * Subclasses may override this method to take any number of
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_37_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_36_run[] = "Greenlet._run(self)\n\n Subclasses may override this method to take any number of\n arguments and keyword arguments.\n\n .. versionadded:: 1.1a3\n Previously, if no callable object was\n passed to the constructor, the spawned greenlet would later\n fail with an AttributeError.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_37_run = {"_run", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_37_run, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_36_run};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_37_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_run (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_36_run(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_36_run(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_run", 0);
-
- /* "src/gevent/greenlet.py":738
- * # We usually override this in __init__
- * # pylint: disable=method-hidden
- * return # <<<<<<<<<<<<<<
- *
- * def has_links(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":726
- * self.kwargs.clear()
- *
- * def _run(self): # <<<<<<<<<<<<<<
- * """
- * Subclasses may override this method to take any number of
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":740
- * return
- *
- * def has_links(self): # <<<<<<<<<<<<<<
- * return len(self._links)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_39has_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_9_greenlet_8Greenlet_has_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- Py_ssize_t __pyx_t_6;
- __Pyx_RefNannySetupContext("has_links", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_39has_links)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":741
- *
- * def has_links(self):
- * return len(self._links) # <<<<<<<<<<<<<<
- *
- * def rawlink(self, callback):
- */
- __pyx_t_1 = __pyx_v_self->_links;
- __Pyx_INCREF(__pyx_t_1);
- if (unlikely(__pyx_t_1 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 741, __pyx_L1_error)
- }
- __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 741, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_6;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":740
- * return
- *
- * def has_links(self): # <<<<<<<<<<<<<<
- * return len(self._links)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._greenlet.Greenlet.has_links", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_39has_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_38has_links[] = "Greenlet.has_links(self) -> bool";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_39has_links = {"has_links", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_39has_links, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_38has_links};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_39has_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("has_links (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_38has_links(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_38has_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("has_links", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_9_greenlet_8Greenlet_has_links(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.has_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":743
- * return len(self._links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callable to be executed when the greenlet finishes
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_41rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet_rawlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("rawlink", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_41rawlink)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":753
- * .. caution:: The callable will be called in the HUB greenlet.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.append(callback) # pylint:disable=no-member
- */
- __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 753, __pyx_L1_error)
- __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/greenlet.py":754
- * """
- * if not callable(callback):
- * raise TypeError('Expected callable: %r' % (callback, )) # <<<<<<<<<<<<<<
- * self._links.append(callback) # pylint:disable=no-member
- * if self.ready() and self._links and not self._notifier:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 754, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":753
- * .. caution:: The callable will be called in the HUB greenlet.
- * """
- * if not callable(callback): # <<<<<<<<<<<<<<
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.append(callback) # pylint:disable=no-member
- */
- }
-
- /* "src/gevent/greenlet.py":755
- * if not callable(callback):
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.append(callback) # pylint:disable=no-member # <<<<<<<<<<<<<<
- * if self.ready() and self._links and not self._notifier:
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
- __PYX_ERR(0, 755, __pyx_L1_error)
- }
- __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 755, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":756
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.append(callback) # pylint:disable=no-member
- * if self.ready() and self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- __pyx_t_6 = (((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_7 = __pyx_t_6;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_6 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_7 = __pyx_t_6;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 756, __pyx_L1_error)
- __pyx_t_9 = ((!__pyx_t_6) != 0);
- __pyx_t_7 = __pyx_t_9;
- __pyx_L5_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "src/gevent/greenlet.py":757
- * self._links.append(callback) # pylint:disable=no-member
- * if self.ready() and self._links and not self._notifier:
- * self._notifier = self.parent.loop.run_callback(self._notify_links) # <<<<<<<<<<<<<<
- *
- * def link(self, callback, SpawnedLink=SpawnedLink):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_notifier);
- __Pyx_DECREF(__pyx_v_self->_notifier);
- __pyx_v_self->_notifier = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":756
- * raise TypeError('Expected callable: %r' % (callback, ))
- * self._links.append(callback) # pylint:disable=no-member
- * if self.ready() and self._links and not self._notifier: # <<<<<<<<<<<<<<
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":743
- * return len(self._links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callable to be executed when the greenlet finishes
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_41rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_40rawlink[] = "Greenlet.rawlink(self, callback)\n\n Register a callable to be executed when the greenlet finishes\n execution.\n\n The *callback* will be called with this instance as an\n argument.\n\n .. caution:: The callable will be called in the HUB greenlet.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_41rawlink = {"rawlink", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_41rawlink, METH_O, __pyx_doc_6gevent_9_greenlet_8Greenlet_40rawlink};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_41rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("rawlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_40rawlink(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_40rawlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("rawlink", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_8Greenlet_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":759
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def link(self, callback, SpawnedLink=SpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Link greenlet's completion to a callable.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_43link(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_42link[] = "Greenlet.link(self, callback, SpawnedLink=SpawnedLink)\n\n Link greenlet's completion to a callable.\n\n The *callback* will be called with this instance as an\n argument once this greenlet is dead. A callable is called in\n its own :class:`greenlet.greenlet` (*not* a\n :class:`Greenlet`).\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_43link = {"link", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_43link, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_42link};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_43link(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_SpawnedLink = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("link (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_SpawnedLink,0};
- PyObject* values[2] = {0,0};
- values[1] = __pyx_k__14;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_SpawnedLink);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "link") < 0)) __PYX_ERR(0, 759, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_callback = values[0];
- __pyx_v_SpawnedLink = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("link", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 759, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_42link(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_callback, __pyx_v_SpawnedLink);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_42link(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("link", 0);
-
- /* "src/gevent/greenlet.py":771
- * # optimization, or do people use it? It's not documented
- * # pylint:disable=redefined-outer-name
- * self.rawlink(SpawnedLink(callback)) # <<<<<<<<<<<<<<
- *
- * def unlink(self, callback):
- */
- __Pyx_INCREF(__pyx_v_SpawnedLink);
- __pyx_t_2 = __pyx_v_SpawnedLink; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_callback);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":759
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def link(self, callback, SpawnedLink=SpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Link greenlet's completion to a callable.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":773
- * self.rawlink(SpawnedLink(callback))
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_45unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_44unlink[] = "Greenlet.unlink(self, callback)\nRemove the callback set by :meth:`link` or :meth:`rawlink`";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_45unlink = {"unlink", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_45unlink, METH_O, __pyx_doc_6gevent_9_greenlet_8Greenlet_44unlink};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_45unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unlink (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_44unlink(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_44unlink(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("unlink", 0);
-
- /* "src/gevent/greenlet.py":775
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback) # pylint:disable=no-member
- * except ValueError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":776
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try:
- * self._links.remove(callback) # pylint:disable=no-member # <<<<<<<<<<<<<<
- * except ValueError:
- * pass
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_links, __pyx_n_s_remove); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_callback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_callback};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_callback};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_callback);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":775
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback) # pylint:disable=no-member
- * except ValueError:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":777
- * try:
- * self._links.remove(callback) # pylint:disable=no-member
- * except ValueError: # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
- if (__pyx_t_8) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/greenlet.py":775
- * def unlink(self, callback):
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try: # <<<<<<<<<<<<<<
- * self._links.remove(callback) # pylint:disable=no-member
- * except ValueError:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/greenlet.py":773
- * self.rawlink(SpawnedLink(callback))
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":780
- * pass
- *
- * def unlink_all(self): # <<<<<<<<<<<<<<
- * """
- * Remove all the callbacks.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_47unlink_all(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_46unlink_all[] = "Greenlet.unlink_all(self)\n\n Remove all the callbacks.\n\n .. versionadded:: 1.3a2\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_47unlink_all = {"unlink_all", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_47unlink_all, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_46unlink_all};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_47unlink_all(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unlink_all (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_46unlink_all(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_46unlink_all(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unlink_all", 0);
-
- /* "src/gevent/greenlet.py":786
- * .. versionadded:: 1.3a2
- * """
- * del self._links[:] # <<<<<<<<<<<<<<
- *
- * def link_value(self, callback, SpawnedLink=SuccessSpawnedLink):
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 786, __pyx_L1_error)
- }
- if (__Pyx_PyObject_DelSlice(__pyx_v_self->_links, 0, 0, NULL, NULL, NULL, 0, 0, 1) < 0) __PYX_ERR(0, 786, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":780
- * pass
- *
- * def unlink_all(self): # <<<<<<<<<<<<<<
- * """
- * Remove all the callbacks.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.unlink_all", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":788
- * del self._links[:]
- *
- * def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the greenlet
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_49link_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_48link_value[] = "Greenlet.link_value(self, callback, SpawnedLink=SuccessSpawnedLink)\n\n Like :meth:`link` but *callback* is only notified when the greenlet\n has completed successfully.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_49link_value = {"link_value", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_49link_value, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_48link_value};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_49link_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_SpawnedLink = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("link_value (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_SpawnedLink,0};
- PyObject* values[2] = {0,0};
- values[1] = __pyx_k__15;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_SpawnedLink);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "link_value") < 0)) __PYX_ERR(0, 788, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_callback = values[0];
- __pyx_v_SpawnedLink = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("link_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 788, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_48link_value(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_callback, __pyx_v_SpawnedLink);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_48link_value(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("link_value", 0);
-
- /* "src/gevent/greenlet.py":794
- * """
- * # pylint:disable=redefined-outer-name
- * self.link(callback, SpawnedLink=SpawnedLink) # <<<<<<<<<<<<<<
- *
- * def link_exception(self, callback, SpawnedLink=FailureSpawnedLink):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_link); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 794, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback);
- __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 794, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_SpawnedLink, __pyx_v_SpawnedLink) < 0) __PYX_ERR(0, 794, __pyx_L1_error)
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":788
- * del self._links[:]
- *
- * def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the greenlet
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":796
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_51link_exception(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_50link_exception[] = "Greenlet.link_exception(self, callback, SpawnedLink=FailureSpawnedLink)\n\n Like :meth:`link` but *callback* is only notified when the\n greenlet dies because of an unhandled exception.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_51link_exception = {"link_exception", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_51link_exception, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_50link_exception};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_51link_exception(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_SpawnedLink = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("link_exception (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_SpawnedLink,0};
- PyObject* values[2] = {0,0};
- values[1] = __pyx_k__16;
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_SpawnedLink);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "link_exception") < 0)) __PYX_ERR(0, 796, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_callback = values[0];
- __pyx_v_SpawnedLink = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("link_exception", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 796, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_50link_exception(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), __pyx_v_callback, __pyx_v_SpawnedLink);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_50link_exception(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_SpawnedLink) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("link_exception", 0);
-
- /* "src/gevent/greenlet.py":802
- * """
- * # pylint:disable=redefined-outer-name
- * self.link(callback, SpawnedLink=SpawnedLink) # <<<<<<<<<<<<<<
- *
- * def _notify_links(self):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_link); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback);
- __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 802, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_SpawnedLink, __pyx_v_SpawnedLink) < 0) __PYX_ERR(0, 802, __pyx_L1_error)
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":796
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.link_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":804
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * while self._links:
- * # Early links are allowed to remove later links
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_53_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_8Greenlet__notify_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_link = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_53_notify_links)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/greenlet.py":805
- *
- * def _notify_links(self):
- * while self._links: # <<<<<<<<<<<<<<
- * # Early links are allowed to remove later links
- * # before we get to them, and they're also allowed to
- */
- while (1) {
- __pyx_t_5 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0);
- if (!__pyx_t_5) break;
-
- /* "src/gevent/greenlet.py":813
- * # manipulating it should be small. a deque is probably not justified.
- * # Cython has optimizations to transform this into a memmove anyway.
- * link = self._links.pop(0) # <<<<<<<<<<<<<<
- * try:
- * link(self)
- */
- if (unlikely(__pyx_v_self->_links == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
- __PYX_ERR(0, 813, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyList_PopIndex(__pyx_v_self->_links, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":814
- * # Cython has optimizations to transform this into a memmove anyway.
- * link = self._links.pop(0)
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":815
- * link = self._links.pop(0)
- * try:
- * link(self) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * self.parent.handle_error((link, self), *sys_exc_info())
- */
- __Pyx_INCREF(__pyx_v_link);
- __pyx_t_2 = __pyx_v_link; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L5_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L5_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 815, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":814
- * # Cython has optimizations to transform this into a memmove anyway.
- * link = self._links.pop(0)
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L12_try_end;
- __pyx_L5_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":816
- * try:
- * link(self)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * self.parent.handle_error((link, self), *sys_exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 816, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "src/gevent/greenlet.py":817
- * link(self)
- * except: # pylint:disable=bare-except
- * self.parent.handle_error((link, self), *sys_exc_info()) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_link);
- __Pyx_GIVEREF(__pyx_v_link);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_link);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
- __pyx_t_3 = 0;
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __pyx_t_11 = __pyx_v_6gevent_9_greenlet_sys_exc_info; __pyx_t_12 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
- __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
- if (likely(__pyx_t_12)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
- __Pyx_INCREF(__pyx_t_12);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_11, function);
- }
- }
- if (__pyx_t_12) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_Add(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 817, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L6_exception_handled;
- }
- __pyx_L7_except_error:;
-
- /* "src/gevent/greenlet.py":814
- * # Cython has optimizations to transform this into a memmove anyway.
- * link = self._links.pop(0)
- * try: # <<<<<<<<<<<<<<
- * link(self)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L6_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L12_try_end:;
- }
- }
-
- /* "src/gevent/greenlet.py":804
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * while self._links:
- * # Early links are allowed to remove later links
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_link);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_53_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_8Greenlet_52_notify_links[] = "Greenlet._notify_links(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_8Greenlet_53_notify_links = {"_notify_links", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_53_notify_links, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_52_notify_links};
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_53_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_52_notify_links(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_52_notify_links(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_notify_links", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_8Greenlet__notify_links(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":87
- *
- * cdef class Greenlet(greenlet):
- * cdef readonly object value # <<<<<<<<<<<<<<
- * cdef readonly tuple args
- * cdef readonly dict kwargs
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_5value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_5value___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_5value___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":88
- * cdef class Greenlet(greenlet):
- * cdef readonly object value
- * cdef readonly tuple args # <<<<<<<<<<<<<<
- * cdef readonly dict kwargs
- * cdef readonly object spawning_greenlet
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4args_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_4args_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_4args___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_4args___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->args);
- __pyx_r = __pyx_v_self->args;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":89
- * cdef readonly object value
- * cdef readonly tuple args
- * cdef readonly dict kwargs # <<<<<<<<<<<<<<
- * cdef readonly object spawning_greenlet
- * cdef public dict spawn_tree_locals
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_6kwargs_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_6kwargs_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_6kwargs___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_6kwargs___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->kwargs);
- __pyx_r = __pyx_v_self->kwargs;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":90
- * cdef readonly tuple args
- * cdef readonly dict kwargs
- * cdef readonly object spawning_greenlet # <<<<<<<<<<<<<<
- * cdef public dict spawn_tree_locals
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17spawning_greenlet_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17spawning_greenlet_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawning_greenlet___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_17spawning_greenlet___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->spawning_greenlet);
- __pyx_r = __pyx_v_self->spawning_greenlet;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":91
- * cdef readonly dict kwargs
- * cdef readonly object spawning_greenlet
- * cdef public dict spawn_tree_locals # <<<<<<<<<<<<<<
- *
- * # This is accessed with getattr() dynamically so it
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->spawn_tree_locals);
- __pyx_r = __pyx_v_self->spawn_tree_locals;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_2__set__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_2__set__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(1, 91, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->spawn_tree_locals);
- __Pyx_DECREF(__pyx_v_self->spawn_tree_locals);
- __pyx_v_self->spawn_tree_locals = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.Greenlet.spawn_tree_locals.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_4__del__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_4__del__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->spawn_tree_locals);
- __Pyx_DECREF(__pyx_v_self->spawn_tree_locals);
- __pyx_v_self->spawn_tree_locals = ((PyObject*)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":95
- * # This is accessed with getattr() dynamically so it
- * # must be visible to Python
- * cdef readonly list _spawning_stack_frames # <<<<<<<<<<<<<<
- *
- * cdef list _links
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames___get__(((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames___get__(struct __pyx_obj_6gevent_9_greenlet_Greenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_spawning_stack_frames);
- __pyx_r = __pyx_v_self->_spawning_stack_frames;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":823
- * __slots__ = ('pending', 'active')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * self.pending = self.active = False
- *
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_9_greenlet_12_dummy_event_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_9_greenlet_12_dummy_event_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event___init__(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_9_greenlet_12_dummy_event___init__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/greenlet.py":824
- *
- * def __init__(self):
- * self.pending = self.active = False # <<<<<<<<<<<<<<
- *
- * def stop(self):
- */
- __pyx_v_self->pending = 0;
- __pyx_v_self->active = 0;
-
- /* "src/gevent/greenlet.py":823
- * __slots__ = ('pending', 'active')
- *
- * def __init__(self): # <<<<<<<<<<<<<<
- * self.pending = self.active = False
- *
- */
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":826
- * self.pending = self.active = False
- *
- * def stop(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_stop(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stop", 0);
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_12_dummy_event_2stop[] = "_dummy_event.stop(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_12_dummy_event_3stop = {"stop", (PyCFunction)__pyx_pw_6gevent_9_greenlet_12_dummy_event_3stop, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_12_dummy_event_2stop};
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stop (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event_2stop(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_2stop(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("stop", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_12_dummy_event_stop(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":829
- * pass
- *
- * def start(self, cb): # pylint:disable=unused-argument # <<<<<<<<<<<<<<
- * raise AssertionError("Cannot start the dummy event")
- *
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_5start(PyObject *__pyx_v_self, PyObject *__pyx_v_cb); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_start(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_cb, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("start", 0);
-
- /* "src/gevent/greenlet.py":830
- *
- * def start(self, cb): # pylint:disable=unused-argument
- * raise AssertionError("Cannot start the dummy event") # <<<<<<<<<<<<<<
- *
- * def close(self):
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 830, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":829
- * pass
- *
- * def start(self, cb): # pylint:disable=unused-argument # <<<<<<<<<<<<<<
- * raise AssertionError("Cannot start the dummy event")
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_5start(PyObject *__pyx_v_self, PyObject *__pyx_v_cb); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_12_dummy_event_4start[] = "_dummy_event.start(self, cb)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_12_dummy_event_5start = {"start", (PyCFunction)__pyx_pw_6gevent_9_greenlet_12_dummy_event_5start, METH_O, __pyx_doc_6gevent_9_greenlet_12_dummy_event_4start};
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_5start(PyObject *__pyx_v_self, PyObject *__pyx_v_cb) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event_4start(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self), ((PyObject *)__pyx_v_cb));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_4start(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, PyObject *__pyx_v_cb) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("start", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_12_dummy_event_start(__pyx_v_self, __pyx_v_cb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":832
- * raise AssertionError("Cannot start the dummy event")
- *
- * def close(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_12_dummy_event_close(CYTHON_UNUSED struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("close", 0);
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_12_dummy_event_6close[] = "_dummy_event.close(self)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_12_dummy_event_7close = {"close", (PyCFunction)__pyx_pw_6gevent_9_greenlet_12_dummy_event_7close, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_12_dummy_event_6close};
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("close (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event_6close(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_6close(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("close", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_12_dummy_event_close(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":158
- * @cython.internal
- * cdef class _dummy_event:
- * cdef readonly bint pending # <<<<<<<<<<<<<<
- * cdef readonly bint active
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_7pending_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event_7pending___get__(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_7pending___get__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->pending); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":159
- * cdef class _dummy_event:
- * cdef readonly bint pending
- * cdef readonly bint active # <<<<<<<<<<<<<<
- *
- * cpdef stop(self)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_6active_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_9_greenlet_12_dummy_event_6active_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_9_greenlet_12_dummy_event_6active___get__(((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_12_dummy_event_6active___get__(struct __pyx_obj_6gevent_9_greenlet__dummy_event *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->active); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet._dummy_event.active.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":839
- *
- *
- * def _kill(glet, exception, waiter): # <<<<<<<<<<<<<<
- * try:
- * glet.throw(exception)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_1_kill(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet__kill[] = "_kill(glet, exception, waiter)";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_1_kill = {"_kill", (PyCFunction)__pyx_pw_6gevent_9_greenlet_1_kill, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet__kill};
-static PyObject *__pyx_pw_6gevent_9_greenlet_1_kill(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_glet = 0;
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_v_waiter = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_kill (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_glet,&__pyx_n_s_exception,&__pyx_n_s_waiter,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_glet)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_kill", 1, 3, 3, 1); __PYX_ERR(0, 839, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_waiter)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_kill", 1, 3, 3, 2); __PYX_ERR(0, 839, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_kill") < 0)) __PYX_ERR(0, 839, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_glet = values[0];
- __pyx_v_exception = values[1];
- __pyx_v_waiter = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_kill", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 839, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet._kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet__kill(__pyx_self, __pyx_v_glet, __pyx_v_exception, __pyx_v_waiter);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet__kill(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_glet, PyObject *__pyx_v_exception, PyObject *__pyx_v_waiter) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- int __pyx_t_12;
- int __pyx_t_13;
- __Pyx_RefNannySetupContext("_kill", 0);
-
- /* "src/gevent/greenlet.py":840
- *
- * def _kill(glet, exception, waiter):
- * try: # <<<<<<<<<<<<<<
- * glet.throw(exception)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":841
- * def _kill(glet, exception, waiter):
- * try:
- * glet.throw(exception) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * # XXX do we need this here?
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_throw); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exception};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_exception};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_exception);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":840
- *
- * def _kill(glet, exception, waiter):
- * try: # <<<<<<<<<<<<<<
- * glet.throw(exception)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":842
- * try:
- * glet.throw(exception)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * # XXX do we need this here?
- * glet.parent.handle_error(glet, *sys_exc_info())
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet._kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 842, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "src/gevent/greenlet.py":844
- * except: # pylint:disable=bare-except
- * # XXX do we need this here?
- * glet.parent.handle_error(glet, *sys_exc_info()) # <<<<<<<<<<<<<<
- * if waiter is not None:
- * waiter.switch(None)
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_parent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_v_glet);
- __Pyx_GIVEREF(__pyx_v_glet);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_glet);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __pyx_t_10 = __pyx_v_6gevent_9_greenlet_sys_exc_info; __pyx_t_11 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_10, function);
- }
- }
- if (__pyx_t_11) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else {
- __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- }
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = __Pyx_PySequence_Tuple(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = PyNumber_Add(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 844, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L4_exception_handled;
- }
- __pyx_L5_except_error:;
-
- /* "src/gevent/greenlet.py":840
- *
- * def _kill(glet, exception, waiter):
- * try: # <<<<<<<<<<<<<<
- * glet.throw(exception)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/greenlet.py":845
- * # XXX do we need this here?
- * glet.parent.handle_error(glet, *sys_exc_info())
- * if waiter is not None: # <<<<<<<<<<<<<<
- * waiter.switch(None)
- *
- */
- __pyx_t_12 = (__pyx_v_waiter != Py_None);
- __pyx_t_13 = (__pyx_t_12 != 0);
- if (__pyx_t_13) {
-
- /* "src/gevent/greenlet.py":846
- * glet.parent.handle_error(glet, *sys_exc_info())
- * if waiter is not None:
- * waiter.switch(None) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_switch); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 846, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 846, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/greenlet.py":845
- * # XXX do we need this here?
- * glet.parent.handle_error(glet, *sys_exc_info())
- * if waiter is not None: # <<<<<<<<<<<<<<
- * waiter.switch(None)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":839
- *
- *
- * def _kill(glet, exception, waiter): # <<<<<<<<<<<<<<
- * try:
- * glet.throw(exception)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_AddTraceback("gevent._greenlet._kill", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":849
- *
- *
- * def joinall(greenlets, timeout=None, raise_error=False, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for the ``greenlets`` to finish.
- */
-
-static PyObject *__pyx_pw_6gevent_9_greenlet_3joinall(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_9_greenlet_joinall(PyObject *__pyx_v_greenlets, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_joinall *__pyx_optional_args) {
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_raise_error = ((PyObject *)Py_False);
- PyObject *__pyx_v_count = ((PyObject *)Py_None);
- PyObject *__pyx_v_done = 0;
- PyObject *__pyx_v_obj = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- Py_ssize_t __pyx_t_6;
- PyObject *(*__pyx_t_7)(PyObject *);
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("joinall", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_raise_error = __pyx_optional_args->raise_error;
- if (__pyx_optional_args->__pyx_n > 2) {
- __pyx_v_count = __pyx_optional_args->count;
- }
- }
- }
- }
-
- /* "src/gevent/greenlet.py":858
- * expired.
- * """
- * if not raise_error: # <<<<<<<<<<<<<<
- * return wait(greenlets, timeout=timeout, count=count)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_raise_error); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 858, __pyx_L1_error)
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/greenlet.py":859
- * """
- * if not raise_error:
- * return wait(greenlets, timeout=timeout, count=count) # <<<<<<<<<<<<<<
- *
- * done = []
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 859, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_greenlets);
- __Pyx_GIVEREF(__pyx_v_greenlets);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_greenlets);
- __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 859, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 859, __pyx_L1_error)
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_count, __pyx_v_count) < 0) __PYX_ERR(0, 859, __pyx_L1_error)
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_6gevent_9_greenlet_wait, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 859, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":858
- * expired.
- * """
- * if not raise_error: # <<<<<<<<<<<<<<
- * return wait(greenlets, timeout=timeout, count=count)
- *
- */
- }
-
- /* "src/gevent/greenlet.py":861
- * return wait(greenlets, timeout=timeout, count=count)
- *
- * done = [] # <<<<<<<<<<<<<<
- * for obj in iwait(greenlets, timeout=timeout, count=count):
- * if getattr(obj, 'exception', None) is not None:
- */
- __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 861, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_v_done = ((PyObject*)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/greenlet.py":862
- *
- * done = []
- * for obj in iwait(greenlets, timeout=timeout, count=count): # <<<<<<<<<<<<<<
- * if getattr(obj, 'exception', None) is not None:
- * if hasattr(obj, '_raise_exception'):
- */
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_greenlets);
- __Pyx_GIVEREF(__pyx_v_greenlets);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_greenlets);
- __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_count, __pyx_v_count) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_6gevent_9_greenlet_iwait, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
- __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
- __pyx_t_7 = NULL;
- } else {
- __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 862, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- for (;;) {
- if (likely(!__pyx_t_7)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 862, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- } else {
- if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 862, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- }
- } else {
- __pyx_t_3 = __pyx_t_7(__pyx_t_4);
- if (unlikely(!__pyx_t_3)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 862, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_3);
- }
- __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":863
- * done = []
- * for obj in iwait(greenlets, timeout=timeout, count=count):
- * if getattr(obj, 'exception', None) is not None: # <<<<<<<<<<<<<<
- * if hasattr(obj, '_raise_exception'):
- * obj._raise_exception()
- */
- __pyx_t_3 = __Pyx_GetAttr3(__pyx_v_obj, __pyx_n_s_exception, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 863, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = (__pyx_t_3 != Py_None);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/greenlet.py":864
- * for obj in iwait(greenlets, timeout=timeout, count=count):
- * if getattr(obj, 'exception', None) is not None:
- * if hasattr(obj, '_raise_exception'): # <<<<<<<<<<<<<<
- * obj._raise_exception()
- * else:
- */
- __pyx_t_1 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_s_raise_exception); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 864, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (likely(__pyx_t_2)) {
-
- /* "src/gevent/greenlet.py":865
- * if getattr(obj, 'exception', None) is not None:
- * if hasattr(obj, '_raise_exception'):
- * obj._raise_exception() # <<<<<<<<<<<<<<
- * else:
- * raise obj.exception
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_raise_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 865, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_8) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 865, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 865, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":864
- * for obj in iwait(greenlets, timeout=timeout, count=count):
- * if getattr(obj, 'exception', None) is not None:
- * if hasattr(obj, '_raise_exception'): # <<<<<<<<<<<<<<
- * obj._raise_exception()
- * else:
- */
- goto __pyx_L7;
- }
-
- /* "src/gevent/greenlet.py":867
- * obj._raise_exception()
- * else:
- * raise obj.exception # <<<<<<<<<<<<<<
- * done.append(obj)
- * return done
- */
- /*else*/ {
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 867, __pyx_L1_error)
- }
- __pyx_L7:;
-
- /* "src/gevent/greenlet.py":863
- * done = []
- * for obj in iwait(greenlets, timeout=timeout, count=count):
- * if getattr(obj, 'exception', None) is not None: # <<<<<<<<<<<<<<
- * if hasattr(obj, '_raise_exception'):
- * obj._raise_exception()
- */
- }
-
- /* "src/gevent/greenlet.py":868
- * else:
- * raise obj.exception
- * done.append(obj) # <<<<<<<<<<<<<<
- * return done
- *
- */
- __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_done, __pyx_v_obj); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 868, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":862
- *
- * done = []
- * for obj in iwait(greenlets, timeout=timeout, count=count): # <<<<<<<<<<<<<<
- * if getattr(obj, 'exception', None) is not None:
- * if hasattr(obj, '_raise_exception'):
- */
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":869
- * raise obj.exception
- * done.append(obj)
- * return done # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_done);
- __pyx_r = __pyx_v_done;
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":849
- *
- *
- * def joinall(greenlets, timeout=None, raise_error=False, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for the ``greenlets`` to finish.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._greenlet.joinall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_done);
- __Pyx_XDECREF(__pyx_v_obj);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_3joinall(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_2joinall[] = "joinall(greenlets, timeout=None, raise_error=False, count=None)\n\n Wait for the ``greenlets`` to finish.\n\n :param greenlets: A sequence (supporting :func:`len`) of greenlets to wait for.\n :keyword float timeout: If given, the maximum number of seconds to wait.\n :return: A sequence of the greenlets that finished before the timeout (if any)\n expired.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_3joinall = {"joinall", (PyCFunction)__pyx_pw_6gevent_9_greenlet_3joinall, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_2joinall};
-static PyObject *__pyx_pw_6gevent_9_greenlet_3joinall(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_greenlets = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_raise_error = 0;
- PyObject *__pyx_v_count = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("joinall (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_greenlets,&__pyx_n_s_timeout,&__pyx_n_s_raise_error,&__pyx_n_s_count,0};
- PyObject* values[4] = {0,0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = ((PyObject *)Py_False);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_greenlets)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_raise_error);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_count);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "joinall") < 0)) __PYX_ERR(0, 849, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_greenlets = values[0];
- __pyx_v_timeout = values[1];
- __pyx_v_raise_error = values[2];
- __pyx_v_count = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("joinall", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 849, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.joinall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_2joinall(__pyx_self, __pyx_v_greenlets, __pyx_v_timeout, __pyx_v_raise_error, __pyx_v_count);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_2joinall(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_timeout, PyObject *__pyx_v_raise_error, PyObject *__pyx_v_count) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_9_greenlet_joinall __pyx_t_2;
- __Pyx_RefNannySetupContext("joinall", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 3;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_2.raise_error = __pyx_v_raise_error;
- __pyx_t_2.count = __pyx_v_count;
- __pyx_t_1 = __pyx_f_6gevent_9_greenlet_joinall(__pyx_v_greenlets, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 849, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.joinall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":872
- *
- *
- * def _killall3(greenlets, exception, waiter): # <<<<<<<<<<<<<<
- * diehards = []
- * for g in greenlets:
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet__killall3(PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception, PyObject *__pyx_v_waiter) {
- PyObject *__pyx_v_diehards = 0;
- PyObject *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- int __pyx_t_16;
- __Pyx_RefNannySetupContext("_killall3", 0);
-
- /* "src/gevent/greenlet.py":873
- *
- * def _killall3(greenlets, exception, waiter):
- * diehards = [] # <<<<<<<<<<<<<<
- * for g in greenlets:
- * if not g.dead:
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 873, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_diehards = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":874
- * def _killall3(greenlets, exception, waiter):
- * diehards = []
- * for g in greenlets: # <<<<<<<<<<<<<<
- * if not g.dead:
- * try:
- */
- if (unlikely(__pyx_v_greenlets == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 874, __pyx_L1_error)
- }
- __pyx_t_1 = __pyx_v_greenlets; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
- for (;;) {
- if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 874, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 874, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_XDECREF_SET(__pyx_v_g, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":875
- * diehards = []
- * for g in greenlets:
- * if not g.dead: # <<<<<<<<<<<<<<
- * try:
- * g.throw(exception)
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_dead); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 875, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 875, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = ((!__pyx_t_4) != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/greenlet.py":876
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":877
- * if not g.dead:
- * try:
- * g.throw(exception) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info())
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_throw); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (!__pyx_t_10) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_exception};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_exception};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_exception);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":876
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L13_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":878
- * try:
- * g.throw(exception)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * g.parent.handle_error(g, *sys_exc_info())
- * if not g.dead:
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet._killall3", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_11) < 0) __PYX_ERR(0, 878, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GOTREF(__pyx_t_11);
-
- /* "src/gevent/greenlet.py":879
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info()) # <<<<<<<<<<<<<<
- * if not g.dead:
- * diehards.append(g)
- */
- __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_parent); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_v_g);
- __Pyx_GIVEREF(__pyx_v_g);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_g);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __pyx_t_14 = __pyx_v_6gevent_9_greenlet_sys_exc_info; __pyx_t_15 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
- __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
- if (likely(__pyx_t_15)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
- __Pyx_INCREF(__pyx_t_15);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_14, function);
- }
- }
- if (__pyx_t_15) {
- __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- } else {
- __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- }
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_14 = __Pyx_PySequence_Tuple(__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_13 = PyNumber_Add(__pyx_t_10, __pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 879, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L7_exception_handled;
- }
- __pyx_L8_except_error:;
-
- /* "src/gevent/greenlet.py":876
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L7_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L13_try_end:;
- }
-
- /* "src/gevent/greenlet.py":880
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info())
- * if not g.dead: # <<<<<<<<<<<<<<
- * diehards.append(g)
- * waiter.switch(diehards)
- */
- __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_dead); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 880, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 880, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_4 = ((!__pyx_t_5) != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/greenlet.py":881
- * g.parent.handle_error(g, *sys_exc_info())
- * if not g.dead:
- * diehards.append(g) # <<<<<<<<<<<<<<
- * waiter.switch(diehards)
- *
- */
- __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_diehards, __pyx_v_g); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 881, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":880
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info())
- * if not g.dead: # <<<<<<<<<<<<<<
- * diehards.append(g)
- * waiter.switch(diehards)
- */
- }
-
- /* "src/gevent/greenlet.py":875
- * diehards = []
- * for g in greenlets:
- * if not g.dead: # <<<<<<<<<<<<<<
- * try:
- * g.throw(exception)
- */
- }
-
- /* "src/gevent/greenlet.py":874
- * def _killall3(greenlets, exception, waiter):
- * diehards = []
- * for g in greenlets: # <<<<<<<<<<<<<<
- * if not g.dead:
- * try:
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":882
- * if not g.dead:
- * diehards.append(g)
- * waiter.switch(diehards) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_switch); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_11, function);
- }
- }
- if (!__pyx_t_9) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_diehards); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_11)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_diehards};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_diehards};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL;
- __Pyx_INCREF(__pyx_v_diehards);
- __Pyx_GIVEREF(__pyx_v_diehards);
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_diehards);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":872
- *
- *
- * def _killall3(greenlets, exception, waiter): # <<<<<<<<<<<<<<
- * diehards = []
- * for g in greenlets:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_AddTraceback("gevent._greenlet._killall3", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_diehards);
- __Pyx_XDECREF(__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":885
- *
- *
- * def _killall(greenlets, exception): # <<<<<<<<<<<<<<
- * for g in greenlets:
- * if not g.dead:
- */
-
-static PyObject *__pyx_f_6gevent_9_greenlet__killall(PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception) {
- PyObject *__pyx_v_g = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- __Pyx_RefNannySetupContext("_killall", 0);
-
- /* "src/gevent/greenlet.py":886
- *
- * def _killall(greenlets, exception):
- * for g in greenlets: # <<<<<<<<<<<<<<
- * if not g.dead:
- * try:
- */
- if (unlikely(__pyx_v_greenlets == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 886, __pyx_L1_error)
- }
- __pyx_t_1 = __pyx_v_greenlets; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
- for (;;) {
- if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 886, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 886, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_XDECREF_SET(__pyx_v_g, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":887
- * def _killall(greenlets, exception):
- * for g in greenlets:
- * if not g.dead: # <<<<<<<<<<<<<<
- * try:
- * g.throw(exception)
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_dead); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 887, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 887, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = ((!__pyx_t_4) != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/greenlet.py":888
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":889
- * if not g.dead:
- * try:
- * g.throw(exception) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info())
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_throw); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (!__pyx_t_10) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_exception};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_exception};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_exception);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":888
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L13_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/greenlet.py":890
- * try:
- * g.throw(exception)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * g.parent.handle_error(g, *sys_exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._greenlet._killall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_11) < 0) __PYX_ERR(0, 890, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GOTREF(__pyx_t_11);
-
- /* "src/gevent/greenlet.py":891
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- * g.parent.handle_error(g, *sys_exc_info()) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_parent); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_v_g);
- __Pyx_GIVEREF(__pyx_v_g);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_g);
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __pyx_t_14 = __pyx_v_6gevent_9_greenlet_sys_exc_info; __pyx_t_15 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
- __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
- if (likely(__pyx_t_15)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
- __Pyx_INCREF(__pyx_t_15);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_14, function);
- }
- }
- if (__pyx_t_15) {
- __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- } else {
- __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- }
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_14 = __Pyx_PySequence_Tuple(__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_13 = PyNumber_Add(__pyx_t_10, __pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 891, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L7_exception_handled;
- }
- __pyx_L8_except_error:;
-
- /* "src/gevent/greenlet.py":888
- * for g in greenlets:
- * if not g.dead:
- * try: # <<<<<<<<<<<<<<
- * g.throw(exception)
- * except: # pylint:disable=bare-except
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L7_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L13_try_end:;
- }
-
- /* "src/gevent/greenlet.py":887
- * def _killall(greenlets, exception):
- * for g in greenlets:
- * if not g.dead: # <<<<<<<<<<<<<<
- * try:
- * g.throw(exception)
- */
- }
-
- /* "src/gevent/greenlet.py":886
- *
- * def _killall(greenlets, exception):
- * for g in greenlets: # <<<<<<<<<<<<<<
- * if not g.dead:
- * try:
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":885
- *
- *
- * def _killall(greenlets, exception): # <<<<<<<<<<<<<<
- * for g in greenlets:
- * if not g.dead:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_AddTraceback("gevent._greenlet._killall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_g);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":894
- *
- *
- * def killall(greenlets, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
- */
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_7__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__defaults__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_exception);
- __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_exception);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_exception);
- __Pyx_INCREF(((PyObject *)Py_True));
- __Pyx_GIVEREF(((PyObject *)Py_True));
- PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_True));
- __Pyx_INCREF(((PyObject *)Py_None));
- __Pyx_GIVEREF(((PyObject *)Py_None));
- PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)Py_None));
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
- __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._greenlet.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_9_greenlet_5killall(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_9_greenlet_4killall[] = "killall(greenlets, exception=GreenletExit, block=True, timeout=None)\n\n Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.\n\n .. caution:: Use care when killing greenlets. If they are not prepared for exceptions,\n this could result in corrupted state.\n\n :param greenlets: A **bounded** iterable of the non-None greenlets to terminate.\n *All* the items in this iterable must be greenlets that belong to the same thread.\n :keyword exception: The exception to raise in the greenlets. By default this is\n :class:`GreenletExit`.\n :keyword bool block: If True (the default) then this function only returns when all the\n greenlets are dead; the current greenlet is unscheduled during that process.\n If greenlets ignore the initial exception raised in them,\n then they will be joined (with :func:`gevent.joinall`) and allowed to die naturally.\n If False, this function returns immediately and greenlets will raise\n the exception asynchronously.\n :keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is\n only honored when ``block`` is True.\n :raise Timeout: If blocking and a timeout is given that elapses before\n all the greenlets are dead.\n\n .. versionchanged:: 1.1a2\n *greenlets* can be any iterable of greenlets, like an iterator or a set.\n Previously it had to be a list or tuple.\n ";
-static PyMethodDef __pyx_mdef_6gevent_9_greenlet_5killall = {"killall", (PyCFunction)__pyx_pw_6gevent_9_greenlet_5killall, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_4killall};
-static PyObject *__pyx_pw_6gevent_9_greenlet_5killall(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_greenlets = 0;
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("killall (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_greenlets,&__pyx_n_s_exception,&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[4] = {0,0,0,0};
- __pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
- values[1] = __pyx_dynamic_args->__pyx_arg_exception;
- values[2] = ((PyObject *)((PyObject *)Py_True));
- values[3] = ((PyObject *)((PyObject *)Py_None));
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_greenlets)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "killall") < 0)) __PYX_ERR(0, 894, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_greenlets = values[0];
- __pyx_v_exception = values[1];
- __pyx_v_block = values[2];
- __pyx_v_timeout = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("killall", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 894, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._greenlet.killall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_9_greenlet_4killall(__pyx_self, __pyx_v_greenlets, __pyx_v_exception, __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_9_greenlet_4killall(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_v_loop = NULL;
- struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_v_t = NULL;
- PyObject *__pyx_v_alive = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- char const *__pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- __Pyx_RefNannySetupContext("killall", 0);
- __Pyx_INCREF(__pyx_v_greenlets);
-
- /* "src/gevent/greenlet.py":921
- * """
- * # support non-indexable containers like iterators or set objects
- * greenlets = list(greenlets) # <<<<<<<<<<<<<<
- * if not greenlets:
- * return
- */
- __pyx_t_1 = PySequence_List(__pyx_v_greenlets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 921, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_greenlets, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":922
- * # support non-indexable containers like iterators or set objects
- * greenlets = list(greenlets)
- * if not greenlets: # <<<<<<<<<<<<<<
- * return
- * loop = greenlets[0].loop
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_greenlets); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 922, __pyx_L1_error)
- __pyx_t_3 = ((!__pyx_t_2) != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":923
- * greenlets = list(greenlets)
- * if not greenlets:
- * return # <<<<<<<<<<<<<<
- * loop = greenlets[0].loop
- * if block:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/greenlet.py":922
- * # support non-indexable containers like iterators or set objects
- * greenlets = list(greenlets)
- * if not greenlets: # <<<<<<<<<<<<<<
- * return
- * loop = greenlets[0].loop
- */
- }
-
- /* "src/gevent/greenlet.py":924
- * if not greenlets:
- * return
- * loop = greenlets[0].loop # <<<<<<<<<<<<<<
- * if block:
- * waiter = Waiter() # pylint:disable=undefined-variable
- */
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_greenlets, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 924, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_loop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 924, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_loop = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":925
- * return
- * loop = greenlets[0].loop
- * if block: # <<<<<<<<<<<<<<
- * waiter = Waiter() # pylint:disable=undefined-variable
- * loop.run_callback(_killall3, greenlets, exception, waiter)
- */
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 925, __pyx_L1_error)
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":926
- * loop = greenlets[0].loop
- * if block:
- * waiter = Waiter() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * loop.run_callback(_killall3, greenlets, exception, waiter)
- * t = Timeout._start_new_or_dummy(timeout)
- */
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 926, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":927
- * if block:
- * waiter = Waiter() # pylint:disable=undefined-variable
- * loop.run_callback(_killall3, greenlets, exception, waiter) # <<<<<<<<<<<<<<
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = __Pyx_CFunc_object____list____object____object___to_py(__pyx_f_6gevent_9_greenlet__killall3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_5, __pyx_v_greenlets, __pyx_v_exception, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_5, __pyx_v_greenlets, __pyx_v_exception, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
- __Pyx_INCREF(__pyx_v_greenlets);
- __Pyx_GIVEREF(__pyx_v_greenlets);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_greenlets);
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_exception);
- __Pyx_INCREF(((PyObject *)__pyx_v_waiter));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_waiter));
- PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, ((PyObject *)__pyx_v_waiter));
- __pyx_t_5 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":928
- * waiter = Waiter() # pylint:disable=undefined-variable
- * loop.run_callback(_killall3, greenlets, exception, waiter)
- * t = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<<
- * try:
- * alive = waiter.get()
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_9_greenlet_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_timeout};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_timeout};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_t = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":929
- * loop.run_callback(_killall3, greenlets, exception, waiter)
- * t = Timeout._start_new_or_dummy(timeout)
- * try: # <<<<<<<<<<<<<<
- * alive = waiter.get()
- * if alive:
- */
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":930
- * t = Timeout._start_new_or_dummy(timeout)
- * try:
- * alive = waiter.get() # <<<<<<<<<<<<<<
- * if alive:
- * joinall(alive, raise_error=False)
- */
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *)__pyx_v_waiter->__pyx_vtab)->get(__pyx_v_waiter, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 930, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_alive = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/greenlet.py":931
- * try:
- * alive = waiter.get()
- * if alive: # <<<<<<<<<<<<<<
- * joinall(alive, raise_error=False)
- * finally:
- */
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_alive); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 931, __pyx_L6_error)
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":932
- * alive = waiter.get()
- * if alive:
- * joinall(alive, raise_error=False) # <<<<<<<<<<<<<<
- * finally:
- * t.cancel()
- */
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_joinall); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_alive);
- __Pyx_GIVEREF(__pyx_v_alive);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_alive);
- __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 932, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_raise_error, Py_False) < 0) __PYX_ERR(0, 932, __pyx_L6_error)
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 932, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "src/gevent/greenlet.py":931
- * try:
- * alive = waiter.get()
- * if alive: # <<<<<<<<<<<<<<
- * joinall(alive, raise_error=False)
- * finally:
- */
- }
- }
-
- /* "src/gevent/greenlet.py":934
- * joinall(alive, raise_error=False)
- * finally:
- * t.cancel() # <<<<<<<<<<<<<<
- * else:
- * loop.run_callback(_killall, greenlets, exception)
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 934, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 934, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 934, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L7;
- }
- __pyx_L6_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __pyx_t_7 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
- {
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_cancel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 934, __pyx_L10_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 934, __pyx_L10_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 934, __pyx_L10_error)
- }
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
- goto __pyx_L1_error;
- __pyx_L10_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L7:;
- }
-
- /* "src/gevent/greenlet.py":925
- * return
- * loop = greenlets[0].loop
- * if block: # <<<<<<<<<<<<<<
- * waiter = Waiter() # pylint:disable=undefined-variable
- * loop.run_callback(_killall3, greenlets, exception, waiter)
- */
- goto __pyx_L4;
- }
-
- /* "src/gevent/greenlet.py":936
- * t.cancel()
- * else:
- * loop.run_callback(_killall, greenlets, exception) # <<<<<<<<<<<<<<
- *
- * def _init():
- */
- /*else*/ {
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_1 = __Pyx_CFunc_object____list____object___to_py(__pyx_f_6gevent_9_greenlet__killall); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = NULL;
- __pyx_t_9 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- __pyx_t_9 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_1, __pyx_v_greenlets, __pyx_v_exception};
- __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_1, __pyx_v_greenlets, __pyx_v_exception};
- __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_greenlets);
- __Pyx_GIVEREF(__pyx_v_greenlets);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_greenlets);
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_9, __pyx_v_exception);
- __pyx_t_1 = 0;
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __pyx_L4:;
-
- /* "src/gevent/greenlet.py":894
- *
- *
- * def killall(greenlets, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._greenlet.killall", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_loop);
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_t);
- __Pyx_XDECREF(__pyx_v_alive);
- __Pyx_XDECREF(__pyx_v_greenlets);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/greenlet.py":938
- * loop.run_callback(_killall, greenlets, exception)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-static void __pyx_f_6gevent_9_greenlet__init(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/greenlet.py":939
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _init()
- */
- __pyx_f_6gevent_9_greenlet_greenlet_init();
-
- /* "src/gevent/greenlet.py":938
- * loop.run_callback(_killall, greenlets, exception)
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_9_greenlet_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_greenlet.pxd":28
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_9_greenlet_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_9_greenlet__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_greenlet.pxd":35
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_greenlet.pxd":36
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef extern from "Python.h":
- */
- __pyx_v_6gevent_9_greenlet__greenlet_imported = 1;
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ):
- * def wrap(list greenlets, object exception, object waiter): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_wrap[] = "wrap(greenlets: list, exception, waiter)";
-static PyMethodDef __pyx_mdef_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_1wrap = {"wrap", (PyCFunction)__pyx_pw_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_1wrap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_wrap};
-static PyObject *__pyx_pw_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_greenlets = 0;
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_v_waiter = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wrap (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_greenlets,&__pyx_n_s_exception,&__pyx_n_s_waiter,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_greenlets)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, 1); __PYX_ERR(4, 65, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_waiter)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, 2); __PYX_ERR(4, 65, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wrap") < 0)) __PYX_ERR(4, 65, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_greenlets = ((PyObject*)values[0]);
- __pyx_v_exception = values[1];
- __pyx_v_waiter = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 65, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object____object___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_greenlets), (&PyList_Type), 1, "greenlets", 1))) __PYX_ERR(4, 65, __pyx_L1_error)
- __pyx_r = __pyx_pf_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_wrap(__pyx_self, __pyx_v_greenlets, __pyx_v_exception, __pyx_v_waiter);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception, PyObject *__pyx_v_waiter) {
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *__pyx_cur_scope;
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *__pyx_outer_scope;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("wrap", 0);
- __pyx_outer_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *) __Pyx_CyFunction_GetClosure(__pyx_self);
- __pyx_cur_scope = __pyx_outer_scope;
-
- /* "cfunc.to_py":67
- * def wrap(list greenlets, object exception, object waiter):
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter) # <<<<<<<<<<<<<<
- * return wrap
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_cur_scope->__pyx_v_f(__pyx_v_greenlets, __pyx_v_exception, __pyx_v_waiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 67, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ):
- * def wrap(list greenlets, object exception, object waiter): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object____object___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception, object waiter):
- * """wrap(greenlets: list, exception, waiter)"""
- */
-
-static PyObject *__Pyx_CFunc_object____list____object____object___to_py(PyObject *(*__pyx_v_f)(PyObject *, PyObject *, PyObject *)) {
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *__pyx_cur_scope;
- PyObject *__pyx_v_wrap = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_CFunc_object____list____object____object___to_py", 0);
- __pyx_cur_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *)__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py(__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py, __pyx_empty_tuple, NULL);
- if (unlikely(!__pyx_cur_scope)) {
- __pyx_cur_scope = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *)Py_None);
- __Pyx_INCREF(Py_None);
- __PYX_ERR(4, 64, __pyx_L1_error)
- } else {
- __Pyx_GOTREF(__pyx_cur_scope);
- }
- __pyx_cur_scope->__pyx_v_f = __pyx_v_f;
-
- /* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ):
- * def wrap(list greenlets, object exception, object waiter): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter)
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11cfunc_dot_to_py_54__Pyx_CFunc_object____list____object____object___to_py_1wrap, 0, __pyx_n_s_Pyx_CFunc_object____list____ob, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cfunc_to_py, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_wrap = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "cfunc.to_py":68
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter)
- * return wrap # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_wrap);
- __pyx_r = __pyx_v_wrap;
- goto __pyx_L0;
-
- /* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception, object waiter):
- * """wrap(greenlets: list, exception, waiter)"""
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object____object___to_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_wrap);
- __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ):
- * def wrap(list greenlets, object exception): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception)"""
- * return f(greenlets, exception)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_wrap[] = "wrap(greenlets: list, exception)";
-static PyMethodDef __pyx_mdef_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_1wrap = {"wrap", (PyCFunction)__pyx_pw_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_1wrap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_wrap};
-static PyObject *__pyx_pw_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_greenlets = 0;
- PyObject *__pyx_v_exception = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("wrap (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_greenlets,&__pyx_n_s_exception,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_greenlets)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("wrap", 1, 2, 2, 1); __PYX_ERR(4, 65, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wrap") < 0)) __PYX_ERR(4, 65, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_greenlets = ((PyObject*)values[0]);
- __pyx_v_exception = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("wrap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 65, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_greenlets), (&PyList_Type), 1, "greenlets", 1))) __PYX_ERR(4, 65, __pyx_L1_error)
- __pyx_r = __pyx_pf_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_wrap(__pyx_self, __pyx_v_greenlets, __pyx_v_exception);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_greenlets, PyObject *__pyx_v_exception) {
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *__pyx_cur_scope;
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *__pyx_outer_scope;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("wrap", 0);
- __pyx_outer_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *) __Pyx_CyFunction_GetClosure(__pyx_self);
- __pyx_cur_scope = __pyx_outer_scope;
-
- /* "cfunc.to_py":67
- * def wrap(list greenlets, object exception):
- * """wrap(greenlets: list, exception)"""
- * return f(greenlets, exception) # <<<<<<<<<<<<<<
- * return wrap
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_cur_scope->__pyx_v_f(__pyx_v_greenlets, __pyx_v_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 67, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ):
- * def wrap(list greenlets, object exception): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception)"""
- * return f(greenlets, exception)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception):
- * """wrap(greenlets: list, exception)"""
- */
-
-static PyObject *__Pyx_CFunc_object____list____object___to_py(PyObject *(*__pyx_v_f)(PyObject *, PyObject *)) {
- struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *__pyx_cur_scope;
- PyObject *__pyx_v_wrap = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_CFunc_object____list____object___to_py", 0);
- __pyx_cur_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *)__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py(__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py, __pyx_empty_tuple, NULL);
- if (unlikely(!__pyx_cur_scope)) {
- __pyx_cur_scope = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *)Py_None);
- __Pyx_INCREF(Py_None);
- __PYX_ERR(4, 64, __pyx_L1_error)
- } else {
- __Pyx_GOTREF(__pyx_cur_scope);
- }
- __pyx_cur_scope->__pyx_v_f = __pyx_v_f;
-
- /* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ):
- * def wrap(list greenlets, object exception): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception)"""
- * return f(greenlets, exception)
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11cfunc_dot_to_py_44__Pyx_CFunc_object____list____object___to_py_1wrap, 0, __pyx_n_s_Pyx_CFunc_object____list____ob_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cfunc_to_py, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_wrap = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "cfunc.to_py":68
- * """wrap(greenlets: list, exception)"""
- * return f(greenlets, exception)
- * return wrap # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_wrap);
- __pyx_r = __pyx_v_wrap;
- goto __pyx_L0;
-
- /* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception):
- * """wrap(greenlets: list, exception)"""
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____list____object___to_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_wrap);
- __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_SpawnedLink(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)o);
- p->callback = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_9_greenlet_SpawnedLink(PyObject *o) {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *p = (struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->callback);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_9_greenlet_SpawnedLink(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *p = (struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)o;
- if (p->callback) {
- e = (*v)(p->callback, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_9_greenlet_SpawnedLink(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *p = (struct __pyx_obj_6gevent_9_greenlet_SpawnedLink *)o;
- tmp = ((PyObject*)p->callback);
- p->callback = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_tp_getattro_6gevent_9_greenlet_SpawnedLink(PyObject *o, PyObject *n) {
- PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
- if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- v = __pyx_pw_6gevent_9_greenlet_11SpawnedLink_13__getattr__(o, n);
- }
- return v;
-}
-
-static PyObject *__pyx_tp_richcompare_6gevent_9_greenlet_SpawnedLink(PyObject *o1, PyObject *o2, int op) {
- switch (op) {
- case Py_EQ: {
- return __pyx_pw_6gevent_9_greenlet_11SpawnedLink_7__eq__(o1, o2);
- }
- case Py_NE: {
- PyObject *ret;
- ret = __pyx_pw_6gevent_9_greenlet_11SpawnedLink_7__eq__(o1, o2);
- if (likely(ret && ret != Py_NotImplemented)) {
- int b = __Pyx_PyObject_IsTrue(ret); Py_DECREF(ret);
- if (unlikely(b < 0)) return NULL;
- ret = (b) ? Py_False : Py_True;
- Py_INCREF(ret);
- }
- return ret;
- }
- default: {
- return __Pyx_NewRef(Py_NotImplemented);
- }
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_11SpawnedLink_callback(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_9_greenlet_11SpawnedLink_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_9_greenlet_11SpawnedLink_8callback_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet_SpawnedLink[] = {
- {"__getattr__", (PyCFunction)__pyx_pw_6gevent_9_greenlet_11SpawnedLink_13__getattr__, METH_O|METH_COEXIST, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_9_greenlet_SpawnedLink[] = {
- {(char *)"callback", __pyx_getprop_6gevent_9_greenlet_11SpawnedLink_callback, __pyx_setprop_6gevent_9_greenlet_11SpawnedLink_callback, (char *)"callback: object", 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet_SpawnedLink = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.SpawnedLink", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet_SpawnedLink, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_11__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_5__hash__, /*tp_hash*/
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_3__call__, /*tp_call*/
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_9__str__, /*tp_str*/
- __pyx_tp_getattro_6gevent_9_greenlet_SpawnedLink, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "SpawnedLink(callback)\n\n A wrapper around link that calls it in another greenlet.\n\n Can be called only from main loop.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_9_greenlet_SpawnedLink, /*tp_traverse*/
- __pyx_tp_clear_6gevent_9_greenlet_SpawnedLink, /*tp_clear*/
- __pyx_tp_richcompare_6gevent_9_greenlet_SpawnedLink, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet_SpawnedLink, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_9_greenlet_SpawnedLink, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet_SpawnedLink, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_SuccessSpawnedLink(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_9_greenlet_SpawnedLink(t, a, k);
- if (unlikely(!o)) return 0;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet_SuccessSpawnedLink[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet_SuccessSpawnedLink = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.SuccessSpawnedLink", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet_SpawnedLink, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_11__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_9_greenlet_18SuccessSpawnedLink_1__call__, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_9__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "A wrapper around link that calls it in another greenlet only if source succeed.\n\n Can be called only from main loop.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_9_greenlet_SpawnedLink, /*tp_traverse*/
- __pyx_tp_clear_6gevent_9_greenlet_SpawnedLink, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet_SuccessSpawnedLink, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet_SuccessSpawnedLink, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_FailureSpawnedLink(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_9_greenlet_SpawnedLink(t, a, k);
- if (unlikely(!o)) return 0;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet_FailureSpawnedLink[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet_FailureSpawnedLink = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.FailureSpawnedLink", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet_SpawnedLink, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_11__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_9_greenlet_18FailureSpawnedLink_1__call__, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_9__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "A wrapper around link that calls it in another greenlet only if source failed.\n\n Can be called only from main loop.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_9_greenlet_SpawnedLink, /*tp_traverse*/
- __pyx_tp_clear_6gevent_9_greenlet_SpawnedLink, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet_FailureSpawnedLink, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_9_greenlet_11SpawnedLink_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet_FailureSpawnedLink, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet__Frame(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_9_greenlet__Frame *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_9_greenlet__Frame *)o);
- p->f_code = ((PyCodeObject *)Py_None); Py_INCREF(Py_None);
- p->f_back = ((struct __pyx_obj_6gevent_9_greenlet__Frame *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_9_greenlet__Frame(PyObject *o) {
- struct __pyx_obj_6gevent_9_greenlet__Frame *p = (struct __pyx_obj_6gevent_9_greenlet__Frame *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->f_code);
- Py_CLEAR(p->f_back);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_9_greenlet__Frame(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_9_greenlet__Frame *p = (struct __pyx_obj_6gevent_9_greenlet__Frame *)o;
- if (p->f_code) {
- e = (*v)(((PyObject *)p->f_code), a); if (e) return e;
- }
- if (p->f_back) {
- e = (*v)(((PyObject *)p->f_back), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_9_greenlet__Frame(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_9_greenlet__Frame *p = (struct __pyx_obj_6gevent_9_greenlet__Frame *)o;
- tmp = ((PyObject*)p->f_code);
- p->f_code = ((PyCodeObject *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->f_back);
- p->f_back = ((struct __pyx_obj_6gevent_9_greenlet__Frame *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_6_Frame_f_globals(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_6_Frame_9f_globals_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_6_Frame_f_code(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_6_Frame_6f_code_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_6_Frame_f_lineno(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_6_Frame_8f_lineno_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_6_Frame_f_back(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_6_Frame_6f_back_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet__Frame[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_9_greenlet__Frame[] = {
- {(char *)"f_globals", __pyx_getprop_6gevent_9_greenlet_6_Frame_f_globals, 0, (char *)0, 0},
- {(char *)"f_code", __pyx_getprop_6gevent_9_greenlet_6_Frame_f_code, 0, (char *)0, 0},
- {(char *)"f_lineno", __pyx_getprop_6gevent_9_greenlet_6_Frame_f_lineno, 0, (char *)0, 0},
- {(char *)"f_back", __pyx_getprop_6gevent_9_greenlet_6_Frame_f_back, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet__Frame = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet._Frame", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet__Frame), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet__Frame, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_Frame(f_code, f_lineno, f_back)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_9_greenlet__Frame, /*tp_traverse*/
- __pyx_tp_clear_6gevent_9_greenlet__Frame, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet__Frame, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_9_greenlet__Frame, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_9_greenlet_6_Frame_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet__Frame, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet __pyx_vtable_6gevent_9_greenlet_Greenlet;
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet_Greenlet(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_9_greenlet_Greenlet *p;
- PyObject *o = __pyx_ptype_6gevent_9_greenlet_greenlet->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_9_greenlet_Greenlet *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_9_greenlet_Greenlet;
- p->value = Py_None; Py_INCREF(Py_None);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->kwargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->spawning_greenlet = Py_None; Py_INCREF(Py_None);
- p->spawn_tree_locals = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_spawning_stack_frames = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_exc_info = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_notifier = Py_None; Py_INCREF(Py_None);
- p->_start_event = Py_None; Py_INCREF(Py_None);
- p->_formatted_info = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_ident = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_9_greenlet_Greenlet(PyObject *o) {
- struct __pyx_obj_6gevent_9_greenlet_Greenlet *p = (struct __pyx_obj_6gevent_9_greenlet_Greenlet *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->value);
- Py_CLEAR(p->args);
- Py_CLEAR(p->kwargs);
- Py_CLEAR(p->spawning_greenlet);
- Py_CLEAR(p->spawn_tree_locals);
- Py_CLEAR(p->_spawning_stack_frames);
- Py_CLEAR(p->_links);
- Py_CLEAR(p->_exc_info);
- Py_CLEAR(p->_notifier);
- Py_CLEAR(p->_start_event);
- Py_CLEAR(p->_formatted_info);
- Py_CLEAR(p->_ident);
- #if CYTHON_USE_TYPE_SLOTS
- if (PyType_IS_GC(Py_TYPE(o)->tp_base))
- #endif
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_9_greenlet_greenlet)) __pyx_ptype_6gevent_9_greenlet_greenlet->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_9_greenlet_Greenlet);
-}
-
-static int __pyx_tp_traverse_6gevent_9_greenlet_Greenlet(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_9_greenlet_Greenlet *p = (struct __pyx_obj_6gevent_9_greenlet_Greenlet *)o;
- e = ((likely(__pyx_ptype_6gevent_9_greenlet_greenlet)) ? ((__pyx_ptype_6gevent_9_greenlet_greenlet->tp_traverse) ? __pyx_ptype_6gevent_9_greenlet_greenlet->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_9_greenlet_Greenlet)); if (e) return e;
- if (p->value) {
- e = (*v)(p->value, a); if (e) return e;
- }
- if (p->args) {
- e = (*v)(p->args, a); if (e) return e;
- }
- if (p->kwargs) {
- e = (*v)(p->kwargs, a); if (e) return e;
- }
- if (p->spawning_greenlet) {
- e = (*v)(p->spawning_greenlet, a); if (e) return e;
- }
- if (p->spawn_tree_locals) {
- e = (*v)(p->spawn_tree_locals, a); if (e) return e;
- }
- if (p->_spawning_stack_frames) {
- e = (*v)(p->_spawning_stack_frames, a); if (e) return e;
- }
- if (p->_links) {
- e = (*v)(p->_links, a); if (e) return e;
- }
- if (p->_exc_info) {
- e = (*v)(p->_exc_info, a); if (e) return e;
- }
- if (p->_notifier) {
- e = (*v)(p->_notifier, a); if (e) return e;
- }
- if (p->_start_event) {
- e = (*v)(p->_start_event, a); if (e) return e;
- }
- if (p->_ident) {
- e = (*v)(p->_ident, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_9_greenlet_Greenlet(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_9_greenlet_Greenlet *p = (struct __pyx_obj_6gevent_9_greenlet_Greenlet *)o;
- if (likely(__pyx_ptype_6gevent_9_greenlet_greenlet)) { if (__pyx_ptype_6gevent_9_greenlet_greenlet->tp_clear) __pyx_ptype_6gevent_9_greenlet_greenlet->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_9_greenlet_Greenlet);
- tmp = ((PyObject*)p->value);
- p->value = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->args);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->kwargs);
- p->kwargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->spawning_greenlet);
- p->spawning_greenlet = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->spawn_tree_locals);
- p->spawn_tree_locals = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_spawning_stack_frames);
- p->_spawning_stack_frames = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_links);
- p->_links = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_exc_info);
- p->_exc_info = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_notifier);
- p->_notifier = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_start_event);
- p->_start_event = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_ident);
- p->_ident = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_minimal_ident(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_13minimal_ident_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_loop(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_4loop_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_dead(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_4dead_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_started(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_7started_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_exception(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_9exception_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_exc_info(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_8exc_info_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_5value_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_args(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_4args_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_kwargs(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_6kwargs_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_spawning_greenlet(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawning_greenlet_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet_spawn_tree_locals(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_9_greenlet_8Greenlet_spawn_tree_locals(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_17spawn_tree_locals_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_8Greenlet__spawning_stack_frames(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_8Greenlet_22_spawning_stack_frames_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet_Greenlet[] = {
- {"spawning_stack", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_3spawning_stack, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_2spawning_stack},
- {"name", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_5name, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_4name},
- {"_raise_exception", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_7_raise_exception, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_6_raise_exception},
- {"throw", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_19throw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_18throw},
- {"start", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_21start, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_20start},
- {"start_later", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_23start_later, METH_O, __pyx_doc_6gevent_9_greenlet_8Greenlet_22start_later},
- {"spawn", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_25spawn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_24spawn},
- {"spawn_later", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_27spawn_later, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_26spawn_later},
- {"kill", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_29kill, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_28kill},
- {"get", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_31get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_30get},
- {"run", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_35run, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_34run},
- {"_run", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_37_run, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_36_run},
- {"link", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_43link, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_42link},
- {"unlink", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_45unlink, METH_O, __pyx_doc_6gevent_9_greenlet_8Greenlet_44unlink},
- {"unlink_all", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_47unlink_all, METH_NOARGS, __pyx_doc_6gevent_9_greenlet_8Greenlet_46unlink_all},
- {"link_value", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_49link_value, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_48link_value},
- {"link_exception", (PyCFunction)__pyx_pw_6gevent_9_greenlet_8Greenlet_51link_exception, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_9_greenlet_8Greenlet_50link_exception},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_9_greenlet_Greenlet[] = {
- {(char *)"minimal_ident", __pyx_getprop_6gevent_9_greenlet_8Greenlet_minimal_ident, 0, (char *)"\n A small, unique integer that identifies this object.\n\n This is similar to :attr:`threading.Thread.ident` (and `id`)\n in that as long as this object is alive, no other greenlet *in\n this hub* will have the same id, but it makes a stronger\n guarantee that the assigned values will be small and\n sequential. Sometime after this object has died, the value\n will be available for reuse.\n\n To get ids that are unique across all hubs, combine this with\n the hub's ``minimal_ident``.\n\n .. versionadded:: 1.3a2\n ", 0},
- {(char *)"loop", __pyx_getprop_6gevent_9_greenlet_8Greenlet_loop, 0, (char *)0, 0},
- {(char *)"dead", __pyx_getprop_6gevent_9_greenlet_8Greenlet_dead, 0, (char *)"Boolean indicating that the greenlet is dead and will not run again.", 0},
- {(char *)"started", __pyx_getprop_6gevent_9_greenlet_8Greenlet_started, 0, (char *)0, 0},
- {(char *)"exception", __pyx_getprop_6gevent_9_greenlet_8Greenlet_exception, 0, (char *)"\n Holds the exception instance raised by the function if the\n greenlet has finished with an error. Otherwise ``None``.\n ", 0},
- {(char *)"exc_info", __pyx_getprop_6gevent_9_greenlet_8Greenlet_exc_info, 0, (char *)"\n Holds the exc_info three-tuple raised by the function if the\n greenlet finished with an error. Otherwise a false value.\n\n .. note:: This is a provisional API and may change.\n\n .. versionadded:: 1.1\n ", 0},
- {(char *)"value", __pyx_getprop_6gevent_9_greenlet_8Greenlet_value, 0, (char *)0, 0},
- {(char *)"args", __pyx_getprop_6gevent_9_greenlet_8Greenlet_args, 0, (char *)0, 0},
- {(char *)"kwargs", __pyx_getprop_6gevent_9_greenlet_8Greenlet_kwargs, 0, (char *)0, 0},
- {(char *)"spawning_greenlet", __pyx_getprop_6gevent_9_greenlet_8Greenlet_spawning_greenlet, 0, (char *)0, 0},
- {(char *)"spawn_tree_locals", __pyx_getprop_6gevent_9_greenlet_8Greenlet_spawn_tree_locals, __pyx_setprop_6gevent_9_greenlet_8Greenlet_spawn_tree_locals, (char *)"spawn_tree_locals: dict", 0},
- {(char *)"_spawning_stack_frames", __pyx_getprop_6gevent_9_greenlet_8Greenlet__spawning_stack_frames, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_Greenlet = {
- 0, /*nb_add*/
- 0, /*nb_subtract*/
- 0, /*nb_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_divide*/
- #endif
- 0, /*nb_remainder*/
- 0, /*nb_divmod*/
- 0, /*nb_power*/
- 0, /*nb_negative*/
- 0, /*nb_positive*/
- 0, /*nb_absolute*/
- __pyx_pw_6gevent_9_greenlet_8Greenlet_9__nonzero__, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_coerce*/
- #endif
- 0, /*nb_int*/
- #if PY_MAJOR_VERSION < 3
- 0, /*nb_long*/
- #else
- 0, /*reserved*/
- #endif
- 0, /*nb_float*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_oct*/
- #endif
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_hex*/
- #endif
- 0, /*nb_inplace_add*/
- 0, /*nb_inplace_subtract*/
- 0, /*nb_inplace_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_inplace_divide*/
- #endif
- 0, /*nb_inplace_remainder*/
- 0, /*nb_inplace_power*/
- 0, /*nb_inplace_lshift*/
- 0, /*nb_inplace_rshift*/
- 0, /*nb_inplace_and*/
- 0, /*nb_inplace_xor*/
- 0, /*nb_inplace_or*/
- 0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
- 0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
- 0, /*nb_index*/
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_matrix_multiply*/
- #endif
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_inplace_matrix_multiply*/
- #endif
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet_Greenlet = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.Greenlet", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet_Greenlet), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet_Greenlet, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_9_greenlet_8Greenlet_15__repr__, /*tp_repr*/
- &__pyx_tp_as_number_Greenlet, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Greenlet(run=None, *args, **kwargs)\n\n A light-weight cooperatively-scheduled execution unit.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_9_greenlet_Greenlet, /*tp_traverse*/
- __pyx_tp_clear_6gevent_9_greenlet_Greenlet, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet_Greenlet, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_9_greenlet_Greenlet, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_9_greenlet_8Greenlet_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet_Greenlet, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event __pyx_vtable_6gevent_9_greenlet__dummy_event;
-
-static PyObject *__pyx_tp_new_6gevent_9_greenlet__dummy_event(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_9_greenlet__dummy_event *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_9_greenlet__dummy_event;
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_9_greenlet__dummy_event(PyObject *o) {
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_12_dummy_event_pending(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_12_dummy_event_7pending_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_9_greenlet_12_dummy_event_active(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_9_greenlet_12_dummy_event_6active_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_9_greenlet__dummy_event[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_9_greenlet__dummy_event[] = {
- {(char *)"pending", __pyx_getprop_6gevent_9_greenlet_12_dummy_event_pending, 0, (char *)0, 0},
- {(char *)"active", __pyx_getprop_6gevent_9_greenlet_12_dummy_event_active, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_9_greenlet__dummy_event = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet._dummy_event", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_9_greenlet__dummy_event), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_9_greenlet__dummy_event, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
- "_dummy_event()", /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_9_greenlet__dummy_event, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_9_greenlet__dummy_event, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_9_greenlet_12_dummy_event_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_9_greenlet__dummy_event, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py[8];
-static int __pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py = 0;
-
-static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- PyObject *o;
- if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py)))) {
- o = (PyObject*)__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py[--__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py];
- memset(o, 0, sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py));
- (void) PyObject_INIT(o, t);
- } else {
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- }
- return o;
-}
-
-static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py(PyObject *o) {
- if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py)))) {
- __pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py[__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py++] = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py *)o);
- } else {
- (*Py_TYPE(o)->tp_free)(o);
- }
-}
-
-static PyTypeObject __pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.__pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py", /*tp_name*/
- sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py[8];
-static int __pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py = 0;
-
-static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- PyObject *o;
- if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py)))) {
- o = (PyObject*)__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py[--__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py];
- memset(o, 0, sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py));
- (void) PyObject_INIT(o, t);
- } else {
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- }
- return o;
-}
-
-static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py(PyObject *o) {
- if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py)))) {
- __pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py[__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py++] = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py *)o);
- } else {
- (*Py_TYPE(o)->tp_free)(o);
- }
-}
-
-static PyTypeObject __pyx_scope_struct____Pyx_CFunc_object____list____object___to_py = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._greenlet.__pyx_scope_struct____Pyx_CFunc_object____list____object___to_py", /*tp_name*/
- sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec__greenlet(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec__greenlet},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "_greenlet",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AssertionError, __pyx_k_AssertionError, sizeof(__pyx_k_AssertionError), 0, 0, 1, 1},
- {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
- {&__pyx_kp_s_Cannot_start_the_dummy_event, __pyx_k_Cannot_start_the_dummy_event, sizeof(__pyx_k_Cannot_start_the_dummy_event), 0, 0, 1, 0},
- {&__pyx_kp_s_Expected_callable_r, __pyx_k_Expected_callable_r, sizeof(__pyx_k_Expected_callable_r), 0, 0, 1, 0},
- {&__pyx_n_s_GEVENT_CONFIG, __pyx_k_GEVENT_CONFIG, sizeof(__pyx_k_GEVENT_CONFIG), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet, __pyx_k_Greenlet, sizeof(__pyx_k_Greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_GreenletExit, __pyx_k_GreenletExit, sizeof(__pyx_k_GreenletExit), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet__formatinfo, __pyx_k_Greenlet__formatinfo, sizeof(__pyx_k_Greenlet__formatinfo), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet__notify_links, __pyx_k_Greenlet__notify_links, sizeof(__pyx_k_Greenlet__notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet__raise_exception, __pyx_k_Greenlet__raise_exception, sizeof(__pyx_k_Greenlet__raise_exception), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet__run, __pyx_k_Greenlet__run, sizeof(__pyx_k_Greenlet__run), 0, 0, 1, 1},
- {&__pyx_kp_s_Greenlet_d, __pyx_k_Greenlet_d, sizeof(__pyx_k_Greenlet_d), 0, 0, 1, 0},
- {&__pyx_n_s_Greenlet_get, __pyx_k_Greenlet_get, sizeof(__pyx_k_Greenlet_get), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_has_links, __pyx_k_Greenlet_has_links, sizeof(__pyx_k_Greenlet_has_links), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_join, __pyx_k_Greenlet_join, sizeof(__pyx_k_Greenlet_join), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_kill, __pyx_k_Greenlet_kill, sizeof(__pyx_k_Greenlet_kill), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_link, __pyx_k_Greenlet_link, sizeof(__pyx_k_Greenlet_link), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_link_exception, __pyx_k_Greenlet_link_exception, sizeof(__pyx_k_Greenlet_link_exception), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_link_value, __pyx_k_Greenlet_link_value, sizeof(__pyx_k_Greenlet_link_value), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_name, __pyx_k_Greenlet_name, sizeof(__pyx_k_Greenlet_name), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_rawlink, __pyx_k_Greenlet_rawlink, sizeof(__pyx_k_Greenlet_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_ready, __pyx_k_Greenlet_ready, sizeof(__pyx_k_Greenlet_ready), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_run, __pyx_k_Greenlet_run, sizeof(__pyx_k_Greenlet_run), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_spawn, __pyx_k_Greenlet_spawn, sizeof(__pyx_k_Greenlet_spawn), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_spawn_later, __pyx_k_Greenlet_spawn_later, sizeof(__pyx_k_Greenlet_spawn_later), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_spawning_stack, __pyx_k_Greenlet_spawning_stack, sizeof(__pyx_k_Greenlet_spawning_stack), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_start, __pyx_k_Greenlet_start, sizeof(__pyx_k_Greenlet_start), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_start_later, __pyx_k_Greenlet_start_later, sizeof(__pyx_k_Greenlet_start_later), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_successful, __pyx_k_Greenlet_successful, sizeof(__pyx_k_Greenlet_successful), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_throw, __pyx_k_Greenlet_throw, sizeof(__pyx_k_Greenlet_throw), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_unlink, __pyx_k_Greenlet_unlink, sizeof(__pyx_k_Greenlet_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_Greenlet_unlink_all, __pyx_k_Greenlet_unlink_all, sizeof(__pyx_k_Greenlet_unlink_all), 0, 0, 1, 1},
- {&__pyx_n_s_InvalidSwitchError, __pyx_k_InvalidSwitchError, sizeof(__pyx_k_InvalidSwitchError), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_switch_into_Greenlet_get, __pyx_k_Invalid_switch_into_Greenlet_get, sizeof(__pyx_k_Invalid_switch_into_Greenlet_get), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_switch_into_Greenlet_joi, __pyx_k_Invalid_switch_into_Greenlet_joi, sizeof(__pyx_k_Invalid_switch_into_Greenlet_joi), 0, 0, 1, 0},
- {&__pyx_n_s_Lazy, __pyx_k_Lazy, sizeof(__pyx_k_Lazy), 0, 0, 1, 1},
- {&__pyx_n_s_NameError, __pyx_k_NameError, sizeof(__pyx_k_NameError), 0, 0, 1, 1},
- {&__pyx_n_s_PYPY, __pyx_k_PYPY, sizeof(__pyx_k_PYPY), 0, 0, 1, 1},
- {&__pyx_n_s_PYPY_2, __pyx_k_PYPY_2, sizeof(__pyx_k_PYPY_2), 0, 0, 1, 1},
- {&__pyx_n_s_Pyx_CFunc_object____list____ob, __pyx_k_Pyx_CFunc_object____list____ob, sizeof(__pyx_k_Pyx_CFunc_object____list____ob), 0, 0, 1, 1},
- {&__pyx_n_s_Pyx_CFunc_object____list____ob_2, __pyx_k_Pyx_CFunc_object____list____ob_2, sizeof(__pyx_k_Pyx_CFunc_object____list____ob_2), 0, 0, 1, 1},
- {&__pyx_n_s_SpawnedLink, __pyx_k_SpawnedLink, sizeof(__pyx_k_SpawnedLink), 0, 0, 1, 1},
- {&__pyx_kp_s_The_run_argument_or_self__run_mu, __pyx_k_The_run_argument_or_self__run_mu, sizeof(__pyx_k_The_run_argument_or_self__run_mu), 0, 0, 1, 0},
- {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter, __pyx_k_Waiter, sizeof(__pyx_k_Waiter), 0, 0, 1, 1},
- {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
- {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
- {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
- {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
- {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0},
- {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
- {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1},
- {&__pyx_n_s_alive, __pyx_k_alive, sizeof(__pyx_k_alive), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- {&__pyx_n_s_block, __pyx_k_block, sizeof(__pyx_k_block), 0, 0, 1, 1},
- {&__pyx_n_s_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 0, 1, 1},
- {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
- {&__pyx_n_s_cancelled_start_event, __pyx_k_cancelled_start_event, sizeof(__pyx_k_cancelled_start_event), 0, 0, 1, 1},
- {&__pyx_n_s_cb, __pyx_k_cb, sizeof(__pyx_k_cb), 0, 0, 1, 1},
- {&__pyx_n_s_cfunc_to_py, __pyx_k_cfunc_to_py, sizeof(__pyx_k_cfunc_to_py), 0, 0, 1, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
- {&__pyx_n_s_config, __pyx_k_config, sizeof(__pyx_k_config), 0, 0, 1, 1},
- {&__pyx_n_s_continuation, __pyx_k_continuation, sizeof(__pyx_k_continuation), 0, 0, 1, 1},
- {&__pyx_n_s_continulet, __pyx_k_continulet, sizeof(__pyx_k_continulet), 0, 0, 1, 1},
- {&__pyx_n_s_continulet_2, __pyx_k_continulet_2, sizeof(__pyx_k_continulet_2), 0, 0, 1, 1},
- {&__pyx_n_s_count, __pyx_k_count, sizeof(__pyx_k_count), 0, 0, 1, 1},
- {&__pyx_n_s_dead, __pyx_k_dead, sizeof(__pyx_k_dead), 0, 0, 1, 1},
- {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
- {&__pyx_n_s_dummy_event_close, __pyx_k_dummy_event_close, sizeof(__pyx_k_dummy_event_close), 0, 0, 1, 1},
- {&__pyx_n_s_dummy_event_start, __pyx_k_dummy_event_start, sizeof(__pyx_k_dummy_event_start), 0, 0, 1, 1},
- {&__pyx_n_s_dummy_event_stop, __pyx_k_dummy_event_stop, sizeof(__pyx_k_dummy_event_stop), 0, 0, 1, 1},
- {&__pyx_n_s_dump_traceback, __pyx_k_dump_traceback, sizeof(__pyx_k_dump_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
- {&__pyx_n_s_f_back, __pyx_k_f_back, sizeof(__pyx_k_f_back), 0, 0, 1, 1},
- {&__pyx_n_s_f_code, __pyx_k_f_code, sizeof(__pyx_k_f_code), 0, 0, 1, 1},
- {&__pyx_n_s_f_lineno, __pyx_k_f_lineno, sizeof(__pyx_k_f_lineno), 0, 0, 1, 1},
- {&__pyx_n_s_formatinfo, __pyx_k_formatinfo, sizeof(__pyx_k_formatinfo), 0, 0, 1, 1},
- {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_get_2, __pyx_k_get_2, sizeof(__pyx_k_get_2), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_class, __pyx_k_get_hub_class, sizeof(__pyx_k_get_hub_class), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_getframe, __pyx_k_getframe, sizeof(__pyx_k_getframe), 0, 0, 1, 1},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__compat, __pyx_k_gevent__compat, sizeof(__pyx_k_gevent__compat), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__config, __pyx_k_gevent__config, sizeof(__pyx_k_gevent__config), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__greenlet, __pyx_k_gevent__greenlet, sizeof(__pyx_k_gevent__greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_local, __pyx_k_gevent__hub_local, sizeof(__pyx_k_gevent__hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_primitives, __pyx_k_gevent__hub_primitives, sizeof(__pyx_k_gevent__hub_primitives), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__tblib, __pyx_k_gevent__tblib, sizeof(__pyx_k_gevent__tblib), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_glet, __pyx_k_glet, sizeof(__pyx_k_glet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet__init, __pyx_k_greenlet__init, sizeof(__pyx_k_greenlet__init), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_greenlets, __pyx_k_greenlets, sizeof(__pyx_k_greenlets), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_has_links, __pyx_k_has_links, sizeof(__pyx_k_has_links), 0, 0, 1, 1},
- {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_n_s_ident_registry, __pyx_k_ident_registry, sizeof(__pyx_k_ident_registry), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
- {&__pyx_n_s_iwait, __pyx_k_iwait, sizeof(__pyx_k_iwait), 0, 0, 1, 1},
- {&__pyx_n_s_iwait_on_objects, __pyx_k_iwait_on_objects, sizeof(__pyx_k_iwait_on_objects), 0, 0, 1, 1},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_joinall, __pyx_k_joinall, sizeof(__pyx_k_joinall), 0, 0, 1, 1},
- {&__pyx_n_s_kill, __pyx_k_kill, sizeof(__pyx_k_kill), 0, 0, 1, 1},
- {&__pyx_n_s_kill_2, __pyx_k_kill_2, sizeof(__pyx_k_kill_2), 0, 0, 1, 1},
- {&__pyx_n_s_killall, __pyx_k_killall, sizeof(__pyx_k_killall), 0, 0, 1, 1},
- {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_link, __pyx_k_link, sizeof(__pyx_k_link), 0, 0, 1, 1},
- {&__pyx_n_s_link_exception, __pyx_k_link_exception, sizeof(__pyx_k_link_exception), 0, 0, 1, 1},
- {&__pyx_n_s_link_value, __pyx_k_link_value, sizeof(__pyx_k_link_value), 0, 0, 1, 1},
- {&__pyx_n_s_load_traceback, __pyx_k_load_traceback, sizeof(__pyx_k_load_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_minimal_ident, __pyx_k_minimal_ident, sizeof(__pyx_k_minimal_ident), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
- {&__pyx_n_s_nonzero, __pyx_k_nonzero, sizeof(__pyx_k_nonzero), 0, 0, 1, 1},
- {&__pyx_n_s_notify_links, __pyx_k_notify_links, sizeof(__pyx_k_notify_links), 0, 0, 1, 1},
- {&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
- {&__pyx_n_s_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_raise_error, __pyx_k_raise_error, sizeof(__pyx_k_raise_error), 0, 0, 1, 1},
- {&__pyx_n_s_raise_exception, __pyx_k_raise_exception, sizeof(__pyx_k_raise_exception), 0, 0, 1, 1},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_readproperty, __pyx_k_readproperty, sizeof(__pyx_k_readproperty), 0, 0, 1, 1},
- {&__pyx_n_s_ready, __pyx_k_ready, sizeof(__pyx_k_ready), 0, 0, 1, 1},
- {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
- {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
- {&__pyx_n_s_reraise, __pyx_k_reraise, sizeof(__pyx_k_reraise), 0, 0, 1, 1},
- {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
- {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
- {&__pyx_n_s_run, __pyx_k_run, sizeof(__pyx_k_run), 0, 0, 1, 1},
- {&__pyx_n_s_run_2, __pyx_k_run_2, sizeof(__pyx_k_run_2), 0, 0, 1, 1},
- {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1},
- {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_s_at_s, __pyx_k_s_s_at_s, sizeof(__pyx_k_s_s_at_s), 0, 0, 1, 0},
- {&__pyx_n_s_seconds, __pyx_k_seconds, sizeof(__pyx_k_seconds), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_self_2, __pyx_k_self_2, sizeof(__pyx_k_self_2), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
- {&__pyx_n_s_spawn, __pyx_k_spawn, sizeof(__pyx_k_spawn), 0, 0, 1, 1},
- {&__pyx_n_s_spawn_later, __pyx_k_spawn_later, sizeof(__pyx_k_spawn_later), 0, 0, 1, 1},
- {&__pyx_n_s_spawn_tree_locals, __pyx_k_spawn_tree_locals, sizeof(__pyx_k_spawn_tree_locals), 0, 0, 1, 1},
- {&__pyx_n_s_spawning_stack, __pyx_k_spawning_stack, sizeof(__pyx_k_spawning_stack), 0, 0, 1, 1},
- {&__pyx_n_s_spawning_stack_frames, __pyx_k_spawning_stack_frames, sizeof(__pyx_k_spawning_stack_frames), 0, 0, 1, 1},
- {&__pyx_n_s_spawning_stack_limit, __pyx_k_spawning_stack_limit, sizeof(__pyx_k_spawning_stack_limit), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_greenlet_py, __pyx_k_src_gevent_greenlet_py, sizeof(__pyx_k_src_gevent_greenlet_py), 0, 0, 1, 0},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_start_completed_event, __pyx_k_start_completed_event, sizeof(__pyx_k_start_completed_event), 0, 0, 1, 1},
- {&__pyx_n_s_start_later, __pyx_k_start_later, sizeof(__pyx_k_start_later), 0, 0, 1, 1},
- {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1},
- {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
- {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
- {&__pyx_n_s_successful, __pyx_k_successful, sizeof(__pyx_k_successful), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_sys_exc_info, __pyx_k_sys_exc_info, sizeof(__pyx_k_sys_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_sys_getframe, __pyx_k_sys_getframe, sizeof(__pyx_k_sys_getframe), 0, 0, 1, 1},
- {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_threadlocal, __pyx_k_threadlocal, sizeof(__pyx_k_threadlocal), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1},
- {&__pyx_n_s_track_greenlet_tree, __pyx_k_track_greenlet_tree, sizeof(__pyx_k_track_greenlet_tree), 0, 0, 1, 1},
- {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_unlink_all, __pyx_k_unlink_all, sizeof(__pyx_k_unlink_all), 0, 0, 1, 1},
- {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
- {&__pyx_n_s_wait_on_objects, __pyx_k_wait_on_objects, sizeof(__pyx_k_wait_on_objects), 0, 0, 1, 1},
- {&__pyx_n_s_waiter, __pyx_k_waiter, sizeof(__pyx_k_waiter), 0, 0, 1, 1},
- {&__pyx_n_s_waiter_2, __pyx_k_waiter_2, sizeof(__pyx_k_waiter_2), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1},
- {&__pyx_n_s_wref, __pyx_k_wref, sizeof(__pyx_k_wref), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 45, __pyx_L1_error)
- __pyx_builtin_NameError = __Pyx_GetBuiltinName(__pyx_n_s_NameError); if (!__pyx_builtin_NameError) __PYX_ERR(0, 323, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 65, __pyx_L1_error)
- __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 127, __pyx_L1_error)
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 135, __pyx_L1_error)
- __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 251, __pyx_L1_error)
- __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 429, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 429, __pyx_L1_error)
- __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 830, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/greenlet.py":222
- * # itself has never been documented or supported.
- * if not callable(self._run):
- * raise TypeError("The run argument or self._run must be callable") # <<<<<<<<<<<<<<
- *
- * self.args = args
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_The_run_argument_or_self__run_mu); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/greenlet.py":560
- * """
- * if cls is Greenlet and not args and 'run' not in kwargs:
- * raise TypeError("") # <<<<<<<<<<<<<<
- * g = cls(*args, **kwargs)
- * g.start_later(seconds)
- */
- __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s__4); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 560, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
-
- /* "src/gevent/greenlet.py":690
- *
- * def _report_result(self, result):
- * self._exc_info = (None, None, None) # <<<<<<<<<<<<<<
- * self.value = result
- * if self._links and not self._notifier:
- */
- __pyx_tuple__10 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 690, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
-
- /* "src/gevent/greenlet.py":722
- * self._report_result(result)
- * finally:
- * self.__dict__.pop('_run', None) # <<<<<<<<<<<<<<
- * self.args = ()
- * self.kwargs.clear()
- */
- __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_s_run_2, Py_None); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
- __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_run_2, Py_None); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__12);
- __Pyx_GIVEREF(__pyx_tuple__12);
- __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_run_2, Py_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
-
- /* "src/gevent/greenlet.py":830
- *
- * def start(self, cb): # pylint:disable=unused-argument
- * raise AssertionError("Cannot start the dummy event") # <<<<<<<<<<<<<<
- *
- * def close(self):
- */
- __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Cannot_start_the_dummy_event); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 830, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
-
- /* "src/gevent/greenlet.py":846
- * glet.parent.handle_error(glet, *sys_exc_info())
- * if waiter is not None:
- * waiter.switch(None) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple__18 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 846, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
-
- /* "cfunc.to_py":65
- * @cname("__Pyx_CFunc_object____list____object____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object____object___to_py(object (*f)(list, object, object) ):
- * def wrap(list greenlets, object exception, object waiter): # <<<<<<<<<<<<<<
- * """wrap(greenlets: list, exception, waiter)"""
- * return f(greenlets, exception, waiter)
- */
- __pyx_tuple__19 = PyTuple_Pack(3, __pyx_n_s_greenlets, __pyx_n_s_exception, __pyx_n_s_waiter); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(4, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
- __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_wrap, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(4, 65, __pyx_L1_error)
- __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_s_greenlets, __pyx_n_s_exception); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(4, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_wrap, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(4, 65, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":45
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter
- */
- __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
-
- /* "src/gevent/greenlet.py":114
- * class _Frame(object):
- *
- * __slots__ = ('f_code', 'f_lineno', 'f_back') # <<<<<<<<<<<<<<
- *
- * def __init__(self, f_code, f_lineno, f_back):
- */
- __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_f_code, __pyx_n_s_f_lineno, __pyx_n_s_f_back); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__24);
- __Pyx_GIVEREF(__pyx_tuple__24);
-
- /* "src/gevent/greenlet.py":268
- *
- * @Lazy
- * def spawning_stack(self): # <<<<<<<<<<<<<<
- * # Store this in the __dict__. We don't use it from the C
- * # code. It's tempting to discard _spawning_stack_frames
- */
- __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__25);
- __Pyx_GIVEREF(__pyx_tuple__25);
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_spawning_stack, 268, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 268, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":301
- *
- * @readproperty
- * def name(self): # <<<<<<<<<<<<<<
- * """
- * The greenlet name. By default, a unique name is constructed using
- */
- __pyx_tuple__27 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 301, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__27);
- __Pyx_GIVEREF(__pyx_tuple__27);
- __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_name_2, 301, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 301, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":311
- * return 'Greenlet-%d' % (self.minimal_ident)
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
- __pyx_tuple__29 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 311, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__29);
- __Pyx_GIVEREF(__pyx_tuple__29);
- __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_raise_exception, 311, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 311, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":402
- * return bool(self)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished
- */
- __pyx_tuple__31 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__31);
- __Pyx_GIVEREF(__pyx_tuple__31);
- __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_ready, 402, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 402, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":413
- * return self.dead or self._exc_info is not None
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished execution
- */
- __pyx_tuple__33 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__33);
- __Pyx_GIVEREF(__pyx_tuple__33);
- __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_successful, 413, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 413, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":436
- *
- *
- * def _formatinfo(self): # <<<<<<<<<<<<<<
- * info = self._formatted_info
- * if info is not None:
- */
- __pyx_tuple__35 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__35);
- __Pyx_GIVEREF(__pyx_tuple__35);
- __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_formatinfo, 436, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 436, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":486
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- * def throw(self, *args): # <<<<<<<<<<<<<<
- * """Immediately switch into the greenlet and raise an exception in it.
- *
- */
- __pyx_tuple__37 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_args); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 486, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__37);
- __Pyx_GIVEREF(__pyx_tuple__37);
- __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_throw, 486, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 486, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":508
- * self.__handle_death_before_start(args)
- *
- * def start(self): # <<<<<<<<<<<<<<
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None:
- */
- __pyx_tuple__39 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 508, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__39);
- __Pyx_GIVEREF(__pyx_tuple__39);
- __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_start, 508, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 508, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":513
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- * def start_later(self, seconds): # <<<<<<<<<<<<<<
- * """
- * start_later(seconds) -> None
- */
- __pyx_tuple__41 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_seconds); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__41);
- __Pyx_GIVEREF(__pyx_tuple__41);
- __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_start_later, 513, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 513, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":525
- *
- * @classmethod
- * def spawn(cls, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn(function, *args, **kwargs) -> Greenlet
- */
- __pyx_tuple__43 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_g); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__43);
- __Pyx_GIVEREF(__pyx_tuple__43);
- __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_spawn, 525, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 525, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":543
- *
- * @classmethod
- * def spawn_later(cls, seconds, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn_later(seconds, function, *args, **kwargs) -> Greenlet
- */
- __pyx_tuple__45 = PyTuple_Pack(5, __pyx_n_s_cls, __pyx_n_s_seconds, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_g); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__45);
- __Pyx_GIVEREF(__pyx_tuple__45);
- __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_spawn_later, 543, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 543, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":565
- * return g
- *
- * def kill(self, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Raise the ``exception`` in the greenlet.
- */
- __pyx_tuple__47 = PyTuple_Pack(5, __pyx_n_s_self_2, __pyx_n_s_exception, __pyx_n_s_block, __pyx_n_s_timeout, __pyx_n_s_waiter); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 565, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__47);
- __Pyx_GIVEREF(__pyx_tuple__47);
- __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_kill_2, 565, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 565, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":617
- * # thus it should not raise when the greenlet is already killed (= not started)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * get(block=True, timeout=None) -> object
- */
- __pyx_tuple__49 = PyTuple_Pack(6, __pyx_n_s_self_2, __pyx_n_s_block, __pyx_n_s_timeout, __pyx_n_s_switch, __pyx_n_s_t, __pyx_n_s_result); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 617, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__49);
- __Pyx_GIVEREF(__pyx_tuple__49);
- __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_get_2, 617, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 617, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":661
- * self._raise_exception()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * join(timeout=None) -> None
- */
- __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__51);
- __Pyx_GIVEREF(__pyx_tuple__51);
- __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_join, 661, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 661, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":710
- * del exc_info
- *
- * def run(self): # <<<<<<<<<<<<<<
- * try:
- * self.__cancel_start()
- */
- __pyx_tuple__53 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_result); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 710, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__53);
- __Pyx_GIVEREF(__pyx_tuple__53);
- __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_run, 710, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 710, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":726
- * self.kwargs.clear()
- *
- * def _run(self): # <<<<<<<<<<<<<<
- * """
- * Subclasses may override this method to take any number of
- */
- __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 726, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__55);
- __Pyx_GIVEREF(__pyx_tuple__55);
- __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_run_2, 726, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 726, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":740
- * return
- *
- * def has_links(self): # <<<<<<<<<<<<<<
- * return len(self._links)
- *
- */
- __pyx_tuple__57 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__57);
- __Pyx_GIVEREF(__pyx_tuple__57);
- __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_has_links, 740, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 740, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":743
- * return len(self._links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callable to be executed when the greenlet finishes
- */
- __pyx_tuple__59 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__59);
- __Pyx_GIVEREF(__pyx_tuple__59);
- __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_rawlink, 743, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 743, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":759
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def link(self, callback, SpawnedLink=SpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Link greenlet's completion to a callable.
- */
- __pyx_tuple__61 = PyTuple_Pack(3, __pyx_n_s_self_2, __pyx_n_s_callback, __pyx_n_s_SpawnedLink); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 759, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__61);
- __Pyx_GIVEREF(__pyx_tuple__61);
- __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_link, 759, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 759, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":773
- * self.rawlink(SpawnedLink(callback))
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try:
- */
- __pyx_tuple__63 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 773, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__63);
- __Pyx_GIVEREF(__pyx_tuple__63);
- __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_unlink, 773, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 773, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":780
- * pass
- *
- * def unlink_all(self): # <<<<<<<<<<<<<<
- * """
- * Remove all the callbacks.
- */
- __pyx_tuple__65 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 780, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__65);
- __Pyx_GIVEREF(__pyx_tuple__65);
- __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_unlink_all, 780, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 780, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":788
- * del self._links[:]
- *
- * def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the greenlet
- */
- __pyx_tuple__67 = PyTuple_Pack(3, __pyx_n_s_self_2, __pyx_n_s_callback, __pyx_n_s_SpawnedLink); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 788, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__67);
- __Pyx_GIVEREF(__pyx_tuple__67);
- __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_link_value, 788, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 788, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":796
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the
- */
- __pyx_tuple__69 = PyTuple_Pack(3, __pyx_n_s_self_2, __pyx_n_s_callback, __pyx_n_s_SpawnedLink); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 796, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__69);
- __Pyx_GIVEREF(__pyx_tuple__69);
- __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_link_exception, 796, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 796, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":804
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * while self._links:
- * # Early links are allowed to remove later links
- */
- __pyx_tuple__71 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__71);
- __Pyx_GIVEREF(__pyx_tuple__71);
- __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_notify_links, 804, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 804, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":821
- *
- * class _dummy_event(object):
- * __slots__ = ('pending', 'active') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- __pyx_tuple__73 = PyTuple_Pack(2, __pyx_n_s_pending, __pyx_n_s_active); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 821, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__73);
- __Pyx_GIVEREF(__pyx_tuple__73);
-
- /* "src/gevent/greenlet.py":826
- * self.pending = self.active = False
- *
- * def stop(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_tuple__74 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 826, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__74);
- __Pyx_GIVEREF(__pyx_tuple__74);
- __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_stop, 826, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(0, 826, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":829
- * pass
- *
- * def start(self, cb): # pylint:disable=unused-argument # <<<<<<<<<<<<<<
- * raise AssertionError("Cannot start the dummy event")
- *
- */
- __pyx_tuple__76 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_cb); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 829, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__76);
- __Pyx_GIVEREF(__pyx_tuple__76);
- __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_start, 829, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) __PYX_ERR(0, 829, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":832
- * raise AssertionError("Cannot start the dummy event")
- *
- * def close(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_tuple__78 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 832, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__78);
- __Pyx_GIVEREF(__pyx_tuple__78);
- __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__78, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_close, 832, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 832, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":839
- *
- *
- * def _kill(glet, exception, waiter): # <<<<<<<<<<<<<<
- * try:
- * glet.throw(exception)
- */
- __pyx_tuple__80 = PyTuple_Pack(3, __pyx_n_s_glet, __pyx_n_s_exception, __pyx_n_s_waiter); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 839, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__80);
- __Pyx_GIVEREF(__pyx_tuple__80);
- __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_kill, 839, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 839, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":849
- *
- *
- * def joinall(greenlets, timeout=None, raise_error=False, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for the ``greenlets`` to finish.
- */
- __pyx_tuple__82 = PyTuple_Pack(4, __pyx_n_s_greenlets, __pyx_n_s_timeout, __pyx_n_s_raise_error, __pyx_n_s_count); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 849, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__82);
- __Pyx_GIVEREF(__pyx_tuple__82);
- __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__82, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_joinall, 849, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 849, __pyx_L1_error)
-
- /* "src/gevent/greenlet.py":894
- *
- *
- * def killall(greenlets, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
- */
- __pyx_tuple__84 = PyTuple_Pack(8, __pyx_n_s_greenlets, __pyx_n_s_exception, __pyx_n_s_block, __pyx_n_s_timeout, __pyx_n_s_loop, __pyx_n_s_waiter, __pyx_n_s_t, __pyx_n_s_alive); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__84);
- __Pyx_GIVEREF(__pyx_tuple__84);
- __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_greenlet_py, __pyx_n_s_killall, 894, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_9_greenlet_sys_getframe = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_sys_exc_info = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_Timeout = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_GreenletExit = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_InvalidSwitchError = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet__greenlet__init__ = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet__threadlocal = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_get_hub_class = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_wref = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_dump_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_load_traceback = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_wait = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_iwait = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_reraise = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet_GEVENT_CONFIG = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet__cancelled_start_event = ((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)Py_None); Py_INCREF(Py_None);
- __pyx_v_6gevent_9_greenlet__start_completed_event = ((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)Py_None); Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_PYPY, (void *)&__pyx_v_6gevent_9_greenlet__PYPY, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_sys_getframe, (void *)&__pyx_v_6gevent_9_greenlet_sys_getframe, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_sys_exc_info, (void *)&__pyx_v_6gevent_9_greenlet_sys_exc_info, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_Timeout, (void *)&__pyx_v_6gevent_9_greenlet_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_GreenletExit, (void *)&__pyx_v_6gevent_9_greenlet_GreenletExit, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_InvalidSwitchError, (void *)&__pyx_v_6gevent_9_greenlet_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_9_greenlet__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet__init, (void *)&__pyx_v_6gevent_9_greenlet__greenlet__init__, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_threadlocal, (void *)&__pyx_v_6gevent_9_greenlet__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_get_hub_class, (void *)&__pyx_v_6gevent_9_greenlet_get_hub_class, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_wref, (void *)&__pyx_v_6gevent_9_greenlet_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_dump_traceback, (void *)&__pyx_v_6gevent_9_greenlet_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_load_traceback, (void *)&__pyx_v_6gevent_9_greenlet_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_wait, (void *)&__pyx_v_6gevent_9_greenlet_wait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_iwait, (void *)&__pyx_v_6gevent_9_greenlet_iwait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_reraise, (void *)&__pyx_v_6gevent_9_greenlet_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_GEVENT_CONFIG, (void *)&__pyx_v_6gevent_9_greenlet_GEVENT_CONFIG, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_cancelled_start_event, (void *)&__pyx_v_6gevent_9_greenlet__cancelled_start_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_start_completed_event, (void *)&__pyx_v_6gevent_9_greenlet__start_completed_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_init", (void (*)(void))__pyx_f_6gevent_9_greenlet__init, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_extract_stack", (void (*)(void))__pyx_f_6gevent_9_greenlet__extract_stack, "PyObject *(int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_Frame_from_list", (void (*)(void))__pyx_f_6gevent_9_greenlet__Frame_from_list, "struct __pyx_obj_6gevent_9_greenlet__Frame *(PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_killall3", (void (*)(void))__pyx_f_6gevent_9_greenlet__killall3, "PyObject *(PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_killall", (void (*)(void))__pyx_f_6gevent_9_greenlet__killall, "PyObject *(PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("joinall", (void (*)(void))__pyx_f_6gevent_9_greenlet_joinall, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_joinall *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_9_greenlet_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_greenlet)) __PYX_ERR(1, 17, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_CodeType = __Pyx_ImportType("types", "CodeType", sizeof(PyCodeObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_CodeType)) __PYX_ERR(1, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FrameType = __Pyx_ImportType("types", "FrameType", sizeof(PyFrameObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_FrameType)) __PYX_ERR(1, 45, __pyx_L1_error)
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet_SpawnedLink) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet_SpawnedLink.tp_print = 0;
- if (PyObject_SetAttrString(__pyx_m, "SpawnedLink", (PyObject *)&__pyx_type_6gevent_9_greenlet_SpawnedLink) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SpawnedLink = &__pyx_type_6gevent_9_greenlet_SpawnedLink;
- __pyx_type_6gevent_9_greenlet_SuccessSpawnedLink.tp_base = __pyx_ptype_6gevent_9_greenlet_SpawnedLink;
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet_SuccessSpawnedLink) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet_SuccessSpawnedLink.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_9_greenlet_SuccessSpawnedLink.tp_dictoffset && __pyx_type_6gevent_9_greenlet_SuccessSpawnedLink.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_9_greenlet_SuccessSpawnedLink.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "SuccessSpawnedLink", (PyObject *)&__pyx_type_6gevent_9_greenlet_SuccessSpawnedLink) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = &__pyx_type_6gevent_9_greenlet_SuccessSpawnedLink;
- __pyx_type_6gevent_9_greenlet_FailureSpawnedLink.tp_base = __pyx_ptype_6gevent_9_greenlet_SpawnedLink;
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet_FailureSpawnedLink) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet_FailureSpawnedLink.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_9_greenlet_FailureSpawnedLink.tp_dictoffset && __pyx_type_6gevent_9_greenlet_FailureSpawnedLink.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_9_greenlet_FailureSpawnedLink.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "FailureSpawnedLink", (PyObject *)&__pyx_type_6gevent_9_greenlet_FailureSpawnedLink) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = &__pyx_type_6gevent_9_greenlet_FailureSpawnedLink;
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet__Frame) < 0) __PYX_ERR(0, 112, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet__Frame.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_9_greenlet__Frame.tp_dictoffset && __pyx_type_6gevent_9_greenlet__Frame.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_9_greenlet__Frame.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_Frame", (PyObject *)&__pyx_type_6gevent_9_greenlet__Frame) < 0) __PYX_ERR(0, 112, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__Frame = &__pyx_type_6gevent_9_greenlet__Frame;
- __pyx_vtabptr_6gevent_9_greenlet_Greenlet = &__pyx_vtable_6gevent_9_greenlet_Greenlet;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.has_links = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet_has_links;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.join = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args))__pyx_f_6gevent_9_greenlet_8Greenlet_join;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.ready = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet_ready;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.successful = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet_successful;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.rawlink = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet_rawlink;
- __pyx_vtable_6gevent_9_greenlet_Greenlet._formatinfo = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet__formatinfo;
- __pyx_vtable_6gevent_9_greenlet_Greenlet._get_minimal_ident = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet__get_minimal_ident;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___started_but_aborted = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___started_but_aborted;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___start_cancelled_by_kill = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___start_cancelled_by_kill;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___start_pending = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___start_pending;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___never_started_or_killed = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___never_started_or_killed;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___start_completed = (int (*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___start_completed;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___handle_death_before_start = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *))__pyx_f_6gevent_9_greenlet_8Greenlet___handle_death_before_start;
- __pyx_vtable_6gevent_9_greenlet_Greenlet.__pyx___cancel_start = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *))__pyx_f_6gevent_9_greenlet_8Greenlet___cancel_start;
- __pyx_vtable_6gevent_9_greenlet_Greenlet._report_result = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *))__pyx_f_6gevent_9_greenlet_8Greenlet__report_result;
- __pyx_vtable_6gevent_9_greenlet_Greenlet._report_error = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *))__pyx_f_6gevent_9_greenlet_8Greenlet__report_error;
- __pyx_vtable_6gevent_9_greenlet_Greenlet._notify_links = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_8Greenlet__notify_links;
- __pyx_type_6gevent_9_greenlet_Greenlet.tp_base = __pyx_ptype_6gevent_9_greenlet_greenlet;
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet_Greenlet) < 0) __PYX_ERR(0, 157, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet_Greenlet.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_9_greenlet_Greenlet.tp_dictoffset && __pyx_type_6gevent_9_greenlet_Greenlet.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_9_greenlet_Greenlet.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- #if CYTHON_COMPILING_IN_CPYTHON
- {
- PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gevent_9_greenlet_Greenlet, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 157, __pyx_L1_error)
- if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
- __pyx_wrapperbase_6gevent_9_greenlet_8Greenlet___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
- __pyx_wrapperbase_6gevent_9_greenlet_8Greenlet___init__.doc = __pyx_doc_6gevent_9_greenlet_8Greenlet___init__;
- ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gevent_9_greenlet_8Greenlet___init__;
- }
- }
- #endif
- if (__Pyx_SetVtable(__pyx_type_6gevent_9_greenlet_Greenlet.tp_dict, __pyx_vtabptr_6gevent_9_greenlet_Greenlet) < 0) __PYX_ERR(0, 157, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Greenlet", (PyObject *)&__pyx_type_6gevent_9_greenlet_Greenlet) < 0) __PYX_ERR(0, 157, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_Greenlet = &__pyx_type_6gevent_9_greenlet_Greenlet;
- __pyx_vtabptr_6gevent_9_greenlet__dummy_event = &__pyx_vtable_6gevent_9_greenlet__dummy_event;
- __pyx_vtable_6gevent_9_greenlet__dummy_event.stop = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_12_dummy_event_stop;
- __pyx_vtable_6gevent_9_greenlet__dummy_event.start = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_12_dummy_event_start;
- __pyx_vtable_6gevent_9_greenlet__dummy_event.close = (PyObject *(*)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch))__pyx_f_6gevent_9_greenlet_12_dummy_event_close;
- if (PyType_Ready(&__pyx_type_6gevent_9_greenlet__dummy_event) < 0) __PYX_ERR(0, 820, __pyx_L1_error)
- __pyx_type_6gevent_9_greenlet__dummy_event.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_9_greenlet__dummy_event.tp_dictoffset && __pyx_type_6gevent_9_greenlet__dummy_event.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_9_greenlet__dummy_event.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_9_greenlet__dummy_event.tp_dict, __pyx_vtabptr_6gevent_9_greenlet__dummy_event) < 0) __PYX_ERR(0, 820, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "_dummy_event", (PyObject *)&__pyx_type_6gevent_9_greenlet__dummy_event) < 0) __PYX_ERR(0, 820, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__dummy_event = &__pyx_type_6gevent_9_greenlet__dummy_event;
- if (PyType_Ready(&__pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py) < 0) __PYX_ERR(4, 64, __pyx_L1_error)
- __pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py.tp_dictoffset && __pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- __pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py = &__pyx_scope_struct____Pyx_CFunc_object____list____object____object___to_py;
- if (PyType_Ready(&__pyx_scope_struct____Pyx_CFunc_object____list____object___to_py) < 0) __PYX_ERR(4, 64, __pyx_L1_error)
- __pyx_scope_struct____Pyx_CFunc_object____list____object___to_py.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_scope_struct____Pyx_CFunc_object____list____object___to_py.tp_dictoffset && __pyx_scope_struct____Pyx_CFunc_object____list____object___to_py.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_scope_struct____Pyx_CFunc_object____list____object___to_py.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- __pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____list____object___to_py = &__pyx_scope_struct____Pyx_CFunc_object____list____object___to_py;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_7__ident_ref = __Pyx_ImportType("weakref", "ref", sizeof(PyWeakReference), 0); if (unlikely(!__pyx_ptype_6gevent_7__ident_ref)) __PYX_ERR(5, 5, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_ValuedWeakRef = __Pyx_ImportType("gevent.__ident", "ValuedWeakRef", sizeof(struct __pyx_obj_6gevent_7__ident_ValuedWeakRef), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_ValuedWeakRef)) __PYX_ERR(5, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_IdentRegistry = __Pyx_ImportType("gevent.__ident", "IdentRegistry", sizeof(struct __pyx_obj_6gevent_7__ident_IdentRegistry), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_IdentRegistry)) __PYX_ERR(5, 19, __pyx_L1_error)
- __pyx_vtabptr_6gevent_7__ident_IdentRegistry = (struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry*)__Pyx_GetVtable(__pyx_ptype_6gevent_7__ident_IdentRegistry->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_7__ident_IdentRegistry)) __PYX_ERR(5, 19, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(2, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(2, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(3, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_Waiter = __Pyx_ImportType("gevent.__waiter", "Waiter", sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_Waiter)) __PYX_ERR(3, 33, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_Waiter)) __PYX_ERR(3, 33, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = __Pyx_ImportType("gevent.__waiter", "MultipleWaiter", sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = (struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__ident"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappop", (void **)&__pyx_vp_6gevent_7__ident_heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappush", (void **)&__pyx_vp_6gevent_7__ident_heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "WeakKeyDictionary", (void **)&__pyx_vp_6gevent_7__ident_WeakKeyDictionary, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = __Pyx_ImportModule("gevent.__waiter"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "sys", (void **)&__pyx_vp_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "ConcurrentObjectUseError", (void **)&__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_greenlet_imported", (void **)&__pyx_vp_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_NONE", (void **)&__pyx_vp_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init_greenlet(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init_greenlet(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit__greenlet(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit__greenlet(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec__greenlet(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_t_10;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__greenlet(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("_greenlet", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent___greenlet) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent._greenlet")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent._greenlet", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/greenlet.py":6
- * from __future__ import absolute_import, print_function, division
- *
- * from sys import _getframe as sys_getframe # <<<<<<<<<<<<<<
- * from sys import exc_info as sys_exc_info
- * from weakref import ref as wref
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_getframe);
- __Pyx_GIVEREF(__pyx_n_s_getframe);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_getframe);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_getframe); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_sys_getframe);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_sys_getframe, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":7
- *
- * from sys import _getframe as sys_getframe
- * from sys import exc_info as sys_exc_info # <<<<<<<<<<<<<<
- * from weakref import ref as wref
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_exc_info);
- __Pyx_GIVEREF(__pyx_n_s_exc_info);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_exc_info);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_sys_exc_info);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_sys_exc_info, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":8
- * from sys import _getframe as sys_getframe
- * from sys import exc_info as sys_exc_info
- * from weakref import ref as wref # <<<<<<<<<<<<<<
- *
- * # XXX: How to get cython to let us rename this as RawGreenlet
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_ref);
- __Pyx_GIVEREF(__pyx_n_s_ref);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ref);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_wref);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_wref, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":12
- * # XXX: How to get cython to let us rename this as RawGreenlet
- * # like we prefer?
- * from greenlet import greenlet # <<<<<<<<<<<<<<
- * from greenlet import GreenletExit
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_greenlet);
- __Pyx_GIVEREF(__pyx_n_s_greenlet);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_greenlet);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":13
- * # like we prefer?
- * from greenlet import greenlet
- * from greenlet import GreenletExit # <<<<<<<<<<<<<<
- *
- * from gevent._compat import reraise
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_GreenletExit);
- __Pyx_GIVEREF(__pyx_n_s_GreenletExit);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_GreenletExit);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_GreenletExit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_GreenletExit, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":15
- * from greenlet import GreenletExit
- *
- * from gevent._compat import reraise # <<<<<<<<<<<<<<
- * from gevent._compat import PYPY as _PYPY
- * from gevent._tblib import dump_traceback
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_reraise);
- __Pyx_GIVEREF(__pyx_n_s_reraise);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_reraise);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_reraise); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_reraise);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_reraise, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":16
- *
- * from gevent._compat import reraise
- * from gevent._compat import PYPY as _PYPY # <<<<<<<<<<<<<<
- * from gevent._tblib import dump_traceback
- * from gevent._tblib import load_traceback
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_PYPY_2);
- __Pyx_GIVEREF(__pyx_n_s_PYPY_2);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PYPY_2);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_PYPY_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L1_error)
- __pyx_v_6gevent_9_greenlet__PYPY = __pyx_t_3;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":17
- * from gevent._compat import reraise
- * from gevent._compat import PYPY as _PYPY
- * from gevent._tblib import dump_traceback # <<<<<<<<<<<<<<
- * from gevent._tblib import load_traceback
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_dump_traceback);
- __Pyx_GIVEREF(__pyx_n_s_dump_traceback);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_dump_traceback);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__tblib, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_dump_traceback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_dump_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_dump_traceback, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":18
- * from gevent._compat import PYPY as _PYPY
- * from gevent._tblib import dump_traceback
- * from gevent._tblib import load_traceback # <<<<<<<<<<<<<<
- *
- * from gevent.exceptions import InvalidSwitchError
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_load_traceback);
- __Pyx_GIVEREF(__pyx_n_s_load_traceback);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_load_traceback);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__tblib, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_load_traceback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_load_traceback);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_load_traceback, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":20
- * from gevent._tblib import load_traceback
- *
- * from gevent.exceptions import InvalidSwitchError # <<<<<<<<<<<<<<
- *
- * from gevent._hub_primitives import iwait_on_objects as iwait
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_InvalidSwitchError);
- __Pyx_GIVEREF(__pyx_n_s_InvalidSwitchError);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_InvalidSwitchError);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_InvalidSwitchError);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_InvalidSwitchError, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":22
- * from gevent.exceptions import InvalidSwitchError
- *
- * from gevent._hub_primitives import iwait_on_objects as iwait # <<<<<<<<<<<<<<
- * from gevent._hub_primitives import wait_on_objects as wait
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_iwait_on_objects);
- __Pyx_GIVEREF(__pyx_n_s_iwait_on_objects);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_iwait_on_objects);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__hub_primitives, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_iwait_on_objects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_iwait);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_iwait, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":23
- *
- * from gevent._hub_primitives import iwait_on_objects as iwait
- * from gevent._hub_primitives import wait_on_objects as wait # <<<<<<<<<<<<<<
- *
- * from gevent.timeout import Timeout
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_wait_on_objects);
- __Pyx_GIVEREF(__pyx_n_s_wait_on_objects);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_wait_on_objects);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__hub_primitives, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_wait_on_objects); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_wait);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_wait, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":25
- * from gevent._hub_primitives import wait_on_objects as wait
- *
- * from gevent.timeout import Timeout # <<<<<<<<<<<<<<
- *
- * from gevent._config import config as GEVENT_CONFIG
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Timeout);
- __Pyx_GIVEREF(__pyx_n_s_Timeout);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Timeout);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_Timeout);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_Timeout, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":27
- * from gevent.timeout import Timeout
- *
- * from gevent._config import config as GEVENT_CONFIG # <<<<<<<<<<<<<<
- * from gevent._util import Lazy
- * from gevent._util import readproperty
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_config);
- __Pyx_GIVEREF(__pyx_n_s_config);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_config);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__config, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_config); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet_GEVENT_CONFIG);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet_GEVENT_CONFIG, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":28
- *
- * from gevent._config import config as GEVENT_CONFIG
- * from gevent._util import Lazy # <<<<<<<<<<<<<<
- * from gevent._util import readproperty
- * from gevent._hub_local import get_hub_noargs as get_hub
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Lazy);
- __Pyx_GIVEREF(__pyx_n_s_Lazy);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Lazy);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Lazy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Lazy, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":29
- * from gevent._config import config as GEVENT_CONFIG
- * from gevent._util import Lazy
- * from gevent._util import readproperty # <<<<<<<<<<<<<<
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from gevent import _waiter
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_readproperty);
- __Pyx_GIVEREF(__pyx_n_s_readproperty);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_readproperty);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_readproperty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_readproperty, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":30
- * from gevent._util import Lazy
- * from gevent._util import readproperty
- * from gevent._hub_local import get_hub_noargs as get_hub # <<<<<<<<<<<<<<
- * from gevent import _waiter
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_hub_noargs);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":31
- * from gevent._util import readproperty
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from gevent import _waiter # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_waiter_2);
- __Pyx_GIVEREF(__pyx_n_s_waiter_2);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_waiter_2);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_waiter_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_waiter_2, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":34
- *
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * 'Greenlet',
- * 'joinall',
- */
- __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Greenlet);
- __Pyx_GIVEREF(__pyx_n_s_Greenlet);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Greenlet);
- __Pyx_INCREF(__pyx_n_s_joinall);
- __Pyx_GIVEREF(__pyx_n_s_joinall);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_joinall);
- __Pyx_INCREF(__pyx_n_s_killall);
- __Pyx_GIVEREF(__pyx_n_s_killall);
- PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_killall);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":45
- * # is assignment) without generating a 'lvalue is not valid target'
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_getcurrent, __pyx_t_2) < 0)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":46
- * # error.
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- * locals()['Waiter'] = _waiter.Waiter
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_6lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_greenlet_init, __pyx_t_2) < 0)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":47
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None
- * locals()['Waiter'] = _waiter.Waiter # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_waiter_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Waiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(PyDict_SetItem(__pyx_t_2, __pyx_n_s_Waiter, __pyx_t_1) < 0)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":50
- *
- *
- * if _PYPY: # <<<<<<<<<<<<<<
- * import _continuation # pylint:disable=import-error
- * _continulet = _continuation.continulet
- */
- __pyx_t_3 = (__pyx_v_6gevent_9_greenlet__PYPY != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":51
- *
- * if _PYPY:
- * import _continuation # pylint:disable=import-error # <<<<<<<<<<<<<<
- * _continulet = _continuation.continulet
- *
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_continuation, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_continuation, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":52
- * if _PYPY:
- * import _continuation # pylint:disable=import-error
- * _continulet = _continuation.continulet # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_continuation); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_continulet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_continulet_2, __pyx_t_2) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":50
- *
- *
- * if _PYPY: # <<<<<<<<<<<<<<
- * import _continuation # pylint:disable=import-error
- * _continulet = _continuation.continulet
- */
- }
-
- /* "src/gevent/greenlet.py":61
- * Can be called only from main loop.
- * """
- * __slots__ = ['callback'] # <<<<<<<<<<<<<<
- *
- * def __init__(self, callback):
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_callback);
- __Pyx_GIVEREF(__pyx_n_s_callback);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_callback);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_SpawnedLink->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_SpawnedLink);
-
- /* "src/gevent/greenlet.py":94
- * Can be called only from main loop.
- * """
- * __slots__ = [] # <<<<<<<<<<<<<<
- *
- * def __call__(self, source):
- */
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink);
-
- /* "src/gevent/greenlet.py":106
- * Can be called only from main loop.
- * """
- * __slots__ = [] # <<<<<<<<<<<<<<
- *
- * def __call__(self, source):
- */
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink);
-
- /* "src/gevent/greenlet.py":114
- * class _Frame(object):
- *
- * __slots__ = ('f_code', 'f_lineno', 'f_back') # <<<<<<<<<<<<<<
- *
- * def __init__(self, f_code, f_lineno, f_back):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet__Frame->tp_dict, __pyx_n_s_slots, __pyx_tuple__24) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet__Frame);
-
- /* "src/gevent/greenlet.py":155
- *
- *
- * _greenlet__init__ = greenlet.__init__ # <<<<<<<<<<<<<<
- *
- * class Greenlet(greenlet):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_9_greenlet_greenlet), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_9_greenlet__greenlet__init__);
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet__greenlet__init__, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":163
- * # pylint:disable=too-many-public-methods,too-many-instance-attributes
- *
- * spawning_stack_limit = 10 # <<<<<<<<<<<<<<
- *
- * # pylint:disable=keyword-arg-before-vararg,super-init-not-called
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawning_stack_limit, __pyx_int_10) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":268
- *
- * @Lazy
- * def spawning_stack(self): # <<<<<<<<<<<<<<
- * # Store this in the __dict__. We don't use it from the C
- * # code. It's tempting to discard _spawning_stack_frames
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_3spawning_stack, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_spawning_stack, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawning_stack, __pyx_t_2) < 0) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":267
- * self._spawning_stack_frames = None
- *
- * @Lazy # <<<<<<<<<<<<<<
- * def spawning_stack(self):
- * # Store this in the __dict__. We don't use it from the C
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Lazy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
-
- /* "src/gevent/greenlet.py":268
- *
- * @Lazy
- * def spawning_stack(self): # <<<<<<<<<<<<<<
- * # Store this in the __dict__. We don't use it from the C
- * # code. It's tempting to discard _spawning_stack_frames
- */
- __pyx_t_4 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet, __pyx_n_s_spawning_stack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_5) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawning_stack, __pyx_t_2) < 0) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":301
- *
- * @readproperty
- * def name(self): # <<<<<<<<<<<<<<
- * """
- * The greenlet name. By default, a unique name is constructed using
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_5name, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_name, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_name_2, __pyx_t_2) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":300
- * return self._ident
- *
- * @readproperty # <<<<<<<<<<<<<<
- * def name(self):
- * """
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_readproperty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
-
- /* "src/gevent/greenlet.py":301
- *
- * @readproperty
- * def name(self): # <<<<<<<<<<<<<<
- * """
- * The greenlet name. By default, a unique name is constructed using
- */
- __pyx_t_6 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet, __pyx_n_s_name_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 301, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
- __pyx_t_6 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_name_2, __pyx_t_2) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":311
- * return 'Greenlet-%d' % (self.minimal_ident)
- *
- * def _raise_exception(self): # <<<<<<<<<<<<<<
- * reraise(*self.exc_info)
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_7_raise_exception, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet__raise_exception, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_raise_exception, __pyx_t_2) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":321
- * def __nonzero__(self):
- * return self._start_event is not None and self._exc_info is None
- * try: # <<<<<<<<<<<<<<
- * __bool__ = __nonzero__ # Python 3
- * except NameError: # pragma: no cover
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- /*try:*/ {
-
- /* "src/gevent/greenlet.py":322
- * return self._start_event is not None and self._exc_info is None
- * try:
- * __bool__ = __nonzero__ # Python 3 # <<<<<<<<<<<<<<
- * except NameError: # pragma: no cover
- * # When we're compiled with Cython, the __nonzero__ function
- */
- __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_bool, __pyx_t_2) < 0) __PYX_ERR(0, 322, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":321
- * def __nonzero__(self):
- * return self._start_event is not None and self._exc_info is None
- * try: # <<<<<<<<<<<<<<
- * __bool__ = __nonzero__ # Python 3
- * except NameError: # pragma: no cover
- */
- }
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":323
- * try:
- * __bool__ = __nonzero__ # Python 3
- * except NameError: # pragma: no cover # <<<<<<<<<<<<<<
- * # When we're compiled with Cython, the __nonzero__ function
- * # goes directly into the slot and can't be accessed by name.
- */
- __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NameError);
- if (__pyx_t_10) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/greenlet.py":321
- * def __nonzero__(self):
- * return self._start_event is not None and self._exc_info is None
- * try: # <<<<<<<<<<<<<<
- * __bool__ = __nonzero__ # Python 3
- * except NameError: # pragma: no cover
- */
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/greenlet.py":330
- * ### Lifecycle
- *
- * if _PYPY: # <<<<<<<<<<<<<<
- * # oops - pypy's .dead relies on __nonzero__ which we overriden above
- * @property
- */
- __pyx_t_3 = (__pyx_v_6gevent_9_greenlet__PYPY != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/greenlet.py":343
- * else:
- * @property
- * def dead(self): # <<<<<<<<<<<<<<
- * "Boolean indicating that the greenlet is dead and will not run again."
- * return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
- */
- goto __pyx_L9;
- }
- /*else*/ {
- }
- __pyx_L9:;
-
- /* "src/gevent/greenlet.py":402
- * return bool(self)
- *
- * def ready(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_11ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_ready, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":413
- * return self.dead or self._exc_info is not None
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * """
- * Return a true value if and only if the greenlet has finished execution
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_13successful, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_successful, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_successful, __pyx_t_2) < 0) __PYX_ERR(0, 413, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":436
- *
- *
- * def _formatinfo(self): # <<<<<<<<<<<<<<
- * info = self._formatted_info
- * if info is not None:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_17_formatinfo, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet__formatinfo, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_formatinfo, __pyx_t_2) < 0) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":486
- * return (ei[0], ei[1], load_traceback(ei[2]))
- *
- * def throw(self, *args): # <<<<<<<<<<<<<<
- * """Immediately switch into the greenlet and raise an exception in it.
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_19throw, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_throw, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 486, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_throw, __pyx_t_2) < 0) __PYX_ERR(0, 486, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":508
- * self.__handle_death_before_start(args)
- *
- * def start(self): # <<<<<<<<<<<<<<
- * """Schedule the greenlet to run in this loop iteration"""
- * if self._start_event is None:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_21start, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_start, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 508, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_start, __pyx_t_2) < 0) __PYX_ERR(0, 508, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":513
- * self._start_event = self.parent.loop.run_callback(self.switch)
- *
- * def start_later(self, seconds): # <<<<<<<<<<<<<<
- * """
- * start_later(seconds) -> None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_23start_later, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_start_later, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_start_later, __pyx_t_2) < 0) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":525
- *
- * @classmethod
- * def spawn(cls, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn(function, *args, **kwargs) -> Greenlet
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_25spawn, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_spawn, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawn, __pyx_t_2) < 0) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":524
- * self._start_event.start(self.switch)
- *
- * @classmethod # <<<<<<<<<<<<<<
- * def spawn(cls, *args, **kwargs):
- * """
- */
- __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawn, __pyx_t_1) < 0) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":543
- *
- * @classmethod
- * def spawn_later(cls, seconds, *args, **kwargs): # <<<<<<<<<<<<<<
- * """
- * spawn_later(seconds, function, *args, **kwargs) -> Greenlet
- */
- __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_27spawn_later, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_spawn_later, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawn_later, __pyx_t_1) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":542
- * return g
- *
- * @classmethod # <<<<<<<<<<<<<<
- * def spawn_later(cls, seconds, *args, **kwargs):
- * """
- */
- __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet, __pyx_n_s_spawn_later); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_spawn_later, __pyx_t_2) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":565
- * return g
- *
- * def kill(self, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Raise the ``exception`` in the greenlet.
- */
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __pyx_k__9 = __pyx_v_6gevent_9_greenlet_GreenletExit;
- __Pyx_GIVEREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_29kill, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_kill, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 565, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_kill_2, __pyx_t_2) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":617
- * # thus it should not raise when the greenlet is already killed (= not started)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * get(block=True, timeout=None) -> object
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_31get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_get, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 617, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_get_2, __pyx_t_2) < 0) __PYX_ERR(0, 617, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":661
- * self._raise_exception()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * """
- * join(timeout=None) -> None
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_33join, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_join, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_join, __pyx_t_2) < 0) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":710
- * del exc_info
- *
- * def run(self): # <<<<<<<<<<<<<<
- * try:
- * self.__cancel_start()
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_35run, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_run, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_run, __pyx_t_2) < 0) __PYX_ERR(0, 710, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":726
- * self.kwargs.clear()
- *
- * def _run(self): # <<<<<<<<<<<<<<
- * """
- * Subclasses may override this method to take any number of
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_37_run, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet__run, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_run_2, __pyx_t_2) < 0) __PYX_ERR(0, 726, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":740
- * return
- *
- * def has_links(self): # <<<<<<<<<<<<<<
- * return len(self._links)
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_39has_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_has_links, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_has_links, __pyx_t_2) < 0) __PYX_ERR(0, 740, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":743
- * return len(self._links)
- *
- * def rawlink(self, callback): # <<<<<<<<<<<<<<
- * """
- * Register a callable to be executed when the greenlet finishes
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_41rawlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_rawlink, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_rawlink, __pyx_t_2) < 0) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":759
- * self._notifier = self.parent.loop.run_callback(self._notify_links)
- *
- * def link(self, callback, SpawnedLink=SpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Link greenlet's completion to a callable.
- */
- __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_9_greenlet_SpawnedLink));
- __pyx_k__14 = ((PyObject *)__pyx_ptype_6gevent_9_greenlet_SpawnedLink);
- __Pyx_GIVEREF(__pyx_ptype_6gevent_9_greenlet_SpawnedLink);
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_43link, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_link, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_link, __pyx_t_2) < 0) __PYX_ERR(0, 759, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":773
- * self.rawlink(SpawnedLink(callback))
- *
- * def unlink(self, callback): # <<<<<<<<<<<<<<
- * """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- * try:
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_45unlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_unlink, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 773, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_unlink, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":780
- * pass
- *
- * def unlink_all(self): # <<<<<<<<<<<<<<
- * """
- * Remove all the callbacks.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_47unlink_all, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_unlink_all, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 780, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_unlink_all, __pyx_t_2) < 0) __PYX_ERR(0, 780, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":788
- * del self._links[:]
- *
- * def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the greenlet
- */
- __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink));
- __pyx_k__15 = ((PyObject *)__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink);
- __Pyx_GIVEREF(__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink);
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_49link_value, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_link_value, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_link_value, __pyx_t_2) < 0) __PYX_ERR(0, 788, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":796
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): # <<<<<<<<<<<<<<
- * """
- * Like :meth:`link` but *callback* is only notified when the
- */
- __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink));
- __pyx_k__16 = ((PyObject *)__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink);
- __Pyx_GIVEREF(__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink);
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_51link_exception, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet_link_exception, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 796, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_link_exception, __pyx_t_2) < 0) __PYX_ERR(0, 796, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":804
- * self.link(callback, SpawnedLink=SpawnedLink)
- *
- * def _notify_links(self): # <<<<<<<<<<<<<<
- * while self._links:
- * # Early links are allowed to remove later links
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_8Greenlet_53_notify_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Greenlet__notify_links, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict, __pyx_n_s_notify_links, __pyx_t_2) < 0) __PYX_ERR(0, 804, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet_Greenlet);
-
- /* "src/gevent/greenlet.py":821
- *
- * class _dummy_event(object):
- * __slots__ = ('pending', 'active') # <<<<<<<<<<<<<<
- *
- * def __init__(self):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict, __pyx_n_s_slots, __pyx_tuple__73) < 0) __PYX_ERR(0, 821, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet__dummy_event);
-
- /* "src/gevent/greenlet.py":826
- * self.pending = self.active = False
- *
- * def stop(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_12_dummy_event_3stop, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_dummy_event_stop, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 826, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict, __pyx_n_s_stop, __pyx_t_2) < 0) __PYX_ERR(0, 826, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet__dummy_event);
-
- /* "src/gevent/greenlet.py":829
- * pass
- *
- * def start(self, cb): # pylint:disable=unused-argument # <<<<<<<<<<<<<<
- * raise AssertionError("Cannot start the dummy event")
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_12_dummy_event_5start, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_dummy_event_start, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__77)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 829, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict, __pyx_n_s_start, __pyx_t_2) < 0) __PYX_ERR(0, 829, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet__dummy_event);
-
- /* "src/gevent/greenlet.py":832
- * raise AssertionError("Cannot start the dummy event")
- *
- * def close(self): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_12_dummy_event_7close, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_dummy_event_close, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__79)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict, __pyx_n_s_close, __pyx_t_2) < 0) __PYX_ERR(0, 832, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_9_greenlet__dummy_event);
-
- /* "src/gevent/greenlet.py":835
- * pass
- *
- * _cancelled_start_event = _dummy_event() # <<<<<<<<<<<<<<
- * _start_completed_event = _dummy_event()
- *
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XGOTREF(((PyObject *)__pyx_v_6gevent_9_greenlet__cancelled_start_event));
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet__cancelled_start_event, ((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_t_2));
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":836
- *
- * _cancelled_start_event = _dummy_event()
- * _start_completed_event = _dummy_event() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_9_greenlet__dummy_event)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 836, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XGOTREF(((PyObject *)__pyx_v_6gevent_9_greenlet__start_completed_event));
- __Pyx_DECREF_SET(__pyx_v_6gevent_9_greenlet__start_completed_event, ((struct __pyx_obj_6gevent_9_greenlet__dummy_event *)__pyx_t_2));
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":839
- *
- *
- * def _kill(glet, exception, waiter): # <<<<<<<<<<<<<<
- * try:
- * glet.throw(exception)
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_1_kill, 0, __pyx_n_s_kill, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 839, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_kill, __pyx_t_2) < 0) __PYX_ERR(0, 839, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":849
- *
- *
- * def joinall(greenlets, timeout=None, raise_error=False, count=None): # <<<<<<<<<<<<<<
- * """
- * Wait for the ``greenlets`` to finish.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_3joinall, 0, __pyx_n_s_joinall, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__83)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_joinall, __pyx_t_2) < 0) __PYX_ERR(0, 849, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":894
- *
- *
- * def killall(greenlets, exception=GreenletExit, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """
- * Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_9_greenlet_5killall, 0, __pyx_n_s_killall, NULL, __pyx_n_s_gevent__greenlet, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults), 1)) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_INCREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_2)->__pyx_arg_exception = __pyx_v_6gevent_9_greenlet_GreenletExit;
- __Pyx_GIVEREF(__pyx_v_6gevent_9_greenlet_GreenletExit);
- __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gevent_9_greenlet_7__defaults__);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_killall, __pyx_t_2) < 0) __PYX_ERR(0, 894, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":941
- * greenlet_init() # pylint:disable=undefined-variable
- *
- * _init() # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __pyx_f_6gevent_9_greenlet__init();
-
- /* "src/gevent/greenlet.py":943
- * _init()
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent._greenlet')
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 943, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 943, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 943, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 943, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/greenlet.py":944
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent._greenlet') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 944, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 944, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_gevent__greenlet);
- __Pyx_GIVEREF(__pyx_n_s_gevent__greenlet);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_gevent__greenlet);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 944, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/greenlet.py":1
- * # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<<
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- *
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "cfunc.to_py":64
- *
- * @cname("__Pyx_CFunc_object____list____object___to_py")
- * cdef object __Pyx_CFunc_object____list____object___to_py(object (*f)(list, object) ): # <<<<<<<<<<<<<<
- * def wrap(list greenlets, object exception):
- * """wrap(greenlets: list, exception)"""
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent._greenlet", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent._greenlet");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetAttr */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
-static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* BytesEquals */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* UnpackUnboundCMethod */
- static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod0 */
- static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_ASSUME_SAFE_MACROS
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
-#else
- args = PyTuple_Pack(1, self);
- if (unlikely(!args)) goto bad;
-#endif
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- Py_DECREF(args);
-bad:
- return result;
-}
-
-/* py_dict_items */
- static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
- if (PY_MAJOR_VERSION >= 3)
- return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
- else
- return PyDict_Items(d);
-}
-
-/* RaiseTooManyValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* StringJoin */
- #if !CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
- return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
-}
-#endif
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* None */
- static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
- PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
-}
-
-/* SliceObject */
- static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
- Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
- int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
-#if CYTHON_USE_TYPE_SLOTS
- PyMappingMethods* mp;
-#if PY_MAJOR_VERSION < 3
- PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
- if (likely(ms && ms->sq_ass_slice)) {
- if (!has_cstart) {
- if (_py_start && (*_py_start != Py_None)) {
- cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
- if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstart = 0;
- }
- if (!has_cstop) {
- if (_py_stop && (*_py_stop != Py_None)) {
- cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
- if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstop = PY_SSIZE_T_MAX;
- }
- if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
- Py_ssize_t l = ms->sq_length(obj);
- if (likely(l >= 0)) {
- if (cstop < 0) {
- cstop += l;
- if (cstop < 0) cstop = 0;
- }
- if (cstart < 0) {
- cstart += l;
- if (cstart < 0) cstart = 0;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- goto bad;
- PyErr_Clear();
- }
- }
- return ms->sq_ass_slice(obj, cstart, cstop, value);
- }
-#endif
- mp = Py_TYPE(obj)->tp_as_mapping;
- if (likely(mp && mp->mp_ass_subscript))
-#endif
- {
- int result;
- PyObject *py_slice, *py_start, *py_stop;
- if (_py_slice) {
- py_slice = *_py_slice;
- } else {
- PyObject* owned_start = NULL;
- PyObject* owned_stop = NULL;
- if (_py_start) {
- py_start = *_py_start;
- } else {
- if (has_cstart) {
- owned_start = py_start = PyInt_FromSsize_t(cstart);
- if (unlikely(!py_start)) goto bad;
- } else
- py_start = Py_None;
- }
- if (_py_stop) {
- py_stop = *_py_stop;
- } else {
- if (has_cstop) {
- owned_stop = py_stop = PyInt_FromSsize_t(cstop);
- if (unlikely(!py_stop)) {
- Py_XDECREF(owned_start);
- goto bad;
- }
- } else
- py_stop = Py_None;
- }
- py_slice = PySlice_New(py_start, py_stop, Py_None);
- Py_XDECREF(owned_start);
- Py_XDECREF(owned_stop);
- if (unlikely(!py_slice)) goto bad;
- }
-#if CYTHON_USE_TYPE_SLOTS
- result = mp->mp_ass_subscript(obj, py_slice, value);
-#else
- result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
-#endif
- if (!_py_slice) {
- Py_DECREF(py_slice);
- }
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "'%.200s' object does not support slice %.10s",
- Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
-bad:
- return -1;
-}
-
-/* PyObjectCallMethod1 */
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = NULL;
-#if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
-#endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- goto done;
-done:
- return result;
-}
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method, *result;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- result = __Pyx__PyObject_CallMethod1(method, arg);
- Py_DECREF(method);
- return result;
-}
-
-/* pop_index */
- static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) {
- PyObject *r;
- if (unlikely(!py_ix)) return NULL;
- r = __Pyx__PyObject_PopIndex(L, py_ix);
- Py_DECREF(py_ix);
- return r;
-}
-static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) {
- return __Pyx_PyObject_CallMethod1(L, __pyx_n_s_pop, py_ix);
-}
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) {
- Py_ssize_t size = PyList_GET_SIZE(L);
- if (likely(size > (((PyListObject*)L)->allocated >> 1))) {
- Py_ssize_t cix = ix;
- if (cix < 0) {
- cix += size;
- }
- if (likely(0 <= cix && cix < size)) {
- PyObject* v = PyList_GET_ITEM(L, cix);
- Py_SIZE(L) -= 1;
- size -= 1;
- memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*));
- return v;
- }
- }
- if (py_ix == Py_None) {
- return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix));
- } else {
- return __Pyx__PyObject_PopIndex(L, py_ix);
- }
-}
-#endif
-
-/* HasAttr */
- static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
- PyObject *r;
- if (unlikely(!__Pyx_PyBaseString_Check(n))) {
- PyErr_SetString(PyExc_TypeError,
- "hasattr(): attribute name must be string");
- return -1;
- }
- r = __Pyx_GetAttr(o, n);
- if (unlikely(!r)) {
- PyErr_Clear();
- return 0;
- } else {
- Py_DECREF(r);
- return 1;
- }
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* ClassMethod */
- static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
-#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
- if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
- return PyClassMethod_New(method);
- }
-#else
-#if CYTHON_COMPILING_IN_PYSTON || CYTHON_COMPILING_IN_PYPY
- if (PyMethodDescr_Check(method)) {
-#else
- static PyTypeObject *methoddescr_type = NULL;
- if (methoddescr_type == NULL) {
- PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
- if (!meth) return NULL;
- methoddescr_type = Py_TYPE(meth);
- Py_DECREF(meth);
- }
- if (__Pyx_TypeCheck(method, methoddescr_type)) {
-#endif
- PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
- #if PY_VERSION_HEX < 0x03020000
- PyTypeObject *d_type = descr->d_type;
- #else
- PyTypeObject *d_type = descr->d_common.d_type;
- #endif
- return PyDescr_NewClassMethod(d_type, descr->d_method);
- }
-#endif
- else if (PyMethod_Check(method)) {
- return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
- }
- else if (PyCFunction_Check(method)) {
- return PyClassMethod_New(method);
- }
-#ifdef __Pyx_CyFunction_USED
- else if (__Pyx_TypeCheck(method, __pyx_CyFunctionType)) {
- return PyClassMethod_New(method);
- }
-#endif
- PyErr_SetString(PyExc_TypeError,
- "Class-level classmethod() can only be called on "
- "a method_descriptor or instance method.");
- return NULL;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/greenlet.py b/python/gevent/greenlet.py
deleted file mode 100644
index 1d37034..0000000
--- a/python/gevent/greenlet.py
+++ /dev/null
@@ -1,944 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-
-from __future__ import absolute_import, print_function, division
-
-from sys import _getframe as sys_getframe
-from sys import exc_info as sys_exc_info
-from weakref import ref as wref
-
-# XXX: How to get cython to let us rename this as RawGreenlet
-# like we prefer?
-from greenlet import greenlet
-from greenlet import GreenletExit
-
-from gevent._compat import reraise
-from gevent._compat import PYPY as _PYPY
-from gevent._tblib import dump_traceback
-from gevent._tblib import load_traceback
-
-from gevent.exceptions import InvalidSwitchError
-
-from gevent._hub_primitives import iwait_on_objects as iwait
-from gevent._hub_primitives import wait_on_objects as wait
-
-from gevent.timeout import Timeout
-
-from gevent._config import config as GEVENT_CONFIG
-from gevent._util import Lazy
-from gevent._util import readproperty
-from gevent._hub_local import get_hub_noargs as get_hub
-from gevent import _waiter
-
-
-__all__ = [
- 'Greenlet',
- 'joinall',
- 'killall',
-]
-
-
-# In Cython, we define these as 'cdef inline' functions. The
-# compilation unit cannot have a direct assignment to them (import
-# is assignment) without generating a 'lvalue is not valid target'
-# error.
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-locals()['Waiter'] = _waiter.Waiter
-
-
-if _PYPY:
- import _continuation # pylint:disable=import-error
- _continulet = _continuation.continulet
-
-
-class SpawnedLink(object):
- """
- A wrapper around link that calls it in another greenlet.
-
- Can be called only from main loop.
- """
- __slots__ = ['callback']
-
- def __init__(self, callback):
- if not callable(callback):
- raise TypeError("Expected callable: %r" % (callback, ))
- self.callback = callback
-
- def __call__(self, source):
- g = greenlet(self.callback, get_hub())
- g.switch(source)
-
- def __hash__(self):
- return hash(self.callback)
-
- def __eq__(self, other):
- return self.callback == getattr(other, 'callback', other)
-
- def __str__(self):
- return str(self.callback)
-
- def __repr__(self):
- return repr(self.callback)
-
- def __getattr__(self, item):
- assert item != 'callback'
- return getattr(self.callback, item)
-
-
-class SuccessSpawnedLink(SpawnedLink):
- """A wrapper around link that calls it in another greenlet only if source succeed.
-
- Can be called only from main loop.
- """
- __slots__ = []
-
- def __call__(self, source):
- if source.successful():
- return SpawnedLink.__call__(self, source)
-
-
-class FailureSpawnedLink(SpawnedLink):
- """A wrapper around link that calls it in another greenlet only if source failed.
-
- Can be called only from main loop.
- """
- __slots__ = []
-
- def __call__(self, source):
- if not source.successful():
- return SpawnedLink.__call__(self, source)
-
-class _Frame(object):
-
- __slots__ = ('f_code', 'f_lineno', 'f_back')
-
- def __init__(self, f_code, f_lineno, f_back):
- self.f_code = f_code
- self.f_lineno = f_lineno
- self.f_back = f_back
-
- @property
- def f_globals(self):
- return None
-
-def _Frame_from_list(frames):
- previous = None
- for frame in reversed(frames):
- f = _Frame(frame[0], frame[1], previous)
- previous = f
- return previous
-
-def _extract_stack(limit):
- try:
- frame = sys_getframe()
- except ValueError:
- # In certain embedded cases that directly use the Python C api
- # to call Greenlet.spawn (e.g., uwsgi) this can raise
- # `ValueError: call stack is not deep enough`. This is because
- # the Cython stack frames for Greenlet.spawn ->
- # Greenlet.__init__ -> _extract_stack are all on the C level,
- # not the Python level.
- # See https://github.com/gevent/gevent/issues/1212
- frame = None
-
- frames = []
-
- while limit and frame is not None:
- limit -= 1
- frames.append((frame.f_code, frame.f_lineno))
- frame = frame.f_back
-
- return frames
-
-
-_greenlet__init__ = greenlet.__init__
-
-class Greenlet(greenlet):
- """
- A light-weight cooperatively-scheduled execution unit.
- """
- # pylint:disable=too-many-public-methods,too-many-instance-attributes
-
- spawning_stack_limit = 10
-
- # pylint:disable=keyword-arg-before-vararg,super-init-not-called
- def __init__(self, run=None, *args, **kwargs):
- """
- :param args: The arguments passed to the ``run`` function.
- :param kwargs: The keyword arguments passed to the ``run`` function.
- :keyword callable run: The callable object to run. If not given, this object's
- `_run` method will be invoked (typically defined by subclasses).
-
- .. versionchanged:: 1.1b1
- The ``run`` argument to the constructor is now verified to be a callable
- object. Previously, passing a non-callable object would fail after the greenlet
- was spawned.
-
- .. versionchanged:: 1.3b1
- The ``GEVENT_TRACK_GREENLET_TREE`` configuration value may be set to
- a false value to disable ``spawn_tree_locals``, ``spawning_greenlet``,
- and ``spawning_stack``. The first two will be None in that case, and the
- latter will be empty.
- """
- # The attributes are documented in the .rst file
-
- # greenlet.greenlet(run=None, parent=None)
- # Calling it with both positional arguments instead of a keyword
- # argument (parent=get_hub()) speeds up creation of this object ~30%:
- # python -m timeit -s 'import gevent' 'gevent.Greenlet()'
- # Python 3.5: 2.70usec with keywords vs 1.94usec with positional
- # Python 3.4: 2.32usec with keywords vs 1.74usec with positional
- # Python 3.3: 2.55usec with keywords vs 1.92usec with positional
- # Python 2.7: 1.73usec with keywords vs 1.40usec with positional
-
- # Timings taken Feb 21 2018 prior to integration of #755
- # python -m perf timeit -s 'import gevent' 'gevent.Greenlet()'
- # 3.6.4 : Mean +- std dev: 1.08 us +- 0.05 us
- # 2.7.14 : Mean +- std dev: 1.44 us +- 0.06 us
- # PyPy2 5.10.0: Mean +- std dev: 2.14 ns +- 0.08 ns
-
- # After the integration of spawning_stack, spawning_greenlet,
- # and spawn_tree_locals on that same date:
- # 3.6.4 : Mean +- std dev: 8.92 us +- 0.36 us -> 8.2x
- # 2.7.14 : Mean +- std dev: 14.8 us +- 0.5 us -> 10.2x
- # PyPy2 5.10.0: Mean +- std dev: 3.24 us +- 0.17 us -> 1.5x
-
- # Compiling with Cython gets us to these numbers:
- # 3.6.4 : Mean +- std dev: 3.63 us +- 0.14 us
- # 2.7.14 : Mean +- std dev: 3.37 us +- 0.20 us
- # PyPy2 5.10.0 : Mean +- std dev: 4.44 us +- 0.28 us
-
-
- _greenlet__init__(self, None, get_hub())
-
- if run is not None:
- self._run = run
-
- # If they didn't pass a callable at all, then they must
- # already have one. Note that subclassing to override the run() method
- # itself has never been documented or supported.
- if not callable(self._run):
- raise TypeError("The run argument or self._run must be callable")
-
- self.args = args
- self.kwargs = kwargs
- self.value = None
-
- #: An event, such as a timer or a callback that fires. It is established in
- #: start() and start_later() as those two objects, respectively.
- #: Once this becomes non-None, the Greenlet cannot be started again. Conversely,
- #: kill() and throw() check for non-None to determine if this object has ever been
- #: scheduled for starting. A placeholder _dummy_event is assigned by them to prevent
- #: the greenlet from being started in the future, if necessary.
- self._start_event = None
-
- self._notifier = None
- self._formatted_info = None
- self._links = []
- self._ident = None
-
- # Initial state: None.
- # Completed successfully: (None, None, None)
- # Failed with exception: (t, v, dump_traceback(tb)))
- self._exc_info = None
-
- if GEVENT_CONFIG.track_greenlet_tree:
- spawner = getcurrent() # pylint:disable=undefined-variable
- self.spawning_greenlet = wref(spawner)
- try:
- self.spawn_tree_locals = spawner.spawn_tree_locals
- except AttributeError:
- self.spawn_tree_locals = {}
- if spawner.parent is not None:
- # The main greenlet has no parent.
- # Its children get separate locals.
- spawner.spawn_tree_locals = self.spawn_tree_locals
-
- self._spawning_stack_frames = _extract_stack(self.spawning_stack_limit)
- self._spawning_stack_frames.extend(getattr(spawner, '_spawning_stack_frames', []))
- else:
- # None is the default for all of these in Cython, but we
- # need to declare them for pure-Python mode.
- self.spawning_greenlet = None
- self.spawn_tree_locals = None
- self._spawning_stack_frames = None
-
- @Lazy
- def spawning_stack(self):
- # Store this in the __dict__. We don't use it from the C
- # code. It's tempting to discard _spawning_stack_frames
- # after this, but child greenlets may still be created
- # that need it.
- return _Frame_from_list(self._spawning_stack_frames or [])
-
- def _get_minimal_ident(self):
- reg = self.parent.ident_registry
- return reg.get_ident(self)
-
- @property
- def minimal_ident(self):
- """
- A small, unique integer that identifies this object.
-
- This is similar to :attr:`threading.Thread.ident` (and `id`)
- in that as long as this object is alive, no other greenlet *in
- this hub* will have the same id, but it makes a stronger
- guarantee that the assigned values will be small and
- sequential. Sometime after this object has died, the value
- will be available for reuse.
-
- To get ids that are unique across all hubs, combine this with
- the hub's ``minimal_ident``.
-
- .. versionadded:: 1.3a2
- """
- if self._ident is None:
- self._ident = self._get_minimal_ident()
- return self._ident
-
- @readproperty
- def name(self):
- """
- The greenlet name. By default, a unique name is constructed using
- the :attr:`minimal_ident`. You can assign a string to this
- value to change it. It is shown in the `repr` of this object.
-
- .. versionadded:: 1.3a2
- """
- return 'Greenlet-%d' % (self.minimal_ident)
-
- def _raise_exception(self):
- reraise(*self.exc_info)
-
- @property
- def loop(self):
- # needed by killall
- return self.parent.loop
-
- def __nonzero__(self):
- return self._start_event is not None and self._exc_info is None
- try:
- __bool__ = __nonzero__ # Python 3
- except NameError: # pragma: no cover
- # When we're compiled with Cython, the __nonzero__ function
- # goes directly into the slot and can't be accessed by name.
- pass
-
- ### Lifecycle
-
- if _PYPY:
- # oops - pypy's .dead relies on __nonzero__ which we overriden above
- @property
- def dead(self):
- "Boolean indicating that the greenlet is dead and will not run again."
- if self._greenlet__main:
- return False
- if self.__start_cancelled_by_kill() or self.__started_but_aborted():
- return True
-
- return self._greenlet__started and not _continulet.is_pending(self)
- else:
- @property
- def dead(self):
- "Boolean indicating that the greenlet is dead and will not run again."
- return self.__start_cancelled_by_kill() or self.__started_but_aborted() or greenlet.dead.__get__(self)
-
- def __never_started_or_killed(self):
- return self._start_event is None
-
- def __start_pending(self):
- return (self._start_event is not None
- and (self._start_event.pending or getattr(self._start_event, 'active', False)))
-
- def __start_cancelled_by_kill(self):
- return self._start_event is _cancelled_start_event
-
- def __start_completed(self):
- return self._start_event is _start_completed_event
-
- def __started_but_aborted(self):
- return (not self.__never_started_or_killed() # we have been started or killed
- and not self.__start_cancelled_by_kill() # we weren't killed, so we must have been started
- and not self.__start_completed() # the start never completed
- and not self.__start_pending()) # and we're not pending, so we must have been aborted
-
- def __cancel_start(self):
- if self._start_event is None:
- # prevent self from ever being started in the future
- self._start_event = _cancelled_start_event
- # cancel any pending start event
- # NOTE: If this was a real pending start event, this will leave a
- # "dangling" callback/timer object in the hub.loop.callbacks list;
- # depending on where we are in the event loop, it may even be in a local
- # variable copy of that list (in _run_callbacks). This isn't a problem,
- # except for the leak-tests.
- self._start_event.stop()
- self._start_event.close()
-
- def __handle_death_before_start(self, args):
- # args is (t, v, tb) or simply t or v
- if self._exc_info is None and self.dead:
- # the greenlet was never switched to before and it will never be, _report_error was not called
- # the result was not set and the links weren't notified. let's do it here.
- # checking that self.dead is true is essential, because throw() does not necessarily kill the greenlet
- # (if the exception raised by throw() is caught somewhere inside the greenlet).
- if len(args) == 1:
- arg = args[0]
- #if isinstance(arg, type):
- if type(arg) is type(Exception):
- args = (arg, arg(), None)
- else:
- args = (type(arg), arg, None)
- elif not args:
- args = (GreenletExit, GreenletExit(), None)
- self._report_error(args)
-
- @property
- def started(self):
- # DEPRECATED
- return bool(self)
-
- def ready(self):
- """
- Return a true value if and only if the greenlet has finished
- execution.
-
- .. versionchanged:: 1.1
- This function is only guaranteed to return true or false *values*, not
- necessarily the literal constants ``True`` or ``False``.
- """
- return self.dead or self._exc_info is not None
-
- def successful(self):
- """
- Return a true value if and only if the greenlet has finished execution
- successfully, that is, without raising an error.
-
- .. tip:: A greenlet that has been killed with the default
- :class:`GreenletExit` exception is considered successful.
- That is, ``GreenletExit`` is not considered an error.
-
- .. note:: This function is only guaranteed to return true or false *values*,
- not necessarily the literal constants ``True`` or ``False``.
- """
- return self._exc_info is not None and self._exc_info[1] is None
-
- def __repr__(self):
- classname = self.__class__.__name__
- result = '<%s "%s" at %s' % (classname, self.name, hex(id(self)))
- formatted = self._formatinfo()
- if formatted:
- result += ': ' + formatted
- return result + '>'
-
-
- def _formatinfo(self):
- info = self._formatted_info
- if info is not None:
- return info
-
- # Are we running an arbitrary function provided to the constructor,
- # or did a subclass override _run?
- func = self._run
- im_self = getattr(func, '__self__', None)
- if im_self is self:
- funcname = '_run'
- elif im_self is not None:
- funcname = repr(func)
- else:
- funcname = getattr(func, '__name__', '') or repr(func)
-
- result = funcname
- args = []
- if self.args:
- args = [repr(x)[:50] for x in self.args]
- if self.kwargs:
- args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self.kwargs.items()])
- if args:
- result += '(' + ', '.join(args) + ')'
- # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed
- self._formatted_info = result
- return result
-
- @property
- def exception(self):
- """
- Holds the exception instance raised by the function if the
- greenlet has finished with an error. Otherwise ``None``.
- """
- return self._exc_info[1] if self._exc_info is not None else None
-
- @property
- def exc_info(self):
- """
- Holds the exc_info three-tuple raised by the function if the
- greenlet finished with an error. Otherwise a false value.
-
- .. note:: This is a provisional API and may change.
-
- .. versionadded:: 1.1
- """
- ei = self._exc_info
- if ei is not None and ei[0] is not None:
- return (ei[0], ei[1], load_traceback(ei[2]))
-
- def throw(self, *args):
- """Immediately switch into the greenlet and raise an exception in it.
-
- Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever.
- To raise an exception in a safe manner from any greenlet, use :meth:`kill`.
-
- If a greenlet was started but never switched to yet, then also
- a) cancel the event that will start it
- b) fire the notifications as if an exception was raised in a greenlet
- """
- self.__cancel_start()
-
- try:
- if not self.dead:
- # Prevent switching into a greenlet *at all* if we had never
- # started it. Usually this is the same thing that happens by throwing,
- # but if this is done from the hub with nothing else running, prevents a
- # LoopExit.
- greenlet.throw(self, *args)
- finally:
- self.__handle_death_before_start(args)
-
- def start(self):
- """Schedule the greenlet to run in this loop iteration"""
- if self._start_event is None:
- self._start_event = self.parent.loop.run_callback(self.switch)
-
- def start_later(self, seconds):
- """
- start_later(seconds) -> None
-
- Schedule the greenlet to run in the future loop iteration
- *seconds* later
- """
- if self._start_event is None:
- self._start_event = self.parent.loop.timer(seconds)
- self._start_event.start(self.switch)
-
- @classmethod
- def spawn(cls, *args, **kwargs):
- """
- spawn(function, *args, **kwargs) -> Greenlet
-
- Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.
- This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.
-
- The arguments are passed to :meth:`Greenlet.__init__`.
-
- .. versionchanged:: 1.1b1
- If a *function* is given that is not callable, immediately raise a :exc:`TypeError`
- instead of spawning a greenlet that will raise an uncaught TypeError.
- """
- g = cls(*args, **kwargs)
- g.start()
- return g
-
- @classmethod
- def spawn_later(cls, seconds, *args, **kwargs):
- """
- spawn_later(seconds, function, *args, **kwargs) -> Greenlet
-
- Create and return a new `Greenlet` object scheduled to run ``function(*args, **kwargs)``
- in a future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``
- or ``gevent.spawn_later``.
-
- The arguments are passed to :meth:`Greenlet.__init__`.
-
- .. versionchanged:: 1.1b1
- If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword )
- is given to this classmethod (and not a classmethod of a subclass),
- it is verified to be callable. Previously, the spawned greenlet would have failed
- when it started running.
- """
- if cls is Greenlet and not args and 'run' not in kwargs:
- raise TypeError("")
- g = cls(*args, **kwargs)
- g.start_later(seconds)
- return g
-
- def kill(self, exception=GreenletExit, block=True, timeout=None):
- """
- Raise the ``exception`` in the greenlet.
-
- If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires.
- If block is ``False``, the current greenlet is not unscheduled.
-
- The function always returns ``None`` and never raises an error.
-
- .. note::
-
- Depending on what this greenlet is executing and the state
- of the event loop, the exception may or may not be raised
- immediately when this greenlet resumes execution. It may
- be raised on a subsequent green call, or, if this greenlet
- exits before making such a call, it may not be raised at
- all. As of 1.1, an example where the exception is raised
- later is if this greenlet had called :func:`sleep(0)
- <gevent.sleep>`; an example where the exception is raised
- immediately is if this greenlet had called
- :func:`sleep(0.1) <gevent.sleep>`.
-
- .. caution::
-
- Use care when killing greenlets. If the code executing is not
- exception safe (e.g., makes proper use of ``finally``) then an
- unexpected exception could result in corrupted state.
-
- See also :func:`gevent.kill`.
-
- :keyword type exception: The type of exception to raise in the greenlet. The default
- is :class:`GreenletExit`, which indicates a :meth:`successful` completion
- of the greenlet.
-
- .. versionchanged:: 0.13.0
- *block* is now ``True`` by default.
- .. versionchanged:: 1.1a2
- If this greenlet had never been switched to, killing it will prevent it from ever being switched to.
- """
- self.__cancel_start()
-
- if self.dead:
- self.__handle_death_before_start((exception,))
- else:
- waiter = Waiter() if block else None # pylint:disable=undefined-variable
- self.parent.loop.run_callback(_kill, self, exception, waiter)
- if block:
- waiter.get()
- self.join(timeout)
- # it should be OK to use kill() in finally or kill a greenlet from more than one place;
- # thus it should not raise when the greenlet is already killed (= not started)
-
- def get(self, block=True, timeout=None):
- """
- get(block=True, timeout=None) -> object
-
- Return the result the greenlet has returned or re-raise the
- exception it has raised.
-
- If block is ``False``, raise :class:`gevent.Timeout` if the
- greenlet is still alive. If block is ``True``, unschedule the
- current greenlet until the result is available or the timeout
- expires. In the latter case, :class:`gevent.Timeout` is
- raised.
- """
- if self.ready():
- if self.successful():
- return self.value
- self._raise_exception()
- if not block:
- raise Timeout()
-
- switch = getcurrent().switch # pylint:disable=undefined-variable
- self.rawlink(switch)
- try:
- t = Timeout._start_new_or_dummy(timeout)
- try:
- result = self.parent.switch()
- if result is not self:
- raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, ))
- finally:
- t.cancel()
- except:
- # unlinking in 'except' instead of finally is an optimization:
- # if switch occurred normally then link was already removed in _notify_links
- # and there's no need to touch the links set.
- # Note, however, that if "Invalid switch" assert was removed and invalid switch
- # did happen, the link would remain, causing another invalid switch later in this greenlet.
- self.unlink(switch)
- raise
-
- if self.ready():
- if self.successful():
- return self.value
- self._raise_exception()
-
- def join(self, timeout=None):
- """
- join(timeout=None) -> None
-
- Wait until the greenlet finishes or *timeout* expires. Return
- ``None`` regardless.
- """
- if self.ready():
- return
-
- switch = getcurrent().switch # pylint:disable=undefined-variable
- self.rawlink(switch)
- try:
- t = Timeout._start_new_or_dummy(timeout)
- try:
- result = self.parent.switch()
- if result is not self:
- raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, ))
- finally:
- t.cancel()
- except Timeout as ex:
- self.unlink(switch)
- if ex is not t:
- raise
- except:
- self.unlink(switch)
- raise
-
- def _report_result(self, result):
- self._exc_info = (None, None, None)
- self.value = result
- if self._links and not self._notifier:
- self._notifier = self.parent.loop.run_callback(self._notify_links)
-
- def _report_error(self, exc_info):
- if isinstance(exc_info[1], GreenletExit):
- self._report_result(exc_info[1])
- return
-
- self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2])
-
- if self._links and not self._notifier:
- self._notifier = self.parent.loop.run_callback(self._notify_links)
-
- try:
- self.parent.handle_error(self, *exc_info)
- finally:
- del exc_info
-
- def run(self):
- try:
- self.__cancel_start()
- self._start_event = _start_completed_event
-
- try:
- result = self._run(*self.args, **self.kwargs)
- except: # pylint:disable=bare-except
- self._report_error(sys_exc_info())
- return
- self._report_result(result)
- finally:
- self.__dict__.pop('_run', None)
- self.args = ()
- self.kwargs.clear()
-
- def _run(self):
- """
- Subclasses may override this method to take any number of
- arguments and keyword arguments.
-
- .. versionadded:: 1.1a3
- Previously, if no callable object was
- passed to the constructor, the spawned greenlet would later
- fail with an AttributeError.
- """
- # We usually override this in __init__
- # pylint: disable=method-hidden
- return
-
- def has_links(self):
- return len(self._links)
-
- def rawlink(self, callback):
- """
- Register a callable to be executed when the greenlet finishes
- execution.
-
- The *callback* will be called with this instance as an
- argument.
-
- .. caution:: The callable will be called in the HUB greenlet.
- """
- if not callable(callback):
- raise TypeError('Expected callable: %r' % (callback, ))
- self._links.append(callback) # pylint:disable=no-member
- if self.ready() and self._links and not self._notifier:
- self._notifier = self.parent.loop.run_callback(self._notify_links)
-
- def link(self, callback, SpawnedLink=SpawnedLink):
- """
- Link greenlet's completion to a callable.
-
- The *callback* will be called with this instance as an
- argument once this greenlet is dead. A callable is called in
- its own :class:`greenlet.greenlet` (*not* a
- :class:`Greenlet`).
- """
- # XXX: Is the redefinition of SpawnedLink supposed to just be an
- # optimization, or do people use it? It's not documented
- # pylint:disable=redefined-outer-name
- self.rawlink(SpawnedLink(callback))
-
- def unlink(self, callback):
- """Remove the callback set by :meth:`link` or :meth:`rawlink`"""
- try:
- self._links.remove(callback) # pylint:disable=no-member
- except ValueError:
- pass
-
- def unlink_all(self):
- """
- Remove all the callbacks.
-
- .. versionadded:: 1.3a2
- """
- del self._links[:]
-
- def link_value(self, callback, SpawnedLink=SuccessSpawnedLink):
- """
- Like :meth:`link` but *callback* is only notified when the greenlet
- has completed successfully.
- """
- # pylint:disable=redefined-outer-name
- self.link(callback, SpawnedLink=SpawnedLink)
-
- def link_exception(self, callback, SpawnedLink=FailureSpawnedLink):
- """
- Like :meth:`link` but *callback* is only notified when the
- greenlet dies because of an unhandled exception.
- """
- # pylint:disable=redefined-outer-name
- self.link(callback, SpawnedLink=SpawnedLink)
-
- def _notify_links(self):
- while self._links:
- # Early links are allowed to remove later links
- # before we get to them, and they're also allowed to
- # add new links, so we have to be careful about iterating.
-
- # We don't expect this list to be very large, so the time spent
- # manipulating it should be small. a deque is probably not justified.
- # Cython has optimizations to transform this into a memmove anyway.
- link = self._links.pop(0)
- try:
- link(self)
- except: # pylint:disable=bare-except
- self.parent.handle_error((link, self), *sys_exc_info())
-
-
-class _dummy_event(object):
- __slots__ = ('pending', 'active')
-
- def __init__(self):
- self.pending = self.active = False
-
- def stop(self):
- pass
-
- def start(self, cb): # pylint:disable=unused-argument
- raise AssertionError("Cannot start the dummy event")
-
- def close(self):
- pass
-
-_cancelled_start_event = _dummy_event()
-_start_completed_event = _dummy_event()
-
-
-def _kill(glet, exception, waiter):
- try:
- glet.throw(exception)
- except: # pylint:disable=bare-except
- # XXX do we need this here?
- glet.parent.handle_error(glet, *sys_exc_info())
- if waiter is not None:
- waiter.switch(None)
-
-
-def joinall(greenlets, timeout=None, raise_error=False, count=None):
- """
- Wait for the ``greenlets`` to finish.
-
- :param greenlets: A sequence (supporting :func:`len`) of greenlets to wait for.
- :keyword float timeout: If given, the maximum number of seconds to wait.
- :return: A sequence of the greenlets that finished before the timeout (if any)
- expired.
- """
- if not raise_error:
- return wait(greenlets, timeout=timeout, count=count)
-
- done = []
- for obj in iwait(greenlets, timeout=timeout, count=count):
- if getattr(obj, 'exception', None) is not None:
- if hasattr(obj, '_raise_exception'):
- obj._raise_exception()
- else:
- raise obj.exception
- done.append(obj)
- return done
-
-
-def _killall3(greenlets, exception, waiter):
- diehards = []
- for g in greenlets:
- if not g.dead:
- try:
- g.throw(exception)
- except: # pylint:disable=bare-except
- g.parent.handle_error(g, *sys_exc_info())
- if not g.dead:
- diehards.append(g)
- waiter.switch(diehards)
-
-
-def _killall(greenlets, exception):
- for g in greenlets:
- if not g.dead:
- try:
- g.throw(exception)
- except: # pylint:disable=bare-except
- g.parent.handle_error(g, *sys_exc_info())
-
-
-def killall(greenlets, exception=GreenletExit, block=True, timeout=None):
- """
- Forceably terminate all the ``greenlets`` by causing them to raise ``exception``.
-
- .. caution:: Use care when killing greenlets. If they are not prepared for exceptions,
- this could result in corrupted state.
-
- :param greenlets: A **bounded** iterable of the non-None greenlets to terminate.
- *All* the items in this iterable must be greenlets that belong to the same thread.
- :keyword exception: The exception to raise in the greenlets. By default this is
- :class:`GreenletExit`.
- :keyword bool block: If True (the default) then this function only returns when all the
- greenlets are dead; the current greenlet is unscheduled during that process.
- If greenlets ignore the initial exception raised in them,
- then they will be joined (with :func:`gevent.joinall`) and allowed to die naturally.
- If False, this function returns immediately and greenlets will raise
- the exception asynchronously.
- :keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is
- only honored when ``block`` is True.
- :raise Timeout: If blocking and a timeout is given that elapses before
- all the greenlets are dead.
-
- .. versionchanged:: 1.1a2
- *greenlets* can be any iterable of greenlets, like an iterator or a set.
- Previously it had to be a list or tuple.
- """
- # support non-indexable containers like iterators or set objects
- greenlets = list(greenlets)
- if not greenlets:
- return
- loop = greenlets[0].loop
- if block:
- waiter = Waiter() # pylint:disable=undefined-variable
- loop.run_callback(_killall3, greenlets, exception, waiter)
- t = Timeout._start_new_or_dummy(timeout)
- try:
- alive = waiter.get()
- if alive:
- joinall(alive, raise_error=False)
- finally:
- t.cancel()
- else:
- loop.run_callback(_killall, greenlets, exception)
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_init()
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent._greenlet')
diff --git a/python/gevent/hub.py b/python/gevent/hub.py
deleted file mode 100644
index ca88d20..0000000
--- a/python/gevent/hub.py
+++ /dev/null
@@ -1,733 +0,0 @@
-# Copyright (c) 2009-2015 Denis Bilenko. See LICENSE for details.
-"""
-Event-loop hub.
-"""
-from __future__ import absolute_import, print_function
-# XXX: FIXME: Refactor to make this smaller
-# pylint:disable=too-many-lines
-from functools import partial as _functools_partial
-
-import sys
-import traceback
-
-
-from greenlet import greenlet as RawGreenlet
-from greenlet import getcurrent
-from greenlet import GreenletExit
-
-
-
-__all__ = [
- 'getcurrent',
- 'GreenletExit',
- 'spawn_raw',
- 'sleep',
- 'kill',
- 'signal',
- 'reinit',
- 'get_hub',
- 'Hub',
- 'Waiter',
-]
-
-from gevent._config import config as GEVENT_CONFIG
-from gevent._compat import thread_mod_name
-from gevent._util import readproperty
-from gevent._util import Lazy
-from gevent._util import gmctime
-from gevent._ident import IdentRegistry
-
-from gevent._hub_local import get_hub
-from gevent._hub_local import get_loop
-from gevent._hub_local import set_hub
-from gevent._hub_local import set_loop
-from gevent._hub_local import get_hub_if_exists as _get_hub
-from gevent._hub_local import get_hub_noargs as _get_hub_noargs
-from gevent._hub_local import set_default_hub_class
-
-from gevent._greenlet_primitives import TrackedRawGreenlet
-from gevent._hub_primitives import WaitOperationsGreenlet
-
-# Export
-from gevent import _hub_primitives
-wait = _hub_primitives.wait_on_objects
-iwait = _hub_primitives.iwait_on_objects
-
-
-from gevent.exceptions import LoopExit
-
-from gevent._waiter import Waiter
-
-# Need the real get_ident. We're imported early enough (by gevent/__init__.py)
-# that we can be sure nothing is monkey patched yet.
-get_thread_ident = __import__(thread_mod_name).get_ident
-MAIN_THREAD_IDENT = get_thread_ident() # XXX: Assuming import is done on the main thread.
-
-
-def spawn_raw(function, *args, **kwargs):
- """
- Create a new :class:`greenlet.greenlet` object and schedule it to
- run ``function(*args, **kwargs)``.
-
- This returns a raw :class:`~greenlet.greenlet` which does not have all the useful
- methods that :class:`gevent.Greenlet` has. Typically, applications
- should prefer :func:`~gevent.spawn`, but this method may
- occasionally be useful as an optimization if there are many
- greenlets involved.
-
- .. versionchanged:: 1.1a3
- Verify that ``function`` is callable, raising a TypeError if not. Previously,
- the spawned greenlet would have failed the first time it was switched to.
-
- .. versionchanged:: 1.1b1
- If *function* is not callable, immediately raise a :exc:`TypeError`
- instead of spawning a greenlet that will raise an uncaught TypeError.
-
- .. versionchanged:: 1.1rc2
- Accept keyword arguments for ``function`` as previously (incorrectly)
- documented. Note that this may incur an additional expense.
-
- .. versionchanged:: 1.3a2
- Populate the ``spawning_greenlet`` and ``spawn_tree_locals``
- attributes of the returned greenlet.
-
- .. versionchanged:: 1.3b1
- *Only* populate ``spawning_greenlet`` and ``spawn_tree_locals``
- if ``GEVENT_TRACK_GREENLET_TREE`` is enabled (the default). If not enabled,
- those attributes will not be set.
-
- """
- if not callable(function):
- raise TypeError("function must be callable")
-
- # The hub is always the parent.
- hub = _get_hub_noargs()
-
- factory = TrackedRawGreenlet if GEVENT_CONFIG.track_greenlet_tree else RawGreenlet
-
- # The callback class object that we use to run this doesn't
- # accept kwargs (and those objects are heavily used, as well as being
- # implemented twice in core.ppyx and corecffi.py) so do it with a partial
- if kwargs:
- function = _functools_partial(function, *args, **kwargs)
- g = factory(function, hub)
- hub.loop.run_callback(g.switch)
- else:
- g = factory(function, hub)
- hub.loop.run_callback(g.switch, *args)
-
- return g
-
-
-def sleep(seconds=0, ref=True):
- """
- Put the current greenlet to sleep for at least *seconds*.
-
- *seconds* may be specified as an integer, or a float if fractional
- seconds are desired.
-
- .. tip:: In the current implementation, a value of 0 (the default)
- means to yield execution to any other runnable greenlets, but
- this greenlet may be scheduled again before the event loop
- cycles (in an extreme case, a greenlet that repeatedly sleeps
- with 0 can prevent greenlets that are ready to do I/O from
- being scheduled for some (small) period of time); a value greater than
- 0, on the other hand, will delay running this greenlet until
- the next iteration of the loop.
-
- If *ref* is False, the greenlet running ``sleep()`` will not prevent :func:`gevent.wait`
- from exiting.
-
- .. versionchanged:: 1.3a1
- Sleeping with a value of 0 will now be bounded to approximately block the
- loop for no longer than :func:`gevent.getswitchinterval`.
-
- .. seealso:: :func:`idle`
- """
- hub = _get_hub_noargs()
- loop = hub.loop
- if seconds <= 0:
- waiter = Waiter(hub)
- loop.run_callback(waiter.switch, None)
- waiter.get()
- else:
- with loop.timer(seconds, ref=ref) as t:
- # Sleeping is expected to be an "absolute" measure with
- # respect to time.time(), not a relative measure, so it's
- # important to update the loop's notion of now before we start
- loop.update_now()
- hub.wait(t)
-
-
-def idle(priority=0):
- """
- Cause the calling greenlet to wait until the event loop is idle.
-
- Idle is defined as having no other events of the same or higher
- *priority* pending. That is, as long as sockets, timeouts or even
- signals of the same or higher priority are being processed, the loop
- is not idle.
-
- .. seealso:: :func:`sleep`
- """
- hub = _get_hub_noargs()
- watcher = hub.loop.idle()
- if priority:
- watcher.priority = priority
- hub.wait(watcher)
-
-
-def kill(greenlet, exception=GreenletExit):
- """
- Kill greenlet asynchronously. The current greenlet is not unscheduled.
-
- .. note::
-
- The method :meth:`Greenlet.kill` method does the same and
- more (and the same caveats listed there apply here). However, the MAIN
- greenlet - the one that exists initially - does not have a
- ``kill()`` method, and neither do any created with :func:`spawn_raw`,
- so you have to use this function.
-
- .. caution:: Use care when killing greenlets. If they are not prepared for
- exceptions, this could result in corrupted state.
-
- .. versionchanged:: 1.1a2
- If the ``greenlet`` has a :meth:`kill <Greenlet.kill>` method, calls it. This prevents a
- greenlet from being switched to for the first time after it's been
- killed but not yet executed.
- """
- if not greenlet.dead:
- if hasattr(greenlet, 'kill'):
- # dealing with gevent.greenlet.Greenlet. Use it, especially
- # to avoid allowing one to be switched to for the first time
- # after it's been killed
- greenlet.kill(exception=exception, block=False)
- else:
- _get_hub_noargs().loop.run_callback(greenlet.throw, exception)
-
-
-class signal(object):
- """
- Call the *handler* with the *args* and *kwargs* when the process
- receives the signal *signalnum*.
-
- The *handler* will be run in a new greenlet when the signal is delivered.
-
- This returns an object with the useful method ``cancel``, which, when called,
- will prevent future deliveries of *signalnum* from calling *handler*.
-
- .. note::
-
- This may not operate correctly with SIGCHLD if libev child watchers
- are used (as they are by default with os.fork).
-
- .. versionchanged:: 1.2a1
- The ``handler`` argument is required to be callable at construction time.
- """
-
- # XXX: This is manually documented in gevent.rst while it is aliased in
- # the gevent module.
-
- greenlet_class = None
-
- def __init__(self, signalnum, handler, *args, **kwargs):
- if not callable(handler):
- raise TypeError("signal handler must be callable.")
-
- self.hub = _get_hub_noargs()
- self.watcher = self.hub.loop.signal(signalnum, ref=False)
- self.watcher.start(self._start)
- self.handler = handler
- self.args = args
- self.kwargs = kwargs
- if self.greenlet_class is None:
- from gevent import Greenlet
- self.greenlet_class = Greenlet
-
- def _get_ref(self):
- return self.watcher.ref
-
- def _set_ref(self, value):
- self.watcher.ref = value
-
- ref = property(_get_ref, _set_ref)
- del _get_ref, _set_ref
-
- def cancel(self):
- self.watcher.stop()
-
- def _start(self):
- try:
- greenlet = self.greenlet_class(self.handle)
- greenlet.switch()
- except: # pylint:disable=bare-except
- self.hub.handle_error(None, *sys._exc_info()) # pylint:disable=no-member
-
- def handle(self):
- try:
- self.handler(*self.args, **self.kwargs)
- except: # pylint:disable=bare-except
- self.hub.handle_error(None, *sys.exc_info())
-
-
-def reinit(hub=None):
- """
- reinit() -> None
-
- Prepare the gevent hub to run in a new (forked) process.
-
- This should be called *immediately* after :func:`os.fork` in the
- child process. This is done automatically by
- :func:`gevent.os.fork` or if the :mod:`os` module has been
- monkey-patched. If this function is not called in a forked
- process, symptoms may include hanging of functions like
- :func:`socket.getaddrinfo`, and the hub's threadpool is unlikely
- to work.
-
- .. note:: Registered fork watchers may or may not run before
- this function (and thus ``gevent.os.fork``) return. If they have
- not run, they will run "soon", after an iteration of the event loop.
- You can force this by inserting a few small (but non-zero) calls to :func:`sleep`
- after fork returns. (As of gevent 1.1 and before, fork watchers will
- not have run, but this may change in the future.)
-
- .. note:: This function may be removed in a future major release
- if the fork process can be more smoothly managed.
-
- .. warning:: See remarks in :func:`gevent.os.fork` about greenlets
- and event loop watchers in the child process.
- """
- # Note the signature line in the docstring: hub is not a public param.
-
- # The loop reinit function in turn calls libev's ev_loop_fork
- # function.
- hub = _get_hub() if hub is None else hub
- if hub is None:
- return
-
- # Note that we reinit the existing loop, not destroy it.
- # See https://github.com/gevent/gevent/issues/200.
- hub.loop.reinit()
- # libev's fork watchers are slow to fire because the only fire
- # at the beginning of a loop; due to our use of callbacks that
- # run at the end of the loop, that may be too late. The
- # threadpool and resolvers depend on the fork handlers being
- # run (specifically, the threadpool will fail in the forked
- # child if there were any threads in it, which there will be
- # if the resolver_thread was in use (the default) before the
- # fork.)
- #
- # If the forked process wants to use the threadpool or
- # resolver immediately (in a queued callback), it would hang.
- #
- # The below is a workaround. Fortunately, all of these
- # methods are idempotent and can be called multiple times
- # following a fork if the suddenly started working, or were
- # already working on some platforms. Other threadpools and fork handlers
- # will be called at an arbitrary time later ('soon')
- for obj in (hub._threadpool, hub._resolver, hub.periodic_monitoring_thread):
- getattr(obj, '_on_fork', lambda: None)()
-
- # TODO: We'd like to sleep for a non-zero amount of time to force the loop to make a
- # pass around before returning to this greenlet. That will allow any
- # user-provided fork watchers to run. (Two calls are necessary.) HOWEVER, if
- # we do this, certain tests that heavily mix threads and forking,
- # like 2.7/test_threading:test_reinit_tls_after_fork, fail. It's not immediately clear
- # why.
- #sleep(0.00001)
- #sleep(0.00001)
-
-
-hub_ident_registry = IdentRegistry()
-
-class Hub(WaitOperationsGreenlet):
- """
- A greenlet that runs the event loop.
-
- It is created automatically by :func:`get_hub`.
-
- .. rubric:: Switching
-
- Every time this greenlet (i.e., the event loop) is switched *to*,
- if the current greenlet has a ``switch_out`` method, it will be
- called. This allows a greenlet to take some cleanup actions before
- yielding control. This method should not call any gevent blocking
- functions.
- """
-
- #: If instances of these classes are raised into the event loop,
- #: they will be propagated out to the main greenlet (where they will
- #: usually be caught by Python itself)
- SYSTEM_ERROR = (KeyboardInterrupt, SystemExit, SystemError)
-
- #: Instances of these classes are not considered to be errors and
- #: do not get logged/printed when raised by the event loop.
- NOT_ERROR = (GreenletExit, SystemExit)
-
- #: The size we use for our threadpool. Either use a subclass
- #: for this, or change it immediately after creating the hub.
- threadpool_size = 10
-
- # An instance of PeriodicMonitoringThread, if started.
- periodic_monitoring_thread = None
-
- # The ident of the thread we were created in, which should be the
- # thread that we run in.
- thread_ident = None
-
- #: A string giving the name of this hub. Useful for associating hubs
- #: with particular threads. Printed as part of the default repr.
- #:
- #: .. versionadded:: 1.3b1
- name = ''
-
- # NOTE: We cannot define a class-level 'loop' attribute
- # because that conflicts with the slot we inherit from the
- # Cythonized-bases.
-
- def __init__(self, loop=None, default=None):
- WaitOperationsGreenlet.__init__(self, None, None)
- self.thread_ident = get_thread_ident()
- if hasattr(loop, 'run'):
- if default is not None:
- raise TypeError("Unexpected argument: default")
- self.loop = loop
- elif get_loop() is not None:
- # Reuse a loop instance previously set by
- # destroying a hub without destroying the associated
- # loop. See #237 and #238.
- self.loop = get_loop()
- else:
- if default is None and self.thread_ident != MAIN_THREAD_IDENT:
- default = False
-
- if loop is None:
- loop = self.backend
- self.loop = self.loop_class(flags=loop, default=default) # pylint:disable=not-callable
- self._resolver = None
- self._threadpool = None
- self.format_context = GEVENT_CONFIG.format_context
- self.minimal_ident = hub_ident_registry.get_ident(self)
-
- @Lazy
- def ident_registry(self):
- return IdentRegistry()
-
- @property
- def loop_class(self):
- return GEVENT_CONFIG.loop
-
- @property
- def backend(self):
- return GEVENT_CONFIG.libev_backend
-
- @property
- def main_hub(self):
- """
- Is this the hub for the main thread?
-
- .. versionadded:: 1.3b1
- """
- return self.thread_ident == MAIN_THREAD_IDENT
-
- def __repr__(self):
- if self.loop is None:
- info = 'destroyed'
- else:
- try:
- info = self.loop._format()
- except Exception as ex: # pylint:disable=broad-except
- info = str(ex) or repr(ex) or 'error'
- result = '<%s %r at 0x%x %s' % (
- self.__class__.__name__,
- self.name,
- id(self),
- info)
- if self._resolver is not None:
- result += ' resolver=%r' % self._resolver
- if self._threadpool is not None:
- result += ' threadpool=%r' % self._threadpool
- result += ' thread_ident=%s' % (hex(self.thread_ident), )
- return result + '>'
-
- def handle_error(self, context, type, value, tb):
- """
- Called by the event loop when an error occurs. The arguments
- type, value, and tb are the standard tuple returned by :func:`sys.exc_info`.
-
- Applications can set a property on the hub with this same signature
- to override the error handling provided by this class.
-
- Errors that are :attr:`system errors <SYSTEM_ERROR>` are passed
- to :meth:`handle_system_error`.
-
- :param context: If this is ``None``, indicates a system error that
- should generally result in exiting the loop and being thrown to the
- parent greenlet.
- """
- if isinstance(value, str):
- # Cython can raise errors where the value is a plain string
- # e.g., AttributeError, "_semaphore.Semaphore has no attr", <traceback>
- value = type(value)
- if not issubclass(type, self.NOT_ERROR):
- self.print_exception(context, type, value, tb)
- if context is None or issubclass(type, self.SYSTEM_ERROR):
- self.handle_system_error(type, value)
-
- def handle_system_error(self, type, value):
- """
- Called from `handle_error` when the exception type is determined
- to be a :attr:`system error <SYSTEM_ERROR>`.
-
- System errors cause the exception to be raised in the main
- greenlet (the parent of this hub).
- """
- current = getcurrent()
- if current is self or current is self.parent or self.loop is None:
- self.parent.throw(type, value)
- else:
- # in case system error was handled and life goes on
- # switch back to this greenlet as well
- cb = None
- try:
- cb = self.loop.run_callback(current.switch)
- except: # pylint:disable=bare-except
- traceback.print_exc(file=self.exception_stream)
- try:
- self.parent.throw(type, value)
- finally:
- if cb is not None:
- cb.stop()
-
- @readproperty
- def exception_stream(self):
- """
- The stream to which exceptions will be written.
- Defaults to ``sys.stderr`` unless assigned to.
-
- .. versionadded:: 1.2a1
- """
- # Unwrap any FileObjectThread we have thrown around sys.stderr
- # (because it can't be used in the hub). Tricky because we are
- # called in error situations when it's not safe to import.
- stderr = sys.stderr
- if type(stderr).__name__ == 'FileObjectThread':
- stderr = stderr.io # pylint:disable=no-member
- return stderr
-
- def print_exception(self, context, type, value, tb):
- # Python 3 does not gracefully handle None value or tb in
- # traceback.print_exception() as previous versions did.
- # pylint:disable=no-member
- errstream = self.exception_stream
-
- if value is None:
- errstream.write('%s\n' % type.__name__)
- else:
- traceback.print_exception(type, value, tb, file=errstream)
- del tb
-
- try:
- errstream.write(gmctime())
- errstream.write(' ' if context is not None else '\n')
- except: # pylint:disable=bare-except
- # Possible not safe to import under certain
- # error conditions in Python 2
- pass
-
- if context is not None:
- if not isinstance(context, str):
- try:
- context = self.format_context(context)
- except: # pylint:disable=bare-except
- traceback.print_exc(file=self.exception_stream)
- context = repr(context)
- errstream.write('%s failed with %s\n\n' % (context, getattr(type, '__name__', 'exception'), ))
-
-
- def run(self):
- """
- Entry-point to running the loop. This method is called automatically
- when the hub greenlet is scheduled; do not call it directly.
-
- :raises gevent.exceptions.LoopExit: If the loop finishes running. This means
- that there are no other scheduled greenlets, and no active
- watchers or servers. In some situations, this indicates a
- programming error.
- """
- assert self is getcurrent(), 'Do not call Hub.run() directly'
- self.start_periodic_monitoring_thread()
- while 1:
- loop = self.loop
- loop.error_handler = self
- try:
- loop.run()
- finally:
- loop.error_handler = None # break the refcount cycle
- debug = []
- if hasattr(loop, 'debug'):
- debug = loop.debug()
- self.parent.throw(LoopExit('This operation would block forever', self, debug))
- # this function must never return, as it will cause switch() in the parent greenlet
- # to return an unexpected value
- # It is still possible to kill this greenlet with throw. However, in that case
- # switching to it is no longer safe, as switch will return immediately
-
- def start_periodic_monitoring_thread(self):
- if self.periodic_monitoring_thread is None and GEVENT_CONFIG.monitor_thread:
- # Note that it is possible for one real thread to
- # (temporarily) wind up with multiple monitoring threads,
- # if hubs are started and stopped within the thread. This shows up
- # in the threadpool tests. The monitoring threads will eventually notice their
- # hub object is gone.
- from gevent._monitor import PeriodicMonitoringThread
- from gevent.events import PeriodicMonitorThreadStartedEvent
- from gevent.events import notify_and_call_entry_points
- self.periodic_monitoring_thread = PeriodicMonitoringThread(self)
-
- if self.main_hub:
- self.periodic_monitoring_thread.install_monitor_memory_usage()
-
- notify_and_call_entry_points(PeriodicMonitorThreadStartedEvent(
- self.periodic_monitoring_thread))
-
- return self.periodic_monitoring_thread
-
- def join(self, timeout=None):
- """Wait for the event loop to finish. Exits only when there are
- no more spawned greenlets, started servers, active timeouts or watchers.
-
- If *timeout* is provided, wait no longer for the specified number of seconds.
-
- Returns True if exited because the loop finished execution.
- Returns False if exited because of timeout expired.
- """
- assert getcurrent() is self.parent, "only possible from the MAIN greenlet"
- if self.dead:
- return True
-
- waiter = Waiter(self)
-
- if timeout is not None:
- timeout = self.loop.timer(timeout, ref=False)
- timeout.start(waiter.switch, None)
-
- try:
- try:
- waiter.get()
- except LoopExit:
- return True
- finally:
- if timeout is not None:
- timeout.stop()
- timeout.close()
- return False
-
- def destroy(self, destroy_loop=None):
- """
- Destroy this hub and clean up its resources.
-
- If you manually create hubs, you *should* call this
- method before disposing of the hub object reference.
- """
- if self.periodic_monitoring_thread is not None:
- self.periodic_monitoring_thread.kill()
- self.periodic_monitoring_thread = None
- if self._resolver is not None:
- self._resolver.close()
- del self._resolver
- if self._threadpool is not None:
- self._threadpool.kill()
- del self._threadpool
- if destroy_loop is None:
- destroy_loop = not self.loop.default
- if destroy_loop:
- if get_loop() is self.loop:
- # Don't let anyone try to reuse this
- set_loop(None)
- self.loop.destroy()
- else:
- # Store in case another hub is created for this
- # thread.
- set_loop(self.loop)
-
-
- self.loop = None
- if _get_hub() is self:
- set_hub(None)
-
-
- # XXX: We can probably simplify the resolver and threadpool properties.
-
- @property
- def resolver_class(self):
- return GEVENT_CONFIG.resolver
-
- def _get_resolver(self):
- if self._resolver is None:
- self._resolver = self.resolver_class(hub=self) # pylint:disable=not-callable
- return self._resolver
-
- def _set_resolver(self, value):
- self._resolver = value
-
- def _del_resolver(self):
- self._resolver = None
-
- resolver = property(_get_resolver, _set_resolver, _del_resolver,
- """
- The DNS resolver that the socket functions will use.
-
- .. seealso:: :doc:`/dns`
- """)
-
-
- @property
- def threadpool_class(self):
- return GEVENT_CONFIG.threadpool
-
- def _get_threadpool(self):
- if self._threadpool is None:
- # pylint:disable=not-callable
- self._threadpool = self.threadpool_class(self.threadpool_size, hub=self)
- return self._threadpool
-
- def _set_threadpool(self, value):
- self._threadpool = value
-
- def _del_threadpool(self):
- self._threadpool = None
-
- threadpool = property(_get_threadpool, _set_threadpool, _del_threadpool,
- """
- The threadpool associated with this hub.
-
- Usually this is a
- :class:`gevent.threadpool.ThreadPool`, but
- you :attr:`can customize that
- <gevent._config.Config.threadpool>`.
-
- Use this object to schedule blocking
- (non-cooperative) operations in a different
- thread to prevent them from halting the event loop.
- """)
-
-
-set_default_hub_class(Hub)
-
-
-
-class linkproxy(object):
- __slots__ = ['callback', 'obj']
-
- def __init__(self, callback, obj):
- self.callback = callback
- self.obj = obj
-
- def __call__(self, *args):
- callback = self.callback
- obj = self.obj
- self.callback = None
- self.obj = None
- callback(obj)
diff --git a/python/gevent/libev/__init__.py b/python/gevent/libev/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/python/gevent/libev/__init__.py
+++ /dev/null
diff --git a/python/gevent/libev/_corecffi_build.py b/python/gevent/libev/_corecffi_build.py
deleted file mode 100644
index a6025fc..0000000
--- a/python/gevent/libev/_corecffi_build.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# pylint: disable=no-member
-
-# This module is only used to create and compile the gevent._corecffi module;
-# nothing should be directly imported from it except `ffi`, which should only be
-# used for `ffi.compile()`; programs should import gevent._corecfffi.
-# However, because we are using "out-of-line" mode, it is necessary to examine
-# this file to know what functions are created and available on the generated
-# module.
-from __future__ import absolute_import, print_function
-import sys
-import os
-import os.path # pylint:disable=no-name-in-module
-import struct
-
-__all__ = []
-
-
-def system_bits():
- return struct.calcsize('P') * 8
-
-
-def st_nlink_type():
- if sys.platform == "darwin" or sys.platform.startswith("freebsd"):
- return "short"
- if system_bits() == 32:
- return "unsigned long"
- return "long long"
-
-
-from cffi import FFI
-ffi = FFI()
-
-thisdir = os.path.dirname(os.path.abspath(__file__))
-def read_source(name):
- with open(os.path.join(thisdir, name), 'r') as f:
- return f.read()
-
-_cdef = read_source('_corecffi_cdef.c')
-_source = read_source('_corecffi_source.c')
-
-_cdef = _cdef.replace('#define GEVENT_ST_NLINK_T int', '')
-_cdef = _cdef.replace('#define GEVENT_STRUCT_DONE int', '')
-_cdef = _cdef.replace('GEVENT_ST_NLINK_T', st_nlink_type())
-_cdef = _cdef.replace("GEVENT_STRUCT_DONE _;", '...;')
-
-
-if sys.platform.startswith('win'):
- # We must have the vfd_open, etc, functions on
- # Windows. But on other platforms, going through
- # CFFI to just return the file-descriptor is slower
- # than just doing it in Python, so we check for and
- # workaround their absence in corecffi.py
- _cdef += """
-typedef int... vfd_socket_t;
-int vfd_open(vfd_socket_t);
-vfd_socket_t vfd_get(int);
-void vfd_free(int);
-"""
-
-
-
-include_dirs = [
- thisdir, # libev_vfd.h
- os.path.abspath(os.path.join(thisdir, '..', '..', '..', 'deps', 'libev')),
-]
-ffi.cdef(_cdef)
-ffi.set_source('gevent.libev._corecffi', _source, include_dirs=include_dirs)
-
-if __name__ == '__main__':
- # XXX: Note, on Windows, we would need to specify the external libraries
- # that should be linked in, such as ws2_32 and (because libev_vfd.h makes
- # Python.h calls) the proper Python library---at least for PyPy. I never got
- # that to work though, and calling python functions is strongly discouraged
- # from CFFI code.
- ffi.compile()
diff --git a/python/gevent/libev/_corecffi_cdef.c b/python/gevent/libev/_corecffi_cdef.c
deleted file mode 100644
index 3280e99..0000000
--- a/python/gevent/libev/_corecffi_cdef.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/* libev interface */
-
-#define EV_MINPRI ...
-#define EV_MAXPRI ...
-
-#define EV_VERSION_MAJOR ...
-#define EV_VERSION_MINOR ...
-
-#define EV_UNDEF ...
-#define EV_NONE ...
-#define EV_READ ...
-#define EV_WRITE ...
-#define EV__IOFDSET ...
-#define EV_TIMER ...
-#define EV_PERIODIC ...
-#define EV_SIGNAL ...
-#define EV_CHILD ...
-#define EV_STAT ...
-#define EV_IDLE ...
-#define EV_PREPARE ...
-#define EV_CHECK ...
-#define EV_EMBED ...
-#define EV_FORK ...
-#define EV_CLEANUP ...
-#define EV_ASYNC ...
-#define EV_CUSTOM ...
-#define EV_ERROR ...
-
-#define EVFLAG_AUTO ...
-#define EVFLAG_NOENV ...
-#define EVFLAG_FORKCHECK ...
-#define EVFLAG_NOINOTIFY ...
-#define EVFLAG_SIGNALFD ...
-#define EVFLAG_NOSIGMASK ...
-
-#define EVBACKEND_SELECT ...
-#define EVBACKEND_POLL ...
-#define EVBACKEND_EPOLL ...
-#define EVBACKEND_KQUEUE ...
-#define EVBACKEND_DEVPOLL ...
-#define EVBACKEND_PORT ...
-/* #define EVBACKEND_IOCP ... */
-
-#define EVBACKEND_ALL ...
-#define EVBACKEND_MASK ...
-
-#define EVRUN_NOWAIT ...
-#define EVRUN_ONCE ...
-
-#define EVBREAK_CANCEL ...
-#define EVBREAK_ONE ...
-#define EVBREAK_ALL ...
-
-/* markers for the CFFI parser. Replaced when the string is read. */
-#define GEVENT_STRUCT_DONE int
-#define GEVENT_ST_NLINK_T int
-
-struct ev_loop {
- int backend_fd;
- int activecnt;
- GEVENT_STRUCT_DONE _;
-};
-
-// Watcher types
-// base for all watchers
-struct ev_watcher{
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct ev_io {
- int fd;
- int events;
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_timer {
- double at;
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_signal {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_idle {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_prepare {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_check {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_fork {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct ev_async {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct ev_child {
- int pid;
- int rpid;
- int rstatus;
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct stat {
- GEVENT_ST_NLINK_T st_nlink;
- GEVENT_STRUCT_DONE _;
-};
-
-struct ev_stat {
- struct stat attr;
- const char* path;
- struct stat prev;
- double interval;
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-
-typedef double ev_tstamp;
-
-int ev_version_major();
-int ev_version_minor();
-
-unsigned int ev_supported_backends (void);
-unsigned int ev_recommended_backends (void);
-unsigned int ev_embeddable_backends (void);
-
-ev_tstamp ev_time (void);
-void ev_set_syserr_cb(void *);
-
-void ev_set_userdata(struct ev_loop*, void*);
-void* ev_userdata(struct ev_loop*);
-
-int ev_priority(void*);
-void ev_set_priority(void*, int);
-
-int ev_is_pending(void*);
-int ev_is_active(void*);
-void ev_io_init(struct ev_io*, void* callback, int fd, int events);
-void ev_io_start(struct ev_loop*, struct ev_io*);
-void ev_io_stop(struct ev_loop*, struct ev_io*);
-void ev_feed_event(struct ev_loop*, void*, int);
-
-void ev_timer_init(struct ev_timer*, void *callback, double, double);
-void ev_timer_start(struct ev_loop*, struct ev_timer*);
-void ev_timer_stop(struct ev_loop*, struct ev_timer*);
-void ev_timer_again(struct ev_loop*, struct ev_timer*);
-
-void ev_signal_init(struct ev_signal*, void* callback, int);
-void ev_signal_start(struct ev_loop*, struct ev_signal*);
-void ev_signal_stop(struct ev_loop*, struct ev_signal*);
-
-void ev_idle_init(struct ev_idle*, void* callback);
-void ev_idle_start(struct ev_loop*, struct ev_idle*);
-void ev_idle_stop(struct ev_loop*, struct ev_idle*);
-
-void ev_prepare_init(struct ev_prepare*, void* callback);
-void ev_prepare_start(struct ev_loop*, struct ev_prepare*);
-void ev_prepare_stop(struct ev_loop*, struct ev_prepare*);
-
-void ev_check_init(struct ev_check*, void* callback);
-void ev_check_start(struct ev_loop*, struct ev_check*);
-void ev_check_stop(struct ev_loop*, struct ev_check*);
-
-void ev_fork_init(struct ev_fork*, void* callback);
-void ev_fork_start(struct ev_loop*, struct ev_fork*);
-void ev_fork_stop(struct ev_loop*, struct ev_fork*);
-
-void ev_async_init(struct ev_async*, void* callback);
-void ev_async_start(struct ev_loop*, struct ev_async*);
-void ev_async_stop(struct ev_loop*, struct ev_async*);
-void ev_async_send(struct ev_loop*, struct ev_async*);
-int ev_async_pending(struct ev_async*);
-
-void ev_child_init(struct ev_child*, void* callback, int, int);
-void ev_child_start(struct ev_loop*, struct ev_child*);
-void ev_child_stop(struct ev_loop*, struct ev_child*);
-
-void ev_stat_init(struct ev_stat*, void* callback, char*, double);
-void ev_stat_start(struct ev_loop*, struct ev_stat*);
-void ev_stat_stop(struct ev_loop*, struct ev_stat*);
-
-struct ev_loop *ev_default_loop (unsigned int flags);
-struct ev_loop* ev_loop_new(unsigned int flags);
-void ev_loop_destroy(struct ev_loop*);
-void ev_loop_fork(struct ev_loop*);
-int ev_is_default_loop (struct ev_loop *);
-unsigned int ev_iteration(struct ev_loop*);
-unsigned int ev_depth(struct ev_loop*);
-unsigned int ev_backend(struct ev_loop*);
-void ev_verify(struct ev_loop*);
-void ev_run(struct ev_loop*, int flags);
-
-ev_tstamp ev_now (struct ev_loop *);
-void ev_now_update (struct ev_loop *); /* update event loop time */
-void ev_ref(struct ev_loop*);
-void ev_unref(struct ev_loop*);
-void ev_break(struct ev_loop*, int);
-unsigned int ev_pending_count(struct ev_loop*);
-
-struct ev_loop* gevent_ev_default_loop(unsigned int flags);
-void gevent_install_sigchld_handler();
-void gevent_reset_sigchld_handler();
-
-void (*gevent_noop)(struct ev_loop *_loop, struct ev_timer *w, int revents);
-void ev_sleep (ev_tstamp delay); /* sleep for a while */
-
-/* gevent callbacks */
-/* These will be created as static functions at the end of the
- * _source.c and must be declared there too.
- */
-extern "Python" {
- int python_callback(void* handle, int revents);
- void python_handle_error(void* handle, int revents);
- void python_stop(void* handle);
- void python_check_callback(struct ev_loop*, void*, int);
- void python_prepare_callback(struct ev_loop*, void*, int);
-
- // libev specific
- void _syserr_cb(char*);
-}
-/*
- * We use a single C callback for every watcher type, which in turn calls the
- * Python callbacks. The ev_watcher pointer type can be used for every watcher type
- * because they all start with the same members---libev itself relies on this. Each
- * watcher types has a 'void* data' that stores the CFFI handle to the Python watcher
- * object.
- */
-static void _gevent_generic_callback(struct ev_loop* loop, struct ev_watcher* watcher, int revents);
-
-static void gevent_zero_check(struct ev_check* handle);
-static void gevent_zero_timer(struct ev_timer* handle);
-static void gevent_zero_prepare(struct ev_prepare* handle);
diff --git a/python/gevent/libev/_corecffi_source.c b/python/gevent/libev/_corecffi_source.c
deleted file mode 100644
index 63b216e..0000000
--- a/python/gevent/libev/_corecffi_source.c
+++ /dev/null
@@ -1,69 +0,0 @@
-// passed to the real C compiler
-#define LIBEV_EMBED 1
-
-#ifdef _WIN32
-#define EV_STANDALONE 1
-#include "libev_vfd.h"
-#endif
-
-
-#include "libev.h"
-
-static void
-_gevent_noop(struct ev_loop *_loop, struct ev_timer *w, int revents) { }
-
-void (*gevent_noop)(struct ev_loop *, struct ev_timer *, int) = &_gevent_noop;
-
-static int python_callback(void* handle, int revents);
-static void python_handle_error(void* handle, int revents);
-static void python_stop(void* handle);
-
-static void _gevent_generic_callback(struct ev_loop* loop,
- struct ev_watcher* watcher,
- int revents)
-{
- void* handle = watcher->data;
- int cb_result = python_callback(handle, revents);
- switch(cb_result) {
- case -1:
- // in case of exception, call self.loop.handle_error;
- // this function is also responsible for stopping the watcher
- // and allowing memory to be freed
- python_handle_error(handle, revents);
- break;
- case 1:
- // Code to stop the event. Note that if python_callback
- // has disposed of the last reference to the handle,
- // `watcher` could now be invalid/disposed memory!
- if (!ev_is_active(watcher)) {
- python_stop(handle);
- }
- break;
- case 2:
- // watcher is already stopped and dead, nothing to do.
- break;
- default:
- fprintf(stderr,
- "WARNING: gevent: Unexpected return value %d from Python callback "
- "for watcher %p and handle %d\n",
- cb_result,
- watcher, handle);
- // XXX: Possible leaking of resources here? Should we be
- // closing the watcher?
- }
-}
-
-static void gevent_zero_timer(struct ev_timer* handle)
-{
- memset(handle, 0, sizeof(struct ev_timer));
-}
-
-static void gevent_zero_check(struct ev_check* handle)
-{
- memset(handle, 0, sizeof(struct ev_check));
-}
-
-static void gevent_zero_prepare(struct ev_prepare* handle)
-{
- memset(handle, 0, sizeof(struct ev_prepare));
-}
diff --git a/python/gevent/libev/callbacks.c b/python/gevent/libev/callbacks.c
deleted file mode 100644
index 751b425..0000000
--- a/python/gevent/libev/callbacks.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */
-#include <stddef.h>
-#include "Python.h"
-#include "ev.h"
-#include "corecext.h"
-#include "callbacks.h"
-#ifdef Py_PYTHON_H
-
-#if PY_MAJOR_VERSION >= 3
- #define PyInt_FromLong PyLong_FromLong
-#endif
-
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-
-static CYTHON_INLINE void gevent_check_signals(struct PyGeventLoopObject* loop) {
- if (!ev_is_default_loop(loop->_ptr)) {
- /* only reporting signals on the default loop */
- return;
- }
- PyErr_CheckSignals();
- if (PyErr_Occurred()) gevent_handle_error(loop, Py_None);
-}
-
-#define GET_OBJECT(PY_TYPE, EV_PTR, MEMBER) \
- ((struct PY_TYPE *)(((char *)EV_PTR) - offsetof(struct PY_TYPE, MEMBER)))
-
-
-#ifdef WITH_THREAD
-#define GIL_DECLARE PyGILState_STATE ___save
-#define GIL_ENSURE ___save = PyGILState_Ensure();
-#define GIL_RELEASE PyGILState_Release(___save);
-#else
-#define GIL_DECLARE
-#define GIL_ENSURE
-#define GIL_RELEASE
-#endif
-
-
-static void gevent_stop(PyObject* watcher, struct PyGeventLoopObject* loop) {
- PyObject *result, *method;
- int error;
- error = 1;
- method = PyObject_GetAttrString(watcher, "stop");
- if (method) {
- result = PyObject_Call(method, _empty_tuple, NULL);
- if (result) {
- Py_DECREF(result);
- error = 0;
- }
- Py_DECREF(method);
- }
- if (error) {
- gevent_handle_error(loop, watcher);
- }
-}
-
-
-static void gevent_callback(struct PyGeventLoopObject* loop, PyObject* callback, PyObject* args, PyObject* watcher, void *c_watcher, int revents) {
- GIL_DECLARE;
- PyObject *result, *py_events;
- long length;
- py_events = 0;
- GIL_ENSURE;
- Py_INCREF(loop);
- Py_INCREF(callback);
- Py_INCREF(args);
- Py_INCREF(watcher);
- gevent_check_signals(loop);
- if (args == Py_None) {
- args = _empty_tuple;
- }
- length = PyTuple_Size(args);
- if (length < 0) {
- gevent_handle_error(loop, watcher);
- goto end;
- }
- if (length > 0 && PyTuple_GET_ITEM(args, 0) == GEVENT_CORE_EVENTS) {
- py_events = PyInt_FromLong(revents);
- if (!py_events) {
- gevent_handle_error(loop, watcher);
- goto end;
- }
- PyTuple_SET_ITEM(args, 0, py_events);
- }
- else {
- py_events = NULL;
- }
- result = PyObject_Call(callback, args, NULL);
- if (result) {
- Py_DECREF(result);
- }
- else {
- gevent_handle_error(loop, watcher);
- if (revents & (EV_READ|EV_WRITE)) {
- /* io watcher: not stopping it may cause the failing callback to be called repeatedly */
- gevent_stop(watcher, loop);
- goto end;
- }
- }
- if (!ev_is_active(c_watcher)) {
- /* Watcher was stopped, maybe by libev. Let's call stop() to clean up
- * 'callback' and 'args' properties, do Py_DECREF() and ev_ref() if necessary.
- * BTW, we don't need to check for EV_ERROR, because libev stops the watcher in that case. */
- gevent_stop(watcher, loop);
- }
-end:
- if (py_events) {
- Py_DECREF(py_events);
- PyTuple_SET_ITEM(args, 0, GEVENT_CORE_EVENTS);
- }
- Py_DECREF(watcher);
- Py_DECREF(args);
- Py_DECREF(callback);
- Py_DECREF(loop);
- GIL_RELEASE;
-}
-
-
-void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb) {
- /* no need for GIL here because it is only called from run_callbacks which already has GIL */
- PyObject *result, *callback, *args;
- if (!loop || !cb)
- return;
- callback = cb->callback;
- args = cb->args;
- if (!callback || !args)
- return;
- if (callback == Py_None || args == Py_None)
- return;
- Py_INCREF(loop);
- Py_INCREF(callback);
- Py_INCREF(args);
-
- Py_INCREF(Py_None);
- Py_DECREF(cb->callback);
- cb->callback = Py_None;
-
- result = PyObject_Call(callback, args, NULL);
- if (result) {
- Py_DECREF(result);
- }
- else {
- gevent_handle_error(loop, (PyObject*)cb);
- }
-
- Py_INCREF(Py_None);
- Py_DECREF(cb->args);
- cb->args = Py_None;
-
- Py_DECREF(callback);
- Py_DECREF(args);
- Py_DECREF(loop);
-}
-
-/*
- * PyGeventWatcherObject is the first member of all the structs, so
- * it is the same in all of them and they can all safely be cast to
- * it. We could also use the *data member of the libev watcher objects.
- */
-
-#undef DEFINE_CALLBACK
-#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \
- void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \
- struct PyGeventWatcherObject* watcher = (struct PyGeventWatcherObject*)GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \
- gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \
- }
-
-
-DEFINE_CALLBACKS
-
-
-void gevent_run_callbacks(struct ev_loop *_loop, void *watcher, int revents) {
- struct PyGeventLoopObject* loop;
- PyObject *result;
- GIL_DECLARE;
- GIL_ENSURE;
- loop = GET_OBJECT(PyGeventLoopObject, watcher, _prepare);
- Py_INCREF(loop);
- gevent_check_signals(loop);
- result = gevent_loop_run_callbacks(loop);
- if (result) {
- Py_DECREF(result);
- }
- else {
- PyErr_Print();
- PyErr_Clear();
- }
- Py_DECREF(loop);
- GIL_RELEASE;
-}
-
-/* This is only used on Win32 */
-
-void gevent_periodic_signal_check(struct ev_loop *_loop, void *watcher, int revents) {
- GIL_DECLARE;
- GIL_ENSURE;
- gevent_check_signals(GET_OBJECT(PyGeventLoopObject, watcher, _periodic_signal_checker));
- GIL_RELEASE;
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/libev/callbacks.h b/python/gevent/libev/callbacks.h
deleted file mode 100644
index ed87224..0000000
--- a/python/gevent/libev/callbacks.h
+++ /dev/null
@@ -1,38 +0,0 @@
-struct ev_loop;
-struct PyGeventLoopObject;
-struct PyGeventCallbackObject;
-
-#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \
- void gevent_callback_##WATCHER_LC(struct ev_loop *, void *, int);
-
-
-#define DEFINE_CALLBACKS0 \
- DEFINE_CALLBACK(io, IO); \
- DEFINE_CALLBACK(timer, Timer); \
- DEFINE_CALLBACK(signal, Signal); \
- DEFINE_CALLBACK(idle, Idle); \
- DEFINE_CALLBACK(prepare, Prepare); \
- DEFINE_CALLBACK(check, Check); \
- DEFINE_CALLBACK(fork, Fork); \
- DEFINE_CALLBACK(async, Async); \
- DEFINE_CALLBACK(stat, Stat); \
- DEFINE_CALLBACK(child, Child);
-
-
-#define DEFINE_CALLBACKS DEFINE_CALLBACKS0
-
-
-DEFINE_CALLBACKS
-
-
-void gevent_run_callbacks(struct ev_loop *, void *, int);
-
-
-
-void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb);
-
-static void gevent_noop(struct ev_loop *_loop, void *watcher, int revents) {
-}
-
-/* Only used on Win32 */
-void gevent_periodic_signal_check(struct ev_loop *, void *, int);
diff --git a/python/gevent/libev/corecext.c b/python/gevent/libev/corecext.c
deleted file mode 100644
index ef4e592..0000000
--- a/python/gevent/libev/corecext.c
+++ /dev/null
@@ -1,22963 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "define_macros": [
- [
- "FD_SETSIZE",
- "1024"
- ],
- [
- "_WIN32",
- "1"
- ],
- [
- "EV_STANDALONE",
- "1"
- ],
- [
- "LIBEV_EMBED",
- "1"
- ],
- [
- "EV_COMMON",
- ""
- ],
- [
- "EV_CLEANUP_ENABLE",
- "0"
- ],
- [
- "EV_EMBED_ENABLE",
- "0"
- ],
- [
- "EV_PERIODIC_ENABLE",
- "0"
- ]
- ],
- "depends": [
- "deps/libev\\ev++.h",
- "deps/libev\\ev.c",
- "deps/libev\\ev.h",
- "deps/libev\\ev_epoll.c",
- "deps/libev\\ev_kqueue.c",
- "deps/libev\\ev_poll.c",
- "deps/libev\\ev_port.c",
- "deps/libev\\ev_select.c",
- "deps/libev\\ev_vars.h",
- "deps/libev\\ev_win32.c",
- "deps/libev\\ev_wrap.h",
- "deps/libev\\event.c",
- "deps/libev\\event.h",
- "deps\\libev\\ev++.h",
- "deps\\libev\\ev.c",
- "deps\\libev\\ev.h",
- "deps\\libev\\ev_epoll.c",
- "deps\\libev\\ev_kqueue.c",
- "deps\\libev\\ev_poll.c",
- "deps\\libev\\ev_port.c",
- "deps\\libev\\ev_select.c",
- "deps\\libev\\ev_vars.h",
- "deps\\libev\\ev_win32.c",
- "deps\\libev\\ev_wrap.h",
- "deps\\libev\\event.c",
- "deps\\libev\\event.h",
- "src/gevent/libev/stathelper.c",
- "src/gevent/libev\\callbacks.c",
- "src/gevent/libev\\callbacks.h",
- "src/gevent/libev\\libev.h",
- "src/gevent/libev\\libev_vfd.h",
- "src\\gevent\\libev\\callbacks.c",
- "src\\gevent\\libev\\callbacks.h",
- "src\\gevent\\libev\\libev.h",
- "src\\gevent\\libev\\libev_vfd.h",
- "src\\gevent\\libev\\stathelper.c"
- ],
- "include_dirs": [
- "src/gevent/libev",
- "C:\\projects\\gevent\\deps\\libev"
- ],
- "libraries": [
- "ws2_32"
- ],
- "name": "gevent.libev.corecext",
- "sources": [
- "src/gevent/libev/corecext.pyx",
- "src/gevent/libev/callbacks.c"
- ]
- },
- "module_name": "gevent.libev.corecext"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 0
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent__libev__corecext
-#define __PYX_HAVE_API__gevent__libev__corecext
-/* Early includes */
-#include "libev_vfd.h"
-#include "libev.h"
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include "callbacks.h"
-#include "stathelper.c"
-#include "pythread.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\libev\\corecext.pyx",
- "type.pxd",
- "bool.pxd",
- "complex.pxd",
-};
-/* NoFastGil.proto */
-#define __Pyx_PyGILState_Ensure PyGILState_Ensure
-#define __Pyx_PyGILState_Release PyGILState_Release
-#define __Pyx_FastGIL_Remember()
-#define __Pyx_FastGIL_Forget()
-#define __Pyx_FastGilFuncInit()
-
-/* ForceInitThreads.proto */
-#ifndef __PYX_FORCE_INIT_THREADS
- #define __PYX_FORCE_INIT_THREADS 0
-#endif
-
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType;
-struct PyGeventCallbackObject;
-struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO;
-struct PyGeventLoopObject;
-struct PyGeventWatcherObject;
-struct PyGeventIOObject;
-struct PyGeventTimerObject;
-struct PyGeventSignalObject;
-struct PyGeventIdleObject;
-struct PyGeventPrepareObject;
-struct PyGeventCheckObject;
-struct PyGeventForkObject;
-struct PyGeventAsyncObject;
-struct PyGeventChildObject;
-struct PyGeventStatObject;
-struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr;
-struct __pyx_t_6gevent_5libev_8corecext_start_and_stop;
-
-typedef void (*__pyx_t_6gevent_5libev_8corecext_start_stop_func)(struct ev_loop *, void *);
-
-struct __pyx_t_6gevent_5libev_8corecext_start_and_stop {
- __pyx_t_6gevent_5libev_8corecext_start_stop_func start;
- __pyx_t_6gevent_5libev_8corecext_start_stop_func stop;
-};
-
-struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType {
- PyObject_HEAD
-};
-
-
-struct PyGeventCallbackObject {
- PyObject_HEAD
- PyObject *callback;
- PyObject *args;
- struct PyGeventCallbackObject *next;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCallback_Type;
-
-struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_5libev_8corecext_CallbackFIFO *__pyx_vtab;
- struct PyGeventCallbackObject *head;
- struct PyGeventCallbackObject *tail;
-};
-
-
-struct PyGeventLoopObject {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *__pyx_vtab;
- struct ev_prepare _prepare;
- struct ev_timer _timer0;
- struct ev_timer _periodic_signal_checker;
- PyObject *error_handler;
- struct ev_loop *_ptr;
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *_callbacks;
- int starting_timer_may_update_loop_time;
- int _default;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type;
-
-struct PyGeventWatcherObject {
- PyObject_HEAD
- struct PyGeventLoopObject *loop;
- PyObject *_callback;
- PyObject *args;
- struct ev_watcher *__pyx___watcher;
- struct __pyx_t_6gevent_5libev_8corecext_start_and_stop *__pyx___ss;
- unsigned int _flags;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventWatcher_Type;
-
-struct PyGeventIOObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_io _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIO_Type;
-
-struct PyGeventTimerObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_timer _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventTimer_Type;
-
-struct PyGeventSignalObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_signal _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventSignal_Type;
-
-struct PyGeventIdleObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_idle _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIdle_Type;
-
-struct PyGeventPrepareObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_prepare _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventPrepare_Type;
-
-struct PyGeventCheckObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_check _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCheck_Type;
-
-struct PyGeventForkObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_fork _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventFork_Type;
-
-struct PyGeventAsyncObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_async _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAsync_Type;
-
-struct PyGeventChildObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_child _watcher;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventChild_Type;
-
-struct PyGeventStatObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_stat _watcher;
- PyObject *path;
- PyObject *_paths;
-};
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventStat_Type;
-
-struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr {
- PyObject_HEAD
- PyObject *__pyx_v_flag;
- PyObject *__pyx_v_string;
-};
-
-
-
-
-struct __pyx_vtabstruct_6gevent_5libev_8corecext_CallbackFIFO {
- struct PyGeventCallbackObject *(*popleft)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *);
- PyObject *(*append)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *, struct PyGeventCallbackObject *);
- int (*has_callbacks)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *);
-};
-static struct __pyx_vtabstruct_6gevent_5libev_8corecext_CallbackFIFO *__pyx_vtabptr_6gevent_5libev_8corecext_CallbackFIFO;
-static CYTHON_INLINE struct PyGeventCallbackObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_popleft(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *);
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_append(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *, struct PyGeventCallbackObject *);
-static int __pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_has_callbacks(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *);
-
-__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type;
-
-
-struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop {
- PyObject *(*_run_callbacks)(struct PyGeventLoopObject *);
- PyObject *(*_stop_watchers)(struct PyGeventLoopObject *, struct ev_loop *);
- PyObject *(*handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_default_handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
- ev_tstamp (*now)(struct PyGeventLoopObject *, int __pyx_skip_dispatch);
- void (*update_now)(struct PyGeventLoopObject *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *__pyx_vtabptr_6gevent_5libev_8corecext_loop;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* StringJoin.proto */
-#if PY_MAJOR_VERSION < 3
-#define __Pyx_PyString_Join __Pyx_PyBytes_Join
-#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
-#else
-#define __Pyx_PyString_Join PyUnicode_Join
-#define __Pyx_PyBaseString_Join PyUnicode_Join
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION < 3
- #define __Pyx_PyBytes_Join _PyString_Join
- #else
- #define __Pyx_PyBytes_Join _PyBytes_Join
- #endif
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* ListCompAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len)) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* IncludeStringH.proto */
-#include <string.h>
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* StrEquals.proto */
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
-#else
-#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* CallableCheck.proto */
-#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
-#else
-#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
-#endif
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* PyObjectCallMethod1.proto */
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
-static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
-
-/* CoroutineBase.proto */
-typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
-typedef struct {
- PyObject_HEAD
- __pyx_coroutine_body_t body;
- PyObject *closure;
- PyObject *exc_type;
- PyObject *exc_value;
- PyObject *exc_traceback;
- PyObject *gi_weakreflist;
- PyObject *classobj;
- PyObject *yieldfrom;
- PyObject *gi_name;
- PyObject *gi_qualname;
- PyObject *gi_modulename;
- PyObject *gi_code;
- int resume_label;
- char is_running;
-} __pyx_CoroutineObject;
-static __pyx_CoroutineObject *__Pyx__Coroutine_New(
- PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
- PyObject *name, PyObject *qualname, PyObject *module_name);
-static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
- __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
- PyObject *name, PyObject *qualname, PyObject *module_name);
-static int __Pyx_Coroutine_clear(PyObject *self);
-static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
-static PyObject *__Pyx_Coroutine_Close(PyObject *self);
-static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
-#define __Pyx_Coroutine_SwapException(self) {\
- __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
- __Pyx_Coroutine_ResetFrameBackpointer(self);\
- }
-#define __Pyx_Coroutine_ResetAndClearException(self) {\
- __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
- (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
- }
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
- __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
-#else
-#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
- __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
-#endif
-static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
-static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);
-
-/* PatchModuleWithCoroutine.proto */
-static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
-
-/* PatchGeneratorABC.proto */
-static int __Pyx_patch_abc(void);
-
-/* Generator.proto */
-#define __Pyx_Generator_USED
-static PyTypeObject *__pyx_GeneratorType = 0;
-#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
-#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
- __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
-static PyObject *__Pyx_Generator_Next(PyObject *self);
-static int __pyx_Generator_init(void);
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static CYTHON_INLINE struct PyGeventCallbackObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_popleft(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto*/
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_append(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self, struct PyGeventCallbackObject *__pyx_v_new_tail); /* proto*/
-static int __pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_has_callbacks(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__stop_watchers(struct PyGeventLoopObject *__pyx_v_self, struct ev_loop *__pyx_v_ptr); /* proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/
-static ev_tstamp __pyx_f_6gevent_5libev_8corecext_4loop_now(struct PyGeventLoopObject *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static void __pyx_f_6gevent_5libev_8corecext_4loop_update_now(struct PyGeventLoopObject *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'gevent.libev.libev' */
-
-/* Module declarations from 'libc.string' */
-
-/* Module declarations from 'libc.stdio' */
-
-/* Module declarations from '__builtin__' */
-
-/* Module declarations from 'cpython.type' */
-static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
-
-/* Module declarations from 'cpython.version' */
-
-/* Module declarations from 'cpython.exc' */
-
-/* Module declarations from 'cpython.module' */
-
-/* Module declarations from 'cpython.mem' */
-
-/* Module declarations from 'cpython.tuple' */
-
-/* Module declarations from 'cpython.list' */
-
-/* Module declarations from 'cpython.sequence' */
-
-/* Module declarations from 'cpython.mapping' */
-
-/* Module declarations from 'cpython.iterator' */
-
-/* Module declarations from 'cpython.number' */
-
-/* Module declarations from 'cpython.int' */
-
-/* Module declarations from '__builtin__' */
-
-/* Module declarations from 'cpython.bool' */
-static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
-
-/* Module declarations from 'cpython.long' */
-
-/* Module declarations from 'cpython.float' */
-
-/* Module declarations from '__builtin__' */
-
-/* Module declarations from 'cpython.complex' */
-static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
-
-/* Module declarations from 'cpython.string' */
-
-/* Module declarations from 'cpython.unicode' */
-
-/* Module declarations from 'cpython.dict' */
-
-/* Module declarations from 'cpython.instance' */
-
-/* Module declarations from 'cpython.function' */
-
-/* Module declarations from 'cpython.method' */
-
-/* Module declarations from 'cpython.weakref' */
-
-/* Module declarations from 'cpython.getargs' */
-
-/* Module declarations from 'cpython.pythread' */
-
-/* Module declarations from 'cpython.pystate' */
-
-/* Module declarations from 'cpython.cobject' */
-
-/* Module declarations from 'cpython.oldbuffer' */
-
-/* Module declarations from 'cpython.set' */
-
-/* Module declarations from 'cpython.buffer' */
-
-/* Module declarations from 'cpython.bytes' */
-
-/* Module declarations from 'cpython.pycapsule' */
-
-/* Module declarations from 'cpython' */
-
-/* Module declarations from 'cpython.object' */
-
-/* Module declarations from 'cpython.ref' */
-
-/* Module declarations from 'libc.errno' */
-
-/* Module declarations from 'gevent.libev.corecext' */
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext__EVENTSType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_callback = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_CallbackFIFO = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_loop = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_watcher = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_io = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_timer = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_signal = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_idle = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_prepare = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_check = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_fork = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_async_ = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_child = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_stat = 0;
-static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = 0;
-static PyObject *__pyx_v_6gevent_5libev_8corecext_integer_types = 0;
-__PYX_EXTERN_C DL_EXPORT(PyObject) *GEVENT_CORE_EVENTS;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_io_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_timer_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_signal_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_idle_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_prepare_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_check_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_fork_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_async_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_child_ss;
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_6gevent_5libev_8corecext_stat_ss;
-__PYX_EXTERN_C DL_EXPORT(PyObject) *_empty_tuple;
-static PyObject *__pyx_f_6gevent_5libev_8corecext__flags_to_list(unsigned int, int __pyx_skip_dispatch); /*proto*/
-static unsigned int __pyx_f_6gevent_5libev_8corecext__flags_to_int(PyObject *, int __pyx_skip_dispatch); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__str_hex(PyObject *); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__check_flags(unsigned int, int __pyx_skip_dispatch); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__events_to_str(int, int __pyx_skip_dispatch); /*proto*/
-static int __pyx_f_6gevent_5libev_8corecext__check_loop(struct PyGeventLoopObject *); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext__python_incref(struct PyGeventWatcherObject *); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext__python_decref(struct PyGeventWatcherObject *); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext__libev_ref(struct PyGeventWatcherObject *); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext__libev_unref(struct PyGeventWatcherObject *); /*proto*/
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_f_6gevent_5libev_8corecext_make_ss(void *, void *); /*proto*/
-static int __pyx_f_6gevent_5libev_8corecext__watcher_start(struct PyGeventWatcherObject *, PyObject *, PyObject *); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext__syserr_cb(char *); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_set_syserr_cb(PyObject *, int __pyx_skip_dispatch); /*proto*/
-__PYX_EXTERN_C void gevent_handle_error(struct PyGeventLoopObject *, PyObject *); /*proto*/
-__PYX_EXTERN_C PyObject *gevent_loop_run_callbacks(struct PyGeventLoopObject *); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.libev.corecext"
-extern int __pyx_module_is_main_gevent__libev__corecext;
-int __pyx_module_is_main_gevent__libev__corecext = 0;
-
-/* Implementation of 'gevent.libev.corecext' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_KeyError;
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_hex;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_SystemError;
-static PyObject *__pyx_builtin_AttributeError;
-static PyObject *__pyx_builtin_TypeError;
-static const char __pyx_k_[] = ",";
-static const char __pyx_k_t[] = "t";
-static const char __pyx_k_v[] = "v";
-static const char __pyx_k__3[] = ", ";
-static const char __pyx_k__4[] = "|";
-static const char __pyx_k__6[] = "<...>";
-static const char __pyx_k__7[] = ">";
-static const char __pyx_k__8[] = "";
-static const char __pyx_k__9[] = ": ";
-static const char __pyx_k_fd[] = "fd";
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_os[] = "os";
-static const char __pyx_k_tb[] = "tb";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_hex[] = "hex";
-static const char __pyx_k_how[] = "how";
-static const char __pyx_k_now[] = "now";
-static const char __pyx_k_pid[] = "pid";
-static const char __pyx_k_ptr[] = "ptr";
-static const char __pyx_k_ref[] = "ref";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_FORK[] = "FORK";
-static const char __pyx_k_IDLE[] = "IDLE";
-static const char __pyx_k_NONE[] = "NONE";
-static const char __pyx_k_NSIG[] = "NSIG";
-static const char __pyx_k_READ[] = "READ";
-static const char __pyx_k_STAT[] = "STAT";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_func[] = "func";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_keys[] = "keys";
-static const char __pyx_k_loop[] = "loop";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_once[] = "once";
-static const char __pyx_k_path[] = "path";
-static const char __pyx_k_poll[] = "poll";
-static const char __pyx_k_port[] = "port";
-static const char __pyx_k_send[] = "send";
-static const char __pyx_k_stop[] = "stop";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_time[] = "time";
-static const char __pyx_k_type[] = "type";
-static const char __pyx_k_ASYNC[] = "ASYNC";
-static const char __pyx_k_CHECK[] = "CHECK";
-static const char __pyx_k_CHILD[] = "CHILD";
-static const char __pyx_k_EMBED[] = "EMBED";
-static const char __pyx_k_ERROR[] = "ERROR";
-static const char __pyx_k_TIMER[] = "TIMER";
-static const char __pyx_k_UNDEF[] = "UNDEF";
-static const char __pyx_k_WRITE[] = "WRITE";
-static const char __pyx_k_after[] = "after";
-static const char __pyx_k_async[] = "async_";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_epoll[] = "epoll";
-static const char __pyx_k_errno[] = "errno";
-static const char __pyx_k_flags[] = "_flags";
-static const char __pyx_k_level[] = "level";
-static const char __pyx_k_lower[] = "lower";
-static const char __pyx_k_noenv[] = "noenv";
-static const char __pyx_k_ref_2[] = " ref=";
-static const char __pyx_k_sigfd[] = "sigfd";
-static const char __pyx_k_split[] = "split";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_strip[] = "strip";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_trace[] = "trace";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_win32[] = "win32";
-static const char __pyx_k_CUSTOM[] = "CUSTOM";
-static const char __pyx_k_EVENTS[] = "EVENTS";
-static const char __pyx_k_MAXPRI[] = "MAXPRI";
-static const char __pyx_k_MINPRI[] = "MINPRI";
-static const char __pyx_k_SIGNAL[] = "SIGNAL";
-static const char __pyx_k_active[] = "active";
-static const char __pyx_k_args_r[] = " args=%r";
-static const char __pyx_k_decode[] = "decode";
-static const char __pyx_k_encode[] = "encode";
-static const char __pyx_k_events[] = "_events";
-static const char __pyx_k_fileno[] = "fileno";
-static const char __pyx_k_format[] = "_format";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_kqueue[] = "kqueue";
-static const char __pyx_k_nowait[] = "nowait";
-static const char __pyx_k_repeat[] = "repeat";
-static const char __pyx_k_select[] = "select";
-static const char __pyx_k_signal[] = "signal";
-static const char __pyx_k_signum[] = "signum";
-static const char __pyx_k_update[] = "update";
-static const char __pyx_k_CLEANUP[] = "CLEANUP";
-static const char __pyx_k_IOFDSET[] = "_IOFDSET";
-static const char __pyx_k_PREPARE[] = "PREPARE";
-static const char __pyx_k_async_2[] = "async";
-static const char __pyx_k_backend[] = "backend";
-static const char __pyx_k_context[] = "context";
-static const char __pyx_k_default[] = "default";
-static const char __pyx_k_flags_2[] = "flags";
-static const char __pyx_k_genexpr[] = "genexpr";
-static const char __pyx_k_message[] = "message";
-static const char __pyx_k_pending[] = "pending";
-static const char __pyx_k_revents[] = "revents";
-static const char __pyx_k_rstatus[] = "rstatus";
-static const char __pyx_k_stopped[] = " stopped";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_PERIODIC[] = "PERIODIC";
-static const char __pyx_k_SIGNALFD[] = "SIGNALFD";
-static const char __pyx_k_active_2[] = " active";
-static const char __pyx_k_builtins[] = "__builtins__";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_events_2[] = "events";
-static const char __pyx_k_fileno_2[] = " fileno=";
-static const char __pyx_k_interval[] = "interval";
-static const char __pyx_k_platform[] = "platform";
-static const char __pyx_k_priority[] = "priority";
-static const char __pyx_k_signalfd[] = "signalfd";
-static const char __pyx_k_strerror[] = "strerror";
-static const char __pyx_k_FORKCHECK[] = "FORKCHECK";
-static const char __pyx_k_NOINOTIFY[] = "NOINOTIFY";
-static const char __pyx_k_NOSIGMASK[] = "NOSIGMASK";
-static const char __pyx_k_READWRITE[] = "READWRITE";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_activecnt[] = "activecnt";
-static const char __pyx_k_default_2[] = " default";
-static const char __pyx_k_destroyed[] = "destroyed";
-static const char __pyx_k_forkcheck[] = "forkcheck";
-static const char __pyx_k_noinotify[] = "noinotify";
-static const char __pyx_k_nosigmask[] = "nosigmask";
-static const char __pyx_k_pending_2[] = " pending";
-static const char __pyx_k_pending_s[] = " pending=%s";
-static const char __pyx_k_print_exc[] = "print_exc";
-static const char __pyx_k_signalnum[] = "signalnum";
-static const char __pyx_k_traceback[] = "traceback";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_basestring[] = "basestring";
-static const char __pyx_k_callback_r[] = " callback=%r";
-static const char __pyx_k_events_str[] = "events_str";
-static const char __pyx_k_pendingcnt[] = "pendingcnt";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_update_now[] = "update_now";
-static const char __pyx_k_LIBEV_EMBED[] = "LIBEV_EMBED";
-static const char __pyx_k_SystemError[] = "SystemError";
-static const char __pyx_k_get_version[] = "get_version";
-static const char __pyx_k_libev_d_02d[] = "libev-%d.%02d";
-static const char __pyx_k_pass_events[] = "pass_events";
-static const char __pyx_k_s_at_0x_x_s[] = "<%s at 0x%x%s";
-static const char __pyx_k_BACKEND_POLL[] = "BACKEND_POLL";
-static const char __pyx_k_BACKEND_PORT[] = "BACKEND_PORT";
-static const char __pyx_k_EV_USE_4HEAP[] = "EV_USE_4HEAP";
-static const char __pyx_k_EV_USE_FLOOR[] = "EV_USE_FLOOR";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_signalmodule[] = "signalmodule";
-static const char __pyx_k_version_info[] = "version_info";
-static const char __pyx_k_BACKEND_EPOLL[] = "BACKEND_EPOLL";
-static const char __pyx_k_fd_s_events_s[] = " fd=%s events=%s";
-static const char __pyx_k_flags_str2int[] = "_flags_str2int";
-static const char __pyx_k_handle_syserr[] = "_handle_syserr";
-static const char __pyx_k_origflags_int[] = "origflags_int";
-static const char __pyx_k_s_at_0x_x_s_2[] = "<%s at 0x%x %s>";
-static const char __pyx_k_AttributeError[] = "AttributeError";
-static const char __pyx_k_BACKEND_KQUEUE[] = "BACKEND_KQUEUE";
-static const char __pyx_k_BACKEND_SELECT[] = "BACKEND_SELECT";
-static const char __pyx_k_EV_USE_EVENTFD[] = "EV_USE_EVENTFD";
-static const char __pyx_k_EV_USE_INOTIFY[] = "EV_USE_INOTIFY";
-static const char __pyx_k_format_details[] = "_format_details";
-static const char __pyx_k_EV_USE_REALTIME[] = "EV_USE_REALTIME";
-static const char __pyx_k_EV_USE_SIGNALFD[] = "EV_USE_SIGNALFD";
-static const char __pyx_k_SYSERR_CALLBACK[] = "__SYSERR_CALLBACK";
-static const char __pyx_k_pid_r_rstatus_r[] = " pid=%r rstatus=%r";
-static const char __pyx_k_print_exception[] = "print_exception";
-static const char __pyx_k_EV_USE_MONOTONIC[] = "EV_USE_MONOTONIC";
-static const char __pyx_k_EV_USE_NANOSLEEP[] = "EV_USE_NANOSLEEP";
-static const char __pyx_k_getswitchinterval[] = "getswitchinterval";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_get_header_version[] = "get_header_version";
-static const char __pyx_k_gevent_core_EVENTS[] = "gevent.core.EVENTS";
-static const char __pyx_k_supported_backends[] = "supported_backends";
-static const char __pyx_k_embeddable_backends[] = "embeddable_backends";
-static const char __pyx_k_EV_USE_CLOCK_SYSCALL[] = "EV_USE_CLOCK_SYSCALL";
-static const char __pyx_k_default_handle_error[] = "_default_handle_error";
-static const char __pyx_k_ev_loop_new_s_failed[] = "ev_loop_new(%s) failed";
-static const char __pyx_k_illegal_event_mask_r[] = "illegal event mask: %r";
-static const char __pyx_k_recommended_backends[] = "recommended_backends";
-static const char __pyx_k_Unsupported_backend_s[] = "Unsupported backend: %s";
-static const char __pyx_k_getfilesystemencoding[] = "getfilesystemencoding";
-static const char __pyx_k_gevent_libev_corecext[] = "gevent.libev.corecext";
-static const char __pyx_k_Expected_callable_not_r[] = "Expected callable, not %r";
-static const char __pyx_k_illegal_signal_number_r[] = "illegal signal number: %r";
-static const char __pyx_k_ev_default_loop_s_failed[] = "ev_default_loop(%s) failed";
-static const char __pyx_k_fd_must_be_non_negative_r[] = "fd must be non-negative: %r";
-static const char __pyx_k_operation_on_destroyed_loop[] = "operation on destroyed loop";
-static const char __pyx_k_src_gevent_libev_corecext_pyx[] = "src\\gevent\\libev\\corecext.pyx";
-static const char __pyx_k_Invalid_value_for_backend_0x_x[] = "Invalid value for backend: 0x%x";
-static const char __pyx_k_io_watcher_attribute_events_is[] = "'io' watcher attribute 'events' is read-only while watcher is active";
-static const char __pyx_k_Cannot_construct_a_bare_watcher[] = "Cannot construct a bare watcher";
-static const char __pyx_k_Expected_callable_or_None_got_r[] = "Expected callable or None, got %r";
-static const char __pyx_k_callbacks_r_len_d_head_r_tail_r[] = "<callbacks@%r len=%d head=%r tail=%r>";
-static const char __pyx_k_io_watcher_attribute_fd_is_read[] = "'io' watcher attribute 'fd' is read-only while watcher is active";
-static const char __pyx_k_repeat_must_be_positive_or_zero[] = "repeat must be positive or zero: %r";
-static const char __pyx_k_Cannot_set_priority_of_an_active[] = "Cannot set priority of an active watcher";
-static const char __pyx_k_Child_watchers_are_not_supported[] = "Child watchers are not supported on Windows";
-static const char __pyx_k_Invalid_backend_or_flag_s_Possib[] = "Invalid backend or flag: %s\nPossible values: %s";
-static const char __pyx_k_child_watchers_are_only_availabl[] = "child watchers are only available on the default loop";
-static PyObject *__pyx_kp_s_;
-static PyObject *__pyx_n_s_ASYNC;
-static PyObject *__pyx_n_s_AttributeError;
-static PyObject *__pyx_n_s_BACKEND_EPOLL;
-static PyObject *__pyx_n_s_BACKEND_KQUEUE;
-static PyObject *__pyx_n_s_BACKEND_POLL;
-static PyObject *__pyx_n_s_BACKEND_PORT;
-static PyObject *__pyx_n_s_BACKEND_SELECT;
-static PyObject *__pyx_n_s_CHECK;
-static PyObject *__pyx_n_s_CHILD;
-static PyObject *__pyx_n_s_CLEANUP;
-static PyObject *__pyx_n_s_CUSTOM;
-static PyObject *__pyx_kp_s_Cannot_construct_a_bare_watcher;
-static PyObject *__pyx_kp_s_Cannot_set_priority_of_an_active;
-static PyObject *__pyx_kp_s_Child_watchers_are_not_supported;
-static PyObject *__pyx_n_s_EMBED;
-static PyObject *__pyx_n_s_ERROR;
-static PyObject *__pyx_n_s_EVENTS;
-static PyObject *__pyx_n_s_EV_USE_4HEAP;
-static PyObject *__pyx_n_s_EV_USE_CLOCK_SYSCALL;
-static PyObject *__pyx_n_s_EV_USE_EVENTFD;
-static PyObject *__pyx_n_s_EV_USE_FLOOR;
-static PyObject *__pyx_n_s_EV_USE_INOTIFY;
-static PyObject *__pyx_n_s_EV_USE_MONOTONIC;
-static PyObject *__pyx_n_s_EV_USE_NANOSLEEP;
-static PyObject *__pyx_n_s_EV_USE_REALTIME;
-static PyObject *__pyx_n_s_EV_USE_SIGNALFD;
-static PyObject *__pyx_kp_s_Expected_callable_not_r;
-static PyObject *__pyx_kp_s_Expected_callable_or_None_got_r;
-static PyObject *__pyx_n_s_FORK;
-static PyObject *__pyx_n_s_FORKCHECK;
-static PyObject *__pyx_n_s_IDLE;
-static PyObject *__pyx_n_s_IOFDSET;
-static PyObject *__pyx_kp_s_Invalid_backend_or_flag_s_Possib;
-static PyObject *__pyx_kp_s_Invalid_value_for_backend_0x_x;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_LIBEV_EMBED;
-static PyObject *__pyx_n_s_MAXPRI;
-static PyObject *__pyx_n_s_MINPRI;
-static PyObject *__pyx_n_s_NOINOTIFY;
-static PyObject *__pyx_n_s_NONE;
-static PyObject *__pyx_n_s_NOSIGMASK;
-static PyObject *__pyx_n_s_NSIG;
-static PyObject *__pyx_n_s_PERIODIC;
-static PyObject *__pyx_n_s_PREPARE;
-static PyObject *__pyx_n_s_READ;
-static PyObject *__pyx_n_s_READWRITE;
-static PyObject *__pyx_n_s_SIGNAL;
-static PyObject *__pyx_n_s_SIGNALFD;
-static PyObject *__pyx_n_s_STAT;
-static PyObject *__pyx_n_s_SYSERR_CALLBACK;
-static PyObject *__pyx_n_s_SystemError;
-static PyObject *__pyx_n_s_TIMER;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_UNDEF;
-static PyObject *__pyx_kp_s_Unsupported_backend_s;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_n_s_WRITE;
-static PyObject *__pyx_kp_s__3;
-static PyObject *__pyx_kp_s__4;
-static PyObject *__pyx_kp_s__6;
-static PyObject *__pyx_kp_s__7;
-static PyObject *__pyx_kp_s__8;
-static PyObject *__pyx_kp_s__9;
-static PyObject *__pyx_n_s_active;
-static PyObject *__pyx_kp_s_active_2;
-static PyObject *__pyx_n_s_activecnt;
-static PyObject *__pyx_n_s_after;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_kp_s_args_r;
-static PyObject *__pyx_n_s_async;
-static PyObject *__pyx_n_s_async_2;
-static PyObject *__pyx_n_s_backend;
-static PyObject *__pyx_n_s_basestring;
-static PyObject *__pyx_n_s_builtins;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_kp_s_callback_r;
-static PyObject *__pyx_kp_s_callbacks_r_len_d_head_r_tail_r;
-static PyObject *__pyx_kp_s_child_watchers_are_only_availabl;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_context;
-static PyObject *__pyx_n_s_decode;
-static PyObject *__pyx_n_s_default;
-static PyObject *__pyx_kp_s_default_2;
-static PyObject *__pyx_n_s_default_handle_error;
-static PyObject *__pyx_n_s_destroyed;
-static PyObject *__pyx_n_s_embeddable_backends;
-static PyObject *__pyx_n_s_encode;
-static PyObject *__pyx_n_s_epoll;
-static PyObject *__pyx_n_s_errno;
-static PyObject *__pyx_kp_s_ev_default_loop_s_failed;
-static PyObject *__pyx_kp_s_ev_loop_new_s_failed;
-static PyObject *__pyx_n_s_events;
-static PyObject *__pyx_n_s_events_2;
-static PyObject *__pyx_n_s_events_str;
-static PyObject *__pyx_n_s_fd;
-static PyObject *__pyx_kp_s_fd_must_be_non_negative_r;
-static PyObject *__pyx_kp_s_fd_s_events_s;
-static PyObject *__pyx_n_s_fileno;
-static PyObject *__pyx_kp_s_fileno_2;
-static PyObject *__pyx_n_s_flags;
-static PyObject *__pyx_n_s_flags_2;
-static PyObject *__pyx_n_s_flags_str2int;
-static PyObject *__pyx_n_s_forkcheck;
-static PyObject *__pyx_n_s_format;
-static PyObject *__pyx_n_s_format_details;
-static PyObject *__pyx_n_s_func;
-static PyObject *__pyx_n_s_genexpr;
-static PyObject *__pyx_n_s_get_header_version;
-static PyObject *__pyx_n_s_get_version;
-static PyObject *__pyx_n_s_getfilesystemencoding;
-static PyObject *__pyx_n_s_getswitchinterval;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_kp_s_gevent_core_EVENTS;
-static PyObject *__pyx_n_s_gevent_libev_corecext;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_handle_syserr;
-static PyObject *__pyx_n_s_hex;
-static PyObject *__pyx_n_s_how;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_kp_s_illegal_event_mask_r;
-static PyObject *__pyx_kp_s_illegal_signal_number_r;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_interval;
-static PyObject *__pyx_kp_s_io_watcher_attribute_events_is;
-static PyObject *__pyx_kp_s_io_watcher_attribute_fd_is_read;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_keys;
-static PyObject *__pyx_n_s_kqueue;
-static PyObject *__pyx_n_s_level;
-static PyObject *__pyx_kp_s_libev_d_02d;
-static PyObject *__pyx_n_s_loop;
-static PyObject *__pyx_n_s_lower;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_message;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_noenv;
-static PyObject *__pyx_n_s_noinotify;
-static PyObject *__pyx_n_s_nosigmask;
-static PyObject *__pyx_n_s_now;
-static PyObject *__pyx_n_s_nowait;
-static PyObject *__pyx_n_s_once;
-static PyObject *__pyx_kp_s_operation_on_destroyed_loop;
-static PyObject *__pyx_n_s_origflags_int;
-static PyObject *__pyx_n_s_os;
-static PyObject *__pyx_n_s_pass_events;
-static PyObject *__pyx_n_s_path;
-static PyObject *__pyx_n_s_pending;
-static PyObject *__pyx_kp_s_pending_2;
-static PyObject *__pyx_kp_s_pending_s;
-static PyObject *__pyx_n_s_pendingcnt;
-static PyObject *__pyx_n_s_pid;
-static PyObject *__pyx_kp_s_pid_r_rstatus_r;
-static PyObject *__pyx_n_s_platform;
-static PyObject *__pyx_n_s_poll;
-static PyObject *__pyx_n_s_port;
-static PyObject *__pyx_n_s_print_exc;
-static PyObject *__pyx_n_s_print_exception;
-static PyObject *__pyx_n_s_priority;
-static PyObject *__pyx_n_s_ptr;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_recommended_backends;
-static PyObject *__pyx_n_s_ref;
-static PyObject *__pyx_kp_s_ref_2;
-static PyObject *__pyx_n_s_repeat;
-static PyObject *__pyx_kp_s_repeat_must_be_positive_or_zero;
-static PyObject *__pyx_n_s_revents;
-static PyObject *__pyx_n_s_rstatus;
-static PyObject *__pyx_kp_s_s_at_0x_x_s;
-static PyObject *__pyx_kp_s_s_at_0x_x_s_2;
-static PyObject *__pyx_n_s_select;
-static PyObject *__pyx_n_s_send;
-static PyObject *__pyx_n_s_sigfd;
-static PyObject *__pyx_n_s_signal;
-static PyObject *__pyx_n_s_signalfd;
-static PyObject *__pyx_n_s_signalmodule;
-static PyObject *__pyx_n_s_signalnum;
-static PyObject *__pyx_n_s_signum;
-static PyObject *__pyx_n_s_split;
-static PyObject *__pyx_kp_s_src_gevent_libev_corecext_pyx;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_stop;
-static PyObject *__pyx_kp_s_stopped;
-static PyObject *__pyx_n_s_strerror;
-static PyObject *__pyx_n_s_strip;
-static PyObject *__pyx_n_s_supported_backends;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_t;
-static PyObject *__pyx_n_s_tb;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_n_s_time;
-static PyObject *__pyx_n_s_trace;
-static PyObject *__pyx_n_s_traceback;
-static PyObject *__pyx_n_s_type;
-static PyObject *__pyx_n_s_update;
-static PyObject *__pyx_n_s_update_now;
-static PyObject *__pyx_n_s_v;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_version_info;
-static PyObject *__pyx_n_s_win32;
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO___init__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_2__nonzero__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto */
-static Py_ssize_t __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_4__len__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_6__iter__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_8__repr__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop___cinit__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, intptr_t __pyx_v_ptr); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_2__init__(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_flags, CYTHON_UNUSED PyObject *__pyx_v_default, CYTHON_UNUSED intptr_t __pyx_v_ptr); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static void __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_28update_now(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_46async_(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_58_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher___init__(struct PyGeventWatcherObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_3ref___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_3ref_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8callback___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_8callback_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8priority___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_8priority_2__set__(struct PyGeventWatcherObject *__pyx_v_self, int __pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6active___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_7pending___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_2start(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4stop(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6feed(struct PyGeventWatcherObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8__repr__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_10_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_12close(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_14__enter__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_16__exit__(struct PyGeventWatcherObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4loop___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_4__del__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4args___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_4__del__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6_flags___get__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_2io_2__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED vfd_socket_t __pyx_v_fd, CYTHON_UNUSED int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_2io_4__cinit__(struct PyGeventIOObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static void __pyx_pf_6gevent_5libev_8corecext_2io_6__dealloc__(struct PyGeventIOObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5timer___cinit__(struct PyGeventTimerObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5timer_2__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED double __pyx_v_after, CYTHON_UNUSED double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_6signal___cinit__(struct PyGeventSignalObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_6signal_2__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4idle___cinit__(struct PyGeventIdleObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_7prepare___cinit__(struct PyGeventPrepareObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5check___cinit__(struct PyGeventCheckObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4fork___cinit__(struct PyGeventForkObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6async__7pending___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_6async____cinit__(struct PyGeventAsyncObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6async__2send(struct PyGeventAsyncObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5child___cinit__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, CYTHON_UNUSED PyObject *__pyx_v_ref); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5child_2__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_v_pid, CYTHON_UNUSED int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4_format(struct PyGeventChildObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4stat___cinit__(struct PyGeventStatObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority); /* proto */
-static int __pyx_pf_6gevent_5libev_8corecext_4stat_2__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_path, CYTHON_UNUSED float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback); /* proto */
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext__EVENTSType(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_callback(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_CallbackFIFO(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_loop(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_watcher(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_async_(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_3;
-static int __pyx_k__10;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__12;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__14;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__16;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__20;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__22;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_codeobj__24;
-static PyObject *__pyx_codeobj__25;
-static PyObject *__pyx_codeobj__26;
-static PyObject *__pyx_codeobj__27;
-static PyObject *__pyx_codeobj__28;
-static PyObject *__pyx_codeobj__29;
-/* Late includes */
-static PyObject *__pyx_gb_6gevent_5libev_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
-
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self) {
- struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("genexpr", 0);
- __pyx_cur_scope = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(__pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, __pyx_empty_tuple, NULL);
- if (unlikely(!__pyx_cur_scope)) {
- __pyx_cur_scope = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)Py_None);
- __Pyx_INCREF(Py_None);
- __PYX_ERR(0, 149, __pyx_L1_error)
- } else {
- __Pyx_GOTREF(__pyx_cur_scope);
- }
- {
- __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gevent_5libev_8corecext_24generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_gevent_libev_corecext); if (unlikely(!gen)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_cur_scope);
- __Pyx_RefNannyFinishContext();
- return (PyObject *) gen;
- }
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_gb_6gevent_5libev_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
-{
- struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)__pyx_generator->closure);
- PyObject *__pyx_r = NULL;
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *(*__pyx_t_8)(PyObject *);
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("genexpr", 0);
- switch (__pyx_generator->resume_label) {
- case 0: goto __pyx_L3_first_run;
- default: /* CPython raises the right error here */
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_r = PyDict_New(); if (unlikely(!__pyx_r)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_r);
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 149, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 149, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- #else
- __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
- index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_5);
- index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_6);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_t_8 = NULL;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L7_unpacking_done;
- __pyx_L6_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_L7_unpacking_done:;
- }
- __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_flag);
- __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_flag, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_5);
- __pyx_t_5 = 0;
- __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_string);
- __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_string, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_6);
- __pyx_t_6 = 0;
- if (unlikely(PyDict_SetItem(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_string, (PyObject*)__pyx_cur_scope->__pyx_v_flag))) __PYX_ERR(0, 149, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
- __pyx_generator->resume_label = -1;
- __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-PyObject *GEVENT_CORE_EVENTS = 0;
-PyObject *_empty_tuple = 0;
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(((struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s_gevent_core_EVENTS);
- __pyx_r = __pyx_kp_s_gevent_core_EVENTS;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_1get_version = {"get_version", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_1get_version, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_version (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_get_version(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("get_version", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(ev_version_major()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(ev_version_minor()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_3get_header_version = {"get_header_version", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_3get_header_version, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_header_version (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2get_header_version(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("get_header_version", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(EV_VERSION_MAJOR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_VERSION_MINOR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.get_header_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__flags_to_list(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_result = 0;
- PyObject *__pyx_v_code = NULL;
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *(*__pyx_t_8)(PyObject *);
- int __pyx_t_9;
- int __pyx_t_10;
- unsigned int __pyx_t_11;
- __Pyx_RefNannySetupContext("_flags_to_list", 0);
-
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 172, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 172, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 172, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 172, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- #else
- __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
- index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_5);
- index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_6);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 172, __pyx_L1_error)
- __pyx_t_8 = NULL;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 172, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_code, __pyx_t_5);
- __pyx_t_5 = 0;
- __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6);
- __pyx_t_6 = 0;
-
- __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_code); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 173, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (__pyx_t_9) {
-
- __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_value); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 174, __pyx_L1_error)
-
- }
-
- __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = PyNumber_Invert(__pyx_v_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = PyNumber_InPlaceAnd(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_11 = __Pyx_PyInt_As_unsigned_int(__pyx_t_5); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_flags = __pyx_t_11;
-
- __pyx_t_9 = ((!(__pyx_v_flags != 0)) != 0);
- if (__pyx_t_9) {
-
- goto __pyx_L4_break;
-
- }
-
- }
- __pyx_L4_break:;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_9 = (__pyx_v_flags != 0);
- if (__pyx_t_9) {
-
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_code);
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags) {
- unsigned int __pyx_v_flags;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_flags_to_list (wrapper)", 0);
- assert(__pyx_arg_flags); {
- __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(__pyx_self, ((unsigned int)__pyx_v_flags));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_flags_to_list", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/
-static unsigned int __pyx_f_6gevent_5libev_8corecext__flags_to_int(PyObject *__pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) {
- unsigned int __pyx_v_result;
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_v_ex = NULL;
- unsigned int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- unsigned int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- Py_ssize_t __pyx_t_9;
- PyObject *(*__pyx_t_10)(PyObject *);
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- int __pyx_t_14;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- int __pyx_t_17;
- __Pyx_RefNannySetupContext("_flags_to_int", 0);
- __Pyx_INCREF(__pyx_v_flags);
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_flags); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 191, __pyx_L1_error)
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- __pyx_r = 0;
- goto __pyx_L0;
-
- }
-
- __pyx_t_3 = __pyx_v_6gevent_5libev_8corecext_integer_types;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_2 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L1_error)
- __pyx_r = __pyx_t_4;
- goto __pyx_L0;
-
- }
-
- __pyx_v_result = 0;
-
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- /*try:*/ {
-
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_basestring); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 197, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_flags, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 198, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF_SET(__pyx_v_flags, __pyx_t_8);
- __pyx_t_8 = 0;
-
- }
-
- if (likely(PyList_CheckExact(__pyx_v_flags)) || PyTuple_CheckExact(__pyx_v_flags)) {
- __pyx_t_8 = __pyx_v_flags; __Pyx_INCREF(__pyx_t_8); __pyx_t_9 = 0;
- __pyx_t_10 = NULL;
- } else {
- __pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 199, __pyx_L5_error)
- }
- for (;;) {
- if (likely(!__pyx_t_10)) {
- if (likely(PyList_CheckExact(__pyx_t_8))) {
- if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 199, __pyx_L5_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- } else {
- if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 199, __pyx_L5_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- }
- } else {
- __pyx_t_3 = __pyx_t_10(__pyx_t_8);
- if (unlikely(!__pyx_t_3)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 199, __pyx_L5_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_3);
- }
- __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_3);
- __pyx_t_3 = 0;
-
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_strip); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_13 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
- __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
- if (likely(__pyx_t_13)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
- __Pyx_INCREF(__pyx_t_13);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_12, function);
- }
- }
- if (__pyx_t_13) {
- __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 200, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- } else {
- __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 200, __pyx_L5_error)
- }
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_lower); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_12, function);
- }
- }
- if (__pyx_t_11) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L5_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
- __pyx_t_3 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 201, __pyx_L5_error)
- if (__pyx_t_2) {
-
- __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 202, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_12, __pyx_v_value); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 202, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = PyNumber_InPlaceOr(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 202, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_12); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_v_result = __pyx_t_4;
-
- }
-
- }
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- }
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L10_try_end;
- __pyx_L5_error:;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_14) {
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 203, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_INCREF(__pyx_t_12);
- __pyx_v_ex = __pyx_t_12;
-
- __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_keys); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- __pyx_t_15 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
- __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16);
- if (likely(__pyx_t_15)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
- __Pyx_INCREF(__pyx_t_15);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_16, function);
- }
- }
- if (__pyx_t_15) {
- __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- } else {
- __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- }
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
- __pyx_t_16 = PySequence_List(__pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_3 = ((PyObject*)__pyx_t_16);
- __pyx_t_16 = 0;
- __pyx_t_17 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __pyx_t_16 = __Pyx_PyString_Join(__pyx_kp_s__3, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_ex);
- __Pyx_GIVEREF(__pyx_v_ex);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ex);
- __Pyx_GIVEREF(__pyx_t_16);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_16);
- __pyx_t_16 = 0;
- __pyx_t_16 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 204, __pyx_L7_except_error)
- }
- goto __pyx_L7_except_error;
- __pyx_L7_except_error:;
-
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- goto __pyx_L1_error;
- __pyx_L10_try_end:;
- }
-
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_XDECREF(__pyx_t_16);
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XDECREF(__pyx_v_ex);
- __Pyx_XDECREF(__pyx_v_flags);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_flags_to_int (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(__pyx_self, ((PyObject *)__pyx_v_flags));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- unsigned int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_flags_to_int", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_1 == ((unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_f_6gevent_5libev_8corecext__str_hex(PyObject *__pyx_v_flag) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("_str_hex", 0);
-
- __pyx_t_1 = __pyx_v_6gevent_5libev_8corecext_integer_types;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_IsInstance(__pyx_v_flag, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 209, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_v_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 210, __pyx_L1_error)
- __pyx_r = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 211, __pyx_L1_error)
- __pyx_r = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext._str_hex", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__check_flags(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_as_list = 0;
- PyObject *__pyx_v_x = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *(*__pyx_t_6)(PyObject *);
- __Pyx_RefNannySetupContext("_check_flags", 0);
-
- __pyx_v_flags = (__pyx_v_flags & EVBACKEND_MASK);
-
- __pyx_t_1 = ((!(__pyx_v_flags != 0)) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- __pyx_t_1 = ((!((__pyx_v_flags & EVBACKEND_ALL) != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 220, __pyx_L1_error)
-
- }
-
- __pyx_t_1 = ((!((__pyx_v_flags & ev_supported_backends()) != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
- __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
- __pyx_t_6 = NULL;
- } else {
- __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- for (;;) {
- if (likely(!__pyx_t_6)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 222, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- } else {
- if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 222, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- }
- } else {
- __pyx_t_3 = __pyx_t_6(__pyx_t_4);
- if (unlikely(!__pyx_t_3)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 222, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_3);
- }
- __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext__str_hex(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_as_list = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_as_list); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_backend_s, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 223, __pyx_L1_error)
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_as_list);
- __Pyx_XDECREF(__pyx_v_x);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags) {
- unsigned int __pyx_v_flags;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_check_flags (wrapper)", 0);
- assert(__pyx_arg_flags); {
- __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 214, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8_check_flags(__pyx_self, ((unsigned int)__pyx_v_flags));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_check_flags", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_flags(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext__events_to_str(int __pyx_v_events, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_result = 0;
- int __pyx_v_c_flag;
- PyObject *__pyx_v_flag = NULL;
- PyObject *__pyx_v_string = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *(*__pyx_t_8)(PyObject *);
- int __pyx_t_9;
- int __pyx_t_10;
- int __pyx_t_11;
- __Pyx_RefNannySetupContext("_events_to_str", 0);
-
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_events); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 229, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 229, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 229, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 229, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 229, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- #else
- __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
- index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_5);
- index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_6);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
- __pyx_t_8 = NULL;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 229, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_flag, __pyx_t_5);
- __pyx_t_5 = 0;
- __Pyx_XDECREF_SET(__pyx_v_string, __pyx_t_6);
- __pyx_t_6 = 0;
-
- __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_flag); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error)
- __pyx_v_c_flag = __pyx_t_9;
-
- __pyx_t_10 = ((__pyx_v_events & __pyx_v_c_flag) != 0);
- if (__pyx_t_10) {
-
- __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_string); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 232, __pyx_L1_error)
-
- __pyx_v_events = (__pyx_v_events & (~__pyx_v_c_flag));
-
- }
-
- __pyx_t_10 = ((!(__pyx_v_events != 0)) != 0);
- if (__pyx_t_10) {
-
- goto __pyx_L4_break;
-
- }
-
- }
- __pyx_L4_break:;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_10 = (__pyx_v_events != 0);
- if (__pyx_t_10) {
-
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 237, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_flag);
- __Pyx_XDECREF(__pyx_v_string);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events) {
- int __pyx_v_events;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_events_to_str (wrapper)", 0);
- assert(__pyx_arg_events); {
- __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 226, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_10_events_to_str(__pyx_self, ((int)__pyx_v_events));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_events_to_str", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__events_to_str(__pyx_v_events, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_13supported_backends = {"supported_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_13supported_backends, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("supported_backends (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12supported_backends(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("supported_backends", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_supported_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.supported_backends", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_15recommended_backends = {"recommended_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_15recommended_backends, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("recommended_backends (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_14recommended_backends(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("recommended_backends", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_recommended_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.recommended_backends", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_17embeddable_backends = {"embeddable_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("embeddable_backends (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("embeddable_backends", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_embeddable_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.embeddable_backends", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_19time = {"time", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_19time, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("time (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_18time(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("time", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(ev_time()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.time", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static int __pyx_f_6gevent_5libev_8corecext__check_loop(struct PyGeventLoopObject *__pyx_v_loop) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("_check_loop", 0);
-
- __pyx_t_1 = ((!(__pyx_v_loop->_ptr != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 258, __pyx_L1_error)
-
- }
-
- __pyx_r = 1;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext._check_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_args = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_args,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 268, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 268, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_callback = values[0];
- __pyx_v_args = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 268, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback___init__(((struct PyGeventCallbackObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = __pyx_v_callback;
-
- if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 270, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_args;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stop (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_2stop(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stop", 0);
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = Py_None;
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)Py_None);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__nonzero__", 0);
-
- __pyx_t_1 = (__pyx_v_self->args != ((PyObject*)Py_None));
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = (__pyx_v_self->callback != Py_None);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.callback.pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_v_format = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- char const *__pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- __pyx_t_1 = ((Py_ReprEnter(((PyObject *)__pyx_v_self)) != 0) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s__6);
- __pyx_r = __pyx_kp_s__6;
- goto __pyx_L0;
-
- }
-
- /*try:*/ {
-
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L5_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_format = __pyx_t_2;
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_format);
- __Pyx_GIVEREF(__pyx_v_format);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_format);
- __pyx_t_3 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_result = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 297, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_1 = (__pyx_v_self->callback != Py_None);
- __pyx_t_5 = (__pyx_t_1 != 0);
- if (__pyx_t_5) {
-
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_self->callback);
- __Pyx_GIVEREF(__pyx_v_self->callback);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->callback);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_5 = (__pyx_v_self->args != ((PyObject*)Py_None));
- __pyx_t_1 = (__pyx_t_5 != 0);
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_self->args);
- __Pyx_GIVEREF(__pyx_v_self->args);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->args);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_5 = (__pyx_v_self->callback == Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_1 = __pyx_t_6;
- goto __pyx_L11_bool_binop_done;
- }
- __pyx_t_6 = (__pyx_v_self->args == ((PyObject*)Py_None));
- __pyx_t_5 = (__pyx_t_6 != 0);
- __pyx_t_1 = __pyx_t_5;
- __pyx_L11_bool_binop_done:;
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_stopped); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L4_return;
- }
-
- /*finally:*/ {
- __pyx_L5_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
- {
- Py_ReprLeave(((PyObject *)__pyx_v_self));
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
- }
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
- __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
- __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
- goto __pyx_L1_error;
- }
- __pyx_L4_return: {
- __pyx_t_15 = __pyx_r;
- __pyx_r = 0;
- Py_ReprLeave(((PyObject *)__pyx_v_self));
- __pyx_r = __pyx_t_15;
- __pyx_t_15 = 0;
- goto __pyx_L0;
- }
- }
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.callback.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_format);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8_format(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s__8);
- __pyx_r = __pyx_kp_s__8;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->callback);
- __pyx_r = __pyx_v_self->callback;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->callback);
- __Pyx_DECREF(__pyx_v_self->callback);
- __pyx_v_self->callback = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->args);
- __pyx_r = __pyx_v_self->args;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 265, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.callback.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
- if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO___init__(((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO___init__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->head);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
- __pyx_v_self->head = ((struct PyGeventCallbackObject *)Py_None);
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->tail);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->tail));
- __pyx_v_self->tail = ((struct PyGeventCallbackObject *)Py_None);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static CYTHON_INLINE struct PyGeventCallbackObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_popleft(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- struct PyGeventCallbackObject *__pyx_v_head = 0;
- struct PyGeventCallbackObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("popleft", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->head);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_head = ((struct PyGeventCallbackObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_1 = ((PyObject *)__pyx_v_head->next);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->head);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
- __pyx_v_self->head = ((struct PyGeventCallbackObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_3 = (__pyx_v_self->head == __pyx_v_self->tail);
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (!__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = (((PyObject *)__pyx_v_self->head) == Py_None);
- __pyx_t_3 = (__pyx_t_4 != 0);
- __pyx_t_2 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_2) {
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->tail);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->tail));
- __pyx_v_self->tail = ((struct PyGeventCallbackObject *)Py_None);
-
- }
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_head->next);
- __Pyx_DECREF(((PyObject *)__pyx_v_head->next));
- __pyx_v_head->next = ((struct PyGeventCallbackObject *)Py_None);
-
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __Pyx_INCREF(((PyObject *)__pyx_v_head));
- __pyx_r = __pyx_v_head;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_head);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_append(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self, struct PyGeventCallbackObject *__pyx_v_new_tail) {
- struct PyGeventCallbackObject *__pyx_v_old_tail = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("append", 0);
-
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_new_tail->next)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 334, __pyx_L1_error)
- if (unlikely(!((!__pyx_t_1) != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 334, __pyx_L1_error)
- }
- }
- #endif
-
- __pyx_t_1 = (((PyObject *)__pyx_v_self->tail) == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- __pyx_t_2 = (((PyObject *)__pyx_v_self->head) == Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- __Pyx_INCREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GOTREF(__pyx_v_self->head);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
- __pyx_v_self->head = __pyx_v_new_tail;
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- __pyx_t_3 = ((PyObject *)__pyx_v_self->head);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->tail);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->tail));
- __pyx_v_self->tail = ((struct PyGeventCallbackObject *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- }
-
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_1 = (((PyObject *)__pyx_v_self->head) != Py_None);
- if (unlikely(!(__pyx_t_1 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 344, __pyx_L1_error)
- }
- }
- #endif
-
- __pyx_t_3 = ((PyObject *)__pyx_v_self->tail);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_v_old_tail = ((struct PyGeventCallbackObject *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- __Pyx_INCREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GOTREF(__pyx_v_old_tail->next);
- __Pyx_DECREF(((PyObject *)__pyx_v_old_tail->next));
- __pyx_v_old_tail->next = __pyx_v_new_tail;
-
- __Pyx_INCREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_new_tail));
- __Pyx_GOTREF(__pyx_v_self->tail);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->tail));
- __pyx_v_self->tail = __pyx_v_new_tail;
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.CallbackFIFO.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_old_tail);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_3__nonzero__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_3__nonzero__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_2__nonzero__(((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_2__nonzero__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__nonzero__", 0);
-
- __pyx_t_1 = (((PyObject *)__pyx_v_self->head) != Py_None);
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static Py_ssize_t __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_5__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_5__len__(PyObject *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_4__len__(((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_ssize_t __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_4__len__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- Py_ssize_t __pyx_v_count;
- struct PyGeventCallbackObject *__pyx_v_head = NULL;
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__len__", 0);
-
- __pyx_v_count = 0;
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->head);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_head = ((struct PyGeventCallbackObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- while (1) {
- __pyx_t_2 = (((PyObject *)__pyx_v_head) != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (!__pyx_t_3) break;
-
- __pyx_v_count = (__pyx_v_count + 1);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_head->next);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_head, ((struct PyGeventCallbackObject *)__pyx_t_1));
- __pyx_t_1 = 0;
- }
-
- __pyx_r = __pyx_v_count;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_head);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_7__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_7__iter__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_6__iter__(((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_6__iter__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- PyObject *__pyx_v_objects = 0;
- struct PyGeventCallbackObject *__pyx_v_head = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_objects = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->head);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_head = ((struct PyGeventCallbackObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- while (1) {
- __pyx_t_2 = (((PyObject *)__pyx_v_head) != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (!__pyx_t_3) break;
-
- __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_objects, ((PyObject *)__pyx_v_head)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 364, __pyx_L1_error)
-
- __pyx_t_1 = ((PyObject *)__pyx_v_head->next);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_head, ((struct PyGeventCallbackObject *)__pyx_t_1));
- __pyx_t_1 = 0;
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_GetIter(__pyx_v_objects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.CallbackFIFO.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_objects);
- __Pyx_XDECREF((PyObject *)__pyx_v_head);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static int __pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_has_callbacks(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("has_callbacks", 0);
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->head)); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 369, __pyx_L1_error)
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_WriteUnraisable("gevent.libev.corecext.CallbackFIFO.has_callbacks", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_9__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_9__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_8__repr__(((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_12CallbackFIFO_8__repr__(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 372, __pyx_L1_error)
- __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->head));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->head));
- PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_self->head));
- __Pyx_INCREF(((PyObject *)__pyx_v_self->tail));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->tail));
- PyTuple_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_v_self->tail));
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_callbacks_r_len_d_head_r_tail_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.CallbackFIFO.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_flags = 0;
- PyObject *__pyx_v_default = 0;
- intptr_t __pyx_v_ptr;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags_2,&__pyx_n_s_default,&__pyx_n_s_ptr,0};
- PyObject* values[3] = {0,0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags_2);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 396, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_flags = values[0];
- __pyx_v_default = values[1];
- if (values[2]) {
- __pyx_v_ptr = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_ptr == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 396, __pyx_L3_error)
- } else {
- __pyx_v_ptr = ((intptr_t)0);
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 396, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop___cinit__(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_flags, __pyx_v_default, __pyx_v_ptr);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop___cinit__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, intptr_t __pyx_v_ptr) {
- unsigned int __pyx_v_c_flags;
- CYTHON_UNUSED PyObject *__pyx_v_old_handler = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- unsigned int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("__cinit__", 0);
- __Pyx_INCREF(__pyx_v_default);
-
- __pyx_v_self->starting_timer_may_update_loop_time = 0;
-
- __pyx_v_self->_default = 0;
-
- ev_prepare_init((&__pyx_v_self->_prepare), ((void *)gevent_run_callbacks));
-
- ev_timer_init((&__pyx_v_self->_periodic_signal_checker), ((void *)gevent_periodic_signal_check), 0.3, 0.3);
-
- ev_timer_init((&__pyx_v_self->_timer0), ((void *)gevent_noop), 0.0, 0.0);
-
- __Pyx_INCREF(Py_None);
- __pyx_v_old_handler = Py_None;
-
- __pyx_t_1 = (__pyx_v_ptr != 0);
- if (__pyx_t_1) {
-
- __pyx_v_self->_ptr = ((struct ev_loop *)__pyx_v_ptr);
-
- __pyx_v_self->_default = ev_is_default_loop(__pyx_v_self->_ptr);
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_2 == ((unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L1_error)
- __pyx_v_c_flags = __pyx_t_2;
-
- __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext__check_flags(__pyx_v_c_flags, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_NOENV);
-
- __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_FORKCHECK);
-
- __pyx_t_1 = (__pyx_v_default == Py_None);
- __pyx_t_4 = (__pyx_t_1 != 0);
- if (__pyx_t_4) {
-
- __Pyx_INCREF(Py_True);
- __Pyx_DECREF_SET(__pyx_v_default, Py_True);
-
- }
-
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 420, __pyx_L1_error)
- if (__pyx_t_4) {
-
- __pyx_v_self->_default = 1;
-
- __pyx_v_self->_ptr = gevent_ev_default_loop(__pyx_v_c_flags);
-
- __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0);
- if (unlikely(__pyx_t_4)) {
-
- __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 424, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_default_loop_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_SystemError, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 424, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_5, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __PYX_ERR(0, 424, __pyx_L1_error)
-
- }
-
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_platform); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_win32, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__pyx_t_4) {
-
- ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_periodic_signal_checker));
-
- ev_unref(__pyx_v_self->_ptr);
-
- }
-
- goto __pyx_L5;
- }
-
- /*else*/ {
- __pyx_v_self->_ptr = ev_loop_new(__pyx_v_c_flags);
-
- __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0);
- if (unlikely(__pyx_t_4)) {
-
- __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_loop_new_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_SystemError, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_5, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __PYX_ERR(0, 431, __pyx_L1_error)
-
- }
- }
- __pyx_L5:;
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 432, __pyx_L1_error)
- if (!__pyx_t_1) {
- } else {
- __pyx_t_4 = __pyx_t_1;
- goto __pyx_L10_bool_binop_done;
- }
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_1 = (__pyx_t_5 == Py_None);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_6 = (__pyx_t_1 != 0);
- __pyx_t_4 = __pyx_t_6;
- __pyx_L10_bool_binop_done:;
- if (__pyx_t_4) {
-
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 433, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(__pyx_t_5, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- }
- }
- __pyx_L3:;
-
- ev_set_userdata(__pyx_v_self->_ptr, __pyx_v_self->_ptr);
-
- ev_prepare_start(__pyx_v_self->_ptr, (&__pyx_v_self->_prepare));
-
- ev_unref(__pyx_v_self->_ptr);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_old_handler);
- __Pyx_XDECREF(__pyx_v_default);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED PyObject *__pyx_v_flags = 0;
- CYTHON_UNUSED PyObject *__pyx_v_default = 0;
- CYTHON_UNUSED intptr_t __pyx_v_ptr;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags_2,&__pyx_n_s_default,&__pyx_n_s_ptr,0};
- PyObject* values[3] = {0,0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags_2);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 441, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_flags = values[0];
- __pyx_v_default = values[1];
- if (values[2]) {
- __pyx_v_ptr = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_ptr == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L3_error)
- } else {
- __pyx_v_ptr = ((intptr_t)0);
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 441, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_2__init__(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_flags, __pyx_v_default, __pyx_v_ptr);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_2__init__(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_flags, CYTHON_UNUSED PyObject *__pyx_v_default, CYTHON_UNUSED intptr_t __pyx_v_ptr) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_CallbackFIFO)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_callbacks);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_callbacks));
- __pyx_v_self->_callbacks = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_t_1);
- __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self) {
- struct PyGeventCallbackObject *__pyx_v_cb = 0;
- int __pyx_v_count;
- ev_tstamp __pyx_v_now;
- ev_tstamp __pyx_v_expiration;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- ev_tstamp __pyx_t_4;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- char const *__pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- __Pyx_RefNannySetupContext("_run_callbacks", 0);
-
- __pyx_v_count = 50;
-
- __pyx_v_self->starting_timer_may_update_loop_time = 1;
-
- __pyx_v_now = ev_now(__pyx_v_self->_ptr);
-
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getswitchinterval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == ((ev_tstamp)-1)) && PyErr_Occurred())) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_expiration = (__pyx_v_now + ((ev_tstamp)__pyx_t_4));
-
- /*try:*/ {
-
- ev_timer_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0));
-
- while (1) {
- __pyx_t_5 = (((PyObject *)__pyx_v_self->_callbacks->head) != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (!__pyx_t_6) break;
-
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_popleft(__pyx_v_self->_callbacks)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XDECREF_SET(__pyx_v_cb, ((struct PyGeventCallbackObject *)__pyx_t_1));
- __pyx_t_1 = 0;
-
- ev_unref(__pyx_v_self->_ptr);
-
- gevent_call(__pyx_v_self, __pyx_v_cb);
-
- __pyx_v_count = (__pyx_v_count - 1);
-
- __pyx_t_5 = ((__pyx_v_count == 0) != 0);
- if (__pyx_t_5) {
- } else {
- __pyx_t_6 = __pyx_t_5;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_5 = (((PyObject *)__pyx_v_self->_callbacks->head) != Py_None);
- __pyx_t_7 = (__pyx_t_5 != 0);
- __pyx_t_6 = __pyx_t_7;
- __pyx_L9_bool_binop_done:;
- if (__pyx_t_6) {
-
- __pyx_v_count = 50;
-
- ev_now_update(__pyx_v_self->_ptr);
-
- __pyx_t_6 = ((ev_now(__pyx_v_self->_ptr) >= __pyx_v_expiration) != 0);
- if (__pyx_t_6) {
-
- __pyx_v_now = 0.0;
-
- goto __pyx_L7_break;
-
- }
-
- }
- }
- __pyx_L7_break:;
-
- __pyx_t_6 = ((__pyx_v_now != 0.0) != 0);
- if (__pyx_t_6) {
-
- ev_now_update(__pyx_v_self->_ptr);
-
- }
-
- __pyx_t_6 = (((PyObject *)__pyx_v_self->_callbacks->head) != Py_None);
- __pyx_t_7 = (__pyx_t_6 != 0);
- if (__pyx_t_7) {
-
- ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0));
-
- }
- }
-
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_v_self->starting_timer_may_update_loop_time = 0;
- goto __pyx_L5;
- }
- __pyx_L4_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __pyx_t_8 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
- {
- __pyx_v_self->starting_timer_may_update_loop_time = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- }
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
- __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
- __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
- goto __pyx_L1_error;
- }
- __pyx_L5:;
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._run_callbacks", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_cb);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__stop_watchers(struct PyGeventLoopObject *__pyx_v_self, struct ev_loop *__pyx_v_ptr) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("_stop_watchers", 0);
-
- __pyx_t_1 = ((!(__pyx_v_ptr != 0)) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- __pyx_t_1 = (ev_is_active((&__pyx_v_self->_prepare)) != 0);
- if (__pyx_t_1) {
-
- ev_ref(__pyx_v_ptr);
-
- ev_prepare_stop(__pyx_v_ptr, (&__pyx_v_self->_prepare));
-
- }
-
- __pyx_t_1 = (ev_is_active((&__pyx_v_self->_periodic_signal_checker)) != 0);
- if (__pyx_t_1) {
-
- ev_ref(__pyx_v_ptr);
-
- ev_timer_stop(__pyx_v_ptr, (&__pyx_v_self->_periodic_signal_checker));
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self) {
- struct ev_loop *__pyx_v_ptr;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- struct ev_loop *__pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("destroy", 0);
-
- __pyx_t_1 = __pyx_v_self->_ptr;
- __pyx_v_ptr = __pyx_t_1;
-
- __pyx_v_self->_ptr = NULL;
-
- __pyx_t_2 = (__pyx_v_ptr != 0);
- if (__pyx_t_2) {
-
- __pyx_t_2 = ((!(ev_userdata(__pyx_v_ptr) != 0)) != 0);
- if (__pyx_t_2) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- ev_set_userdata(__pyx_v_ptr, NULL);
-
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->_stop_watchers(__pyx_v_self, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 502, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 503, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 503, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (__pyx_t_2) {
-
- __pyx_t_5 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- }
-
- ev_loop_destroy(__pyx_v_ptr);
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static void __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self) {
- struct ev_loop *__pyx_v_ptr;
- __Pyx_RefNannyDeclarations
- struct ev_loop *__pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- __pyx_t_1 = __pyx_v_self->_ptr;
- __pyx_v_ptr = __pyx_t_1;
-
- __pyx_v_self->_ptr = NULL;
-
- __pyx_t_2 = ((__pyx_v_ptr != NULL) != 0);
- if (__pyx_t_2) {
-
- __pyx_t_2 = ((!(ev_userdata(__pyx_v_ptr) != 0)) != 0);
- if (__pyx_t_2) {
-
- goto __pyx_L0;
-
- }
-
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->_stop_watchers(__pyx_v_self, __pyx_v_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 514, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- __pyx_t_2 = ((!(__pyx_v_self->_default != 0)) != 0);
- if (__pyx_t_2) {
-
- ev_loop_destroy(__pyx_v_ptr);
-
- ev_set_userdata(__pyx_v_ptr, NULL);
-
- }
-
- }
-
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_WriteUnraisable("gevent.libev.corecext.loop.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.ptr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher));
- __pyx_r = ((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher);
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.MAXPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.MINPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_message = 0;
- PyObject *__pyx_v_errno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_handle_syserr (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_message,&__pyx_n_s_errno,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_errno)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, 1); __PYX_ERR(0, 536, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_syserr") < 0)) __PYX_ERR(0, 536, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_message = values[0];
- __pyx_v_errno = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 536, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_message, __pyx_v_errno);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("_handle_syserr", 0);
- __Pyx_INCREF(__pyx_v_message);
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 537, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_3) {
-
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_message, __pyx_t_2);
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_2 = PyNumber_Add(__pyx_v_message, __pyx_kp_s__9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strerror); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_errno); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_errno};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_errno};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_errno);
- __Pyx_GIVEREF(__pyx_v_errno);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_errno);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_SystemError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->handle_error(__pyx_v_self, Py_None, __pyx_builtin_SystemError, __pyx_t_1, Py_None, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_message);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) {
- PyObject *__pyx_v_handle_error = 0;
- PyObject *__pyx_v_error_handler = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("handle_error", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_context);
- __Pyx_GIVEREF(__pyx_v_context);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context);
- __Pyx_INCREF(__pyx_v_type);
- __Pyx_GIVEREF(__pyx_v_type);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value);
- __Pyx_INCREF(__pyx_v_tb);
- __Pyx_GIVEREF(__pyx_v_tb);
- PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- __pyx_t_1 = __pyx_v_self->error_handler;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_error_handler = __pyx_t_1;
- __pyx_t_1 = 0;
-
- __pyx_t_7 = (__pyx_v_error_handler != Py_None);
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_error_handler, __pyx_n_s_handle_error, __pyx_v_error_handler); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_handle_error = __pyx_t_1;
- __pyx_t_1 = 0;
-
- __Pyx_INCREF(__pyx_v_handle_error);
- __pyx_t_2 = __pyx_v_handle_error; __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 547, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_context);
- __Pyx_GIVEREF(__pyx_v_context);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context);
- __Pyx_INCREF(__pyx_v_type);
- __Pyx_GIVEREF(__pyx_v_type);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value);
- __Pyx_INCREF(__pyx_v_tb);
- __Pyx_GIVEREF(__pyx_v_tb);
- PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->_default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L3:;
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_handle_error);
- __Pyx_XDECREF(__pyx_v_error_handler);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_context = 0;
- PyObject *__pyx_v_type = 0;
- PyObject *__pyx_v_value = 0;
- PyObject *__pyx_v_tb = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("handle_error (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0};
- PyObject* values[4] = {0,0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 1); __PYX_ERR(0, 541, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 2); __PYX_ERR(0, 541, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 3); __PYX_ERR(0, 541, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_error") < 0)) __PYX_ERR(0, 541, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- }
- __pyx_v_context = values[0];
- __pyx_v_type = values[1];
- __pyx_v_value = values[2];
- __pyx_v_tb = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 541, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("handle_error", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_4loop_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("_default_handle_error", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_default_handle_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_context);
- __Pyx_GIVEREF(__pyx_v_context);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context);
- __Pyx_INCREF(__pyx_v_type);
- __Pyx_GIVEREF(__pyx_v_type);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value);
- __Pyx_INCREF(__pyx_v_tb);
- __Pyx_GIVEREF(__pyx_v_tb);
- PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_print_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_type, __pyx_v_value, __pyx_v_tb};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_2) {
- __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
- }
- __Pyx_INCREF(__pyx_v_type);
- __Pyx_GIVEREF(__pyx_v_type);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_type);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_value);
- __Pyx_INCREF(__pyx_v_tb);
- __Pyx_GIVEREF(__pyx_v_tb);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_7 = (__pyx_v_self->_ptr != 0);
- if (__pyx_t_7) {
-
- ev_break(__pyx_v_self->_ptr, EVBREAK_ONE);
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_context = 0;
- PyObject *__pyx_v_type = 0;
- PyObject *__pyx_v_value = 0;
- PyObject *__pyx_v_tb = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_default_handle_error (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0};
- PyObject* values[4] = {0,0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 1); __PYX_ERR(0, 551, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 2); __PYX_ERR(0, 551, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 3); __PYX_ERR(0, 551, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_default_handle_error") < 0)) __PYX_ERR(0, 551, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- }
- __pyx_v_context = values[0];
- __pyx_v_type = values[1];
- __pyx_v_value = values[2];
- __pyx_v_tb = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 551, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_default_handle_error", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_nowait = 0;
- PyObject *__pyx_v_once = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("run (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nowait,&__pyx_n_s_once,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_False);
- values[1] = ((PyObject *)Py_False);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nowait);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_once);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run") < 0)) __PYX_ERR(0, 558, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_nowait = values[0];
- __pyx_v_once = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("run", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 558, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_14run(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_nowait, __pyx_v_once);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once) {
- unsigned int __pyx_v_flags;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("run", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 559, __pyx_L1_error)
-
- __pyx_v_flags = 0;
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_nowait); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 561, __pyx_L1_error)
- if (__pyx_t_1) {
-
- __pyx_v_flags = (__pyx_v_flags | EVRUN_NOWAIT);
-
- }
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_once); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 563, __pyx_L1_error)
- if (__pyx_t_1) {
-
- __pyx_v_flags = (__pyx_v_flags | EVRUN_ONCE);
-
- }
-
- {
- #ifdef WITH_THREAD
- PyThreadState *_save;
- Py_UNBLOCK_THREADS
- __Pyx_FastGIL_Remember();
- #endif
- /*try:*/ {
-
- ev_run(__pyx_v_self->_ptr, __pyx_v_flags);
- }
-
- /*finally:*/ {
- /*normal exit:*/{
- #ifdef WITH_THREAD
- __Pyx_FastGIL_Forget();
- Py_BLOCK_THREADS
- #endif
- goto __pyx_L7;
- }
- __pyx_L7:;
- }
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("reinit (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("reinit", 0);
-
- __pyx_t_1 = (__pyx_v_self->_ptr != 0);
- if (__pyx_t_1) {
-
- ev_loop_fork(__pyx_v_self->_ptr);
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("ref (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_18ref(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("ref", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 573, __pyx_L1_error)
-
- ev_ref(__pyx_v_self->_ptr);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.ref", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("unref (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_20unref(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("unref", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 577, __pyx_L1_error)
-
- ev_unref(__pyx_v_self->_ptr);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.unref", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_how;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("break_ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_how,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_how);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "break_") < 0)) __PYX_ERR(0, 580, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- if (values[0]) {
- __pyx_v_how = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_how == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 580, __pyx_L3_error)
- } else {
- __pyx_v_how = __pyx_k__10;
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("break_", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 580, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_22break_(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_how);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("break_", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 581, __pyx_L1_error)
-
- ev_break(__pyx_v_self->_ptr, __pyx_v_how);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("verify (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_24verify(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("verify", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 585, __pyx_L1_error)
-
- ev_verify(__pyx_v_self->_ptr);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.verify", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static ev_tstamp __pyx_f_6gevent_5libev_8corecext_4loop_now(struct PyGeventLoopObject *__pyx_v_self, int __pyx_skip_dispatch) {
- ev_tstamp __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- ev_tstamp __pyx_t_5;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("now", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_now); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_27now)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == ((ev_tstamp)-1)) && PyErr_Occurred())) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- __pyx_t_6 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 589, __pyx_L1_error)
-
- __pyx_r = ev_now(__pyx_v_self->_ptr);
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.now", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("now (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_26now(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- ev_tstamp __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("now", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_4loop_now(__pyx_v_self, 1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 588, __pyx_L1_error)
- __pyx_t_2 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.now", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_29update_now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static void __pyx_f_6gevent_5libev_8corecext_4loop_update_now(struct PyGeventLoopObject *__pyx_v_self, int __pyx_skip_dispatch) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("update_now", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_now); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_29update_now)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- __pyx_t_5 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 593, __pyx_L1_error)
-
- ev_now_update(__pyx_v_self->_ptr);
-
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.update_now", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_29update_now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_29update_now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("update_now (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_28update_now(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_28update_now(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("update_now", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_f_6gevent_5libev_8corecext_4loop_update_now(__pyx_v_self, 1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 592, __pyx_L1_error)
- __pyx_t_1 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.update_now", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- if ((__pyx_v_self->_ptr != 0)) {
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->_default); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __pyx_t_2;
- __pyx_t_2 = 0;
- } else {
- __Pyx_INCREF(Py_False);
- __pyx_t_1 = Py_False;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.default.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 609, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_iteration(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.iteration.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 614, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_depth(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.depth.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 619, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_backend(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.backend_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self) {
- unsigned int __pyx_v_backend;
- PyObject *__pyx_v_key = NULL;
- PyObject *__pyx_v_value = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- Py_ssize_t __pyx_t_4;
- PyObject *(*__pyx_t_5)(PyObject *);
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *(*__pyx_t_9)(PyObject *);
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 624, __pyx_L1_error)
-
- __pyx_v_backend = ev_backend(__pyx_v_self->_ptr);
-
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
- __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
- __pyx_t_5 = NULL;
- } else {
- __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 626, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- for (;;) {
- if (likely(!__pyx_t_5)) {
- if (likely(PyList_CheckExact(__pyx_t_3))) {
- if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 626, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- } else {
- if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 626, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- }
- } else {
- __pyx_t_2 = __pyx_t_5(__pyx_t_3);
- if (unlikely(!__pyx_t_2)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 626, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_2);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
- PyObject* sequence = __pyx_t_2;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 626, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- #else
- __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- #endif
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 626, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
- index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_6);
- index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_7);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 626, __pyx_L1_error)
- __pyx_t_9 = NULL;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_9 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 626, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6);
- __pyx_t_6 = 0;
- __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_7);
- __pyx_t_7 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = PyObject_RichCompare(__pyx_v_key, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 627, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 627, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_value);
- __pyx_r = __pyx_v_value;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L0;
-
- }
-
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.backend.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_key);
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 633, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_pending_count(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.pendingcnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- vfd_socket_t __pyx_v_fd;
- int __pyx_v_events;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("io (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[4] = {0,0,0,0};
- values[2] = ((PyObject *)Py_True);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); __PYX_ERR(0, 636, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) __PYX_ERR(0, 636, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_fd = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 636, __pyx_L3_error)
- __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 636, __pyx_L3_error)
- __pyx_v_ref = values[2];
- __pyx_v_priority = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 636, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_32io(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("io", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- double __pyx_v_after;
- double __pyx_v_repeat;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("timer (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[4] = {0,0,0,0};
- values[2] = ((PyObject *)Py_True);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_after)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_repeat);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "timer") < 0)) __PYX_ERR(0, 639, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_after = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
- if (values[1]) {
- __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
- } else {
- __pyx_v_repeat = ((double)0.0);
- }
- __pyx_v_ref = values[2];
- __pyx_v_priority = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("timer", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 639, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_34timer(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("timer", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_after); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_timer), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_signum;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("signal (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signum,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signum)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "signal") < 0)) __PYX_ERR(0, 642, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_signum = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_signum == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 642, __pyx_L3_error)
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("signal", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 642, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_36signal(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_signum, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("signal", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_signum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_priority);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_signal), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("idle (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "idle") < 0)) __PYX_ERR(0, 645, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_ref = values[0];
- __pyx_v_priority = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("idle", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 645, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_38idle(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("idle", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_idle), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("prepare (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prepare") < 0)) __PYX_ERR(0, 648, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_ref = values[0];
- __pyx_v_priority = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("prepare", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 648, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("prepare", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_prepare), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("check (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check") < 0)) __PYX_ERR(0, 651, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_ref = values[0];
- __pyx_v_priority = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("check", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 651, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_42check(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("check", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_check), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("fork (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fork") < 0)) __PYX_ERR(0, 654, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_ref = values[0];
- __pyx_v_priority = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("fork", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 654, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_44fork(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("fork", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_fork), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 655, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_47async_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_47async_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("async_ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "async_") < 0)) __PYX_ERR(0, 657, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_ref = values[0];
- __pyx_v_priority = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("async_", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 657, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.async_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_46async_(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_46async_(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("async_", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_async_), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.async_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_pid;
- int __pyx_v_trace;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("child (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0};
- PyObject* values[3] = {0,0,0};
- values[2] = ((PyObject *)Py_True);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_trace);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "child") < 0)) __PYX_ERR(0, 663, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_pid = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 663, __pyx_L3_error)
- if (values[1]) {
- __pyx_v_trace = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 663, __pyx_L3_error)
- } else {
- __pyx_v_trace = ((int)0);
- }
- __pyx_v_ref = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("child", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 663, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_48child(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_pid, __pyx_v_trace, __pyx_v_ref);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("child", 0);
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_win32, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 664, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(__pyx_t_3)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 665, __pyx_L1_error)
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_ref);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_child), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("install_sigchld (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("install_sigchld", 0);
-
- gevent_install_sigchld_handler();
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("reset_sigchld (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("reset_sigchld", 0);
-
- gevent_reset_sigchld_handler();
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_path = 0;
- float __pyx_v_interval;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stat (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[4] = {0,0,0,0};
- values[2] = ((PyObject *)Py_True);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interval);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stat") < 0)) __PYX_ERR(0, 674, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_path = ((PyObject*)values[0]);
- if (values[1]) {
- __pyx_v_interval = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L3_error)
- } else {
- __pyx_v_interval = ((float)0.0);
- }
- __pyx_v_ref = values[2];
- __pyx_v_priority = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("stat", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 674, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) __PYX_ERR(0, 674, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_54stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("stat", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_path);
- __Pyx_GIVEREF(__pyx_v_path);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_path);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_priority);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_stat), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_func = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("run_callback (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "run_callback") < 0)) __PYX_ERR(0, 677, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_func = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("run_callback", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 677, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) {
- struct PyGeventCallbackObject *__pyx_v_cb = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("run_callback", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 678, __pyx_L1_error)
-
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_func);
- __Pyx_GIVEREF(__pyx_v_func);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_func);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_args);
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_callback), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_cb = ((struct PyGeventCallbackObject *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_append(__pyx_v_self->_callbacks, __pyx_v_cb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 680, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- ev_ref(__pyx_v_self->_ptr);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_cb));
- __pyx_r = ((PyObject *)__pyx_v_cb);
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_cb);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_59_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_59_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_58_format(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_58_format(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_v_msg = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_format", 0);
-
- __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_n_s_destroyed);
- __pyx_r = __pyx_n_s_destroyed;
- goto __pyx_L0;
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 687, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_msg = __pyx_t_2;
- __pyx_t_2 = 0;
-
- __pyx_t_1 = (__pyx_v_self->_default != 0);
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_kp_s_default_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2);
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pendingcnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 690, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_pending_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 690, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2);
- __pyx_t_2 = 0;
-
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format_details); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 691, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 691, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 691, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 691, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_3);
- __pyx_t_3 = 0;
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_msg);
- __pyx_r = __pyx_v_msg;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_msg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format_details (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_v_msg = 0;
- PyObject *__pyx_v_fileno = 0;
- PyObject *__pyx_v_activecnt = 0;
- CYTHON_UNUSED PyObject *__pyx_v_sigfd = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("_format_details", 0);
-
- __Pyx_INCREF(__pyx_kp_s__8);
- __pyx_v_msg = __pyx_kp_s__8;
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_fileno = __pyx_t_1;
- __pyx_t_1 = 0;
-
- __Pyx_INCREF(Py_None);
- __pyx_v_activecnt = Py_None;
-
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sigfd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 699, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_sigfd = __pyx_t_1;
- __pyx_t_1 = 0;
-
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_7) {
- __Pyx_AddTraceback("gevent.libev.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 700, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_3);
-
- __Pyx_INCREF(Py_None);
- __Pyx_XDECREF_SET(__pyx_v_sigfd, Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- __pyx_L8_try_end:;
- }
-
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_4);
- /*try:*/ {
-
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_activecnt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF_SET(__pyx_v_activecnt, __pyx_t_3);
- __pyx_t_3 = 0;
-
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L16_try_end;
- __pyx_L11_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_7) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L12_exception_handled;
- }
- goto __pyx_L13_except_error;
- __pyx_L13_except_error:;
-
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
- goto __pyx_L1_error;
- __pyx_L12_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
- __pyx_L16_try_end:;
- }
-
- __pyx_t_8 = (__pyx_v_activecnt != Py_None);
- __pyx_t_9 = (__pyx_t_8 != 0);
- if (__pyx_t_9) {
-
- __pyx_t_3 = PyObject_Repr(__pyx_v_activecnt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = PyNumber_Add(__pyx_kp_s_ref_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3));
- __pyx_t_3 = 0;
-
- }
-
- __pyx_t_9 = (__pyx_v_fileno != Py_None);
- __pyx_t_8 = (__pyx_t_9 != 0);
- if (__pyx_t_8) {
-
- __pyx_t_3 = PyObject_Repr(__pyx_v_fileno); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = PyNumber_Add(__pyx_kp_s_fileno_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3));
- __pyx_t_3 = 0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_msg);
- __pyx_r = __pyx_v_msg;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_msg);
- __Pyx_XDECREF(__pyx_v_fileno);
- __Pyx_XDECREF(__pyx_v_activecnt);
- __Pyx_XDECREF(__pyx_v_sigfd);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("fileno (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(struct PyGeventLoopObject *__pyx_v_self) {
- int __pyx_v_fd;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("fileno", 0);
-
- __pyx_t_1 = (__pyx_v_self->_ptr != 0);
- if (__pyx_t_1) {
-
- __pyx_v_fd = gevent_ev_loop_backend_fd(__pyx_v_self->_ptr);
-
- __pyx_t_1 = ((__pyx_v_fd >= 0) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- }
-
- }
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.fileno", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 721, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(gevent_ev_loop_activecnt(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.activecnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 726, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(gevent_ev_loop_sig_pending(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 727, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.sig_pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- unsigned int __pyx_t_2;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_origflags_int); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 731, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.origflags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 735, __pyx_L1_error)
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(gevent_ev_loop_origflags(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.origflags_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self) {
- int __pyx_v_fd;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_loop(__pyx_v_self); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 740, __pyx_L1_error)
-
- __pyx_v_fd = gevent_ev_loop_sigfd(__pyx_v_self->_ptr);
-
- __pyx_t_1 = ((__pyx_v_fd >= 0) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 746, __pyx_L1_error)
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.loop.sigfd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->error_handler);
- __pyx_r = __pyx_v_self->error_handler;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->error_handler);
- __Pyx_DECREF(__pyx_v_self->error_handler);
- __pyx_v_self->error_handler = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->error_handler);
- __Pyx_DECREF(__pyx_v_self->error_handler);
- __pyx_v_self->error_handler = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->_callbacks));
- __pyx_r = ((PyObject *)__pyx_v_self->_callbacks);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_CallbackFIFO))))) __PYX_ERR(0, 386, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_callbacks);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_callbacks));
- __pyx_v_self->_callbacks = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.loop._callbacks.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(((struct PyGeventLoopObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_callbacks);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_callbacks));
- __pyx_v_self->_callbacks = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static void __pyx_f_6gevent_5libev_8corecext__python_incref(struct PyGeventWatcherObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("_python_incref", 0);
-
- __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0);
- if (__pyx_t_1) {
-
- Py_INCREF(((PyObject *)__pyx_v_self));
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags | 1);
-
- }
-
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-
-static void __pyx_f_6gevent_5libev_8corecext__python_decref(struct PyGeventWatcherObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("_python_decref", 0);
-
- __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0);
- if (__pyx_t_1) {
-
- Py_DECREF(((PyObject *)__pyx_v_self));
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1));
-
- }
-
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-
-static void __pyx_f_6gevent_5libev_8corecext__libev_ref(struct PyGeventWatcherObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("_libev_ref", 0);
-
- __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0);
- if (__pyx_t_1) {
-
- ev_ref(__pyx_v_self->loop->_ptr);
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2));
-
- }
-
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-
-static void __pyx_f_6gevent_5libev_8corecext__libev_unref(struct PyGeventWatcherObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("_libev_unref", 0);
-
- __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0);
- if (__pyx_t_1) {
-
- ev_unref(__pyx_v_self->loop->_ptr);
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags | 2);
-
- }
-
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-
-static struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_f_6gevent_5libev_8corecext_make_ss(void *__pyx_v_start, void *__pyx_v_stop) {
- struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_v_result;
- struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_r;
- __Pyx_RefNannyDeclarations
- struct __pyx_t_6gevent_5libev_8corecext_start_and_stop __pyx_t_1;
- __Pyx_RefNannySetupContext("make_ss", 0);
-
- __pyx_t_1.start = ((__pyx_t_6gevent_5libev_8corecext_start_stop_func)__pyx_v_start);
- __pyx_t_1.stop = ((__pyx_t_6gevent_5libev_8corecext_start_stop_func)__pyx_v_stop);
- __pyx_v_result = __pyx_t_1;
-
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static int __pyx_f_6gevent_5libev_8corecext__watcher_start(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("_watcher_start", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 805, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_3 = (__pyx_v_callback == Py_None);
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (!__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 806, __pyx_L1_error)
- __pyx_t_3 = ((!(__pyx_t_4 != 0)) != 0);
- __pyx_t_2 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_2)) {
-
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 807, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 807, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 807, __pyx_L1_error)
-
- }
-
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- __Pyx_GOTREF(__pyx_v_self->_callback);
- __Pyx_DECREF(__pyx_v_self->_callback);
- __pyx_v_self->_callback = __pyx_v_callback;
-
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_v_args;
-
- __pyx_f_6gevent_5libev_8corecext__libev_unref(__pyx_v_self);
-
- __pyx_f_6gevent_5libev_8corecext__python_incref(__pyx_v_self);
-
- __pyx_v_self->__pyx___ss->start(__pyx_v_self->loop->_ptr, __pyx_v_self->__pyx___watcher);
-
- __pyx_r = 1;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext._watcher_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 860, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 860, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 860, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher___init__(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher___init__(struct PyGeventWatcherObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- unsigned int __pyx_t_4;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = ((!(__pyx_v_self->__pyx___watcher != 0)) != 0);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = ((!(__pyx_v_self->__pyx___ss->start != 0)) != 0);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = ((!(__pyx_v_self->__pyx___ss->stop != 0)) != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 862, __pyx_L1_error)
-
- }
-
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->loop));
- __pyx_v_self->loop = __pyx_v_loop;
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 864, __pyx_L1_error)
- if (__pyx_t_1) {
- __pyx_t_4 = 0;
- } else {
- __pyx_t_4 = 4;
- }
- __pyx_v_self->_flags = __pyx_t_4;
-
- __pyx_t_1 = (__pyx_v_priority != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 866, __pyx_L1_error)
- ev_set_priority(__pyx_v_self->__pyx___watcher, __pyx_t_5);
-
- }
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_3ref___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_3ref___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- if (((__pyx_v_self->_flags & 4) != 0)) {
- __Pyx_INCREF(Py_False);
- __pyx_t_1 = Py_False;
- } else {
- __Pyx_INCREF(Py_True);
- __pyx_t_1 = Py_True;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_3ref_2__set__(((struct PyGeventWatcherObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_3ref_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 874, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 875, __pyx_L1_error)
- if (__pyx_t_2) {
-
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 877, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 877, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_2) {
-
- __pyx_r = 0;
- goto __pyx_L0;
-
- }
-
- __pyx_t_2 = ((__pyx_v_self->_flags & 2) != 0);
- if (__pyx_t_2) {
-
- ev_ref(__pyx_v_self->loop->_ptr);
-
- }
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6));
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 886, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 886, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = ((!__pyx_t_2) != 0);
- if (__pyx_t_3) {
-
- __pyx_r = 0;
- goto __pyx_L0;
-
- }
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags | 4);
-
- __pyx_t_2 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_3 = __pyx_t_2;
- goto __pyx_L8_bool_binop_done;
- }
- __pyx_t_2 = (ev_is_active(__pyx_v_self->__pyx___watcher) != 0);
- __pyx_t_3 = __pyx_t_2;
- __pyx_L8_bool_binop_done:;
- if (__pyx_t_3) {
-
- ev_unref(__pyx_v_self->loop->_ptr);
-
- __pyx_v_self->_flags = (__pyx_v_self->_flags | 2);
-
- }
- }
- __pyx_L3:;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_8callback___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8callback___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_callback);
- __pyx_r = __pyx_v_self->_callback;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_8callback_2__set__(((struct PyGeventWatcherObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_8callback_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_callback) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_t_2 = (__pyx_v_callback != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 899, __pyx_L1_error)
- __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 900, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback);
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 900, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 900, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 900, __pyx_L1_error)
-
- }
-
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- __Pyx_GOTREF(__pyx_v_self->_callback);
- __Pyx_DECREF(__pyx_v_self->_callback);
- __pyx_v_self->_callback = __pyx_v_callback;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_8priority___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8priority___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority(__pyx_v_self->__pyx___watcher)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 905, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) {
- int __pyx_v_priority;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- assert(__pyx_arg_priority); {
- __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 908, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_8priority_2__set__(((struct PyGeventWatcherObject *)__pyx_v_self), ((int)__pyx_v_priority));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_8priority_2__set__(struct PyGeventWatcherObject *__pyx_v_self, int __pyx_v_priority) {
- struct ev_watcher *__pyx_v_w;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- struct ev_watcher *__pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_t_1 = __pyx_v_self->__pyx___watcher;
- __pyx_v_w = __pyx_t_1;
-
- __pyx_t_2 = (ev_is_active(__pyx_v_w) != 0);
- if (unlikely(__pyx_t_2)) {
-
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 911, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 911, __pyx_L1_error)
-
- }
-
- ev_set_priority(__pyx_v_w, __pyx_v_priority);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_6active_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_6active_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_6active___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6active___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- if ((ev_is_active(__pyx_v_self->__pyx___watcher) != 0)) {
- __Pyx_INCREF(Py_True);
- __pyx_t_1 = Py_True;
- } else {
- __Pyx_INCREF(Py_False);
- __pyx_t_1 = Py_False;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_7pending_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_7pending___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_7pending___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- if ((ev_is_pending(__pyx_v_self->__pyx___watcher) != 0)) {
- __Pyx_INCREF(Py_True);
- __pyx_t_1 = Py_True;
- } else {
- __Pyx_INCREF(Py_False);
- __pyx_t_1 = Py_False;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 922, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_callback = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 922, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_2start(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_2start(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("start", 0);
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__watcher_start(__pyx_v_self, __pyx_v_callback, __pyx_v_args); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 923, __pyx_L1_error)
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_5stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_5stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("stop (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4stop(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4stop(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("stop", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 926, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_f_6gevent_5libev_8corecext__libev_ref(__pyx_v_self);
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_callback);
- __Pyx_DECREF(__pyx_v_self->_callback);
- __pyx_v_self->_callback = Py_None;
-
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)Py_None);
-
- __pyx_v_self->__pyx___ss->stop(__pyx_v_self->loop->_ptr, __pyx_v_self->__pyx___watcher);
-
- __pyx_f_6gevent_5libev_8corecext__python_decref(__pyx_v_self);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_7feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_7feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_revents;
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("feed (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 2) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 935, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 935, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 935, __pyx_L3_error)
- __pyx_v_callback = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 935, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.feed", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_6feed(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6feed(struct PyGeventWatcherObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("feed", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 936, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 937, __pyx_L1_error)
-
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = __pyx_v_args;
-
- __pyx_f_6gevent_5libev_8corecext__libev_unref(__pyx_v_self);
-
- ev_feed_event(__pyx_v_self->loop->_ptr, __pyx_v_self->__pyx___watcher, __pyx_v_revents);
-
- __pyx_f_6gevent_5libev_8corecext__python_incref(__pyx_v_self);
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.feed", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_8__repr__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_8__repr__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_v_format = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- char const *__pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- __pyx_t_1 = ((Py_ReprEnter(((PyObject *)__pyx_v_self)) != 0) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s__6);
- __pyx_r = __pyx_kp_s__6;
- goto __pyx_L0;
-
- }
-
- /*try:*/ {
-
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 947, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L5_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_format = __pyx_t_2;
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 948, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 948, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 948, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 948, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_format);
- __Pyx_GIVEREF(__pyx_v_format);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_format);
- __pyx_t_3 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 948, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_result = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_active); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 949, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_active_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 951, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 951, __pyx_L5_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 952, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2));
- __pyx_t_2 = 0;
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = (__pyx_t_2 != Py_None);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_5 = (__pyx_t_1 != 0);
- if (__pyx_t_5) {
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 954, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 954, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4));
- __pyx_t_4 = 0;
-
- }
-
- __pyx_t_5 = (__pyx_v_self->args != ((PyObject*)Py_None));
- __pyx_t_1 = (__pyx_t_5 != 0);
- if (__pyx_t_1) {
-
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_self->args);
- __Pyx_GIVEREF(__pyx_v_self->args);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->args);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 956, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4));
- __pyx_t_4 = 0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 957, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L4_return;
- }
-
- /*finally:*/ {
- __pyx_L5_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
- {
- Py_ReprLeave(((PyObject *)__pyx_v_self));
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- }
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
- __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
- __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
- goto __pyx_L1_error;
- }
- __pyx_L4_return: {
- __pyx_t_14 = __pyx_r;
- __pyx_r = 0;
- Py_ReprLeave(((PyObject *)__pyx_v_self));
- __pyx_r = __pyx_t_14;
- __pyx_t_14 = 0;
- goto __pyx_L0;
- }
- }
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_format);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_11_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_11_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_10_format(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_10_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s__8);
- __pyx_r = __pyx_kp_s__8;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_13close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_13close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("close (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_12close(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_12close(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("close", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 965, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 965, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 965, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_15__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_15__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_14__enter__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_14__enter__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__enter__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_17__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_17__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED PyObject *__pyx_v_t = 0;
- CYTHON_UNUSED PyObject *__pyx_v_v = 0;
- CYTHON_UNUSED PyObject *__pyx_v_tb = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 970, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 970, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 970, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_t = values[0];
- __pyx_v_v = values[1];
- __pyx_v_tb = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 970, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_16__exit__(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_16__exit__(struct PyGeventWatcherObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__exit__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4loop___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->loop));
- __pyx_r = ((PyObject *)__pyx_v_self->loop);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_2__set__(((struct PyGeventWatcherObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 818, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->loop));
- __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_4__del__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4loop_4__del__(struct PyGeventWatcherObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->loop));
- __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_4args_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_4args_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4args___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_4args___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->args);
- __pyx_r = __pyx_v_self->args;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_2__set__(((struct PyGeventWatcherObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_2__set__(struct PyGeventWatcherObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 820, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_4__del__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7watcher_4args_4__del__(struct PyGeventWatcherObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->args);
- __Pyx_DECREF(__pyx_v_self->args);
- __pyx_v_self->args = ((PyObject*)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_6_flags_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_6_flags___get__(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_6_flags___get__(struct PyGeventWatcherObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.watcher._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_1start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_1start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_pass_events = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_pass_events,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_False);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (kw_args == 1) {
- const Py_ssize_t index = 1;
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
- if (value) { values[index] = value; kw_args--; }
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 980, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_callback = values[0];
- __pyx_v_pass_events = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 980, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_start(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_pass_events, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("start", 0);
- __Pyx_INCREF(__pyx_v_args);
-
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_pass_events); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 981, __pyx_L1_error)
- if (__pyx_t_1) {
-
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(GEVENT_CORE_EVENTS);
- __Pyx_GIVEREF(GEVENT_CORE_EVENTS);
- PyTuple_SET_ITEM(__pyx_t_2, 0, GEVENT_CORE_EVENTS);
- __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 982, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_3));
- __pyx_t_3 = 0;
-
- }
-
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__watcher_start(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 983, __pyx_L1_error)
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_2io_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_2io_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED vfd_socket_t __pyx_v_fd;
- CYTHON_UNUSED int __pyx_v_events;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 985, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 985, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 985, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_fd = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 985, __pyx_L3_error)
- __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 985, __pyx_L3_error)
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 985, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 985, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2__init__(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_2io_2__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED vfd_socket_t __pyx_v_fd, CYTHON_UNUSED int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 986, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 986, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)__pyx_v_loop));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_priority);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_2io_5__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_2io_5__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- vfd_socket_t __pyx_v_fd;
- int __pyx_v_events;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(0, 988, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(0, 988, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 988, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_fd = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 988, __pyx_L3_error)
- __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 988, __pyx_L3_error)
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 988, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.io.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 988, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4__cinit__(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_2io_4__cinit__(struct PyGeventIOObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_v_vfd;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- __pyx_t_1 = ((__pyx_v_fd < 0) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 990, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_fd_must_be_non_negative_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 990, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 990, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 990, __pyx_L1_error)
-
- }
-
- __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 992, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 992, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 992, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 992, __pyx_L1_error)
-
- }
-
- __pyx_t_4 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 994, __pyx_L1_error)
- __pyx_v_vfd = __pyx_t_4;
-
- ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_events);
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_io_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.io.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static void __pyx_pw_6gevent_5libev_8corecext_2io_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_6gevent_5libev_8corecext_2io_7__dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_6gevent_5libev_8corecext_2io_6__dealloc__(((struct PyGeventIOObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_pf_6gevent_5libev_8corecext_2io_6__dealloc__(struct PyGeventIOObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- vfd_free(__pyx_v_self->_watcher.fd);
-
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(((struct PyGeventIOObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromSsize_t(vfd_get(__pyx_v_self->_watcher.fd)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1004, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd) {
- long __pyx_v_fd;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- assert(__pyx_arg_fd); {
- __pyx_v_fd = __Pyx_PyInt_As_long(__pyx_arg_fd); if (unlikely((__pyx_v_fd == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1007, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((long)__pyx_v_fd));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd) {
- int __pyx_v_vfd;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1009, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 1009, __pyx_L1_error)
-
- }
-
- __pyx_t_3 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1010, __pyx_L1_error)
- __pyx_v_vfd = __pyx_t_3;
-
- vfd_free(__pyx_v_self->_watcher.fd);
-
- ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_self->_watcher.events);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(((struct PyGeventIOObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.events); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1016, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.io.events.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events) {
- int __pyx_v_events;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- assert(__pyx_arg_events); {
- __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1019, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((int)__pyx_v_events));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1021, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 1021, __pyx_L1_error)
-
- }
-
- ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_self->_watcher.fd, __pyx_v_events);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(((struct PyGeventIOObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__events_to_str(__pyx_v_self->_watcher.events, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1026, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.io.events_str.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8_format(((struct PyGeventIOObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_format", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_events_str); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1029, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_fd_s_events_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.io._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5timer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5timer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- double __pyx_v_after;
- double __pyx_v_repeat;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_after);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_repeat);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1037, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- if (values[1]) {
- __pyx_v_after = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1037, __pyx_L3_error)
- } else {
- __pyx_v_after = ((double)0.0);
- }
- if (values[2]) {
- __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1037, __pyx_L3_error)
- } else {
- __pyx_v_repeat = ((double)0.0);
- }
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1037, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.timer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1037, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer___cinit__(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5timer___cinit__(struct PyGeventTimerObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- __pyx_t_1 = ((__pyx_v_repeat < 0.0) != 0);
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1039, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1039, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1039, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 1039, __pyx_L1_error)
-
- }
-
- ev_timer_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_timer), __pyx_v_after, __pyx_v_repeat);
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_timer_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.timer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5timer_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5timer_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED double __pyx_v_after;
- CYTHON_UNUSED double __pyx_v_repeat;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_after);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_repeat);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1044, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- if (values[1]) {
- __pyx_v_after = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1044, __pyx_L3_error)
- } else {
- __pyx_v_after = ((double)0.0);
- }
- if (values[2]) {
- __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1044, __pyx_L3_error)
- } else {
- __pyx_v_repeat = ((double)0.0);
- }
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1044, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1044, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_2__init__(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5timer_2__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED double __pyx_v_after, CYTHON_UNUSED double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1045, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1045, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)__pyx_v_loop));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_priority);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_update = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("start (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (kw_args == 1) {
- const Py_ssize_t index = 1;
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
- if (value) { values[index] = value; kw_args--; }
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1047, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_callback = values[0];
- __pyx_v_update = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1047, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4start(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("start", 0);
- __Pyx_INCREF(__pyx_v_update);
-
- __pyx_t_2 = (__pyx_v_update != Py_None);
- if ((__pyx_t_2 != 0)) {
- __Pyx_INCREF(__pyx_v_update);
- __pyx_t_1 = __pyx_v_update;
- } else {
- __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.loop->starting_timer_may_update_loop_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1048, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __pyx_t_3;
- __pyx_t_3 = 0;
- }
- __Pyx_DECREF_SET(__pyx_v_update, __pyx_t_1);
- __pyx_t_1 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1049, __pyx_L1_error)
- if (__pyx_t_2) {
-
- ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_base.loop->__pyx_vtab)->update_now(__pyx_v_self->__pyx_base.loop, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1050, __pyx_L1_error)
-
- }
-
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__watcher_start(((struct PyGeventWatcherObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1051, __pyx_L1_error)
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_update);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(((struct PyGeventTimerObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.timer.at.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_7again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_7again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_update = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("again (wrapper)", 0);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0};
- PyObject* values[2] = {0,0};
- values[1] = ((PyObject *)Py_True);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (kw_args == 1) {
- const Py_ssize_t index = 1;
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
- if (value) { values[index] = value; kw_args--; }
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "again") < 0)) __PYX_ERR(0, 1059, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_callback = values[0];
- __pyx_v_update = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("again", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1059, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_AddTraceback("gevent.libev.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_6again(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("again", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1060, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1061, __pyx_L1_error)
-
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- __Pyx_GOTREF(__pyx_v_self->__pyx_base.args);
- __Pyx_DECREF(__pyx_v_self->__pyx_base.args);
- __pyx_v_self->__pyx_base.args = __pyx_v_args;
-
- __pyx_f_6gevent_5libev_8corecext__libev_unref(((struct PyGeventWatcherObject *)__pyx_v_self));
-
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1064, __pyx_L1_error)
- if (__pyx_t_2) {
-
- ev_now_update(__pyx_v_self->__pyx_base.loop->_ptr);
-
- }
-
- ev_timer_again(__pyx_v_self->__pyx_base.loop->_ptr, (&__pyx_v_self->_watcher));
-
- __pyx_f_6gevent_5libev_8corecext__python_incref(((struct PyGeventWatcherObject *)__pyx_v_self));
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_6signal_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_6signal_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- int __pyx_v_signalnum;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_signalnum,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[4] = {0,0,0,0};
- values[2] = ((PyObject *)Py_True);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signalnum)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 4, 1); __PYX_ERR(0, 1077, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1077, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_signalnum = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1077, __pyx_L3_error)
- __pyx_v_ref = values[2];
- __pyx_v_priority = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1077, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.signal.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1077, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal___cinit__(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_signalnum, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_6signal___cinit__(struct PyGeventSignalObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- __pyx_t_2 = ((__pyx_v_signalnum < 1) != 0);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1078, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_signalmodule); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1078, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NSIG); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1078, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1078, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1078, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1079, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_illegal_signal_number_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1079, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1079, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 1079, __pyx_L1_error)
-
- }
-
- ev_signal_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_signal), __pyx_v_signalnum);
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_signal_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.signal.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_6signal_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_6signal_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED int __pyx_v_signalnum;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_signalnum,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[4] = {0,0,0,0};
- values[2] = ((PyObject *)Py_True);
- values[3] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signalnum)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 1089, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1089, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_signalnum = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1089, __pyx_L3_error)
- __pyx_v_ref = values[2];
- __pyx_v_priority = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1089, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1089, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_2__init__(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_signalnum, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_6signal_2__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1090, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1090, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1090, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1090, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)__pyx_v_loop));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_priority);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1090, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4idle_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4idle_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1100, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1100, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.idle.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1100, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle___cinit__(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4idle___cinit__(struct PyGeventIdleObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- ev_idle_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_idle));
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_idle_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_7prepare_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_7prepare_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1113, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1113, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.prepare.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1113, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare___cinit__(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_7prepare___cinit__(struct PyGeventPrepareObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- ev_prepare_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_prepare));
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_prepare_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5check_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5check_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1126, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1126, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.check.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1126, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check___cinit__(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5check___cinit__(struct PyGeventCheckObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- ev_check_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_check));
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_check_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4fork_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4fork_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1139, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1139, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.fork.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1139, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork___cinit__(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4fork___cinit__(struct PyGeventForkObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- ev_fork_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_fork));
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_fork_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_6async__7pending_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_6async__7pending_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6async__7pending___get__(((struct PyGeventAsyncObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6async__7pending___get__(struct PyGeventAsyncObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- if ((ev_async_pending((&__pyx_v_self->_watcher)) != 0)) {
- __Pyx_INCREF(Py_True);
- __pyx_t_1 = Py_True;
- } else {
- __Pyx_INCREF(Py_False);
- __pyx_t_1 = Py_False;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_6async__1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_6async__1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1156, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_ref = values[1];
- __pyx_v_priority = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1156, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.async_.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1156, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6async____cinit__(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_6async____cinit__(struct PyGeventAsyncObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- ev_async_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_async));
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_async_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_6async__3send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_6async__3send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("send (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6async__2send(((struct PyGeventAsyncObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_6async__2send(struct PyGeventAsyncObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("send", 0);
-
- __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.loop);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__check_loop(((struct PyGeventLoopObject *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1163, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- ev_async_send(__pyx_v_self->__pyx_base.loop->_ptr, (&__pyx_v_self->_watcher));
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.async_.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5child_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5child_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- int __pyx_v_pid;
- int __pyx_v_trace;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0};
- PyObject* values[4] = {0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 4, 1); __PYX_ERR(0, 1174, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_trace);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1174, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_pid = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1174, __pyx_L3_error)
- if (values[2]) {
- __pyx_v_trace = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1174, __pyx_L3_error)
- } else {
- __pyx_v_trace = ((int)0);
- }
- __pyx_v_ref = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1174, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.child.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1174, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child___cinit__(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_pid, __pyx_v_trace, __pyx_v_ref);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5child___cinit__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, CYTHON_UNUSED PyObject *__pyx_v_ref) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_win32, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1175, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(__pyx_t_3)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 1176, __pyx_L1_error)
-
- }
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_loop), __pyx_n_s_default); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = ((!__pyx_t_3) != 0);
- if (unlikely(__pyx_t_4)) {
-
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 1178, __pyx_L1_error)
-
- }
-
- gevent_install_sigchld_handler();
-
- ev_child_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_child), __pyx_v_pid, __pyx_v_trace);
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_child_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.child.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5child_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5child_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED int __pyx_v_pid;
- CYTHON_UNUSED int __pyx_v_trace;
- PyObject *__pyx_v_ref = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0};
- PyObject* values[4] = {0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 1184, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_trace);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1184, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_pid = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1184, __pyx_L3_error)
- if (values[2]) {
- __pyx_v_trace = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1184, __pyx_L3_error)
- } else {
- __pyx_v_trace = ((int)0);
- }
- __pyx_v_ref = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1184, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1184, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_2__init__(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_pid, __pyx_v_trace, __pyx_v_ref);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5child_2__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_v_pid, CYTHON_UNUSED int __pyx_v_trace, PyObject *__pyx_v_ref) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, Py_None};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, Py_None};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)__pyx_v_loop));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ref);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, Py_None);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_5_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_5_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4_format(((struct PyGeventChildObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4_format(struct PyGeventChildObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_format", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rstatus); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_pid_r_rstatus_r, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.libev.corecext.child._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(((struct PyGeventChildObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.child.pid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(((struct PyGeventChildObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rpid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1197, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.child.rpid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
- int __pyx_v_value;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- assert(__pyx_arg_value); {
- __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1200, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.child.rpid.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_v_self->_watcher.rpid = __pyx_v_value;
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(((struct PyGeventChildObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1205, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.child.rstatus.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
- int __pyx_v_value;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- assert(__pyx_arg_value); {
- __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1208, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.child.rstatus.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
-
- __pyx_v_self->_watcher.rstatus = __pyx_v_value;
-
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4stat_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4stat_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop = 0;
- PyObject *__pyx_v_path = 0;
- float __pyx_v_interval;
- CYTHON_UNUSED PyObject *__pyx_v_ref = 0;
- CYTHON_UNUSED PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 5, 1); __PYX_ERR(0, 1219, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interval);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1219, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_path = ((PyObject*)values[1]);
- if (values[2]) {
- __pyx_v_interval = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1219, __pyx_L3_error)
- } else {
- __pyx_v_interval = ((float)0.0);
- }
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1219, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.stat.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1219, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) __PYX_ERR(0, 1219, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat___cinit__(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4stat___cinit__(struct PyGeventStatObject *__pyx_v_self, CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, CYTHON_UNUSED PyObject *__pyx_v_ref, CYTHON_UNUSED PyObject *__pyx_v_priority) {
- PyObject *__pyx_v_paths = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- char *__pyx_t_8;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- __Pyx_INCREF(__pyx_v_path);
- __Pyx_GIVEREF(__pyx_v_path);
- __Pyx_GOTREF(__pyx_v_self->path);
- __Pyx_DECREF(__pyx_v_self->path);
- __pyx_v_self->path = __pyx_v_path;
-
- __pyx_t_1 = PyUnicode_Check(__pyx_v_path);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1226, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1226, __pyx_L1_error)
- __pyx_v_paths = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- __Pyx_INCREF(__pyx_v_paths);
- __Pyx_GIVEREF(__pyx_v_paths);
- __Pyx_GOTREF(__pyx_v_self->_paths);
- __Pyx_DECREF(__pyx_v_self->_paths);
- __pyx_v_self->_paths = __pyx_v_paths;
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_3 = __pyx_v_path;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_v_paths = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- __Pyx_INCREF(__pyx_v_paths);
- __Pyx_GIVEREF(__pyx_v_paths);
- __Pyx_GOTREF(__pyx_v_self->_paths);
- __Pyx_DECREF(__pyx_v_self->_paths);
- __pyx_v_self->_paths = __pyx_v_paths;
- }
- __pyx_L3:;
-
- if (unlikely(__pyx_v_paths == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 1231, __pyx_L1_error)
- }
- __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_paths); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1231, __pyx_L1_error)
- ev_stat_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_stat), ((char *)__pyx_t_8), __pyx_v_interval);
-
- __pyx_v_self->__pyx_base.__pyx___watcher = ((struct ev_watcher *)(&__pyx_v_self->_watcher));
-
- __pyx_v_self->__pyx_base.__pyx___ss = (&__pyx_v_6gevent_5libev_8corecext_stat_ss);
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.libev.corecext.stat.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_paths);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_5libev_8corecext_4stat_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_5libev_8corecext_4stat_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct PyGeventLoopObject *__pyx_v_loop = 0;
- CYTHON_UNUSED PyObject *__pyx_v_path = 0;
- CYTHON_UNUSED float __pyx_v_interval;
- PyObject *__pyx_v_ref = 0;
- PyObject *__pyx_v_priority = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)Py_True);
- values[4] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); __PYX_ERR(0, 1235, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interval);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_priority);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1235, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]);
- __pyx_v_path = ((PyObject*)values[1]);
- if (values[2]) {
- __pyx_v_interval = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1235, __pyx_L3_error)
- } else {
- __pyx_v_interval = ((float)0.0);
- }
- __pyx_v_ref = values[3];
- __pyx_v_priority = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1235, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.libev.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1235, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) __PYX_ERR(0, 1235, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_2__init__(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_5libev_8corecext_4stat_2__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, CYTHON_UNUSED PyObject *__pyx_v_path, CYTHON_UNUSED float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_loop), __pyx_v_ref, __pyx_v_priority};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_loop));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_loop));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)__pyx_v_loop));
- __Pyx_INCREF(__pyx_v_ref);
- __Pyx_GIVEREF(__pyx_v_ref);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_ref);
- __Pyx_INCREF(__pyx_v_priority);
- __Pyx_GIVEREF(__pyx_v_priority);
- PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_priority);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.libev.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(((struct PyGeventStatObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = ((!(__pyx_v_self->_watcher.attr.st_nlink != 0)) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.attr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.stat.attr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(((struct PyGeventStatObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __pyx_t_1 = ((!(__pyx_v_self->_watcher.prev.st_nlink != 0)) != 0);
- if (__pyx_t_1) {
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- }
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.prev)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.libev.corecext.stat.prev.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(((struct PyGeventStatObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1253, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.stat.interval.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(((struct PyGeventStatObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->path);
- __pyx_r = __pyx_v_self->path;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(((struct PyGeventStatObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_paths);
- __pyx_r = __pyx_v_self->_paths;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-static void __pyx_f_6gevent_5libev_8corecext__syserr_cb(char *__pyx_v_msg) {
- PyObject *__pyx_v_print_exc = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- int __pyx_t_11;
- int __pyx_t_12;
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_RefNannySetupContext("_syserr_cb", 0);
-
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_msg); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = NULL;
- __pyx_t_9 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- __pyx_t_9 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_10);
- if (__pyx_t_8) {
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1262, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /*except:*/ {
- __Pyx_AddTraceback("gevent.libev.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 1263, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_10);
-
- __pyx_t_7 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1264, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1265, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_7, __pyx_n_s_print_exc, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1265, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_v_print_exc = __pyx_t_6;
- __pyx_t_6 = 0;
-
- __pyx_t_11 = (__pyx_v_print_exc != Py_None);
- __pyx_t_12 = (__pyx_t_11 != 0);
- if (__pyx_t_12) {
-
- __Pyx_INCREF(__pyx_v_print_exc);
- __pyx_t_7 = __pyx_v_print_exc; __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- if (__pyx_t_8) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1267, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1267, __pyx_L5_except_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L4_exception_handled;
- }
- __pyx_L5_except_error:;
-
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_WriteUnraisable("gevent.libev.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_print_exc);
- __Pyx_RefNannyFinishContext();
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
-}
-
-
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_f_6gevent_5libev_8corecext_set_syserr_cb(PyObject *__pyx_v_callback, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("set_syserr_cb", 0);
-
- __pyx_t_1 = (__pyx_v_callback == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- ev_set_syserr_cb(NULL);
-
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) __PYX_ERR(0, 1274, __pyx_L1_error)
-
- goto __pyx_L3;
- }
-
- __pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1275, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (likely(__pyx_t_1)) {
-
- ev_set_syserr_cb(((void *)__pyx_f_6gevent_5libev_8corecext__syserr_cb));
-
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, __pyx_v_callback) < 0) __PYX_ERR(0, 1277, __pyx_L1_error)
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 1279, __pyx_L1_error)
- }
- __pyx_L3:;
-
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.libev.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/
-static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_syserr_cb (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(__pyx_self, ((PyObject *)__pyx_v_callback));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("set_syserr_cb", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(__pyx_v_callback, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-
-void gevent_handle_error(struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_context) {
- PyObject *__pyx_v_typep;
- PyObject *__pyx_v_valuep;
- PyObject *__pyx_v_tracebackp;
- PyObject *__pyx_v_type = 0;
- PyObject *__pyx_v_value = 0;
- PyObject *__pyx_v_traceback = 0;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("gevent_handle_error", 0);
-
- __Pyx_INCREF(Py_None);
- __pyx_v_value = Py_None;
-
- __Pyx_INCREF(Py_None);
- __pyx_v_traceback = Py_None;
-
- PyErr_Fetch((&__pyx_v_typep), (&__pyx_v_valuep), (&__pyx_v_tracebackp));
-
- __pyx_t_1 = ((!(__pyx_v_typep != 0)) != 0);
- if (__pyx_t_1) {
-
- goto __pyx_L0;
-
- }
-
- __pyx_t_2 = ((PyObject *)__pyx_v_typep);
- __Pyx_INCREF(__pyx_t_2);
- __pyx_v_type = __pyx_t_2;
- __pyx_t_2 = 0;
-
- Py_DECREF(__pyx_v_type);
-
- __pyx_t_1 = (__pyx_v_valuep != 0);
- if (__pyx_t_1) {
-
- __pyx_t_2 = ((PyObject *)__pyx_v_valuep);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
- __pyx_t_2 = 0;
-
- Py_DECREF(__pyx_v_value);
-
- }
-
- __pyx_t_1 = (__pyx_v_tracebackp != 0);
- if (__pyx_t_1) {
-
- __pyx_t_2 = ((PyObject *)__pyx_v_tracebackp);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_DECREF_SET(__pyx_v_traceback, __pyx_t_2);
- __pyx_t_2 = 0;
-
- Py_DECREF(__pyx_v_traceback);
-
- }
-
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_loop->__pyx_vtab)->handle_error(__pyx_v_loop, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_traceback, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1335, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_WriteUnraisable("gevent.libev.corecext.gevent_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_type);
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XDECREF(__pyx_v_traceback);
- __Pyx_RefNannyFinishContext();
-}
-
-
-PyObject *gevent_loop_run_callbacks(struct PyGeventLoopObject *__pyx_v_loop) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("gevent_loop_run_callbacks", 0);
-
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_loop->__pyx_vtab)->_run_callbacks(__pyx_v_loop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.libev.corecext.gevent_loop_run_callbacks", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext__EVENTSType(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext__EVENTSType(PyObject *o) {
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext__EVENTSType[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_5libev_8corecext__EVENTSType = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext._EVENTSType", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext__EVENTSType, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext__EVENTSType, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext__EVENTSType, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_callback(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct PyGeventCallbackObject *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct PyGeventCallbackObject *)o);
- p->callback = Py_None; Py_INCREF(Py_None);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->next = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_callback(PyObject *o) {
- struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->callback);
- Py_CLEAR(p->args);
- Py_CLEAR(p->next);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_5libev_8corecext_callback(PyObject *o, visitproc v, void *a) {
- int e;
- struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o;
- if (p->callback) {
- e = (*v)(p->callback, a); if (e) return e;
- }
- if (p->args) {
- e = (*v)(p->args, a); if (e) return e;
- }
- if (p->next) {
- e = (*v)(((PyObject *)p->next), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_5libev_8corecext_callback(PyObject *o) {
- PyObject* tmp;
- struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o;
- tmp = ((PyObject*)p->callback);
- p->callback = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->args);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->next);
- p->next = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_pending(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_callback(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_8callback_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_args(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_8callback_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_callback[] = {
- {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_8callback_3stop, METH_NOARGS, 0},
- {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_8callback_9_format, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_callback[] = {
- {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_8callback_pending, 0, (char *)0, 0},
- {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_8callback_callback, __pyx_setprop_6gevent_5libev_8corecext_8callback_callback, (char *)0, 0},
- {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_8callback_args, __pyx_setprop_6gevent_5libev_8corecext_8callback_args, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_callback = {
- 0, /*nb_add*/
- 0, /*nb_subtract*/
- 0, /*nb_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_divide*/
- #endif
- 0, /*nb_remainder*/
- 0, /*nb_divmod*/
- 0, /*nb_power*/
- 0, /*nb_negative*/
- 0, /*nb_positive*/
- 0, /*nb_absolute*/
- __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_coerce*/
- #endif
- 0, /*nb_int*/
- #if PY_MAJOR_VERSION < 3
- 0, /*nb_long*/
- #else
- 0, /*reserved*/
- #endif
- 0, /*nb_float*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_oct*/
- #endif
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_hex*/
- #endif
- 0, /*nb_inplace_add*/
- 0, /*nb_inplace_subtract*/
- 0, /*nb_inplace_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_inplace_divide*/
- #endif
- 0, /*nb_inplace_remainder*/
- 0, /*nb_inplace_power*/
- 0, /*nb_inplace_lshift*/
- 0, /*nb_inplace_rshift*/
- 0, /*nb_inplace_and*/
- 0, /*nb_inplace_xor*/
- 0, /*nb_inplace_or*/
- 0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
- 0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
- 0, /*nb_index*/
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_matrix_multiply*/
- #endif
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_inplace_matrix_multiply*/
- #endif
-};
-
-DL_EXPORT(PyTypeObject) PyGeventCallback_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.callback", /*tp_name*/
- sizeof(struct PyGeventCallbackObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_callback, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__, /*tp_repr*/
- &__pyx_tp_as_number_callback, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_callback, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_callback, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_callback, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_callback, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_callback, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_5libev_8corecext_CallbackFIFO __pyx_vtable_6gevent_5libev_8corecext_CallbackFIFO;
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_CallbackFIFO(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_5libev_8corecext_CallbackFIFO;
- p->head = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- p->tail = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_CallbackFIFO(PyObject *o) {
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *p = (struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->head);
- Py_CLEAR(p->tail);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_5libev_8corecext_CallbackFIFO(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *p = (struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)o;
- if (p->head) {
- e = (*v)(((PyObject *)p->head), a); if (e) return e;
- }
- if (p->tail) {
- e = (*v)(((PyObject *)p->tail), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_5libev_8corecext_CallbackFIFO(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *p = (struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)o;
- tmp = ((PyObject*)p->head);
- p->head = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->tail);
- p->tail = ((struct PyGeventCallbackObject *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_CallbackFIFO[] = {
- {0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_CallbackFIFO = {
- 0, /*nb_add*/
- 0, /*nb_subtract*/
- 0, /*nb_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_divide*/
- #endif
- 0, /*nb_remainder*/
- 0, /*nb_divmod*/
- 0, /*nb_power*/
- 0, /*nb_negative*/
- 0, /*nb_positive*/
- 0, /*nb_absolute*/
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_3__nonzero__, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_coerce*/
- #endif
- 0, /*nb_int*/
- #if PY_MAJOR_VERSION < 3
- 0, /*nb_long*/
- #else
- 0, /*reserved*/
- #endif
- 0, /*nb_float*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_oct*/
- #endif
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_hex*/
- #endif
- 0, /*nb_inplace_add*/
- 0, /*nb_inplace_subtract*/
- 0, /*nb_inplace_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_inplace_divide*/
- #endif
- 0, /*nb_inplace_remainder*/
- 0, /*nb_inplace_power*/
- 0, /*nb_inplace_lshift*/
- 0, /*nb_inplace_rshift*/
- 0, /*nb_inplace_and*/
- 0, /*nb_inplace_xor*/
- 0, /*nb_inplace_or*/
- 0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
- 0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
- 0, /*nb_index*/
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_matrix_multiply*/
- #endif
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_inplace_matrix_multiply*/
- #endif
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_CallbackFIFO = {
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_5__len__, /*sq_length*/
- 0, /*sq_concat*/
- 0, /*sq_repeat*/
- 0, /*sq_item*/
- 0, /*sq_slice*/
- 0, /*sq_ass_item*/
- 0, /*sq_ass_slice*/
- 0, /*sq_contains*/
- 0, /*sq_inplace_concat*/
- 0, /*sq_inplace_repeat*/
-};
-
-static PyMappingMethods __pyx_tp_as_mapping_CallbackFIFO = {
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_5__len__, /*mp_length*/
- 0, /*mp_subscript*/
- 0, /*mp_ass_subscript*/
-};
-
-static PyTypeObject __pyx_type_6gevent_5libev_8corecext_CallbackFIFO = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.CallbackFIFO", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_CallbackFIFO, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_9__repr__, /*tp_repr*/
- &__pyx_tp_as_number_CallbackFIFO, /*tp_as_number*/
- &__pyx_tp_as_sequence_CallbackFIFO, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_CallbackFIFO, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_CallbackFIFO, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_CallbackFIFO, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_7__iter__, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_CallbackFIFO, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_12CallbackFIFO_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_CallbackFIFO, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop __pyx_vtable_6gevent_5libev_8corecext_loop;
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_loop(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct PyGeventLoopObject *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct PyGeventLoopObject *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_5libev_8corecext_loop;
- p->error_handler = Py_None; Py_INCREF(Py_None);
- p->_callbacks = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)Py_None); Py_INCREF(Py_None);
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_4loop_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_loop(PyObject *o) {
- struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- ++Py_REFCNT(o);
- __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(o);
- --Py_REFCNT(o);
- PyErr_Restore(etype, eval, etb);
- }
- Py_CLEAR(p->error_handler);
- Py_CLEAR(p->_callbacks);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_5libev_8corecext_loop(PyObject *o, visitproc v, void *a) {
- int e;
- struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o;
- if (p->error_handler) {
- e = (*v)(p->error_handler, a); if (e) return e;
- }
- if (p->_callbacks) {
- e = (*v)(((PyObject *)p->_callbacks), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_5libev_8corecext_loop(PyObject *o) {
- PyObject* tmp;
- struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o;
- tmp = ((PyObject*)p->error_handler);
- p->error_handler = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_callbacks);
- p->_callbacks = ((struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_ptr(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_WatcherType(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_MAXPRI(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_MINPRI(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_default(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_iteration(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_depth(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_backend_int(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_backend(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_pendingcnt(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_activecnt(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_sig_pending(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_origflags(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_origflags_int(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_sigfd(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_error_handler(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_4loop_error_handler(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop__callbacks(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_4loop__callbacks(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_loop[] = {
- {"destroy", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy, METH_NOARGS, 0},
- {"_handle_syserr", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr, METH_VARARGS|METH_KEYWORDS, 0},
- {"handle_error", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error, METH_VARARGS|METH_KEYWORDS, 0},
- {"_default_handle_error", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error, METH_VARARGS|METH_KEYWORDS, 0},
- {"run", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_15run, METH_VARARGS|METH_KEYWORDS, 0},
- {"reinit", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit, METH_NOARGS, 0},
- {"ref", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_19ref, METH_NOARGS, 0},
- {"unref", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_21unref, METH_NOARGS, 0},
- {"break_", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_23break_, METH_VARARGS|METH_KEYWORDS, 0},
- {"verify", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_25verify, METH_NOARGS, 0},
- {"now", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_27now, METH_NOARGS, 0},
- {"update_now", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_29update_now, METH_NOARGS, 0},
- {"io", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_33io, METH_VARARGS|METH_KEYWORDS, 0},
- {"timer", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_35timer, METH_VARARGS|METH_KEYWORDS, 0},
- {"signal", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_37signal, METH_VARARGS|METH_KEYWORDS, 0},
- {"idle", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_39idle, METH_VARARGS|METH_KEYWORDS, 0},
- {"prepare", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare, METH_VARARGS|METH_KEYWORDS, 0},
- {"check", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_43check, METH_VARARGS|METH_KEYWORDS, 0},
- {"fork", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_45fork, METH_VARARGS|METH_KEYWORDS, 0},
- {"async_", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_47async_, METH_VARARGS|METH_KEYWORDS, 0},
- {"child", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_49child, METH_VARARGS|METH_KEYWORDS, 0},
- {"install_sigchld", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld, METH_NOARGS, 0},
- {"reset_sigchld", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld, METH_NOARGS, 0},
- {"stat", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_55stat, METH_VARARGS|METH_KEYWORDS, 0},
- {"run_callback", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback, METH_VARARGS|METH_KEYWORDS, 0},
- {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_59_format, METH_NOARGS, 0},
- {"_format_details", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details, METH_NOARGS, 0},
- {"fileno", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_loop[] = {
- {(char *)"ptr", __pyx_getprop_6gevent_5libev_8corecext_4loop_ptr, 0, (char *)0, 0},
- {(char *)"WatcherType", __pyx_getprop_6gevent_5libev_8corecext_4loop_WatcherType, 0, (char *)0, 0},
- {(char *)"MAXPRI", __pyx_getprop_6gevent_5libev_8corecext_4loop_MAXPRI, 0, (char *)0, 0},
- {(char *)"MINPRI", __pyx_getprop_6gevent_5libev_8corecext_4loop_MINPRI, 0, (char *)0, 0},
- {(char *)"default", __pyx_getprop_6gevent_5libev_8corecext_4loop_default, 0, (char *)0, 0},
- {(char *)"iteration", __pyx_getprop_6gevent_5libev_8corecext_4loop_iteration, 0, (char *)0, 0},
- {(char *)"depth", __pyx_getprop_6gevent_5libev_8corecext_4loop_depth, 0, (char *)0, 0},
- {(char *)"backend_int", __pyx_getprop_6gevent_5libev_8corecext_4loop_backend_int, 0, (char *)0, 0},
- {(char *)"backend", __pyx_getprop_6gevent_5libev_8corecext_4loop_backend, 0, (char *)0, 0},
- {(char *)"pendingcnt", __pyx_getprop_6gevent_5libev_8corecext_4loop_pendingcnt, 0, (char *)0, 0},
- {(char *)"activecnt", __pyx_getprop_6gevent_5libev_8corecext_4loop_activecnt, 0, (char *)0, 0},
- {(char *)"sig_pending", __pyx_getprop_6gevent_5libev_8corecext_4loop_sig_pending, 0, (char *)0, 0},
- {(char *)"origflags", __pyx_getprop_6gevent_5libev_8corecext_4loop_origflags, 0, (char *)0, 0},
- {(char *)"origflags_int", __pyx_getprop_6gevent_5libev_8corecext_4loop_origflags_int, 0, (char *)0, 0},
- {(char *)"sigfd", __pyx_getprop_6gevent_5libev_8corecext_4loop_sigfd, 0, (char *)0, 0},
- {(char *)"error_handler", __pyx_getprop_6gevent_5libev_8corecext_4loop_error_handler, __pyx_setprop_6gevent_5libev_8corecext_4loop_error_handler, (char *)0, 0},
- {(char *)"_callbacks", __pyx_getprop_6gevent_5libev_8corecext_4loop__callbacks, __pyx_setprop_6gevent_5libev_8corecext_4loop__callbacks, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventLoop_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.loop", /*tp_name*/
- sizeof(struct PyGeventLoopObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_loop, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_loop, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_loop, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_loop, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_loop, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_4loop_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_loop, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_watcher(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct PyGeventWatcherObject *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct PyGeventWatcherObject *)o);
- p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None);
- p->_callback = Py_None; Py_INCREF(Py_None);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(PyObject *o) {
- struct PyGeventWatcherObject *p = (struct PyGeventWatcherObject *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->loop);
- Py_CLEAR(p->_callback);
- Py_CLEAR(p->args);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_5libev_8corecext_watcher(PyObject *o, visitproc v, void *a) {
- int e;
- struct PyGeventWatcherObject *p = (struct PyGeventWatcherObject *)o;
- if (p->loop) {
- e = (*v)(((PyObject *)p->loop), a); if (e) return e;
- }
- if (p->_callback) {
- e = (*v)(p->_callback, a); if (e) return e;
- }
- if (p->args) {
- e = (*v)(p->args, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_5libev_8corecext_watcher(PyObject *o) {
- PyObject* tmp;
- struct PyGeventWatcherObject *p = (struct PyGeventWatcherObject *)o;
- tmp = ((PyObject*)p->loop);
- p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_callback);
- p->_callback = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->args);
- p->args = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_ref(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_7watcher_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_3ref_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_callback(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_7watcher_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_8callback_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_priority(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_7watcher_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_8priority_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_active(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_6active_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_pending(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_7pending_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_loop(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_7watcher_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4loop_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher_args(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_7watcher_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_4args_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7watcher__flags(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_7watcher_6_flags_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_watcher[] = {
- {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_3start, METH_VARARGS|METH_KEYWORDS, 0},
- {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_5stop, METH_NOARGS, 0},
- {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_7feed, METH_VARARGS|METH_KEYWORDS, 0},
- {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_11_format, METH_NOARGS, 0},
- {"close", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_13close, METH_NOARGS, 0},
- {"__enter__", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_15__enter__, METH_NOARGS, 0},
- {"__exit__", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_17__exit__, METH_VARARGS|METH_KEYWORDS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_watcher[] = {
- {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_7watcher_ref, __pyx_setprop_6gevent_5libev_8corecext_7watcher_ref, (char *)0, 0},
- {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_7watcher_callback, __pyx_setprop_6gevent_5libev_8corecext_7watcher_callback, (char *)0, 0},
- {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_7watcher_priority, __pyx_setprop_6gevent_5libev_8corecext_7watcher_priority, (char *)0, 0},
- {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_7watcher_active, 0, (char *)0, 0},
- {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_7watcher_pending, 0, (char *)0, 0},
- {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_7watcher_loop, __pyx_setprop_6gevent_5libev_8corecext_7watcher_loop, (char *)0, 0},
- {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_7watcher_args, __pyx_setprop_6gevent_5libev_8corecext_7watcher_args, (char *)0, 0},
- {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_7watcher__flags, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventWatcher_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.watcher", /*tp_name*/
- sizeof(struct PyGeventWatcherObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Abstract base class for all the watchers", /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_watcher, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_watcher, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_watcher, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_2io_5__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_io(PyObject *o) {
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- ++Py_REFCNT(o);
- __pyx_pw_6gevent_5libev_8corecext_2io_7__dealloc__(o);
- --Py_REFCNT(o);
- PyErr_Restore(etype, eval, etb);
- }
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_fd(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_2io_fd(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_events(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_2io_events(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_events_str(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_io[] = {
- {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_1start, METH_VARARGS|METH_KEYWORDS, 0},
- {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_9_format, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_io[] = {
- {(char *)"fd", __pyx_getprop_6gevent_5libev_8corecext_2io_fd, __pyx_setprop_6gevent_5libev_8corecext_2io_fd, (char *)0, 0},
- {(char *)"events", __pyx_getprop_6gevent_5libev_8corecext_2io_events, __pyx_setprop_6gevent_5libev_8corecext_2io_events, (char *)0, 0},
- {(char *)"events_str", __pyx_getprop_6gevent_5libev_8corecext_2io_events_str, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventIO_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.io", /*tp_name*/
- sizeof(struct PyGeventIOObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_io, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_io, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_io, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_2io_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_io, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_5timer_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_at(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_timer[] = {
- {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_5start, METH_VARARGS|METH_KEYWORDS, 0},
- {"again", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_7again, METH_VARARGS|METH_KEYWORDS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_timer[] = {
- {(char *)"at", __pyx_getprop_6gevent_5libev_8corecext_5timer_at, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventTimer_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.timer", /*tp_name*/
- sizeof(struct PyGeventTimerObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_timer, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_timer, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_5timer_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_timer, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_6signal_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_signal[] = {
- {0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventSignal_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.signal", /*tp_name*/
- sizeof(struct PyGeventSignalObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_signal, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_6signal_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_signal, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_4idle_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_idle[] = {
- {0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventIdle_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.idle", /*tp_name*/
- sizeof(struct PyGeventIdleObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_idle, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_idle, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_7prepare_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_prepare[] = {
- {0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventPrepare_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.prepare", /*tp_name*/
- sizeof(struct PyGeventPrepareObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_prepare, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_prepare, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_5check_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_check[] = {
- {0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventCheck_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.check", /*tp_name*/
- sizeof(struct PyGeventCheckObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_check, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_check, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_4fork_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_fork[] = {
- {0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventFork_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.fork", /*tp_name*/
- sizeof(struct PyGeventForkObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_fork, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_fork, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_async_(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_6async__1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6async__pending(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_6async__7pending_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_async_[] = {
- {"send", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_6async__3send, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_async_[] = {
- {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_6async__pending, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventAsync_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.async_", /*tp_name*/
- sizeof(struct PyGeventAsyncObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_async_, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_async_, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_async_, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_5child_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_pid(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_rpid(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_5child_rpid(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_rstatus(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_5libev_8corecext_5child_rstatus(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_child[] = {
- {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5child_5_format, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_child[] = {
- {(char *)"pid", __pyx_getprop_6gevent_5libev_8corecext_5child_pid, 0, (char *)0, 0},
- {(char *)"rpid", __pyx_getprop_6gevent_5libev_8corecext_5child_rpid, __pyx_setprop_6gevent_5libev_8corecext_5child_rpid, (char *)0, 0},
- {(char *)"rstatus", __pyx_getprop_6gevent_5libev_8corecext_5child_rstatus, __pyx_setprop_6gevent_5libev_8corecext_5child_rstatus, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventChild_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.child", /*tp_name*/
- sizeof(struct PyGeventChildObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_child, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_child, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_5child_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_child, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct PyGeventStatObject *p;
- PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct PyGeventStatObject *)o);
- p->path = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_paths = ((PyObject*)Py_None); Py_INCREF(Py_None);
- if (unlikely(__pyx_pw_6gevent_5libev_8corecext_4stat_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext_stat(PyObject *o) {
- struct PyGeventStatObject *p = (struct PyGeventStatObject *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->path);
- Py_CLEAR(p->_paths);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_attr(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_prev(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_interval(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_path(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat__paths(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_stat[] = {
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_stat[] = {
- {(char *)"attr", __pyx_getprop_6gevent_5libev_8corecext_4stat_attr, 0, (char *)0, 0},
- {(char *)"prev", __pyx_getprop_6gevent_5libev_8corecext_4stat_prev, 0, (char *)0, 0},
- {(char *)"interval", __pyx_getprop_6gevent_5libev_8corecext_4stat_interval, 0, (char *)0, 0},
- {(char *)"path", __pyx_getprop_6gevent_5libev_8corecext_4stat_path, 0, (char *)0, 0},
- {(char *)"_paths", __pyx_getprop_6gevent_5libev_8corecext_4stat__paths, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-DL_EXPORT(PyTypeObject) PyGeventStat_Type = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.stat", /*tp_name*/
- sizeof(struct PyGeventStatObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext_stat, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_5libev_8corecext_7watcher_9__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext_watcher, /*tp_traverse*/
- __pyx_tp_clear_6gevent_5libev_8corecext_watcher, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_5libev_8corecext_stat, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_5libev_8corecext_stat, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_5libev_8corecext_4stat_3__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext_stat, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[8];
-static int __pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = 0;
-
-static PyObject *__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- PyObject *o;
- if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr)))) {
- o = (PyObject*)__pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[--__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr];
- memset(o, 0, sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr));
- (void) PyObject_INIT(o, t);
- PyObject_GC_Track(o);
- } else {
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- }
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyObject *o) {
- struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->__pyx_v_flag);
- Py_CLEAR(p->__pyx_v_string);
- if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr)))) {
- __pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr++] = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o);
- } else {
- (*Py_TYPE(o)->tp_free)(o);
- }
-}
-
-static int __pyx_tp_traverse_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o;
- if (p->__pyx_v_flag) {
- e = (*v)(p->__pyx_v_flag, a); if (e) return e;
- }
- if (p->__pyx_v_string) {
- e = (*v)(p->__pyx_v_string, a); if (e) return e;
- }
- return 0;
-}
-
-static PyTypeObject __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.libev.corecext.__pyx_scope_struct__genexpr", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {"_flags_to_list", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list, METH_O, 0},
- {"_flags_to_int", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int, METH_O, 0},
- {"_check_flags", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_9_check_flags, METH_O, 0},
- {"_events_to_str", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_11_events_to_str, METH_O, 0},
- {"set_syserr_cb", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec_corecext(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec_corecext},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "corecext",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
- {&__pyx_n_s_ASYNC, __pyx_k_ASYNC, sizeof(__pyx_k_ASYNC), 0, 0, 1, 1},
- {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
- {&__pyx_n_s_BACKEND_EPOLL, __pyx_k_BACKEND_EPOLL, sizeof(__pyx_k_BACKEND_EPOLL), 0, 0, 1, 1},
- {&__pyx_n_s_BACKEND_KQUEUE, __pyx_k_BACKEND_KQUEUE, sizeof(__pyx_k_BACKEND_KQUEUE), 0, 0, 1, 1},
- {&__pyx_n_s_BACKEND_POLL, __pyx_k_BACKEND_POLL, sizeof(__pyx_k_BACKEND_POLL), 0, 0, 1, 1},
- {&__pyx_n_s_BACKEND_PORT, __pyx_k_BACKEND_PORT, sizeof(__pyx_k_BACKEND_PORT), 0, 0, 1, 1},
- {&__pyx_n_s_BACKEND_SELECT, __pyx_k_BACKEND_SELECT, sizeof(__pyx_k_BACKEND_SELECT), 0, 0, 1, 1},
- {&__pyx_n_s_CHECK, __pyx_k_CHECK, sizeof(__pyx_k_CHECK), 0, 0, 1, 1},
- {&__pyx_n_s_CHILD, __pyx_k_CHILD, sizeof(__pyx_k_CHILD), 0, 0, 1, 1},
- {&__pyx_n_s_CLEANUP, __pyx_k_CLEANUP, sizeof(__pyx_k_CLEANUP), 0, 0, 1, 1},
- {&__pyx_n_s_CUSTOM, __pyx_k_CUSTOM, sizeof(__pyx_k_CUSTOM), 0, 0, 1, 1},
- {&__pyx_kp_s_Cannot_construct_a_bare_watcher, __pyx_k_Cannot_construct_a_bare_watcher, sizeof(__pyx_k_Cannot_construct_a_bare_watcher), 0, 0, 1, 0},
- {&__pyx_kp_s_Cannot_set_priority_of_an_active, __pyx_k_Cannot_set_priority_of_an_active, sizeof(__pyx_k_Cannot_set_priority_of_an_active), 0, 0, 1, 0},
- {&__pyx_kp_s_Child_watchers_are_not_supported, __pyx_k_Child_watchers_are_not_supported, sizeof(__pyx_k_Child_watchers_are_not_supported), 0, 0, 1, 0},
- {&__pyx_n_s_EMBED, __pyx_k_EMBED, sizeof(__pyx_k_EMBED), 0, 0, 1, 1},
- {&__pyx_n_s_ERROR, __pyx_k_ERROR, sizeof(__pyx_k_ERROR), 0, 0, 1, 1},
- {&__pyx_n_s_EVENTS, __pyx_k_EVENTS, sizeof(__pyx_k_EVENTS), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_4HEAP, __pyx_k_EV_USE_4HEAP, sizeof(__pyx_k_EV_USE_4HEAP), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_k_EV_USE_CLOCK_SYSCALL, sizeof(__pyx_k_EV_USE_CLOCK_SYSCALL), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_EVENTFD, __pyx_k_EV_USE_EVENTFD, sizeof(__pyx_k_EV_USE_EVENTFD), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_FLOOR, __pyx_k_EV_USE_FLOOR, sizeof(__pyx_k_EV_USE_FLOOR), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_INOTIFY, __pyx_k_EV_USE_INOTIFY, sizeof(__pyx_k_EV_USE_INOTIFY), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_MONOTONIC, __pyx_k_EV_USE_MONOTONIC, sizeof(__pyx_k_EV_USE_MONOTONIC), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_NANOSLEEP, __pyx_k_EV_USE_NANOSLEEP, sizeof(__pyx_k_EV_USE_NANOSLEEP), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_REALTIME, __pyx_k_EV_USE_REALTIME, sizeof(__pyx_k_EV_USE_REALTIME), 0, 0, 1, 1},
- {&__pyx_n_s_EV_USE_SIGNALFD, __pyx_k_EV_USE_SIGNALFD, sizeof(__pyx_k_EV_USE_SIGNALFD), 0, 0, 1, 1},
- {&__pyx_kp_s_Expected_callable_not_r, __pyx_k_Expected_callable_not_r, sizeof(__pyx_k_Expected_callable_not_r), 0, 0, 1, 0},
- {&__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_k_Expected_callable_or_None_got_r, sizeof(__pyx_k_Expected_callable_or_None_got_r), 0, 0, 1, 0},
- {&__pyx_n_s_FORK, __pyx_k_FORK, sizeof(__pyx_k_FORK), 0, 0, 1, 1},
- {&__pyx_n_s_FORKCHECK, __pyx_k_FORKCHECK, sizeof(__pyx_k_FORKCHECK), 0, 0, 1, 1},
- {&__pyx_n_s_IDLE, __pyx_k_IDLE, sizeof(__pyx_k_IDLE), 0, 0, 1, 1},
- {&__pyx_n_s_IOFDSET, __pyx_k_IOFDSET, sizeof(__pyx_k_IOFDSET), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_k_Invalid_backend_or_flag_s_Possib, sizeof(__pyx_k_Invalid_backend_or_flag_s_Possib), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_k_Invalid_value_for_backend_0x_x, sizeof(__pyx_k_Invalid_value_for_backend_0x_x), 0, 0, 1, 0},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_LIBEV_EMBED, __pyx_k_LIBEV_EMBED, sizeof(__pyx_k_LIBEV_EMBED), 0, 0, 1, 1},
- {&__pyx_n_s_MAXPRI, __pyx_k_MAXPRI, sizeof(__pyx_k_MAXPRI), 0, 0, 1, 1},
- {&__pyx_n_s_MINPRI, __pyx_k_MINPRI, sizeof(__pyx_k_MINPRI), 0, 0, 1, 1},
- {&__pyx_n_s_NOINOTIFY, __pyx_k_NOINOTIFY, sizeof(__pyx_k_NOINOTIFY), 0, 0, 1, 1},
- {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1},
- {&__pyx_n_s_NOSIGMASK, __pyx_k_NOSIGMASK, sizeof(__pyx_k_NOSIGMASK), 0, 0, 1, 1},
- {&__pyx_n_s_NSIG, __pyx_k_NSIG, sizeof(__pyx_k_NSIG), 0, 0, 1, 1},
- {&__pyx_n_s_PERIODIC, __pyx_k_PERIODIC, sizeof(__pyx_k_PERIODIC), 0, 0, 1, 1},
- {&__pyx_n_s_PREPARE, __pyx_k_PREPARE, sizeof(__pyx_k_PREPARE), 0, 0, 1, 1},
- {&__pyx_n_s_READ, __pyx_k_READ, sizeof(__pyx_k_READ), 0, 0, 1, 1},
- {&__pyx_n_s_READWRITE, __pyx_k_READWRITE, sizeof(__pyx_k_READWRITE), 0, 0, 1, 1},
- {&__pyx_n_s_SIGNAL, __pyx_k_SIGNAL, sizeof(__pyx_k_SIGNAL), 0, 0, 1, 1},
- {&__pyx_n_s_SIGNALFD, __pyx_k_SIGNALFD, sizeof(__pyx_k_SIGNALFD), 0, 0, 1, 1},
- {&__pyx_n_s_STAT, __pyx_k_STAT, sizeof(__pyx_k_STAT), 0, 0, 1, 1},
- {&__pyx_n_s_SYSERR_CALLBACK, __pyx_k_SYSERR_CALLBACK, sizeof(__pyx_k_SYSERR_CALLBACK), 0, 0, 1, 1},
- {&__pyx_n_s_SystemError, __pyx_k_SystemError, sizeof(__pyx_k_SystemError), 0, 0, 1, 1},
- {&__pyx_n_s_TIMER, __pyx_k_TIMER, sizeof(__pyx_k_TIMER), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_UNDEF, __pyx_k_UNDEF, sizeof(__pyx_k_UNDEF), 0, 0, 1, 1},
- {&__pyx_kp_s_Unsupported_backend_s, __pyx_k_Unsupported_backend_s, sizeof(__pyx_k_Unsupported_backend_s), 0, 0, 1, 0},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_n_s_WRITE, __pyx_k_WRITE, sizeof(__pyx_k_WRITE), 0, 0, 1, 1},
- {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
- {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
- {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0},
- {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
- {&__pyx_kp_s__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 0, 1, 0},
- {&__pyx_kp_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 0},
- {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1},
- {&__pyx_kp_s_active_2, __pyx_k_active_2, sizeof(__pyx_k_active_2), 0, 0, 1, 0},
- {&__pyx_n_s_activecnt, __pyx_k_activecnt, sizeof(__pyx_k_activecnt), 0, 0, 1, 1},
- {&__pyx_n_s_after, __pyx_k_after, sizeof(__pyx_k_after), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- {&__pyx_kp_s_args_r, __pyx_k_args_r, sizeof(__pyx_k_args_r), 0, 0, 1, 0},
- {&__pyx_n_s_async, __pyx_k_async, sizeof(__pyx_k_async), 0, 0, 1, 1},
- {&__pyx_n_s_async_2, __pyx_k_async_2, sizeof(__pyx_k_async_2), 0, 0, 1, 1},
- {&__pyx_n_s_backend, __pyx_k_backend, sizeof(__pyx_k_backend), 0, 0, 1, 1},
- {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1},
- {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_kp_s_callback_r, __pyx_k_callback_r, sizeof(__pyx_k_callback_r), 0, 0, 1, 0},
- {&__pyx_kp_s_callbacks_r_len_d_head_r_tail_r, __pyx_k_callbacks_r_len_d_head_r_tail_r, sizeof(__pyx_k_callbacks_r_len_d_head_r_tail_r), 0, 0, 1, 0},
- {&__pyx_kp_s_child_watchers_are_only_availabl, __pyx_k_child_watchers_are_only_availabl, sizeof(__pyx_k_child_watchers_are_only_availabl), 0, 0, 1, 0},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 0, 1, 1},
- {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
- {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
- {&__pyx_kp_s_default_2, __pyx_k_default_2, sizeof(__pyx_k_default_2), 0, 0, 1, 0},
- {&__pyx_n_s_default_handle_error, __pyx_k_default_handle_error, sizeof(__pyx_k_default_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_destroyed, __pyx_k_destroyed, sizeof(__pyx_k_destroyed), 0, 0, 1, 1},
- {&__pyx_n_s_embeddable_backends, __pyx_k_embeddable_backends, sizeof(__pyx_k_embeddable_backends), 0, 0, 1, 1},
- {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
- {&__pyx_n_s_epoll, __pyx_k_epoll, sizeof(__pyx_k_epoll), 0, 0, 1, 1},
- {&__pyx_n_s_errno, __pyx_k_errno, sizeof(__pyx_k_errno), 0, 0, 1, 1},
- {&__pyx_kp_s_ev_default_loop_s_failed, __pyx_k_ev_default_loop_s_failed, sizeof(__pyx_k_ev_default_loop_s_failed), 0, 0, 1, 0},
- {&__pyx_kp_s_ev_loop_new_s_failed, __pyx_k_ev_loop_new_s_failed, sizeof(__pyx_k_ev_loop_new_s_failed), 0, 0, 1, 0},
- {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1},
- {&__pyx_n_s_events_2, __pyx_k_events_2, sizeof(__pyx_k_events_2), 0, 0, 1, 1},
- {&__pyx_n_s_events_str, __pyx_k_events_str, sizeof(__pyx_k_events_str), 0, 0, 1, 1},
- {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
- {&__pyx_kp_s_fd_must_be_non_negative_r, __pyx_k_fd_must_be_non_negative_r, sizeof(__pyx_k_fd_must_be_non_negative_r), 0, 0, 1, 0},
- {&__pyx_kp_s_fd_s_events_s, __pyx_k_fd_s_events_s, sizeof(__pyx_k_fd_s_events_s), 0, 0, 1, 0},
- {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
- {&__pyx_kp_s_fileno_2, __pyx_k_fileno_2, sizeof(__pyx_k_fileno_2), 0, 0, 1, 0},
- {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
- {&__pyx_n_s_flags_2, __pyx_k_flags_2, sizeof(__pyx_k_flags_2), 0, 0, 1, 1},
- {&__pyx_n_s_flags_str2int, __pyx_k_flags_str2int, sizeof(__pyx_k_flags_str2int), 0, 0, 1, 1},
- {&__pyx_n_s_forkcheck, __pyx_k_forkcheck, sizeof(__pyx_k_forkcheck), 0, 0, 1, 1},
- {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
- {&__pyx_n_s_format_details, __pyx_k_format_details, sizeof(__pyx_k_format_details), 0, 0, 1, 1},
- {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
- {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
- {&__pyx_n_s_get_header_version, __pyx_k_get_header_version, sizeof(__pyx_k_get_header_version), 0, 0, 1, 1},
- {&__pyx_n_s_get_version, __pyx_k_get_version, sizeof(__pyx_k_get_version), 0, 0, 1, 1},
- {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1},
- {&__pyx_n_s_getswitchinterval, __pyx_k_getswitchinterval, sizeof(__pyx_k_getswitchinterval), 0, 0, 1, 1},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_kp_s_gevent_core_EVENTS, __pyx_k_gevent_core_EVENTS, sizeof(__pyx_k_gevent_core_EVENTS), 0, 0, 1, 0},
- {&__pyx_n_s_gevent_libev_corecext, __pyx_k_gevent_libev_corecext, sizeof(__pyx_k_gevent_libev_corecext), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_handle_syserr, __pyx_k_handle_syserr, sizeof(__pyx_k_handle_syserr), 0, 0, 1, 1},
- {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
- {&__pyx_n_s_how, __pyx_k_how, sizeof(__pyx_k_how), 0, 0, 1, 1},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_kp_s_illegal_event_mask_r, __pyx_k_illegal_event_mask_r, sizeof(__pyx_k_illegal_event_mask_r), 0, 0, 1, 0},
- {&__pyx_kp_s_illegal_signal_number_r, __pyx_k_illegal_signal_number_r, sizeof(__pyx_k_illegal_signal_number_r), 0, 0, 1, 0},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 0, 1, 1},
- {&__pyx_kp_s_io_watcher_attribute_events_is, __pyx_k_io_watcher_attribute_events_is, sizeof(__pyx_k_io_watcher_attribute_events_is), 0, 0, 1, 0},
- {&__pyx_kp_s_io_watcher_attribute_fd_is_read, __pyx_k_io_watcher_attribute_fd_is_read, sizeof(__pyx_k_io_watcher_attribute_fd_is_read), 0, 0, 1, 0},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
- {&__pyx_n_s_kqueue, __pyx_k_kqueue, sizeof(__pyx_k_kqueue), 0, 0, 1, 1},
- {&__pyx_n_s_level, __pyx_k_level, sizeof(__pyx_k_level), 0, 0, 1, 1},
- {&__pyx_kp_s_libev_d_02d, __pyx_k_libev_d_02d, sizeof(__pyx_k_libev_d_02d), 0, 0, 1, 0},
- {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
- {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_noenv, __pyx_k_noenv, sizeof(__pyx_k_noenv), 0, 0, 1, 1},
- {&__pyx_n_s_noinotify, __pyx_k_noinotify, sizeof(__pyx_k_noinotify), 0, 0, 1, 1},
- {&__pyx_n_s_nosigmask, __pyx_k_nosigmask, sizeof(__pyx_k_nosigmask), 0, 0, 1, 1},
- {&__pyx_n_s_now, __pyx_k_now, sizeof(__pyx_k_now), 0, 0, 1, 1},
- {&__pyx_n_s_nowait, __pyx_k_nowait, sizeof(__pyx_k_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_once, __pyx_k_once, sizeof(__pyx_k_once), 0, 0, 1, 1},
- {&__pyx_kp_s_operation_on_destroyed_loop, __pyx_k_operation_on_destroyed_loop, sizeof(__pyx_k_operation_on_destroyed_loop), 0, 0, 1, 0},
- {&__pyx_n_s_origflags_int, __pyx_k_origflags_int, sizeof(__pyx_k_origflags_int), 0, 0, 1, 1},
- {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
- {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1},
- {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
- {&__pyx_n_s_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 0, 0, 1, 1},
- {&__pyx_kp_s_pending_2, __pyx_k_pending_2, sizeof(__pyx_k_pending_2), 0, 0, 1, 0},
- {&__pyx_kp_s_pending_s, __pyx_k_pending_s, sizeof(__pyx_k_pending_s), 0, 0, 1, 0},
- {&__pyx_n_s_pendingcnt, __pyx_k_pendingcnt, sizeof(__pyx_k_pendingcnt), 0, 0, 1, 1},
- {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1},
- {&__pyx_kp_s_pid_r_rstatus_r, __pyx_k_pid_r_rstatus_r, sizeof(__pyx_k_pid_r_rstatus_r), 0, 0, 1, 0},
- {&__pyx_n_s_platform, __pyx_k_platform, sizeof(__pyx_k_platform), 0, 0, 1, 1},
- {&__pyx_n_s_poll, __pyx_k_poll, sizeof(__pyx_k_poll), 0, 0, 1, 1},
- {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1},
- {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1},
- {&__pyx_n_s_print_exception, __pyx_k_print_exception, sizeof(__pyx_k_print_exception), 0, 0, 1, 1},
- {&__pyx_n_s_priority, __pyx_k_priority, sizeof(__pyx_k_priority), 0, 0, 1, 1},
- {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_recommended_backends, __pyx_k_recommended_backends, sizeof(__pyx_k_recommended_backends), 0, 0, 1, 1},
- {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
- {&__pyx_kp_s_ref_2, __pyx_k_ref_2, sizeof(__pyx_k_ref_2), 0, 0, 1, 0},
- {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
- {&__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_k_repeat_must_be_positive_or_zero, sizeof(__pyx_k_repeat_must_be_positive_or_zero), 0, 0, 1, 0},
- {&__pyx_n_s_revents, __pyx_k_revents, sizeof(__pyx_k_revents), 0, 0, 1, 1},
- {&__pyx_n_s_rstatus, __pyx_k_rstatus, sizeof(__pyx_k_rstatus), 0, 0, 1, 1},
- {&__pyx_kp_s_s_at_0x_x_s, __pyx_k_s_at_0x_x_s, sizeof(__pyx_k_s_at_0x_x_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_at_0x_x_s_2, __pyx_k_s_at_0x_x_s_2, sizeof(__pyx_k_s_at_0x_x_s_2), 0, 0, 1, 0},
- {&__pyx_n_s_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 1, 1},
- {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
- {&__pyx_n_s_sigfd, __pyx_k_sigfd, sizeof(__pyx_k_sigfd), 0, 0, 1, 1},
- {&__pyx_n_s_signal, __pyx_k_signal, sizeof(__pyx_k_signal), 0, 0, 1, 1},
- {&__pyx_n_s_signalfd, __pyx_k_signalfd, sizeof(__pyx_k_signalfd), 0, 0, 1, 1},
- {&__pyx_n_s_signalmodule, __pyx_k_signalmodule, sizeof(__pyx_k_signalmodule), 0, 0, 1, 1},
- {&__pyx_n_s_signalnum, __pyx_k_signalnum, sizeof(__pyx_k_signalnum), 0, 0, 1, 1},
- {&__pyx_n_s_signum, __pyx_k_signum, sizeof(__pyx_k_signum), 0, 0, 1, 1},
- {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_k_src_gevent_libev_corecext_pyx, sizeof(__pyx_k_src_gevent_libev_corecext_pyx), 0, 0, 1, 0},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
- {&__pyx_kp_s_stopped, __pyx_k_stopped, sizeof(__pyx_k_stopped), 0, 0, 1, 0},
- {&__pyx_n_s_strerror, __pyx_k_strerror, sizeof(__pyx_k_strerror), 0, 0, 1, 1},
- {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
- {&__pyx_n_s_supported_backends, __pyx_k_supported_backends, sizeof(__pyx_k_supported_backends), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
- {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
- {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1},
- {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
- {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
- {&__pyx_n_s_update_now, __pyx_k_update_now, sizeof(__pyx_k_update_now), 0, 0, 1, 1},
- {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
- {&__pyx_n_s_win32, __pyx_k_win32, sizeof(__pyx_k_win32), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 39, __pyx_L1_error)
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 203, __pyx_L1_error)
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 204, __pyx_L1_error)
- __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 210, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 296, __pyx_L1_error)
- __pyx_builtin_SystemError = __Pyx_GetBuiltinName(__pyx_n_s_SystemError); if (!__pyx_builtin_SystemError) __PYX_ERR(0, 424, __pyx_L1_error)
- __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 665, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 807, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 198, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
-
- __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Child_watchers_are_not_supported); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
-
- __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_sigfd); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 746, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__12);
- __Pyx_GIVEREF(__pyx_tuple__12);
-
- __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Cannot_construct_a_bare_watcher); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 862, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
-
- __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 911, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__14);
- __Pyx_GIVEREF(__pyx_tuple__14);
-
- __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1009, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
-
- __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1021, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__16);
- __Pyx_GIVEREF(__pyx_tuple__16);
-
- __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Child_watchers_are_not_supported); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1176, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
-
- __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 1178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
-
- __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 39, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
-
- __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__20);
- __Pyx_GIVEREF(__pyx_tuple__20);
-
- __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
-
- __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__22);
- __Pyx_GIVEREF(__pyx_tuple__22);
-
- __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_gevent); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
-
- __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_get_version, 128, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 128, __pyx_L1_error)
-
- __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_get_header_version, 132, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 132, __pyx_L1_error)
-
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_supported_backends, 241, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 241, __pyx_L1_error)
-
- __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_recommended_backends, 245, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 245, __pyx_L1_error)
-
- __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_embeddable_backends, 249, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 249, __pyx_L1_error)
-
- __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_libev_corecext_pyx, __pyx_n_s_time, 253, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 253, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_5libev_8corecext_integer_types = ((PyObject*)Py_None); Py_INCREF(Py_None);
- GEVENT_CORE_EVENTS = Py_None; Py_INCREF(Py_None);
- _empty_tuple = ((PyObject*)Py_None); Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_6gevent_5libev_8corecext__EVENTSType) < 0) __PYX_ERR(0, 118, __pyx_L1_error)
- __pyx_type_6gevent_5libev_8corecext__EVENTSType.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_5libev_8corecext__EVENTSType.tp_dictoffset && __pyx_type_6gevent_5libev_8corecext__EVENTSType.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_5libev_8corecext__EVENTSType.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- __pyx_ptype_6gevent_5libev_8corecext__EVENTSType = &__pyx_type_6gevent_5libev_8corecext__EVENTSType;
- if (PyType_Ready(&PyGeventCallback_Type) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
- PyGeventCallback_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventCallback_Type.tp_dictoffset && PyGeventCallback_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventCallback_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "callback", (PyObject *)&PyGeventCallback_Type) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_callback = &PyGeventCallback_Type;
- __pyx_vtabptr_6gevent_5libev_8corecext_CallbackFIFO = &__pyx_vtable_6gevent_5libev_8corecext_CallbackFIFO;
- __pyx_vtable_6gevent_5libev_8corecext_CallbackFIFO.popleft = (struct PyGeventCallbackObject *(*)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *))__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_popleft;
- __pyx_vtable_6gevent_5libev_8corecext_CallbackFIFO.append = (PyObject *(*)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *, struct PyGeventCallbackObject *))__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_append;
- __pyx_vtable_6gevent_5libev_8corecext_CallbackFIFO.has_callbacks = (int (*)(struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *))__pyx_f_6gevent_5libev_8corecext_12CallbackFIFO_has_callbacks;
- if (PyType_Ready(&__pyx_type_6gevent_5libev_8corecext_CallbackFIFO) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
- __pyx_type_6gevent_5libev_8corecext_CallbackFIFO.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_5libev_8corecext_CallbackFIFO.tp_dictoffset && __pyx_type_6gevent_5libev_8corecext_CallbackFIFO.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_5libev_8corecext_CallbackFIFO.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_5libev_8corecext_CallbackFIFO.tp_dict, __pyx_vtabptr_6gevent_5libev_8corecext_CallbackFIFO) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_CallbackFIFO = &__pyx_type_6gevent_5libev_8corecext_CallbackFIFO;
- __pyx_vtabptr_6gevent_5libev_8corecext_loop = &__pyx_vtable_6gevent_5libev_8corecext_loop;
- __pyx_vtable_6gevent_5libev_8corecext_loop._run_callbacks = (PyObject *(*)(struct PyGeventLoopObject *))__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks;
- __pyx_vtable_6gevent_5libev_8corecext_loop._stop_watchers = (PyObject *(*)(struct PyGeventLoopObject *, struct ev_loop *))__pyx_f_6gevent_5libev_8corecext_4loop__stop_watchers;
- __pyx_vtable_6gevent_5libev_8corecext_loop.handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop_handle_error;
- __pyx_vtable_6gevent_5libev_8corecext_loop._default_handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error;
- __pyx_vtable_6gevent_5libev_8corecext_loop.now = (ev_tstamp (*)(struct PyGeventLoopObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop_now;
- __pyx_vtable_6gevent_5libev_8corecext_loop.update_now = (void (*)(struct PyGeventLoopObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop_update_now;
- if (PyType_Ready(&PyGeventLoop_Type) < 0) __PYX_ERR(0, 375, __pyx_L1_error)
- PyGeventLoop_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventLoop_Type.tp_dictoffset && PyGeventLoop_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventLoop_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(PyGeventLoop_Type.tp_dict, __pyx_vtabptr_6gevent_5libev_8corecext_loop) < 0) __PYX_ERR(0, 375, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "loop", (PyObject *)&PyGeventLoop_Type) < 0) __PYX_ERR(0, 375, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_loop = &PyGeventLoop_Type;
- if (PyType_Ready(&PyGeventWatcher_Type) < 0) __PYX_ERR(0, 815, __pyx_L1_error)
- PyGeventWatcher_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventWatcher_Type.tp_dictoffset && PyGeventWatcher_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventWatcher_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "watcher", (PyObject *)&PyGeventWatcher_Type) < 0) __PYX_ERR(0, 815, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_watcher = &PyGeventWatcher_Type;
- PyGeventIO_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventIO_Type) < 0) __PYX_ERR(0, 976, __pyx_L1_error)
- PyGeventIO_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventIO_Type.tp_dictoffset && PyGeventIO_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventIO_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "io", (PyObject *)&PyGeventIO_Type) < 0) __PYX_ERR(0, 976, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_io = &PyGeventIO_Type;
- PyGeventTimer_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventTimer_Type) < 0) __PYX_ERR(0, 1033, __pyx_L1_error)
- PyGeventTimer_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventTimer_Type.tp_dictoffset && PyGeventTimer_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventTimer_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "timer", (PyObject *)&PyGeventTimer_Type) < 0) __PYX_ERR(0, 1033, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_timer = &PyGeventTimer_Type;
- PyGeventSignal_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventSignal_Type) < 0) __PYX_ERR(0, 1073, __pyx_L1_error)
- PyGeventSignal_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventSignal_Type.tp_dictoffset && PyGeventSignal_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventSignal_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "signal", (PyObject *)&PyGeventSignal_Type) < 0) __PYX_ERR(0, 1073, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_signal = &PyGeventSignal_Type;
- PyGeventIdle_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventIdle_Type) < 0) __PYX_ERR(0, 1096, __pyx_L1_error)
- PyGeventIdle_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventIdle_Type.tp_dictoffset && PyGeventIdle_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventIdle_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "idle", (PyObject *)&PyGeventIdle_Type) < 0) __PYX_ERR(0, 1096, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_idle = &PyGeventIdle_Type;
- PyGeventPrepare_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventPrepare_Type) < 0) __PYX_ERR(0, 1109, __pyx_L1_error)
- PyGeventPrepare_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventPrepare_Type.tp_dictoffset && PyGeventPrepare_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventPrepare_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "prepare", (PyObject *)&PyGeventPrepare_Type) < 0) __PYX_ERR(0, 1109, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_prepare = &PyGeventPrepare_Type;
- PyGeventCheck_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventCheck_Type) < 0) __PYX_ERR(0, 1122, __pyx_L1_error)
- PyGeventCheck_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventCheck_Type.tp_dictoffset && PyGeventCheck_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventCheck_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "check", (PyObject *)&PyGeventCheck_Type) < 0) __PYX_ERR(0, 1122, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_check = &PyGeventCheck_Type;
- PyGeventFork_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventFork_Type) < 0) __PYX_ERR(0, 1135, __pyx_L1_error)
- PyGeventFork_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventFork_Type.tp_dictoffset && PyGeventFork_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventFork_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "fork", (PyObject *)&PyGeventFork_Type) < 0) __PYX_ERR(0, 1135, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_fork = &PyGeventFork_Type;
- PyGeventAsync_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventAsync_Type) < 0) __PYX_ERR(0, 1147, __pyx_L1_error)
- PyGeventAsync_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventAsync_Type.tp_dictoffset && PyGeventAsync_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventAsync_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "async_", (PyObject *)&PyGeventAsync_Type) < 0) __PYX_ERR(0, 1147, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_async_ = &PyGeventAsync_Type;
- PyGeventChild_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventChild_Type) < 0) __PYX_ERR(0, 1170, __pyx_L1_error)
- PyGeventChild_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventChild_Type.tp_dictoffset && PyGeventChild_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventChild_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "child", (PyObject *)&PyGeventChild_Type) < 0) __PYX_ERR(0, 1170, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_child = &PyGeventChild_Type;
- PyGeventStat_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher;
- if (PyType_Ready(&PyGeventStat_Type) < 0) __PYX_ERR(0, 1213, __pyx_L1_error)
- PyGeventStat_Type.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!PyGeventStat_Type.tp_dictoffset && PyGeventStat_Type.tp_getattro == PyObject_GenericGetAttr)) {
- PyGeventStat_Type.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "stat", (PyObject *)&PyGeventStat_Type) < 0) __PYX_ERR(0, 1213, __pyx_L1_error)
- __pyx_ptype_6gevent_5libev_8corecext_stat = &PyGeventStat_Type;
- if (PyType_Ready(&__pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr.tp_dictoffset && __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- __pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = &__pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
- #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
- sizeof(PyTypeObject),
- #else
- sizeof(PyHeapTypeObject),
- #endif
- 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(1, 9, __pyx_L1_error)
- __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(2, 8, __pyx_L1_error)
- __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(3, 15, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC initcorecext(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC initcorecext(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit_corecext(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit_corecext(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec_corecext(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_corecext(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("corecext", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent__libev__corecext) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.libev.corecext")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.libev.corecext", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- (void)__Pyx_modinit_variable_export_code();
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__19, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__20, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__21, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_traceback, __pyx_t_2) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__22, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_signalmodule, __pyx_t_1) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__23, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getswitchinterval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_getswitchinterval, __pyx_t_1) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_get_version);
- __Pyx_GIVEREF(__pyx_n_s_get_version);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_version);
- __Pyx_INCREF(__pyx_n_s_get_header_version);
- __Pyx_GIVEREF(__pyx_n_s_get_header_version);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_get_header_version);
- __Pyx_INCREF(__pyx_n_s_supported_backends);
- __Pyx_GIVEREF(__pyx_n_s_supported_backends);
- PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_supported_backends);
- __Pyx_INCREF(__pyx_n_s_recommended_backends);
- __Pyx_GIVEREF(__pyx_n_s_recommended_backends);
- PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_recommended_backends);
- __Pyx_INCREF(__pyx_n_s_embeddable_backends);
- __Pyx_GIVEREF(__pyx_n_s_embeddable_backends);
- PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_embeddable_backends);
- __Pyx_INCREF(__pyx_n_s_time);
- __Pyx_GIVEREF(__pyx_n_s_time);
- PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_time);
- __Pyx_INCREF(__pyx_n_s_loop);
- __Pyx_GIVEREF(__pyx_n_s_loop);
- PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_loop);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_3) {
-
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type)));
- __Pyx_XGOTREF(__pyx_v_6gevent_5libev_8corecext_integer_types);
- __Pyx_DECREF_SET(__pyx_v_6gevent_5libev_8corecext_integer_types, ((PyObject*)__pyx_t_2));
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- goto __pyx_L2;
- }
-
- /*else*/ {
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type)));
- __Pyx_INCREF(((PyObject *)(&PyLong_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyLong_Type)));
- PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyLong_Type)));
- __Pyx_XGOTREF(__pyx_v_6gevent_5libev_8corecext_integer_types);
- __Pyx_DECREF_SET(__pyx_v_6gevent_5libev_8corecext_integer_types, ((PyObject*)__pyx_t_2));
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
- }
- __pyx_L2:;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_UNDEF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_UNDEF, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_NONE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONE, __pyx_t_2) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_READ, __pyx_t_2) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_WRITE, __pyx_t_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_TIMER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMER, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_PERIODIC, __pyx_t_2) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNAL, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHILD, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_STAT, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDLE, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_PREPARE, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHECK, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMBED, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORK, __pyx_t_2) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_CLEANUP, __pyx_t_2) < 0) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ASYNC, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUSTOM, __pyx_t_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ERROR, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int((EV_READ | EV_WRITE)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_READWRITE, __pyx_t_2) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_MINPRI, __pyx_t_2) < 0) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAXPRI, __pyx_t_2) < 0) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_PORT, __pyx_t_2) < 0) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_KQUEUE, __pyx_t_2) < 0) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_EPOLL, __pyx_t_2) < 0) __PYX_ERR(0, 108, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_POLL, __pyx_t_2) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_SELECT, __pyx_t_2) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORKCHECK, __pyx_t_2) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOINOTIFY, __pyx_t_2) < 0) __PYX_ERR(0, 112, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNALFD, __pyx_t_2) < 0) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOSIGMASK, __pyx_t_2) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext__EVENTSType)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XGOTREF(GEVENT_CORE_EVENTS);
- __Pyx_DECREF_SET(GEVENT_CORE_EVENTS, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EVENTS, GEVENT_CORE_EVENTS) < 0) __PYX_ERR(0, 125, __pyx_L1_error)
-
- __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_1get_version, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_2) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_3get_header_version, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_header_version, __pyx_t_2) < 0) __PYX_ERR(0, 132, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_port);
- __Pyx_GIVEREF(__pyx_n_s_port);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_port);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_kqueue);
- __Pyx_GIVEREF(__pyx_n_s_kqueue);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_kqueue);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_epoll);
- __Pyx_GIVEREF(__pyx_n_s_epoll);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_epoll);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_poll);
- __Pyx_GIVEREF(__pyx_n_s_poll);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_poll);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_select);
- __Pyx_GIVEREF(__pyx_n_s_select);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_select);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOENV); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_noenv);
- __Pyx_GIVEREF(__pyx_n_s_noenv);
- PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_noenv);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_forkcheck);
- __Pyx_GIVEREF(__pyx_n_s_forkcheck);
- PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_forkcheck);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_noinotify);
- __Pyx_GIVEREF(__pyx_n_s_noinotify);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_noinotify);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_signalfd);
- __Pyx_GIVEREF(__pyx_n_s_signalfd);
- PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_signalfd);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_nosigmask);
- __Pyx_GIVEREF(__pyx_n_s_nosigmask);
- PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_nosigmask);
- __pyx_t_2 = 0;
-
- __pyx_t_2 = PyList_New(10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_8);
- PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_9);
- PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_10);
- PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_11);
- PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_12);
- PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12);
- __pyx_t_1 = 0;
- __pyx_t_4 = 0;
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- __pyx_t_8 = 0;
- __pyx_t_9 = 0;
- __pyx_t_10 = 0;
- __pyx_t_11 = 0;
- __pyx_t_12 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_2) < 0) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_t_2 = __pyx_pf_6gevent_5libev_8corecext_22genexpr(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_12 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags_str2int, __pyx_t_12) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_READ);
- __Pyx_GIVEREF(__pyx_n_s_READ);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_READ);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_WRITE);
- __Pyx_GIVEREF(__pyx_n_s_WRITE);
- PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_WRITE);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV__IOFDSET); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_IOFDSET);
- __Pyx_GIVEREF(__pyx_n_s_IOFDSET);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_IOFDSET);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_PERIODIC);
- __Pyx_GIVEREF(__pyx_n_s_PERIODIC);
- PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_PERIODIC);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_SIGNAL);
- __Pyx_GIVEREF(__pyx_n_s_SIGNAL);
- PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_SIGNAL);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_CHILD);
- __Pyx_GIVEREF(__pyx_n_s_CHILD);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_CHILD);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_STAT);
- __Pyx_GIVEREF(__pyx_n_s_STAT);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_STAT);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_IDLE);
- __Pyx_GIVEREF(__pyx_n_s_IDLE);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_IDLE);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_PREPARE);
- __Pyx_GIVEREF(__pyx_n_s_PREPARE);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_PREPARE);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_CHECK);
- __Pyx_GIVEREF(__pyx_n_s_CHECK);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CHECK);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_EMBED);
- __Pyx_GIVEREF(__pyx_n_s_EMBED);
- PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_EMBED);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_FORK);
- __Pyx_GIVEREF(__pyx_n_s_FORK);
- PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_FORK);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_CLEANUP);
- __Pyx_GIVEREF(__pyx_n_s_CLEANUP);
- PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_CLEANUP);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_ASYNC);
- __Pyx_GIVEREF(__pyx_n_s_ASYNC);
- PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ASYNC);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_CUSTOM);
- __Pyx_GIVEREF(__pyx_n_s_CUSTOM);
- PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_CUSTOM);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_GIVEREF(__pyx_t_12);
- PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_12);
- __Pyx_INCREF(__pyx_n_s_ERROR);
- __Pyx_GIVEREF(__pyx_n_s_ERROR);
- PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ERROR);
- __pyx_t_12 = 0;
-
- __pyx_t_12 = PyList_New(16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_2);
- PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_11);
- PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_10);
- PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_9);
- PyList_SET_ITEM(__pyx_t_12, 3, __pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8);
- PyList_SET_ITEM(__pyx_t_12, 4, __pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_7);
- PyList_SET_ITEM(__pyx_t_12, 5, __pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6);
- PyList_SET_ITEM(__pyx_t_12, 6, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_5);
- PyList_SET_ITEM(__pyx_t_12, 7, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4);
- PyList_SET_ITEM(__pyx_t_12, 8, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyList_SET_ITEM(__pyx_t_12, 9, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_13);
- PyList_SET_ITEM(__pyx_t_12, 10, __pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_14);
- PyList_SET_ITEM(__pyx_t_12, 11, __pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_15);
- PyList_SET_ITEM(__pyx_t_12, 12, __pyx_t_15);
- __Pyx_GIVEREF(__pyx_t_16);
- PyList_SET_ITEM(__pyx_t_12, 13, __pyx_t_16);
- __Pyx_GIVEREF(__pyx_t_17);
- PyList_SET_ITEM(__pyx_t_12, 14, __pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_18);
- PyList_SET_ITEM(__pyx_t_12, 15, __pyx_t_18);
- __pyx_t_2 = 0;
- __pyx_t_11 = 0;
- __pyx_t_10 = 0;
- __pyx_t_9 = 0;
- __pyx_t_8 = 0;
- __pyx_t_7 = 0;
- __pyx_t_6 = 0;
- __pyx_t_5 = 0;
- __pyx_t_4 = 0;
- __pyx_t_1 = 0;
- __pyx_t_13 = 0;
- __pyx_t_14 = 0;
- __pyx_t_15 = 0;
- __pyx_t_16 = 0;
- __pyx_t_17 = 0;
- __pyx_t_18 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_events, __pyx_t_12) < 0) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_version_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_18, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- __pyx_t_18 = PyObject_RichCompare(__pyx_t_12, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- if (__pyx_t_3) {
-
- __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_INCREF(((PyObject *)(&PyBytes_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyBytes_Type)));
- PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)(&PyBytes_Type)));
- __Pyx_INCREF(((PyObject *)(&PyString_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
- PyTuple_SET_ITEM(__pyx_t_18, 1, ((PyObject *)(&PyString_Type)));
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_18) < 0) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
-
- goto __pyx_L3;
- }
-
- /*else*/ {
- __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_18);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_basestring); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_12) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- }
- __pyx_L3:;
-
- __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_13supported_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 241, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_supported_backends, __pyx_t_12) < 0) __PYX_ERR(0, 241, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_15recommended_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_recommended_backends, __pyx_t_12) < 0) __PYX_ERR(0, 245, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_17embeddable_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_embeddable_backends, __pyx_t_12) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_19time, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 253, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_12) < 0) __PYX_ERR(0, 253, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_callback, __pyx_n_s_stop); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_callback->tp_dict, __pyx_n_s_close, __pyx_t_12) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- PyType_Modified(__pyx_ptype_6gevent_5libev_8corecext_callback);
-
- __pyx_k__10 = EVBREAK_ONE;
-
- __pyx_t_12 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_loop, __pyx_n_s_update_now); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 596, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_loop->tp_dict, __pyx_n_s_update, __pyx_t_12) < 0) __PYX_ERR(0, 596, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- PyType_Modified(__pyx_ptype_6gevent_5libev_8corecext_loop);
-
- __pyx_t_12 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_loop, __pyx_n_s_async); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_loop->tp_dict, __pyx_n_s_async_2, __pyx_t_12) < 0) __PYX_ERR(0, 661, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- PyType_Modified(__pyx_ptype_6gevent_5libev_8corecext_loop);
-
- __pyx_v_6gevent_5libev_8corecext_io_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_io_start), ((void *)ev_io_stop));
-
- __pyx_v_6gevent_5libev_8corecext_timer_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_timer_start), ((void *)ev_timer_stop));
-
- __pyx_v_6gevent_5libev_8corecext_signal_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_signal_start), ((void *)ev_signal_stop));
-
- __pyx_v_6gevent_5libev_8corecext_idle_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_idle_start), ((void *)ev_idle_stop));
-
- __pyx_v_6gevent_5libev_8corecext_prepare_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_prepare_start), ((void *)ev_prepare_stop));
-
- __pyx_v_6gevent_5libev_8corecext_check_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_check_start), ((void *)ev_check_stop));
-
- __pyx_v_6gevent_5libev_8corecext_fork_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_fork_start), ((void *)ev_fork_stop));
-
- __pyx_v_6gevent_5libev_8corecext_async_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_async_start), ((void *)ev_async_stop));
-
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_async_2, ((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_async_)) < 0) __PYX_ERR(0, 1166, __pyx_L1_error)
-
- __pyx_v_6gevent_5libev_8corecext_child_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_child_start), ((void *)ev_child_stop));
-
- __pyx_v_6gevent_5libev_8corecext_stat_ss = __pyx_f_6gevent_5libev_8corecext_make_ss(((void *)ev_stat_start), ((void *)ev_stat_stop));
-
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) __PYX_ERR(0, 1257, __pyx_L1_error)
-
- __pyx_t_12 = __Pyx_PyInt_From_int(LIBEV_EMBED); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1283, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1283, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1283, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBEV_EMBED, __pyx_t_12) < 0) __PYX_ERR(0, 1283, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_FLOOR); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1284, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_FLOOR, __pyx_t_12) < 0) __PYX_ERR(0, 1284, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_CLOCK_SYSCALL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_t_12) < 0) __PYX_ERR(0, 1285, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_REALTIME); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1286, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_REALTIME, __pyx_t_12) < 0) __PYX_ERR(0, 1286, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_MONOTONIC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_MONOTONIC, __pyx_t_12) < 0) __PYX_ERR(0, 1287, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_NANOSLEEP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1288, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_NANOSLEEP, __pyx_t_12) < 0) __PYX_ERR(0, 1288, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_INOTIFY); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_INOTIFY, __pyx_t_12) < 0) __PYX_ERR(0, 1289, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_SIGNALFD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1290, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_SIGNALFD, __pyx_t_12) < 0) __PYX_ERR(0, 1290, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_EVENTFD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_EVENTFD, __pyx_t_12) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_4HEAP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_4HEAP, __pyx_t_12) < 0) __PYX_ERR(0, 1292, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- __Pyx_INCREF(__pyx_empty_tuple);
- __Pyx_XGOTREF(_empty_tuple);
- __Pyx_DECREF_SET(_empty_tuple, __pyx_empty_tuple);
- __Pyx_GIVEREF(__pyx_empty_tuple);
-
- __pyx_t_12 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_12) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_XDECREF(__pyx_t_16);
- __Pyx_XDECREF(__pyx_t_17);
- __Pyx_XDECREF(__pyx_t_18);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.libev.corecext", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.libev.corecext");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* GetModuleGlobalName */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* RaiseTooManyValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* PyObjectCall */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyCFunctionFastCall */
- #if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
- #if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCallMethO */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* ObjectGetItem */
- #if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* StringJoin */
- #if !CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
- return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* RaiseArgTupleInvalid */
- static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* BytesEquals */
- static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
- static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
- const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(unsigned int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(unsigned int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
- const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(unsigned int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (unsigned int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (unsigned int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
- case 2:
- if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
- return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
- return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
- return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (unsigned int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(unsigned int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (unsigned int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0])
- case -2:
- if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
- return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
- return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
- return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
- return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
- return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
- return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(unsigned int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- unsigned int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (unsigned int) -1;
- }
- } else {
- unsigned int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (unsigned int) -1;
- val = __Pyx_PyInt_As_unsigned_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to unsigned int");
- return (unsigned int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to unsigned int");
- return (unsigned int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* PyObjectCallMethod1 */
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = NULL;
-#if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
-#endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- goto done;
-done:
- return result;
-}
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method, *result;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- result = __Pyx__PyObject_CallMethod1(method, arg);
- Py_DECREF(method);
- return result;
-}
-
-/* CoroutineBase */
- #include <structmember.h>
-#include <frameobject.h>
-#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
-static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
- PyObject *et, *ev, *tb;
- PyObject *value = NULL;
- __Pyx_ErrFetch(&et, &ev, &tb);
- if (!et) {
- Py_XDECREF(tb);
- Py_XDECREF(ev);
- Py_INCREF(Py_None);
- *pvalue = Py_None;
- return 0;
- }
- if (likely(et == PyExc_StopIteration)) {
- if (!ev) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#if PY_VERSION_HEX >= 0x030300A0
- else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
- value = ((PyStopIterationObject *)ev)->value;
- Py_INCREF(value);
- Py_DECREF(ev);
- }
-#endif
- else if (unlikely(PyTuple_Check(ev))) {
- if (PyTuple_GET_SIZE(ev) >= 1) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- value = PyTuple_GET_ITEM(ev, 0);
- Py_INCREF(value);
-#else
- value = PySequence_ITEM(ev, 0);
-#endif
- } else {
- Py_INCREF(Py_None);
- value = Py_None;
- }
- Py_DECREF(ev);
- }
- else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
- value = ev;
- }
- if (likely(value)) {
- Py_XDECREF(tb);
- Py_DECREF(et);
- *pvalue = value;
- return 0;
- }
- } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
- __Pyx_ErrRestore(et, ev, tb);
- return -1;
- }
- PyErr_NormalizeException(&et, &ev, &tb);
- if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
- __Pyx_ErrRestore(et, ev, tb);
- return -1;
- }
- Py_XDECREF(tb);
- Py_DECREF(et);
-#if PY_VERSION_HEX >= 0x030300A0
- value = ((PyStopIterationObject *)ev)->value;
- Py_INCREF(value);
- Py_DECREF(ev);
-#else
- {
- PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
- Py_DECREF(ev);
- if (likely(args)) {
- value = PySequence_GetItem(args, 0);
- Py_DECREF(args);
- }
- if (unlikely(!value)) {
- __Pyx_ErrRestore(NULL, NULL, NULL);
- Py_INCREF(Py_None);
- value = Py_None;
- }
- }
-#endif
- *pvalue = value;
- return 0;
-}
-static CYTHON_INLINE
-void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
- PyObject *exc_type = self->exc_type;
- PyObject *exc_value = self->exc_value;
- PyObject *exc_traceback = self->exc_traceback;
- self->exc_type = NULL;
- self->exc_value = NULL;
- self->exc_traceback = NULL;
- Py_XDECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_traceback);
-}
-#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
-static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
- const char *msg;
- if (0) {
- #ifdef __Pyx_Coroutine_USED
- } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
- msg = "coroutine already executing";
- #endif
- #ifdef __Pyx_AsyncGen_USED
- } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
- msg = "async generator already executing";
- #endif
- } else {
- msg = "generator already executing";
- }
- PyErr_SetString(PyExc_ValueError, msg);
-}
-#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
-static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
- const char *msg;
- if (0) {
- #ifdef __Pyx_Coroutine_USED
- } else if (__Pyx_Coroutine_Check(gen)) {
- msg = "can't send non-None value to a just-started coroutine";
- #endif
- #ifdef __Pyx_AsyncGen_USED
- } else if (__Pyx_AsyncGen_CheckExact(gen)) {
- msg = "can't send non-None value to a just-started async generator";
- #endif
- } else {
- msg = "can't send non-None value to a just-started generator";
- }
- PyErr_SetString(PyExc_TypeError, msg);
-}
-#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
-static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
- #ifdef __Pyx_Coroutine_USED
- if (!closing && __Pyx_Coroutine_Check(gen)) {
- PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
- } else
- #endif
- if (value) {
- #ifdef __Pyx_AsyncGen_USED
- if (__Pyx_AsyncGen_CheckExact(gen))
- PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
- else
- #endif
- PyErr_SetNone(PyExc_StopIteration);
- }
-}
-static
-PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
- __Pyx_PyThreadState_declare
- PyThreadState *tstate;
- PyObject *retval;
- assert(!self->is_running);
- if (unlikely(self->resume_label == 0)) {
- if (unlikely(value && value != Py_None)) {
- return __Pyx_Coroutine_NotStartedError((PyObject*)self);
- }
- }
- if (unlikely(self->resume_label == -1)) {
- return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
- }
-#if CYTHON_FAST_THREAD_STATE
- __Pyx_PyThreadState_assign
- tstate = __pyx_tstate;
-#else
- tstate = __Pyx_PyThreadState_Current;
-#endif
- if (self->exc_type) {
-#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
-#else
- if (self->exc_traceback) {
- PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
- PyFrameObject *f = tb->tb_frame;
- Py_XINCREF(tstate->frame);
- assert(f->f_back == NULL);
- f->f_back = tstate->frame;
- }
-#endif
- __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
- &self->exc_traceback);
- } else {
- __Pyx_Coroutine_ExceptionClear(self);
- __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
- }
- self->is_running = 1;
- retval = self->body((PyObject *) self, tstate, value);
- self->is_running = 0;
- return retval;
-}
-static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
- if (likely(self->exc_traceback)) {
-#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
-#else
- PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
- PyFrameObject *f = tb->tb_frame;
- Py_CLEAR(f->f_back);
-#endif
- }
-}
-static CYTHON_INLINE
-PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
- if (unlikely(!retval)) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (!__Pyx_PyErr_Occurred()) {
- PyObject *exc = PyExc_StopIteration;
- #ifdef __Pyx_AsyncGen_USED
- if (__Pyx_AsyncGen_CheckExact(gen))
- exc = __Pyx_PyExc_StopAsyncIteration;
- #endif
- __Pyx_PyErr_SetNone(exc);
- }
- }
- return retval;
-}
-static CYTHON_INLINE
-PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
- PyObject *ret;
- PyObject *val = NULL;
- __Pyx_Coroutine_Undelegate(gen);
- __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
- ret = __Pyx_Coroutine_SendEx(gen, val, 0);
- Py_XDECREF(val);
- return ret;
-}
-static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
- PyObject *retval;
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
- PyObject *yf = gen->yieldfrom;
- if (unlikely(gen->is_running))
- return __Pyx_Coroutine_AlreadyRunningError(gen);
- if (yf) {
- PyObject *ret;
- gen->is_running = 1;
- #ifdef __Pyx_Generator_USED
- if (__Pyx_Generator_CheckExact(yf)) {
- ret = __Pyx_Coroutine_Send(yf, value);
- } else
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__Pyx_Coroutine_Check(yf)) {
- ret = __Pyx_Coroutine_Send(yf, value);
- } else
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
- ret = __Pyx_async_gen_asend_send(yf, value);
- } else
- #endif
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
- if (PyGen_CheckExact(yf)) {
- ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
- } else
- #endif
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
- if (PyCoro_CheckExact(yf)) {
- ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
- } else
- #endif
- {
- if (value == Py_None)
- ret = Py_TYPE(yf)->tp_iternext(yf);
- else
- ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
- }
- gen->is_running = 0;
- if (likely(ret)) {
- return ret;
- }
- retval = __Pyx_Coroutine_FinishDelegation(gen);
- } else {
- retval = __Pyx_Coroutine_SendEx(gen, value, 0);
- }
- return __Pyx_Coroutine_MethodReturn(self, retval);
-}
-static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
- PyObject *retval = NULL;
- int err = 0;
- #ifdef __Pyx_Generator_USED
- if (__Pyx_Generator_CheckExact(yf)) {
- retval = __Pyx_Coroutine_Close(yf);
- if (!retval)
- return -1;
- } else
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__Pyx_Coroutine_Check(yf)) {
- retval = __Pyx_Coroutine_Close(yf);
- if (!retval)
- return -1;
- } else
- if (__Pyx_CoroutineAwait_CheckExact(yf)) {
- retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
- if (!retval)
- return -1;
- } else
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
- retval = __Pyx_async_gen_asend_close(yf, NULL);
- } else
- if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
- retval = __Pyx_async_gen_athrow_close(yf, NULL);
- } else
- #endif
- {
- PyObject *meth;
- gen->is_running = 1;
- meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
- if (unlikely(!meth)) {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_WriteUnraisable(yf);
- }
- PyErr_Clear();
- } else {
- retval = PyObject_CallFunction(meth, NULL);
- Py_DECREF(meth);
- if (!retval)
- err = -1;
- }
- gen->is_running = 0;
- }
- Py_XDECREF(retval);
- return err;
-}
-static PyObject *__Pyx_Generator_Next(PyObject *self) {
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
- PyObject *yf = gen->yieldfrom;
- if (unlikely(gen->is_running))
- return __Pyx_Coroutine_AlreadyRunningError(gen);
- if (yf) {
- PyObject *ret;
- gen->is_running = 1;
- #ifdef __Pyx_Generator_USED
- if (__Pyx_Generator_CheckExact(yf)) {
- ret = __Pyx_Generator_Next(yf);
- } else
- #endif
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
- if (PyGen_CheckExact(yf)) {
- ret = _PyGen_Send((PyGenObject*)yf, NULL);
- } else
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__Pyx_Coroutine_Check(yf)) {
- ret = __Pyx_Coroutine_Send(yf, Py_None);
- } else
- #endif
- ret = Py_TYPE(yf)->tp_iternext(yf);
- gen->is_running = 0;
- if (likely(ret)) {
- return ret;
- }
- return __Pyx_Coroutine_FinishDelegation(gen);
- }
- return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
-}
-static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
- PyObject *retval, *raised_exception;
- PyObject *yf = gen->yieldfrom;
- int err = 0;
- if (unlikely(gen->is_running))
- return __Pyx_Coroutine_AlreadyRunningError(gen);
- if (yf) {
- Py_INCREF(yf);
- err = __Pyx_Coroutine_CloseIter(gen, yf);
- __Pyx_Coroutine_Undelegate(gen);
- Py_DECREF(yf);
- }
- if (err == 0)
- PyErr_SetNone(PyExc_GeneratorExit);
- retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
- if (unlikely(retval)) {
- const char *msg;
- Py_DECREF(retval);
- if ((0)) {
- #ifdef __Pyx_Coroutine_USED
- } else if (__Pyx_Coroutine_Check(self)) {
- msg = "coroutine ignored GeneratorExit";
- #endif
- #ifdef __Pyx_AsyncGen_USED
- } else if (__Pyx_AsyncGen_CheckExact(self)) {
-#if PY_VERSION_HEX < 0x03060000
- msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
-#else
- msg = "async generator ignored GeneratorExit";
-#endif
- #endif
- } else {
- msg = "generator ignored GeneratorExit";
- }
- PyErr_SetString(PyExc_RuntimeError, msg);
- return NULL;
- }
- raised_exception = PyErr_Occurred();
- if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
- if (raised_exception) PyErr_Clear();
- Py_INCREF(Py_None);
- return Py_None;
- }
- return NULL;
-}
-static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
- PyObject *args, int close_on_genexit) {
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
- PyObject *yf = gen->yieldfrom;
- if (unlikely(gen->is_running))
- return __Pyx_Coroutine_AlreadyRunningError(gen);
- if (yf) {
- PyObject *ret;
- Py_INCREF(yf);
- if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
- int err = __Pyx_Coroutine_CloseIter(gen, yf);
- Py_DECREF(yf);
- __Pyx_Coroutine_Undelegate(gen);
- if (err < 0)
- return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
- goto throw_here;
- }
- gen->is_running = 1;
- if (0
- #ifdef __Pyx_Generator_USED
- || __Pyx_Generator_CheckExact(yf)
- #endif
- #ifdef __Pyx_Coroutine_USED
- || __Pyx_Coroutine_Check(yf)
- #endif
- ) {
- ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
- #ifdef __Pyx_Coroutine_USED
- } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
- ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
- #endif
- } else {
- PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
- if (unlikely(!meth)) {
- Py_DECREF(yf);
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
- gen->is_running = 0;
- return NULL;
- }
- PyErr_Clear();
- __Pyx_Coroutine_Undelegate(gen);
- gen->is_running = 0;
- goto throw_here;
- }
- if (likely(args)) {
- ret = PyObject_CallObject(meth, args);
- } else {
- ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
- }
- Py_DECREF(meth);
- }
- gen->is_running = 0;
- Py_DECREF(yf);
- if (!ret) {
- ret = __Pyx_Coroutine_FinishDelegation(gen);
- }
- return __Pyx_Coroutine_MethodReturn(self, ret);
- }
-throw_here:
- __Pyx_Raise(typ, val, tb, NULL);
- return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
-}
-static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
- PyObject *typ;
- PyObject *val = NULL;
- PyObject *tb = NULL;
- if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
- return NULL;
- return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
-}
-static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
- Py_VISIT(gen->closure);
- Py_VISIT(gen->classobj);
- Py_VISIT(gen->yieldfrom);
- Py_VISIT(gen->exc_type);
- Py_VISIT(gen->exc_value);
- Py_VISIT(gen->exc_traceback);
- return 0;
-}
-static int __Pyx_Coroutine_clear(PyObject *self) {
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
- Py_CLEAR(gen->closure);
- Py_CLEAR(gen->classobj);
- Py_CLEAR(gen->yieldfrom);
- Py_CLEAR(gen->exc_type);
- Py_CLEAR(gen->exc_value);
- Py_CLEAR(gen->exc_traceback);
-#ifdef __Pyx_AsyncGen_USED
- if (__Pyx_AsyncGen_CheckExact(self)) {
- Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
- }
-#endif
- Py_CLEAR(gen->gi_code);
- Py_CLEAR(gen->gi_name);
- Py_CLEAR(gen->gi_qualname);
- Py_CLEAR(gen->gi_modulename);
- return 0;
-}
-static void __Pyx_Coroutine_dealloc(PyObject *self) {
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
- PyObject_GC_UnTrack(gen);
- if (gen->gi_weakreflist != NULL)
- PyObject_ClearWeakRefs(self);
- if (gen->resume_label >= 0) {
- PyObject_GC_Track(self);
-#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
- if (PyObject_CallFinalizerFromDealloc(self))
-#else
- Py_TYPE(gen)->tp_del(self);
- if (self->ob_refcnt > 0)
-#endif
- {
- return;
- }
- PyObject_GC_UnTrack(self);
- }
-#ifdef __Pyx_AsyncGen_USED
- if (__Pyx_AsyncGen_CheckExact(self)) {
- /* We have to handle this case for asynchronous generators
- right here, because this code has to be between UNTRACK
- and GC_Del. */
- Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
- }
-#endif
- __Pyx_Coroutine_clear(self);
- PyObject_GC_Del(gen);
-}
-static void __Pyx_Coroutine_del(PyObject *self) {
- PyObject *error_type, *error_value, *error_traceback;
- __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
- __Pyx_PyThreadState_declare
- if (gen->resume_label < 0) {
- return;
- }
-#if !CYTHON_USE_TP_FINALIZE
- assert(self->ob_refcnt == 0);
- self->ob_refcnt = 1;
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
-#ifdef __Pyx_AsyncGen_USED
- if (__Pyx_AsyncGen_CheckExact(self)) {
- __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
- PyObject *finalizer = agen->ag_finalizer;
- if (finalizer && !agen->ag_closed) {
- PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
- if (unlikely(!res)) {
- PyErr_WriteUnraisable(self);
- } else {
- Py_DECREF(res);
- }
- __Pyx_ErrRestore(error_type, error_value, error_traceback);
- return;
- }
- }
-#endif
- if (unlikely(gen->resume_label == 0 && !error_value)) {
-#ifdef __Pyx_Coroutine_USED
-#ifdef __Pyx_Generator_USED
- if (!__Pyx_Generator_CheckExact(self))
-#endif
- {
- PyObject_GC_UnTrack(self);
-#if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
- if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
- PyErr_WriteUnraisable(self);
-#else
- {PyObject *msg;
- char *cmsg;
- #if CYTHON_COMPILING_IN_PYPY
- msg = NULL;
- cmsg = (char*) "coroutine was never awaited";
- #else
- char *cname;
- PyObject *qualname;
- qualname = gen->gi_qualname;
- cname = PyString_AS_STRING(qualname);
- msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
- if (unlikely(!msg)) {
- PyErr_Clear();
- cmsg = (char*) "coroutine was never awaited";
- } else {
- cmsg = PyString_AS_STRING(msg);
- }
- #endif
- if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
- PyErr_WriteUnraisable(self);
- Py_XDECREF(msg);}
-#endif
- PyObject_GC_Track(self);
- }
-#endif
- } else {
- PyObject *res = __Pyx_Coroutine_Close(self);
- if (unlikely(!res)) {
- if (PyErr_Occurred())
- PyErr_WriteUnraisable(self);
- } else {
- Py_DECREF(res);
- }
- }
- __Pyx_ErrRestore(error_type, error_value, error_traceback);
-#if !CYTHON_USE_TP_FINALIZE
- assert(self->ob_refcnt > 0);
- if (--self->ob_refcnt == 0) {
- return;
- }
- {
- Py_ssize_t refcnt = self->ob_refcnt;
- _Py_NewReference(self);
- self->ob_refcnt = refcnt;
- }
-#if CYTHON_COMPILING_IN_CPYTHON
- assert(PyType_IS_GC(self->ob_type) &&
- _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
- _Py_DEC_REFTOTAL;
-#endif
-#ifdef COUNT_ALLOCS
- --Py_TYPE(self)->tp_frees;
- --Py_TYPE(self)->tp_allocs;
-#endif
-#endif
-}
-static PyObject *
-__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
-{
- PyObject *name = self->gi_name;
- if (unlikely(!name)) name = Py_None;
- Py_INCREF(name);
- return name;
-}
-static int
-__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = self->gi_name;
- Py_INCREF(value);
- self->gi_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
-{
- PyObject *name = self->gi_qualname;
- if (unlikely(!name)) name = Py_None;
- Py_INCREF(name);
- return name;
-}
-static int
-__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = self->gi_qualname;
- Py_INCREF(value);
- self->gi_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static __pyx_CoroutineObject *__Pyx__Coroutine_New(
- PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
- PyObject *name, PyObject *qualname, PyObject *module_name) {
- __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
- if (unlikely(!gen))
- return NULL;
- return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
-}
-static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
- __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
- PyObject *name, PyObject *qualname, PyObject *module_name) {
- gen->body = body;
- gen->closure = closure;
- Py_XINCREF(closure);
- gen->is_running = 0;
- gen->resume_label = 0;
- gen->classobj = NULL;
- gen->yieldfrom = NULL;
- gen->exc_type = NULL;
- gen->exc_value = NULL;
- gen->exc_traceback = NULL;
- gen->gi_weakreflist = NULL;
- Py_XINCREF(qualname);
- gen->gi_qualname = qualname;
- Py_XINCREF(name);
- gen->gi_name = name;
- Py_XINCREF(module_name);
- gen->gi_modulename = module_name;
- Py_XINCREF(code);
- gen->gi_code = code;
- PyObject_GC_Track(gen);
- return gen;
-}
-
-/* PatchModuleWithCoroutine */
- static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
-#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- int result;
- PyObject *globals, *result_obj;
- globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
- result = PyDict_SetItemString(globals, "_cython_coroutine_type",
- #ifdef __Pyx_Coroutine_USED
- (PyObject*)__pyx_CoroutineType);
- #else
- Py_None);
- #endif
- if (unlikely(result < 0)) goto ignore;
- result = PyDict_SetItemString(globals, "_cython_generator_type",
- #ifdef __Pyx_Generator_USED
- (PyObject*)__pyx_GeneratorType);
- #else
- Py_None);
- #endif
- if (unlikely(result < 0)) goto ignore;
- if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
- if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
- result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
- if (unlikely(!result_obj)) goto ignore;
- Py_DECREF(result_obj);
- Py_DECREF(globals);
- return module;
-ignore:
- Py_XDECREF(globals);
- PyErr_WriteUnraisable(module);
- if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
- Py_DECREF(module);
- module = NULL;
- }
-#else
- py_code++;
-#endif
- return module;
-}
-
-/* PatchGeneratorABC */
- #ifndef CYTHON_REGISTER_ABCS
-#define CYTHON_REGISTER_ABCS 1
-#endif
-#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
-static PyObject* __Pyx_patch_abc_module(PyObject *module);
-static PyObject* __Pyx_patch_abc_module(PyObject *module) {
- module = __Pyx_Coroutine_patch_module(
- module, ""
-"if _cython_generator_type is not None:\n"
-" try: Generator = _module.Generator\n"
-" except AttributeError: pass\n"
-" else: Generator.register(_cython_generator_type)\n"
-"if _cython_coroutine_type is not None:\n"
-" try: Coroutine = _module.Coroutine\n"
-" except AttributeError: pass\n"
-" else: Coroutine.register(_cython_coroutine_type)\n"
- );
- return module;
-}
-#endif
-static int __Pyx_patch_abc(void) {
-#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- static int abc_patched = 0;
- if (CYTHON_REGISTER_ABCS && !abc_patched) {
- PyObject *module;
- module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
- if (!module) {
- PyErr_WriteUnraisable(NULL);
- if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
- ((PY_MAJOR_VERSION >= 3) ?
- "Cython module failed to register with collections.abc module" :
- "Cython module failed to register with collections module"), 1) < 0)) {
- return -1;
- }
- } else {
- module = __Pyx_patch_abc_module(module);
- abc_patched = 1;
- if (unlikely(!module))
- return -1;
- Py_DECREF(module);
- }
- module = PyImport_ImportModule("backports_abc");
- if (module) {
- module = __Pyx_patch_abc_module(module);
- Py_XDECREF(module);
- }
- if (!module) {
- PyErr_Clear();
- }
- }
-#else
- if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
-#endif
- return 0;
-}
-
-/* Generator */
- static PyMethodDef __pyx_Generator_methods[] = {
- {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
- (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
- {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
- (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
- {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
- (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
- {0, 0, 0, 0}
-};
-static PyMemberDef __pyx_Generator_memberlist[] = {
- {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
- {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
- (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
- {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
- {0, 0, 0, 0, 0}
-};
-static PyGetSetDef __pyx_Generator_getsets[] = {
- {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
- (char*) PyDoc_STR("name of the generator"), 0},
- {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
- (char*) PyDoc_STR("qualified name of the generator"), 0},
- {0, 0, 0, 0, 0}
-};
-static PyTypeObject __pyx_GeneratorType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "generator",
- sizeof(__pyx_CoroutineObject),
- 0,
- (destructor) __Pyx_Coroutine_dealloc,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
- 0,
- (traverseproc) __Pyx_Coroutine_traverse,
- 0,
- 0,
- offsetof(__pyx_CoroutineObject, gi_weakreflist),
- 0,
- (iternextfunc) __Pyx_Generator_Next,
- __pyx_Generator_methods,
- __pyx_Generator_memberlist,
- __pyx_Generator_getsets,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if CYTHON_USE_TP_FINALIZE
- 0,
-#else
- __Pyx_Coroutine_del,
-#endif
- 0,
-#if CYTHON_USE_TP_FINALIZE
- __Pyx_Coroutine_del,
-#elif PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_Generator_init(void) {
- __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
- __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
- if (unlikely(!__pyx_GeneratorType)) {
- return -1;
- }
- return 0;
-}
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/libev/corecext.cp36-win32.pyd b/python/gevent/libev/corecext.cp36-win32.pyd
deleted file mode 100644
index 2170737..0000000
--- a/python/gevent/libev/corecext.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/libev/corecext.h b/python/gevent/libev/corecext.h
deleted file mode 100644
index 0878511..0000000
--- a/python/gevent/libev/corecext.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-#ifndef __PYX_HAVE__gevent__libev__corecext
-#define __PYX_HAVE__gevent__libev__corecext
-
-struct PyGeventCallbackObject;
-struct PyGeventLoopObject;
-struct PyGeventWatcherObject;
-struct PyGeventIOObject;
-struct PyGeventTimerObject;
-struct PyGeventSignalObject;
-struct PyGeventIdleObject;
-struct PyGeventPrepareObject;
-struct PyGeventCheckObject;
-struct PyGeventForkObject;
-struct PyGeventAsyncObject;
-struct PyGeventChildObject;
-struct PyGeventStatObject;
-
-struct PyGeventCallbackObject {
- PyObject_HEAD
- PyObject *callback;
- PyObject *args;
- struct PyGeventCallbackObject *next;
-};
-
-struct PyGeventLoopObject {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *__pyx_vtab;
- struct ev_prepare _prepare;
- struct ev_timer _timer0;
- struct ev_timer _periodic_signal_checker;
- PyObject *error_handler;
- struct ev_loop *_ptr;
- struct __pyx_obj_6gevent_5libev_8corecext_CallbackFIFO *_callbacks;
- int starting_timer_may_update_loop_time;
- int _default;
-};
-
-struct PyGeventWatcherObject {
- PyObject_HEAD
- struct PyGeventLoopObject *loop;
- PyObject *_callback;
- PyObject *args;
- struct ev_watcher *__pyx___watcher;
- struct __pyx_t_6gevent_5libev_8corecext_start_and_stop *__pyx___ss;
- unsigned int _flags;
-};
-
-struct PyGeventIOObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_io _watcher;
-};
-
-struct PyGeventTimerObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_timer _watcher;
-};
-
-struct PyGeventSignalObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_signal _watcher;
-};
-
-struct PyGeventIdleObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_idle _watcher;
-};
-
-struct PyGeventPrepareObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_prepare _watcher;
-};
-
-struct PyGeventCheckObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_check _watcher;
-};
-
-struct PyGeventForkObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_fork _watcher;
-};
-
-struct PyGeventAsyncObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_async _watcher;
-};
-
-struct PyGeventChildObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_child _watcher;
-};
-
-struct PyGeventStatObject {
- struct PyGeventWatcherObject __pyx_base;
- struct ev_stat _watcher;
- PyObject *path;
- PyObject *_paths;
-};
-
-#ifndef __PYX_HAVE_API__gevent__libev__corecext
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#ifndef DL_IMPORT
- #define DL_IMPORT(_T) _T
-#endif
-
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventCallback_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventLoop_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventWatcher_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventIO_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventTimer_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventSignal_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventIdle_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventPrepare_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventCheck_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventFork_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventAsync_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventChild_Type;
-__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventStat_Type;
-
-__PYX_EXTERN_C void gevent_handle_error(struct PyGeventLoopObject *, PyObject *);
-__PYX_EXTERN_C PyObject *gevent_loop_run_callbacks(struct PyGeventLoopObject *);
-
-__PYX_EXTERN_C PyObject *GEVENT_CORE_EVENTS;
-__PYX_EXTERN_C PyObject *_empty_tuple;
-
-#endif /* !__PYX_HAVE_API__gevent__libev__corecext */
-
-/* WARNING: the interface of the module init function changed in CPython 3.5. */
-/* It now returns a PyModuleDef instance instead of a PyModule instance. */
-
-#if PY_MAJOR_VERSION < 3
-PyMODINIT_FUNC initcorecext(void);
-#else
-PyMODINIT_FUNC PyInit_corecext(void);
-#endif
-
-#endif /* !__PYX_HAVE__gevent__libev__corecext */
diff --git a/python/gevent/libev/corecext.pyx b/python/gevent/libev/corecext.pyx
deleted file mode 100644
index 793b002..0000000
--- a/python/gevent/libev/corecext.pyx
+++ /dev/null
@@ -1,1340 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-
-# This first directive, supported in Cython 0.24+, causes sources
-# files to be *much* smaller when it's false (139,027 LOC vs 35,000
-# LOC) and thus cythonpp.py (and probably the compiler; also Visual C
-# has limits on source file sizes) to be faster (73s vs 46s). But it does
-# make debugging more difficult. Auto-pickling was added in 0.26, and
-# that's a new feature that we don't need or want to allow in a gevent
-# point release.
-
-# cython: emit_code_comments=False, auto_pickle=False
-
-# NOTE: We generally cannot use the Cython IF directive as documented
-# at
-# http://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#conditional-compilation
-# (e.g., IF UNAME_SYSNAME == "Windows") because when Cython says
-# "compilation", it means when *Cython* compiles, not when the C
-# compiler compiles. We distribute an sdist with a single pre-compiled
-# C file for all platforms so that end users that don't use a binary
-# wheel don't have to sit through cythonpp and other steps the Makefile does.
-# See https://github.com/gevent/gevent/issues/1076
-
-cimport cython
-cimport libev
-
-from cpython.ref cimport Py_INCREF
-from cpython.ref cimport Py_DECREF
-from cpython.mem cimport PyMem_Malloc
-from cpython.mem cimport PyMem_Free
-from libc.errno cimport errno
-
-cdef extern from "Python.h":
- int Py_ReprEnter(object)
- void Py_ReprLeave(object)
-
-# Work around lack of absolute_import in Cython
-# Note for PY3: not doing so will leave reference to locals() on import
-# (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py)
-sys = __import__('sys', level=0)
-os = __import__('os', level=0)
-traceback = __import__('traceback', level=0)
-signalmodule = __import__('signal', level=0)
-getswitchinterval = __import__('gevent', level=0).getswitchinterval
-
-
-__all__ = ['get_version',
- 'get_header_version',
- 'supported_backends',
- 'recommended_backends',
- 'embeddable_backends',
- 'time',
- 'loop']
-
-cdef tuple integer_types
-
-if sys.version_info[0] >= 3:
- integer_types = int,
-else:
- integer_types = (int, long)
-
-
-cdef extern from "callbacks.h":
- void gevent_callback_io(libev.ev_loop, void*, int)
- void gevent_callback_timer(libev.ev_loop, void*, int)
- void gevent_callback_signal(libev.ev_loop, void*, int)
- void gevent_callback_idle(libev.ev_loop, void*, int)
- void gevent_callback_prepare(libev.ev_loop, void*, int)
- void gevent_callback_check(libev.ev_loop, void*, int)
- void gevent_callback_fork(libev.ev_loop, void*, int)
- void gevent_callback_async(libev.ev_loop, void*, int)
- void gevent_callback_child(libev.ev_loop, void*, int)
- void gevent_callback_stat(libev.ev_loop, void*, int)
- void gevent_run_callbacks(libev.ev_loop, void*, int)
- void gevent_periodic_signal_check(libev.ev_loop, void*, int)
- void gevent_call(loop, callback)
- void gevent_noop(libev.ev_loop, void*, int)
-
-cdef extern from "stathelper.c":
- object _pystat_fromstructstat(void*)
-
-
-UNDEF = libev.EV_UNDEF
-NONE = libev.EV_NONE
-READ = libev.EV_READ
-WRITE = libev.EV_WRITE
-TIMER = libev.EV_TIMER
-PERIODIC = libev.EV_PERIODIC
-SIGNAL = libev.EV_SIGNAL
-CHILD = libev.EV_CHILD
-STAT = libev.EV_STAT
-IDLE = libev.EV_IDLE
-PREPARE = libev.EV_PREPARE
-CHECK = libev.EV_CHECK
-EMBED = libev.EV_EMBED
-FORK = libev.EV_FORK
-CLEANUP = libev.EV_CLEANUP
-ASYNC = libev.EV_ASYNC
-CUSTOM = libev.EV_CUSTOM
-ERROR = libev.EV_ERROR
-
-READWRITE = libev.EV_READ | libev.EV_WRITE
-
-MINPRI = libev.EV_MINPRI
-MAXPRI = libev.EV_MAXPRI
-
-BACKEND_PORT = libev.EVBACKEND_PORT
-BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE
-BACKEND_EPOLL = libev.EVBACKEND_EPOLL
-BACKEND_POLL = libev.EVBACKEND_POLL
-BACKEND_SELECT = libev.EVBACKEND_SELECT
-FORKCHECK = libev.EVFLAG_FORKCHECK
-NOINOTIFY = libev.EVFLAG_NOINOTIFY
-SIGNALFD = libev.EVFLAG_SIGNALFD
-NOSIGMASK = libev.EVFLAG_NOSIGMASK
-
-
-@cython.internal
-cdef class _EVENTSType:
-
- def __repr__(self):
- return 'gevent.core.EVENTS'
-
-
-cdef public object GEVENT_CORE_EVENTS = _EVENTSType()
-EVENTS = GEVENT_CORE_EVENTS
-
-
-def get_version():
- return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor())
-
-
-def get_header_version():
- return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
-
-
-# This list backends in the order they are actually tried by libev
-_flags = [(libev.EVBACKEND_PORT, 'port'),
- (libev.EVBACKEND_KQUEUE, 'kqueue'),
- (libev.EVBACKEND_EPOLL, 'epoll'),
- (libev.EVBACKEND_POLL, 'poll'),
- (libev.EVBACKEND_SELECT, 'select'),
- (libev.EVFLAG_NOENV, 'noenv'),
- (libev.EVFLAG_FORKCHECK, 'forkcheck'),
- (libev.EVFLAG_NOINOTIFY, 'noinotify'),
- (libev.EVFLAG_SIGNALFD, 'signalfd'),
- (libev.EVFLAG_NOSIGMASK, 'nosigmask')]
-
-
-_flags_str2int = dict((string, flag) for (flag, string) in _flags)
-
-
-_events = [(libev.EV_READ, 'READ'),
- (libev.EV_WRITE, 'WRITE'),
- (libev.EV__IOFDSET, '_IOFDSET'),
- (libev.EV_PERIODIC, 'PERIODIC'),
- (libev.EV_SIGNAL, 'SIGNAL'),
- (libev.EV_CHILD, 'CHILD'),
- (libev.EV_STAT, 'STAT'),
- (libev.EV_IDLE, 'IDLE'),
- (libev.EV_PREPARE, 'PREPARE'),
- (libev.EV_CHECK, 'CHECK'),
- (libev.EV_EMBED, 'EMBED'),
- (libev.EV_FORK, 'FORK'),
- (libev.EV_CLEANUP, 'CLEANUP'),
- (libev.EV_ASYNC, 'ASYNC'),
- (libev.EV_CUSTOM, 'CUSTOM'),
- (libev.EV_ERROR, 'ERROR')]
-
-
-cpdef _flags_to_list(unsigned int flags):
- cdef list result = []
- for code, value in _flags:
- if flags & code:
- result.append(value)
- flags &= ~code
- if not flags:
- break
- if flags:
- result.append(flags)
- return result
-
-
-if sys.version_info[0] >= 3:
- basestring = (bytes, str)
-else:
- basestring = __builtins__.basestring
-
-
-cpdef unsigned int _flags_to_int(object flags) except? -1:
- # Note, that order does not matter, libev has its own predefined order
- if not flags:
- return 0
- if isinstance(flags, integer_types):
- return flags
- cdef unsigned int result = 0
- try:
- if isinstance(flags, basestring):
- flags = flags.split(',')
- for value in flags:
- value = value.strip().lower()
- if value:
- result |= _flags_str2int[value]
- except KeyError as ex:
- raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys()))))
- return result
-
-
-cdef str _str_hex(object flag):
- if isinstance(flag, integer_types):
- return hex(flag)
- return str(flag)
-
-
-cpdef _check_flags(unsigned int flags):
- cdef list as_list
- flags &= libev.EVBACKEND_MASK
- if not flags:
- return
- if not (flags & libev.EVBACKEND_ALL):
- raise ValueError('Invalid value for backend: 0x%x' % flags)
- if not (flags & libev.ev_supported_backends()):
- as_list = [_str_hex(x) for x in _flags_to_list(flags)]
- raise ValueError('Unsupported backend: %s' % '|'.join(as_list))
-
-
-cpdef _events_to_str(int events):
- cdef list result = []
- cdef int c_flag
- for (flag, string) in _events:
- c_flag = flag
- if events & c_flag:
- result.append(string)
- events = events & (~c_flag)
- if not events:
- break
- if events:
- result.append(hex(events))
- return '|'.join(result)
-
-
-def supported_backends():
- return _flags_to_list(libev.ev_supported_backends())
-
-
-def recommended_backends():
- return _flags_to_list(libev.ev_recommended_backends())
-
-
-def embeddable_backends():
- return _flags_to_list(libev.ev_embeddable_backends())
-
-
-def time():
- return libev.ev_time()
-
-cdef bint _check_loop(loop loop) except -1:
- if not loop._ptr:
- raise ValueError('operation on destroyed loop')
- return 1
-
-
-
-cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]:
- cdef public object callback
- cdef public tuple args
- cdef callback next
-
- def __init__(self, callback, args):
- self.callback = callback
- self.args = args
-
- def stop(self):
- self.callback = None
- self.args = None
-
- close = stop
-
- # Note, that __nonzero__ and pending are different
- # nonzero is used in contexts where we need to know whether to schedule another callback,
- # so it's true if it's pending or currently running
- # 'pending' has the same meaning as libev watchers: it is cleared before entering callback
-
- def __nonzero__(self):
- # it's nonzero if it's pending or currently executing
- return self.args is not None
-
- @property
- def pending(self):
- return self.callback is not None
-
- def __repr__(self):
- if Py_ReprEnter(self) != 0:
- return "<...>"
- try:
- format = self._format()
- result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format)
- if self.pending:
- result += " pending"
- if self.callback is not None:
- result += " callback=%r" % (self.callback, )
- if self.args is not None:
- result += " args=%r" % (self.args, )
- if self.callback is None and self.args is None:
- result += " stopped"
- return result + ">"
- finally:
- Py_ReprLeave(self)
-
- def _format(self):
- return ''
-
-DEF CALLBACK_CHECK_COUNT = 50
-
-@cython.final
-@cython.internal
-cdef class CallbackFIFO(object):
- cdef callback head
- cdef callback tail
-
- def __init__(self):
- self.head = None
- self.tail = None
-
- cdef inline callback popleft(self):
- cdef callback head = self.head
- self.head = head.next
- if self.head is self.tail or self.head is None:
- self.tail = None
- head.next = None
- return head
-
-
- cdef inline append(self, callback new_tail):
- assert not new_tail.next
- if self.tail is None:
- if self.head is None:
- # Completely empty, so this
- # is now our head
- self.head = new_tail
- return
- self.tail = self.head
-
-
- assert self.head is not None
- old_tail = self.tail
- old_tail.next = new_tail
- self.tail = new_tail
-
- def __nonzero__(self):
- return self.head is not None
-
- def __len__(self):
- cdef Py_ssize_t count = 0
- head = self.head
- while head is not None:
- count += 1
- head = head.next
- return count
-
- def __iter__(self):
- cdef list objects = []
- head = self.head
- while head is not None:
- objects.append(head)
- head = head.next
- return iter(objects)
-
- cdef bint has_callbacks(self):
- return self.head
-
- def __repr__(self):
- return "<callbacks@%r len=%d head=%r tail=%r>" % (id(self), len(self), self.head, self.tail)
-
-
-cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
- ## embedded struct members
- cdef libev.ev_prepare _prepare
- cdef libev.ev_timer _timer0
- # We'll only actually start this timer if we're on Windows,
- # but it doesn't hurt to compile it in on all platforms.
- cdef libev.ev_timer _periodic_signal_checker
-
- ## pointer members
- cdef public object error_handler
- cdef libev.ev_loop* _ptr
- cdef public CallbackFIFO _callbacks
-
- ## data members
- cdef bint starting_timer_may_update_loop_time
- # We must capture the 'default' state at initialiaztion
- # time. Destroying the default loop in libev sets
- # the libev internal pointer to 0, and ev_is_default_loop will
- # no longer work.
- cdef bint _default
-
- def __cinit__(self, object flags=None, object default=None, libev.intptr_t ptr=0):
- self.starting_timer_may_update_loop_time = 0
- self._default = 0
- libev.ev_prepare_init(&self._prepare,
- <void*>gevent_run_callbacks)
- libev.ev_timer_init(&self._periodic_signal_checker,
- <void*>gevent_periodic_signal_check,
- 0.3, 0.3)
- libev.ev_timer_init(&self._timer0,
- <void*>gevent_noop,
- 0.0, 0.0)
-
- cdef unsigned int c_flags
- cdef object old_handler = None
- if ptr:
- self._ptr = <libev.ev_loop*>ptr
- self._default = libev.ev_is_default_loop(self._ptr)
- else:
- c_flags = _flags_to_int(flags)
- _check_flags(c_flags)
- c_flags |= libev.EVFLAG_NOENV
- c_flags |= libev.EVFLAG_FORKCHECK
- if default is None:
- default = True
- if default:
- self._default = 1
- self._ptr = libev.gevent_ev_default_loop(c_flags)
- if not self._ptr:
- raise SystemError("ev_default_loop(%s) failed" % (c_flags, ))
- if sys.platform == "win32":
- libev.ev_timer_start(self._ptr, &self._periodic_signal_checker)
- libev.ev_unref(self._ptr)
- else:
- self._ptr = libev.ev_loop_new(c_flags)
- if not self._ptr:
- raise SystemError("ev_loop_new(%s) failed" % (c_flags, ))
- if default or __SYSERR_CALLBACK is None:
- set_syserr_cb(self._handle_syserr)
-
- # Mark as not destroyed
- libev.ev_set_userdata(self._ptr, self._ptr)
-
- libev.ev_prepare_start(self._ptr, &self._prepare)
- libev.ev_unref(self._ptr)
-
- def __init__(self, object flags=None, object default=None, libev.intptr_t ptr=0):
- self._callbacks = CallbackFIFO()
-
- cdef _run_callbacks(self):
- cdef callback cb
- cdef object callbacks
- cdef int count = CALLBACK_CHECK_COUNT
- self.starting_timer_may_update_loop_time = True
- cdef libev.ev_tstamp now = libev.ev_now(self._ptr)
- cdef libev.ev_tstamp expiration = now + <libev.ev_tstamp>getswitchinterval()
-
- try:
- libev.ev_timer_stop(self._ptr, &self._timer0)
- while self._callbacks.head is not None:
- cb = self._callbacks.popleft()
-
- libev.ev_unref(self._ptr)
- gevent_call(self, cb) # XXX: Why is this a C callback, not cython?
- count -= 1
-
- if count == 0 and self._callbacks.head is not None:
- # We still have more to run but we've reached
- # the end of one check group
- count = CALLBACK_CHECK_COUNT
-
- libev.ev_now_update(self._ptr)
- if libev.ev_now(self._ptr) >= expiration:
- now = 0
- break
-
- if now != 0:
- libev.ev_now_update(self._ptr)
- if self._callbacks.head is not None:
- libev.ev_timer_start(self._ptr, &self._timer0)
- finally:
- self.starting_timer_may_update_loop_time = False
-
- cdef _stop_watchers(self, libev.ev_loop* ptr):
- if not ptr:
- return
-
- if libev.ev_is_active(&self._prepare):
- libev.ev_ref(ptr)
- libev.ev_prepare_stop(ptr, &self._prepare)
- if libev.ev_is_active(&self._periodic_signal_checker):
- libev.ev_ref(ptr)
- libev.ev_timer_stop(ptr, &self._periodic_signal_checker)
-
- def destroy(self):
- cdef libev.ev_loop* ptr = self._ptr
- self._ptr = NULL
-
- if ptr:
- if not libev.ev_userdata(ptr):
- # Whoops! Program error. They destroyed the loop,
- # using a different loop object. Our _ptr is still
- # valid, but the libev loop is gone. Doing anything
- # else with it will likely cause a crash.
- return
- # Mark as destroyed
- libev.ev_set_userdata(ptr, NULL)
- self._stop_watchers(ptr)
- if __SYSERR_CALLBACK == self._handle_syserr:
- set_syserr_cb(None)
- libev.ev_loop_destroy(ptr)
-
- def __dealloc__(self):
- cdef libev.ev_loop* ptr = self._ptr
- self._ptr = NULL
- if ptr != NULL:
- if not libev.ev_userdata(ptr):
- # See destroy(). This is a bug in the caller.
- return
- self._stop_watchers(ptr)
- if not self._default:
- libev.ev_loop_destroy(ptr)
- # Mark as destroyed
- libev.ev_set_userdata(ptr, NULL)
-
- @property
- def ptr(self):
- return <size_t>self._ptr
-
- @property
- def WatcherType(self):
- return watcher
-
- @property
- def MAXPRI(self):
- return libev.EV_MAXPRI
-
- @property
- def MINPRI(self):
- return libev.EV_MINPRI
-
- def _handle_syserr(self, message, errno):
- if sys.version_info[0] >= 3:
- message = message.decode()
- self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None)
-
- cpdef handle_error(self, context, type, value, tb):
- cdef object handle_error
- cdef object error_handler = self.error_handler
- if error_handler is not None:
- # we do want to do getattr every time so that setting Hub.handle_error property just works
- handle_error = getattr(error_handler, 'handle_error', error_handler)
- handle_error(context, type, value, tb)
- else:
- self._default_handle_error(context, type, value, tb)
-
- cpdef _default_handle_error(self, context, type, value, tb):
- # note: Hub sets its own error handler so this is not used by gevent
- # this is here to make core.loop usable without the rest of gevent
- traceback.print_exception(type, value, tb)
- if self._ptr:
- libev.ev_break(self._ptr, libev.EVBREAK_ONE)
-
- def run(self, nowait=False, once=False):
- _check_loop(self)
- cdef unsigned int flags = 0
- if nowait:
- flags |= libev.EVRUN_NOWAIT
- if once:
- flags |= libev.EVRUN_ONCE
- with nogil:
- libev.ev_run(self._ptr, flags)
-
- def reinit(self):
- if self._ptr:
- libev.ev_loop_fork(self._ptr)
-
- def ref(self):
- _check_loop(self)
- libev.ev_ref(self._ptr)
-
- def unref(self):
- _check_loop(self)
- libev.ev_unref(self._ptr)
-
- def break_(self, int how=libev.EVBREAK_ONE):
- _check_loop(self)
- libev.ev_break(self._ptr, how)
-
- def verify(self):
- _check_loop(self)
- libev.ev_verify(self._ptr)
-
- cpdef libev.ev_tstamp now(self) except *:
- _check_loop(self)
- return libev.ev_now(self._ptr)
-
- cpdef void update_now(self) except *:
- _check_loop(self)
- libev.ev_now_update(self._ptr)
-
- update = update_now # Old name, deprecated.
-
- def __repr__(self):
- return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format())
-
- @property
- def default(self):
- # If we're destroyed, we are not the default loop anymore,
- # as far as Python is concerned.
- return self._default if self._ptr else False
-
- @property
- def iteration(self):
- _check_loop(self)
- return libev.ev_iteration(self._ptr)
-
- @property
- def depth(self):
- _check_loop(self)
- return libev.ev_depth(self._ptr)
-
- @property
- def backend_int(self):
- _check_loop(self)
- return libev.ev_backend(self._ptr)
-
- @property
- def backend(self):
- _check_loop(self)
- cdef unsigned int backend = libev.ev_backend(self._ptr)
- for key, value in _flags:
- if key == backend:
- return value
- return backend
-
- @property
- def pendingcnt(self):
- _check_loop(self)
- return libev.ev_pending_count(self._ptr)
-
- def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None):
- return io(self, fd, events, ref, priority)
-
- def timer(self, double after, double repeat=0.0, ref=True, priority=None):
- return timer(self, after, repeat, ref, priority)
-
- def signal(self, int signum, ref=True, priority=None):
- return signal(self, signum, ref, priority)
-
- def idle(self, ref=True, priority=None):
- return idle(self, ref, priority)
-
- def prepare(self, ref=True, priority=None):
- return prepare(self, ref, priority)
-
- def check(self, ref=True, priority=None):
- return check(self, ref, priority)
-
- def fork(self, ref=True, priority=None):
- return fork(self, ref, priority)
-
- def async_(self, ref=True, priority=None):
- return async_(self, ref, priority)
-
- # cython doesn't enforce async as a keyword
- async = async_
-
- def child(self, int pid, bint trace=0, ref=True):
- if sys.platform == 'win32':
- raise AttributeError("Child watchers are not supported on Windows")
- return child(self, pid, trace, ref)
-
- def install_sigchld(self):
- libev.gevent_install_sigchld_handler()
-
- def reset_sigchld(self):
- libev.gevent_reset_sigchld_handler()
-
- def stat(self, str path, float interval=0.0, ref=True, priority=None):
- return stat(self, path, interval, ref, priority)
-
- def run_callback(self, func, *args):
- _check_loop(self)
- cdef callback cb = callback(func, args)
- self._callbacks.append(cb)
- libev.ev_ref(self._ptr)
- return cb
-
- def _format(self):
- if not self._ptr:
- return 'destroyed'
- cdef object msg = self.backend
- if self._default:
- msg += ' default'
- msg += ' pending=%s' % self.pendingcnt
- msg += self._format_details()
- return msg
-
- def _format_details(self):
- cdef str msg = ''
- cdef object fileno = self.fileno()
- cdef object activecnt = None
- try:
- sigfd = self.sigfd
- except AttributeError:
- sigfd = None
- try:
- activecnt = self.activecnt
- except AttributeError:
- pass
- if activecnt is not None:
- msg += ' ref=' + repr(activecnt)
- if fileno is not None:
- msg += ' fileno=' + repr(fileno)
- return msg
-
- def fileno(self):
- cdef int fd
- if self._ptr:
- fd = libev.gevent_ev_loop_backend_fd(self._ptr)
- if fd >= 0:
- return fd
-
- @property
- def activecnt(self):
- _check_loop(self)
- return libev.gevent_ev_loop_activecnt(self._ptr)
-
- @property
- def sig_pending(self):
- _check_loop(self)
- return libev.gevent_ev_loop_sig_pending(self._ptr)
-
- @property
- def origflags(self):
- return _flags_to_list(self.origflags_int)
-
- @property
- def origflags_int(self):
- _check_loop(self)
- return libev.gevent_ev_loop_origflags(self._ptr)
-
- @property
- def sigfd(self):
- _check_loop(self)
- fd = libev.gevent_ev_loop_sigfd(self._ptr)
- if fd >= 0:
- return fd
-
- # Explicitly not EV_USE_SIGNALFD
- raise AttributeError("sigfd")
-
-
-# about readonly _flags attribute:
-# bit #1 set if object owns Python reference to itself (Py_INCREF was
-# called and we must call Py_DECREF later)
-DEF FLAG_WATCHER_OWNS_PYREF = 1 << 0 # 0x1
-# bit #2 set if ev_unref() was called and we must call ev_ref() later
-DEF FLAG_WATCHER_NEEDS_EVREF = 1 << 1 # 0x2
-# bit #3 set if user wants to call ev_unref() before start()
-DEF FLAG_WATCHER_UNREF_BEFORE_START = 1 << 2 # 0x4
-# bits 2 and 3 are *both* set when we are active, but the user
-# request us not to be ref'd anymore. We unref us (because going active will
-# ref us) and then make a note of this in the future
-DEF FLAG_WATCHER_MASK_UNREF_NEEDS_REF = 0x6
-
-
-cdef void _python_incref(watcher self):
- if not self._flags & FLAG_WATCHER_OWNS_PYREF:
- Py_INCREF(self)
- self._flags |= FLAG_WATCHER_OWNS_PYREF
-
-cdef void _python_decref(watcher self):
- if self._flags & FLAG_WATCHER_OWNS_PYREF:
- Py_DECREF(self)
- self._flags &= ~FLAG_WATCHER_OWNS_PYREF
-
-cdef void _libev_ref(watcher self):
- if self._flags & FLAG_WATCHER_NEEDS_EVREF:
- libev.ev_ref(self.loop._ptr)
- self._flags &= ~FLAG_WATCHER_NEEDS_EVREF
-
-cdef void _libev_unref(watcher self):
- if self._flags & FLAG_WATCHER_MASK_UNREF_NEEDS_REF == FLAG_WATCHER_UNREF_BEFORE_START:
- libev.ev_unref(self.loop._ptr)
- self._flags |= FLAG_WATCHER_NEEDS_EVREF
-
-
-ctypedef void (*start_stop_func)(libev.ev_loop*, void*) nogil
-
-cdef struct start_and_stop:
- start_stop_func start
- start_stop_func stop
-
-cdef start_and_stop make_ss(void* start, void* stop):
- cdef start_and_stop result = start_and_stop(<start_stop_func>start, <start_stop_func>stop)
- return result
-
-cdef bint _watcher_start(watcher self, object callback, tuple args) except -1:
- # This method should be called by subclasses of watcher, if they
- # override the python-level `start` function: they've already paid
- # for argument unpacking, and `start` cannot be cpdef since it
- # uses varargs.
-
- # We keep this as a function, not a cdef method of watcher.
- # If it's a cdef method, it could potentially be overridden
- # by a subclass, which means that the watcher gains a pointer to a
- # function table (vtable), making each object 8 bytes larger.
-
- _check_loop(self.loop)
- if callback is None or not callable(callback):
- raise TypeError("Expected callable, not %r" % (callback, ))
- self._callback = callback
- self.args = args
- _libev_unref(self)
- _python_incref(self)
- self.__ss.start(self.loop._ptr, self.__watcher)
- return 1
-
-cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]:
- """Abstract base class for all the watchers"""
- ## pointer members
- cdef public loop loop
- cdef object _callback
- cdef public tuple args
-
- # By keeping a __watcher cached, the size of the io and timer
- # structs becomes 152 bytes and child is 160 and stat is 512 (when
- # the start_and_stop is inlined). On 64-bit macOS CPython 2.7. I
- # hoped that using libev's data pointer and allocating the
- # watchers directly and not as inline members would result in
- # overall savings thanks to better padding, but it didn't. And it
- # added lots of casts, making the code ugly.
-
- # Table:
- # gevent ver | 1.2 | This | +data
- # Watcher Kind | | |
- # Timer | 120 | 152 | 160
- # IO | 120 | 152 | 160
- # Child | 128 | 160 | 168
- # Stat | 480 | 512 | 512
- cdef libev.ev_watcher* __watcher
-
- # By inlining the start_and_stop struct, instead of taking the address
- # of a static struct or using the watcher's data pointer, we
- # use an additional pointer of memory and incur an additional pointer copy
- # on creation.
- # But we use fewer pointer accesses for start/stop, and they have
- # better cache locality. (Then again, we're bigger).
- # Right now we're going for size, so we use the pointer. IO/Timer objects
- # are then 144 bytes.
- cdef start_and_stop* __ss
-
- ## Int members
-
- # Our subclasses will declare the ev_X struct
- # as an inline member. This is good for locality, but
- # probably bad for alignment, as it will get tacked on
- # immediately after our data.
-
- # But all ev_watchers start with some ints, so maybe we can help that
- # out by putting our ints here.
- cdef readonly unsigned int _flags
-
- def __init__(self, loop loop, ref=True, priority=None):
- if not self.__watcher or not self.__ss.start or not self.__ss.stop:
- raise ValueError("Cannot construct a bare watcher")
- self.loop = loop
- self._flags = 0 if ref else FLAG_WATCHER_UNREF_BEFORE_START
- if priority is not None:
- libev.ev_set_priority(self.__watcher, priority)
-
- @property
- def ref(self):
- return False if self._flags & 4 else True
-
- @ref.setter
- def ref(self, object value):
- _check_loop(self.loop)
- if value:
- # self.ref should be true after this.
- if self.ref:
- return # ref is already True
-
- if self._flags & FLAG_WATCHER_NEEDS_EVREF: # ev_unref was called, undo
- libev.ev_ref(self.loop._ptr)
- # do not want unref, no outstanding unref
- self._flags &= ~FLAG_WATCHER_MASK_UNREF_NEEDS_REF
- else:
- # self.ref must be false after this
- if not self.ref:
- return # ref is already False
- self._flags |= FLAG_WATCHER_UNREF_BEFORE_START
- if not self._flags & FLAG_WATCHER_NEEDS_EVREF and libev.ev_is_active(self.__watcher):
- libev.ev_unref(self.loop._ptr)
- self._flags |= FLAG_WATCHER_NEEDS_EVREF
-
- @property
- def callback(self):
- return self._callback
-
- @callback.setter
- def callback(self, object callback):
- if callback is not None and not callable(callback):
- raise TypeError("Expected callable, not %r" % (callback, ))
- self._callback = callback
-
- @property
- def priority(self):
- return libev.ev_priority(self.__watcher)
-
- @priority.setter
- def priority(self, int priority):
- cdef libev.ev_watcher* w = self.__watcher
- if libev.ev_is_active(w):
- raise AttributeError("Cannot set priority of an active watcher")
- libev.ev_set_priority(w, priority)
-
- @property
- def active(self):
- return True if libev.ev_is_active(self.__watcher) else False
-
- @property
- def pending(self):
- return True if libev.ev_is_pending(self.__watcher) else False
-
- def start(self, object callback, *args):
- _watcher_start(self, callback, args)
-
- def stop(self):
- _check_loop(self.loop)
- _libev_ref(self)
- # The callback cannot possibly fire while we are executing,
- # so this is safe.
- self._callback = None
- self.args = None
- self.__ss.stop(self.loop._ptr, self.__watcher)
- _python_decref(self)
-
- def feed(self, int revents, object callback, *args):
- _check_loop(self.loop)
- self.callback = callback
- self.args = args
- _libev_unref(self)
- libev.ev_feed_event(self.loop._ptr, self.__watcher, revents)
- _python_incref(self)
-
- def __repr__(self):
- if Py_ReprEnter(self) != 0:
- return "<...>"
- try:
- format = self._format()
- result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format)
- if self.active:
- result += " active"
- if self.pending:
- result += " pending"
- if self.callback is not None:
- result += " callback=%r" % (self.callback, )
- if self.args is not None:
- result += " args=%r" % (self.args, )
- return result + ">"
- finally:
- Py_ReprLeave(self)
-
- def _format(self):
- return ''
-
- def close(self):
- self.stop()
-
- def __enter__(self):
- return self
-
- def __exit__(self, t, v, tb):
- self.close()
- return
-
-cdef start_and_stop io_ss = make_ss(<void*>libev.ev_io_start, <void*>libev.ev_io_stop)
-
-cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
-
- cdef libev.ev_io _watcher
-
- def start(self, object callback, *args, pass_events=False):
- if pass_events:
- args = (GEVENT_CORE_EVENTS, ) + args
- _watcher_start(self, callback, args)
-
- def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None):
- watcher.__init__(self, loop, ref, priority)
-
- def __cinit__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None):
- if fd < 0:
- raise ValueError('fd must be non-negative: %r' % fd)
- if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE):
- raise ValueError('illegal event mask: %r' % events)
- # All the vfd_functions are no-ops on POSIX
- cdef int vfd = libev.vfd_open(fd)
- libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, events)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &io_ss
-
- def __dealloc__(self):
- libev.vfd_free(self._watcher.fd)
-
- @property
- def fd(self):
- return libev.vfd_get(self._watcher.fd)
-
- @fd.setter
- def fd(self, long fd):
- if libev.ev_is_active(&self._watcher):
- raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active")
- cdef int vfd = libev.vfd_open(fd)
- libev.vfd_free(self._watcher.fd)
- libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events)
-
- @property
- def events(self):
- return self._watcher.events
-
- @events.setter
- def events(self, int events):
- if libev.ev_is_active(&self._watcher):
- raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active")
- libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events)
-
- @property
- def events_str(self):
- return _events_to_str(self._watcher.events)
-
- def _format(self):
- return ' fd=%s events=%s' % (self.fd, self.events_str)
-
-cdef start_and_stop timer_ss = make_ss(<void*>libev.ev_timer_start, <void*>libev.ev_timer_stop)
-
-cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]:
-
- cdef libev.ev_timer _watcher
-
- def __cinit__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None):
- if repeat < 0.0:
- raise ValueError("repeat must be positive or zero: %r" % repeat)
- libev.ev_timer_init(&self._watcher, <void *>gevent_callback_timer, after, repeat)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &timer_ss
-
- def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None):
- watcher.__init__(self, loop, ref, priority)
-
- def start(self, object callback, *args, update=None):
- update = update if update is not None else self.loop.starting_timer_may_update_loop_time
- if update:
- self.loop.update_now()
- _watcher_start(self, callback, args)
-
- @property
- def at(self):
- return self._watcher.at
-
- # QQQ: add 'after' and 'repeat' properties?
-
- def again(self, object callback, *args, update=True):
- _check_loop(self.loop)
- self.callback = callback
- self.args = args
- _libev_unref(self)
- if update:
- libev.ev_now_update(self.loop._ptr)
- libev.ev_timer_again(self.loop._ptr, &self._watcher)
- _python_incref(self)
-
-
-
-cdef start_and_stop signal_ss = make_ss(<void*>libev.ev_signal_start, <void*>libev.ev_signal_stop)
-
-cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]:
-
- cdef libev.ev_signal _watcher
-
- def __cinit__(self, loop loop, int signalnum, ref=True, priority=None):
- if signalnum < 1 or signalnum >= signalmodule.NSIG:
- raise ValueError('illegal signal number: %r' % signalnum)
- # still possible to crash on one of libev's asserts:
- # 1) "libev: ev_signal_start called with illegal signal number"
- # EV_NSIG might be different from signal.NSIG on some platforms
- # 2) "libev: a signal must not be attached to two different loops"
- # we probably could check that in LIBEV_EMBED mode, but not in general
- libev.ev_signal_init(&self._watcher, <void *>gevent_callback_signal, signalnum)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &signal_ss
-
- def __init__(self, loop loop, int signalnum, ref=True, priority=None):
- watcher.__init__(self, loop, ref, priority)
-
-
-
-cdef start_and_stop idle_ss = make_ss(<void*>libev.ev_idle_start, <void*>libev.ev_idle_stop)
-
-cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]:
-
- cdef libev.ev_idle _watcher
-
- def __cinit__(self, loop loop, ref=True, priority=None):
- libev.ev_idle_init(&self._watcher, <void*>gevent_callback_idle)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &idle_ss
-
-
-
-cdef start_and_stop prepare_ss = make_ss(<void*>libev.ev_prepare_start, <void*>libev.ev_prepare_stop)
-
-cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]:
-
- cdef libev.ev_prepare _watcher
-
- def __cinit__(self, loop loop, ref=True, priority=None):
- libev.ev_prepare_init(&self._watcher, <void*>gevent_callback_prepare)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &prepare_ss
-
-
-
-cdef start_and_stop check_ss = make_ss(<void*>libev.ev_check_start, <void*>libev.ev_check_stop)
-
-cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]:
-
- cdef libev.ev_check _watcher
-
- def __cinit__(self, loop loop, ref=True, priority=None):
- libev.ev_check_init(&self._watcher, <void*>gevent_callback_check)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &check_ss
-
-
-
-cdef start_and_stop fork_ss = make_ss(<void*>libev.ev_fork_start, <void*>libev.ev_fork_stop)
-
-cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]:
-
- cdef libev.ev_fork _watcher
-
- def __cinit__(self, loop loop, ref=True, priority=None):
- libev.ev_fork_init(&self._watcher, <void*>gevent_callback_fork)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &fork_ss
-
-
-cdef start_and_stop async_ss = make_ss(<void*>libev.ev_async_start, <void*>libev.ev_async_stop)
-
-cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]:
-
- cdef libev.ev_async _watcher
-
- @property
- def pending(self):
- # Note the use of ev_async_pending instead of ev_is_pending
- return True if libev.ev_async_pending(&self._watcher) else False
-
- def __cinit__(self, loop loop, ref=True, priority=None):
- libev.ev_async_init(&self._watcher, <void*>gevent_callback_async)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &async_ss
-
-
- def send(self):
- _check_loop(self.loop)
- libev.ev_async_send(self.loop._ptr, &self._watcher)
-
-async = async_
-
-cdef start_and_stop child_ss = make_ss(<void*>libev.ev_child_start, <void*>libev.ev_child_stop)
-
-cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]:
-
- cdef libev.ev_child _watcher
-
- def __cinit__(self, loop loop, int pid, bint trace=0, ref=True):
- if sys.platform == 'win32':
- raise AttributeError("Child watchers are not supported on Windows")
- if not loop.default:
- raise TypeError('child watchers are only available on the default loop')
- libev.gevent_install_sigchld_handler()
- libev.ev_child_init(&self._watcher, <void *>gevent_callback_child, pid, trace)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &child_ss
-
- def __init__(self, loop loop, int pid, bint trace=0, ref=True):
- watcher.__init__(self, loop, ref, None)
-
-
- def _format(self):
- return ' pid=%r rstatus=%r' % (self.pid, self.rstatus)
-
- @property
- def pid(self):
- return self._watcher.pid
-
- @property
- def rpid(self):
- return self._watcher.rpid
-
- @rpid.setter
- def rpid(self, int value):
- self._watcher.rpid = value
-
- @property
- def rstatus(self):
- return self._watcher.rstatus
-
- @rstatus.setter
- def rstatus(self, int value):
- self._watcher.rstatus = value
-
-cdef start_and_stop stat_ss = make_ss(<void*>libev.ev_stat_start, <void*>libev.ev_stat_stop)
-
-cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]:
-
- cdef libev.ev_stat _watcher
- cdef readonly str path
- cdef readonly bytes _paths
-
- def __cinit__(self, loop loop, str path, float interval=0.0, ref=True, priority=None):
- self.path = path
- cdef bytes paths
- if isinstance(path, unicode):
- # the famous Python3 filesystem encoding debacle hits us here. Can we do better?
- # We must keep a reference to the encoded string so that its bytes don't get freed
- # and overwritten, leading to strange errors from libev ("no such file or directory")
- paths = (<unicode>path).encode(sys.getfilesystemencoding())
- self._paths = paths
- else:
- paths = <bytes>path
- self._paths = paths
- libev.ev_stat_init(&self._watcher, <void *>gevent_callback_stat, <char*>paths, interval)
- self.__watcher = <libev.ev_watcher*>&self._watcher
- self.__ss = &stat_ss
-
- def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None):
- watcher.__init__(self, loop, ref, priority)
-
-
- @property
- def attr(self):
- if not self._watcher.attr.st_nlink:
- return
- return _pystat_fromstructstat(&self._watcher.attr)
-
- @property
- def prev(self):
- if not self._watcher.prev.st_nlink:
- return
- return _pystat_fromstructstat(&self._watcher.prev)
-
- @property
- def interval(self):
- return self._watcher.interval
-
-
-
-__SYSERR_CALLBACK = None
-
-
-cdef void _syserr_cb(char* msg) with gil:
- try:
- __SYSERR_CALLBACK(msg, errno)
- except:
- set_syserr_cb(None)
- print_exc = getattr(traceback, 'print_exc', None)
- if print_exc is not None:
- print_exc()
-
-
-cpdef set_syserr_cb(callback):
- global __SYSERR_CALLBACK
- if callback is None:
- libev.ev_set_syserr_cb(NULL)
- __SYSERR_CALLBACK = None
- elif callable(callback):
- libev.ev_set_syserr_cb(<void *>_syserr_cb)
- __SYSERR_CALLBACK = callback
- else:
- raise TypeError('Expected callable or None, got %r' % (callback, ))
-
-
-
-LIBEV_EMBED = bool(libev.LIBEV_EMBED)
-EV_USE_FLOOR = libev.EV_USE_FLOOR
-EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL
-EV_USE_REALTIME = libev.EV_USE_REALTIME
-EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC
-EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP
-EV_USE_INOTIFY = libev.EV_USE_INOTIFY
-EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD
-EV_USE_EVENTFD = libev.EV_USE_EVENTFD
-EV_USE_4HEAP = libev.EV_USE_4HEAP
-
-# Things used in callbacks.c
-
-from cpython cimport PyErr_Fetch
-from cpython cimport PyObject
-
-cdef public void gevent_handle_error(loop loop, object context):
- cdef PyObject* typep
- cdef PyObject* valuep
- cdef PyObject* tracebackp
-
- cdef object type
- cdef object value = None
- cdef object traceback = None
- cdef object result
-
- # If it was set, this will clear it, and we will own
- # the references.
- PyErr_Fetch(&typep, &valuep, &tracebackp)
- # TODO: Should we call PyErr_Normalize? There's code in
- # Hub.handle_error that works around what looks like an
- # unnormalized exception.
-
- if not typep:
- return
- # This assignment will do a Py_INCREF
- # on the value. We already own the reference
- # returned from PyErr_Fetch,
- # so we must decref immediately
- type = <object>typep
- Py_DECREF(type)
-
- if valuep:
- value = <object>valuep
- Py_DECREF(value)
- if tracebackp:
- traceback = <object>tracebackp
- Py_DECREF(traceback)
-
- # If this method fails by raising an exception,
- # cython will print it for us because we don't return a
- # Python object and we don't declare an `except` clause.
- loop.handle_error(context, type, value, traceback)
-
-cdef public tuple _empty_tuple = ()
-
-cdef public object gevent_loop_run_callbacks(loop loop):
- return loop._run_callbacks()
diff --git a/python/gevent/libev/corecffi.py b/python/gevent/libev/corecffi.py
deleted file mode 100644
index d57993c..0000000
--- a/python/gevent/libev/corecffi.py
+++ /dev/null
@@ -1,418 +0,0 @@
-# pylint: disable=too-many-lines, protected-access, redefined-outer-name, not-callable
-# pylint: disable=no-member
-from __future__ import absolute_import, print_function
-import sys
-
-# pylint: disable=undefined-all-variable
-__all__ = [
- 'get_version',
- 'get_header_version',
- 'supported_backends',
- 'recommended_backends',
- 'embeddable_backends',
- 'time',
- 'loop',
-]
-
-from gevent._util import implementer
-from gevent._interfaces import ILoop
-
-from gevent.libev import _corecffi # pylint:disable=no-name-in-module,import-error
-
-ffi = _corecffi.ffi # pylint:disable=no-member
-libev = _corecffi.lib # pylint:disable=no-member
-
-if hasattr(libev, 'vfd_open'):
- # Must be on windows
- assert sys.platform.startswith("win"), "vfd functions only needed on windows"
- vfd_open = libev.vfd_open
- vfd_free = libev.vfd_free
- vfd_get = libev.vfd_get
-else:
- vfd_open = vfd_free = vfd_get = lambda fd: fd
-
-#####
-## NOTE on Windows:
-# The C implementation does several things specially for Windows;
-# a possibly incomplete list is:
-#
-# - the loop runs a periodic signal checker;
-# - the io watcher constructor is different and it has a destructor;
-# - the child watcher is not defined
-#
-# The CFFI implementation does none of these things, and so
-# is possibly NOT FUNCTIONALLY CORRECT on Win32
-#####
-
-
-from gevent._ffi.loop import AbstractCallbacks
-from gevent._ffi.loop import assign_standard_callbacks
-
-class _Callbacks(AbstractCallbacks):
- # pylint:disable=arguments-differ
-
- def python_check_callback(self, _loop, watcher_ptr, _events):
- pass
-
- def python_prepare_callback(self, _loop_ptr, watcher_ptr, _events):
- AbstractCallbacks.python_prepare_callback(self, watcher_ptr)
-
- def _find_loop_from_c_watcher(self, watcher_ptr):
- loop_handle = ffi.cast('struct ev_watcher*', watcher_ptr).data
- return self.from_handle(loop_handle)
-
-_callbacks = assign_standard_callbacks(ffi, libev, _Callbacks)
-
-
-UNDEF = libev.EV_UNDEF
-NONE = libev.EV_NONE
-READ = libev.EV_READ
-WRITE = libev.EV_WRITE
-TIMER = libev.EV_TIMER
-PERIODIC = libev.EV_PERIODIC
-SIGNAL = libev.EV_SIGNAL
-CHILD = libev.EV_CHILD
-STAT = libev.EV_STAT
-IDLE = libev.EV_IDLE
-PREPARE = libev.EV_PREPARE
-CHECK = libev.EV_CHECK
-EMBED = libev.EV_EMBED
-FORK = libev.EV_FORK
-CLEANUP = libev.EV_CLEANUP
-ASYNC = libev.EV_ASYNC
-CUSTOM = libev.EV_CUSTOM
-ERROR = libev.EV_ERROR
-
-READWRITE = libev.EV_READ | libev.EV_WRITE
-
-MINPRI = libev.EV_MINPRI
-MAXPRI = libev.EV_MAXPRI
-
-BACKEND_PORT = libev.EVBACKEND_PORT
-BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE
-BACKEND_EPOLL = libev.EVBACKEND_EPOLL
-BACKEND_POLL = libev.EVBACKEND_POLL
-BACKEND_SELECT = libev.EVBACKEND_SELECT
-FORKCHECK = libev.EVFLAG_FORKCHECK
-NOINOTIFY = libev.EVFLAG_NOINOTIFY
-SIGNALFD = libev.EVFLAG_SIGNALFD
-NOSIGMASK = libev.EVFLAG_NOSIGMASK
-
-
-from gevent._ffi.loop import EVENTS
-GEVENT_CORE_EVENTS = EVENTS
-
-
-def get_version():
- return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor())
-
-
-def get_header_version():
- return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
-
-_flags = [(libev.EVBACKEND_PORT, 'port'),
- (libev.EVBACKEND_KQUEUE, 'kqueue'),
- (libev.EVBACKEND_EPOLL, 'epoll'),
- (libev.EVBACKEND_POLL, 'poll'),
- (libev.EVBACKEND_SELECT, 'select'),
- (libev.EVFLAG_NOENV, 'noenv'),
- (libev.EVFLAG_FORKCHECK, 'forkcheck'),
- (libev.EVFLAG_SIGNALFD, 'signalfd'),
- (libev.EVFLAG_NOSIGMASK, 'nosigmask')]
-
-_flags_str2int = dict((string, flag) for (flag, string) in _flags)
-
-
-
-def _flags_to_list(flags):
- result = []
- for code, value in _flags:
- if flags & code:
- result.append(value)
- flags &= ~code
- if not flags:
- break
- if flags:
- result.append(flags)
- return result
-
-if sys.version_info[0] >= 3:
- basestring = (bytes, str)
- integer_types = (int,)
-else:
- import __builtin__ # pylint:disable=import-error
- basestring = (__builtin__.basestring,)
- integer_types = (int, __builtin__.long)
-
-
-def _flags_to_int(flags):
- # Note, that order does not matter, libev has its own predefined order
- if not flags:
- return 0
- if isinstance(flags, integer_types):
- return flags
- result = 0
- try:
- if isinstance(flags, basestring):
- flags = flags.split(',')
- for value in flags:
- value = value.strip().lower()
- if value:
- result |= _flags_str2int[value]
- except KeyError as ex:
- raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys()))))
- return result
-
-
-def _str_hex(flag):
- if isinstance(flag, integer_types):
- return hex(flag)
- return str(flag)
-
-
-def _check_flags(flags):
- as_list = []
- flags &= libev.EVBACKEND_MASK
- if not flags:
- return
- if not flags & libev.EVBACKEND_ALL:
- raise ValueError('Invalid value for backend: 0x%x' % flags)
- if not flags & libev.ev_supported_backends():
- as_list = [_str_hex(x) for x in _flags_to_list(flags)]
- raise ValueError('Unsupported backend: %s' % '|'.join(as_list))
-
-
-def supported_backends():
- return _flags_to_list(libev.ev_supported_backends())
-
-
-def recommended_backends():
- return _flags_to_list(libev.ev_recommended_backends())
-
-
-def embeddable_backends():
- return _flags_to_list(libev.ev_embeddable_backends())
-
-
-def time():
- return libev.ev_time()
-
-from gevent._ffi.loop import AbstractLoop
-
-
-from gevent.libev import watcher as _watchers
-_events_to_str = _watchers._events_to_str # exported
-
-
-@implementer(ILoop)
-class loop(AbstractLoop):
- # pylint:disable=too-many-public-methods
-
- error_handler = None
-
- _CHECK_POINTER = 'struct ev_check *'
-
- _PREPARE_POINTER = 'struct ev_prepare *'
-
- _TIMER_POINTER = 'struct ev_timer *'
-
- def __init__(self, flags=None, default=None):
- AbstractLoop.__init__(self, ffi, libev, _watchers, flags, default)
- self._default = True if libev.ev_is_default_loop(self._ptr) else False
-
-
- def _init_loop(self, flags, default):
- c_flags = _flags_to_int(flags)
- _check_flags(c_flags)
- c_flags |= libev.EVFLAG_NOENV
- c_flags |= libev.EVFLAG_FORKCHECK
- if default is None:
- default = True
- if default:
- ptr = libev.gevent_ev_default_loop(c_flags)
- if not ptr:
- raise SystemError("ev_default_loop(%s) failed" % (c_flags, ))
- else:
- ptr = libev.ev_loop_new(c_flags)
- if not ptr:
- raise SystemError("ev_loop_new(%s) failed" % (c_flags, ))
- if default or globals()["__SYSERR_CALLBACK"] is None:
- set_syserr_cb(self._handle_syserr)
-
- # Mark this loop as being used.
- libev.ev_set_userdata(ptr, ptr)
- return ptr
-
- def _init_and_start_check(self):
- libev.ev_check_init(self._check, libev.python_check_callback)
- self._check.data = self._handle_to_self
- libev.ev_check_start(self._ptr, self._check)
- self.unref()
-
- def _init_and_start_prepare(self):
- libev.ev_prepare_init(self._prepare, libev.python_prepare_callback)
- libev.ev_prepare_start(self._ptr, self._prepare)
- self.unref()
-
- def _init_callback_timer(self):
- libev.ev_timer_init(self._timer0, libev.gevent_noop, 0.0, 0.0)
-
- def _stop_callback_timer(self):
- libev.ev_timer_stop(self._ptr, self._timer0)
-
- def _start_callback_timer(self):
- libev.ev_timer_start(self._ptr, self._timer0)
-
- def _stop_aux_watchers(self):
- if libev.ev_is_active(self._prepare):
- self.ref()
- libev.ev_prepare_stop(self._ptr, self._prepare)
- if libev.ev_is_active(self._check):
- self.ref()
- libev.ev_check_stop(self._ptr, self._check)
- if libev.ev_is_active(self._timer0):
- libev.ev_timer_stop(self._timer0)
-
- def _setup_for_run_callback(self):
- self.ref() # we should go through the loop now
-
- def destroy(self):
- if self._ptr:
- super(loop, self).destroy()
- # pylint:disable=comparison-with-callable
- if globals()["__SYSERR_CALLBACK"] == self._handle_syserr:
- set_syserr_cb(None)
-
-
- def _can_destroy_loop(self, ptr):
- # Is it marked as destroyed?
- return libev.ev_userdata(ptr)
-
- def _destroy_loop(self, ptr):
- # Mark as destroyed.
- libev.ev_set_userdata(ptr, ffi.NULL)
- libev.ev_loop_destroy(ptr)
-
- libev.gevent_zero_prepare(self._prepare)
- libev.gevent_zero_check(self._check)
- libev.gevent_zero_timer(self._timer0)
-
- del self._prepare
- del self._check
- del self._timer0
-
-
- @property
- def MAXPRI(self):
- return libev.EV_MAXPRI
-
- @property
- def MINPRI(self):
- return libev.EV_MINPRI
-
- def _default_handle_error(self, context, type, value, tb): # pylint:disable=unused-argument
- super(loop, self)._default_handle_error(context, type, value, tb)
- libev.ev_break(self._ptr, libev.EVBREAK_ONE)
-
- def run(self, nowait=False, once=False):
- flags = 0
- if nowait:
- flags |= libev.EVRUN_NOWAIT
- if once:
- flags |= libev.EVRUN_ONCE
-
- libev.ev_run(self._ptr, flags)
-
- def reinit(self):
- libev.ev_loop_fork(self._ptr)
-
- def ref(self):
- libev.ev_ref(self._ptr)
-
- def unref(self):
- libev.ev_unref(self._ptr)
-
- def break_(self, how=libev.EVBREAK_ONE):
- libev.ev_break(self._ptr, how)
-
- def verify(self):
- libev.ev_verify(self._ptr)
-
- def now(self):
- return libev.ev_now(self._ptr)
-
- def update_now(self):
- libev.ev_now_update(self._ptr)
-
- def __repr__(self):
- return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format())
-
- @property
- def iteration(self):
- return libev.ev_iteration(self._ptr)
-
- @property
- def depth(self):
- return libev.ev_depth(self._ptr)
-
- @property
- def backend_int(self):
- return libev.ev_backend(self._ptr)
-
- @property
- def backend(self):
- backend = libev.ev_backend(self._ptr)
- for key, value in _flags:
- if key == backend:
- return value
- return backend
-
- @property
- def pendingcnt(self):
- return libev.ev_pending_count(self._ptr)
-
- if sys.platform != "win32":
-
- def install_sigchld(self):
- libev.gevent_install_sigchld_handler()
-
- def reset_sigchld(self):
- libev.gevent_reset_sigchld_handler()
-
- def fileno(self):
- if self._ptr:
- fd = self._ptr.backend_fd
- if fd >= 0:
- return fd
-
- @property
- def activecnt(self):
- if not self._ptr:
- raise ValueError('operation on destroyed loop')
- return self._ptr.activecnt
-
-
-@ffi.def_extern()
-def _syserr_cb(msg):
- try:
- msg = ffi.string(msg)
- __SYSERR_CALLBACK(msg, ffi.errno)
- except:
- set_syserr_cb(None)
- raise # let cffi print the traceback
-
-
-def set_syserr_cb(callback):
- global __SYSERR_CALLBACK
- if callback is None:
- libev.ev_set_syserr_cb(ffi.NULL)
- __SYSERR_CALLBACK = None
- elif callable(callback):
- libev.ev_set_syserr_cb(libev._syserr_cb)
- __SYSERR_CALLBACK = callback
- else:
- raise TypeError('Expected callable or None, got %r' % (callback, ))
-
-__SYSERR_CALLBACK = None
-
-LIBEV_EMBED = True
diff --git a/python/gevent/libev/libev.h b/python/gevent/libev/libev.h
deleted file mode 100644
index 66959d9..0000000
--- a/python/gevent/libev/libev.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#if defined(LIBEV_EMBED)
-#include "ev.c"
-#undef LIBEV_EMBED
-#define LIBEV_EMBED 1
-#define gevent_ev_loop_origflags(loop) ((loop)->origflags)
-#define gevent_ev_loop_sig_pending(loop) ((loop))->sig_pending
-#define gevent_ev_loop_backend_fd(loop) ((loop))->backend_fd
-#define gevent_ev_loop_activecnt(loop) ((loop))->activecnt
-#if EV_USE_SIGNALFD
-#define gevent_ev_loop_sigfd(loop) ((loop))->sigfd
-#else
-#define gevent_ev_loop_sigfd(loop) -1
-#endif /* !EV_USE_SIGNALFD */
-#else /* !LIBEV_EMBED */
-#include "ev.h"
-
-#define gevent_ev_loop_origflags(loop) -1
-#define gevent_ev_loop_sig_pending(loop) -1
-#define gevent_ev_loop_backend_fd(loop) -1
-#define gevent_ev_loop_activecnt(loop) -1
-#define gevent_ev_loop_sigfd(loop) -1
-
-#define LIBEV_EMBED 0
-#define EV_USE_FLOOR -1
-#define EV_USE_CLOCK_SYSCALL -1
-#define EV_USE_REALTIME -1
-#define EV_USE_MONOTONIC -1
-#define EV_USE_NANOSLEEP -1
-#define EV_USE_INOTIFY -1
-#define EV_USE_SIGNALFD -1
-#define EV_USE_EVENTFD -1
-#define EV_USE_4HEAP -1
-
-
-#ifndef _WIN32
-#include <signal.h>
-#endif /* !_WIN32 */
-
-#endif /* LIBEV_EMBED */
-
-#ifndef _WIN32
-
-static struct sigaction libev_sigchld;
-/*
- * Track the state of whether we have installed
- * the libev sigchld handler specifically.
- * If it's non-zero, libev_sigchld will be valid and set to the action
- * that libev needs to do.
- * If it's 1, we need to install libev_sigchld to make libev
- * child handlers work (on request).
- */
-static int sigchld_state = 0;
-
-static struct ev_loop* gevent_ev_default_loop(unsigned int flags)
-{
- struct ev_loop* result;
- struct sigaction tmp;
-
- if (sigchld_state)
- return ev_default_loop(flags);
-
- // Request the old SIGCHLD handler
- sigaction(SIGCHLD, NULL, &tmp);
- // Get the loop, which will install a SIGCHLD handler
- result = ev_default_loop(flags);
- // XXX what if SIGCHLD received there?
- // Now restore the previous SIGCHLD handler
- sigaction(SIGCHLD, &tmp, &libev_sigchld);
- sigchld_state = 1;
- return result;
-}
-
-
-static void gevent_install_sigchld_handler(void) {
- if (sigchld_state == 1) {
- sigaction(SIGCHLD, &libev_sigchld, NULL);
- sigchld_state = 2;
- }
-}
-
-static void gevent_reset_sigchld_handler(void) {
- // We could have any state at this point, depending on
- // whether the default loop has been used. If it has,
- // then always be in state 1 ("need to install)
- if (sigchld_state) {
- sigchld_state = 1;
- }
-}
-
-#else /* !_WIN32 */
-
-#define gevent_ev_default_loop ev_default_loop
-static void gevent_install_sigchld_handler(void) { }
-static void gevent_reset_sigchld_handler(void) { }
-
-// Fake child functions that we can link to.
-static void ev_child_start(struct ev_loop* loop, ev_child* w) {};
-static void ev_child_stop(struct ev_loop* loop, ev_child* w) {};
-
-#endif /* _WIN32 */
diff --git a/python/gevent/libev/libev.pxd b/python/gevent/libev/libev.pxd
deleted file mode 100644
index e3be525..0000000
--- a/python/gevent/libev/libev.pxd
+++ /dev/null
@@ -1,235 +0,0 @@
-# From cython/includes/libc/stdint.pxd
-# Longness only used for type promotion.
-# Actual compile time size used for conversions.
-# We don't have stdint.h on visual studio 9.0 (2008) on windows, sigh,
-# so go with Py_ssize_t
-# ssize_t -> intptr_t
-
-cdef extern from "libev_vfd.h":
-# cython doesn't process pre-processor directives, so they
-# don't matter in this file. It just takes the last definition it sees.
- ctypedef Py_ssize_t intptr_t
- ctypedef intptr_t vfd_socket_t
-
- vfd_socket_t vfd_get(int)
- int vfd_open(long) except -1
- void vfd_free(int)
-
-cdef extern from "libev.h" nogil:
- int LIBEV_EMBED
- int EV_MINPRI
- int EV_MAXPRI
-
- int EV_VERSION_MAJOR
- int EV_VERSION_MINOR
-
- int EV_USE_FLOOR
- int EV_USE_CLOCK_SYSCALL
- int EV_USE_REALTIME
- int EV_USE_MONOTONIC
- int EV_USE_NANOSLEEP
- int EV_USE_SELECT
- int EV_USE_POLL
- int EV_USE_EPOLL
- int EV_USE_KQUEUE
- int EV_USE_PORT
- int EV_USE_INOTIFY
- int EV_USE_SIGNALFD
- int EV_USE_EVENTFD
- int EV_USE_4HEAP
- int EV_USE_IOCP
- int EV_SELECT_IS_WINSOCKET
-
- int EV_UNDEF
- int EV_NONE
- int EV_READ
- int EV_WRITE
- int EV__IOFDSET
- int EV_TIMER
- int EV_PERIODIC
- int EV_SIGNAL
- int EV_CHILD
- int EV_STAT
- int EV_IDLE
- int EV_PREPARE
- int EV_CHECK
- int EV_EMBED
- int EV_FORK
- int EV_CLEANUP
- int EV_ASYNC
- int EV_CUSTOM
- int EV_ERROR
-
- int EVFLAG_AUTO
- int EVFLAG_NOENV
- int EVFLAG_FORKCHECK
- int EVFLAG_NOINOTIFY
- int EVFLAG_SIGNALFD
- int EVFLAG_NOSIGMASK
-
- int EVBACKEND_SELECT
- int EVBACKEND_POLL
- int EVBACKEND_EPOLL
- int EVBACKEND_KQUEUE
- int EVBACKEND_DEVPOLL
- int EVBACKEND_PORT
- int EVBACKEND_IOCP
- int EVBACKEND_ALL
- int EVBACKEND_MASK
-
- int EVRUN_NOWAIT
- int EVRUN_ONCE
-
- int EVBREAK_CANCEL
- int EVBREAK_ONE
- int EVBREAK_ALL
-
- struct ev_loop:
- int activecnt
- int sig_pending
- int backend_fd
- int sigfd
- unsigned int origflags
-
- struct ev_watcher:
- void* data;
-
- struct ev_io:
- int fd
- int events
-
- struct ev_timer:
- double at
-
- struct ev_signal:
- pass
-
- struct ev_idle:
- pass
-
- struct ev_prepare:
- pass
-
- struct ev_check:
- pass
-
- struct ev_fork:
- pass
-
- struct ev_async:
- pass
-
- struct ev_child:
- int pid
- int rpid
- int rstatus
-
- struct stat:
- int st_nlink
-
- struct ev_stat:
- stat attr
- stat prev
- double interval
-
- union ev_any_watcher:
- ev_watcher w
- ev_io io
- ev_timer timer
- ev_signal signal
- ev_idle idle
-
- int ev_version_major()
- int ev_version_minor()
-
- unsigned int ev_supported_backends()
- unsigned int ev_recommended_backends()
- unsigned int ev_embeddable_backends()
-
- ctypedef double ev_tstamp
-
- ev_tstamp ev_time()
- void ev_set_syserr_cb(void *)
-
- int ev_priority(void*)
- void ev_set_priority(void*, int)
-
- int ev_is_pending(void*)
- int ev_is_active(void*)
- void ev_io_init(ev_io*, void* callback, int fd, int events)
- void ev_io_start(ev_loop*, ev_io*)
- void ev_io_stop(ev_loop*, ev_io*)
- void ev_feed_event(ev_loop*, void*, int)
-
- void ev_timer_init(ev_timer*, void* callback, double, double)
- void ev_timer_start(ev_loop*, ev_timer*)
- void ev_timer_stop(ev_loop*, ev_timer*)
- void ev_timer_again(ev_loop*, ev_timer*)
-
- void ev_signal_init(ev_signal*, void* callback, int)
- void ev_signal_start(ev_loop*, ev_signal*)
- void ev_signal_stop(ev_loop*, ev_signal*)
-
- void ev_idle_init(ev_idle*, void* callback)
- void ev_idle_start(ev_loop*, ev_idle*)
- void ev_idle_stop(ev_loop*, ev_idle*)
-
- void ev_prepare_init(ev_prepare*, void* callback)
- void ev_prepare_start(ev_loop*, ev_prepare*)
- void ev_prepare_stop(ev_loop*, ev_prepare*)
-
- void ev_check_init(ev_check*, void* callback)
- void ev_check_start(ev_loop*, ev_check*)
- void ev_check_stop(ev_loop*, ev_check*)
-
- void ev_fork_init(ev_fork*, void* callback)
- void ev_fork_start(ev_loop*, ev_fork*)
- void ev_fork_stop(ev_loop*, ev_fork*)
-
- void ev_async_init(ev_async*, void* callback)
- void ev_async_start(ev_loop*, ev_async*)
- void ev_async_stop(ev_loop*, ev_async*)
- void ev_async_send(ev_loop*, ev_async*)
- int ev_async_pending(ev_async*)
-
- void ev_child_init(ev_child*, void* callback, int, int)
- void ev_child_start(ev_loop*, ev_child*)
- void ev_child_stop(ev_loop*, ev_child*)
-
- void ev_stat_init(ev_stat*, void* callback, char*, double)
- void ev_stat_start(ev_loop*, ev_stat*)
- void ev_stat_stop(ev_loop*, ev_stat*)
-
- ev_loop* ev_default_loop(unsigned int flags)
- ev_loop* ev_loop_new(unsigned int flags)
- void* ev_userdata(ev_loop*)
- void ev_set_userdata(ev_loop*, void*)
- void ev_loop_destroy(ev_loop*)
- void ev_loop_fork(ev_loop*)
- int ev_is_default_loop(ev_loop*)
- unsigned int ev_iteration(ev_loop*)
- unsigned int ev_depth(ev_loop*)
- unsigned int ev_backend(ev_loop*)
- void ev_verify(ev_loop*)
- void ev_run(ev_loop*, int flags) nogil
-
- ev_tstamp ev_now(ev_loop*)
- void ev_now_update(ev_loop*)
-
- void ev_ref(ev_loop*)
- void ev_unref(ev_loop*)
- void ev_break(ev_loop*, int)
- unsigned int ev_pending_count(ev_loop*)
-
- # gevent extra functions. These are defined in libev.h.
- ev_loop* gevent_ev_default_loop(unsigned int flags)
- void gevent_install_sigchld_handler()
- void gevent_reset_sigchld_handler()
-
- # These compensate for lack of access to ev_loop struct definition
- # when LIBEV_EMBED is false.
- unsigned int gevent_ev_loop_origflags(ev_loop*);
- int gevent_ev_loop_sig_pending(ev_loop*);
- int gevent_ev_loop_backend_fd(ev_loop*);
- int gevent_ev_loop_activecnt(ev_loop*);
- int gevent_ev_loop_sigfd(ev_loop*);
diff --git a/python/gevent/libev/libev_vfd.h b/python/gevent/libev/libev_vfd.h
deleted file mode 100644
index ff30fd8..0000000
--- a/python/gevent/libev/libev_vfd.h
+++ /dev/null
@@ -1,225 +0,0 @@
-#ifdef _WIN32
-/* see discussion in the libuv directory: this is a SOCKET which is a
- HANDLE which is a PVOID (even though they're really small ints),
- and CPython and PyPy return that SOCKET cast to an int from
- fileno()
-*/
-typedef intptr_t vfd_socket_t;
-#define vfd_socket_object PyLong_FromLongLong
-
-#ifdef LIBEV_EMBED
-/*
- * If libev on win32 is embedded, then we can use an
- * arbitrary mapping between integer fds and OS
- * handles. Then by defining special macros libev
- * will use our functions.
- */
-
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
-
-typedef struct vfd_entry_t
-{
- vfd_socket_t handle; /* OS handle, i.e. SOCKET */
- int count; /* Reference count, 0 if free */
- int next; /* Next free fd, -1 if last */
-} vfd_entry;
-
-#define VFD_INCREMENT 128
-static int vfd_num = 0; /* num allocated fds */
-static int vfd_max = 0; /* max allocated fds */
-static int vfd_next = -1; /* next free fd for reuse */
-static PyObject* vfd_map = NULL; /* map OS handle -> virtual fd */
-static vfd_entry* vfd_entries = NULL; /* list of virtual fd entries */
-
-#ifdef WITH_THREAD
-static CRITICAL_SECTION* volatile vfd_lock = NULL;
-static CRITICAL_SECTION* vfd_make_lock()
-{
- if (vfd_lock == NULL) {
- /* must use malloc and not PyMem_Malloc here */
- CRITICAL_SECTION* lock = malloc(sizeof(CRITICAL_SECTION));
- InitializeCriticalSection(lock);
- if (InterlockedCompareExchangePointer(&vfd_lock, lock, NULL) != NULL) {
- /* another thread initialized lock first */
- DeleteCriticalSection(lock);
- free(lock);
- }
- }
- return vfd_lock;
-}
-#define VFD_LOCK_ENTER EnterCriticalSection(vfd_make_lock())
-#define VFD_LOCK_LEAVE LeaveCriticalSection(vfd_lock)
-#define VFD_GIL_DECLARE PyGILState_STATE ___save
-#define VFD_GIL_ENSURE ___save = PyGILState_Ensure()
-#define VFD_GIL_RELEASE PyGILState_Release(___save)
-#else /* ! WITH_THREAD */
-#define VFD_LOCK_ENTER
-#define VFD_LOCK_LEAVE
-#define VFD_GIL_DECLARE
-#define VFD_GIL_ENSURE
-#define VFD_GIL_RELEASE
-#endif /*_WITH_THREAD */
-
-/*
- * Given a virtual fd returns an OS handle or -1
- * This function is speed critical, so it cannot use GIL
- */
-static vfd_socket_t vfd_get(int fd)
-{
- vfd_socket_t handle = -1;
- VFD_LOCK_ENTER;
- if (vfd_entries != NULL && fd >= 0 && fd < vfd_num)
- handle = vfd_entries[fd].handle;
- VFD_LOCK_LEAVE;
- return handle;
-}
-
-#define EV_FD_TO_WIN32_HANDLE(fd) vfd_get((fd))
-
-/*
- * Given an OS handle finds or allocates a virtual fd
- * Returns -1 on failure and sets Python exception if pyexc is non-zero
- */
-static int vfd_open_(vfd_socket_t handle, int pyexc)
-{
- VFD_GIL_DECLARE;
- int fd = -1;
- unsigned long arg;
- PyObject* key = NULL;
- PyObject* value;
-
- if (!pyexc) {
- VFD_GIL_ENSURE;
- }
- if (ioctlsocket(handle, FIONREAD, &arg) != 0) {
- if (pyexc)
- PyErr_Format(PyExc_IOError,
-#ifdef _WIN64
- "%lld is not a socket (files are not supported)",
-#else
- "%ld is not a socket (files are not supported)",
-#endif
- handle);
- goto done;
- }
- if (vfd_map == NULL) {
- vfd_map = PyDict_New();
- if (vfd_map == NULL)
- goto done;
- }
- key = vfd_socket_object(handle);
- /* check if it's already in the dict */
- value = PyDict_GetItem(vfd_map, key);
- if (value != NULL) {
- /* is it safe to use PyInt_AS_LONG(value) here? */
- fd = PyInt_AsLong(value);
- if (fd >= 0) {
- ++vfd_entries[fd].count;
- goto done;
- }
- }
- /* use the free entry, if available */
- if (vfd_next >= 0) {
- fd = vfd_next;
- vfd_next = vfd_entries[fd].next;
- VFD_LOCK_ENTER;
- goto allocated;
- }
- /* check if it would be out of bounds */
- if (vfd_num >= FD_SETSIZE) {
- /* libev's select doesn't support more that FD_SETSIZE fds */
- if (pyexc)
- PyErr_Format(PyExc_IOError, "cannot watch more than %d sockets", (int)FD_SETSIZE);
- goto done;
- }
- /* allocate more space if needed */
- VFD_LOCK_ENTER;
- if (vfd_num >= vfd_max) {
- int newsize = vfd_max + VFD_INCREMENT;
- vfd_entry* entries = PyMem_Realloc(vfd_entries, sizeof(vfd_entry) * newsize);
- if (entries == NULL) {
- VFD_LOCK_LEAVE;
- if (pyexc)
- PyErr_NoMemory();
- goto done;
- }
- vfd_entries = entries;
- vfd_max = newsize;
- }
- fd = vfd_num++;
-allocated:
- /* vfd_lock must be acquired when entering here */
- vfd_entries[fd].handle = handle;
- vfd_entries[fd].count = 1;
- VFD_LOCK_LEAVE;
- value = PyInt_FromLong(fd);
- PyDict_SetItem(vfd_map, key, value);
- Py_DECREF(value);
-done:
- Py_XDECREF(key);
- if (!pyexc) {
- VFD_GIL_RELEASE;
- }
- return fd;
-}
-
-#define vfd_open(fd) vfd_open_((fd), 1)
-#define EV_WIN32_HANDLE_TO_FD(handle) vfd_open_((handle), 0)
-
-static void vfd_free_(int fd, int needclose)
-{
- VFD_GIL_DECLARE;
- PyObject* key;
-
- if (needclose) {
- VFD_GIL_ENSURE;
- }
- if (fd < 0 || fd >= vfd_num)
- goto done; /* out of bounds */
- if (vfd_entries[fd].count <= 0)
- goto done; /* free entry, ignore */
- if (!--vfd_entries[fd].count) {
- /* fd has just been freed */
- vfd_socket_t handle = vfd_entries[fd].handle;
- vfd_entries[fd].handle = -1;
- vfd_entries[fd].next = vfd_next;
- vfd_next = fd;
- if (needclose)
- closesocket(handle);
- /* vfd_map is assumed to be != NULL */
- key = vfd_socket_object(handle);
- PyDict_DelItem(vfd_map, key);
- Py_DECREF(key);
- }
-done:
- if (needclose) {
- VFD_GIL_RELEASE;
- }
-}
-
-#define vfd_free(fd) vfd_free_((fd), 0)
-#define EV_WIN32_CLOSE_FD(fd) vfd_free_((fd), 1)
-
-#else /* !LIBEV_EMBED */
-/*
- * If libev on win32 is not embedded in gevent, then
- * the only way to map vfds is to use the default of
- * using runtime fds in libev. Note that it will leak
- * fds, because there's no way of closing them safely
- */
-#define vfd_get(fd) _get_osfhandle((fd))
-#define vfd_open(fd) _open_osfhandle((fd), 0)
-#define vfd_free(fd)
-#endif /* LIBEV_EMBED */
-
-#else /* !_WIN32 */
-/*
- * On non-win32 platforms vfd_* are noop macros
- */
-typedef int vfd_socket_t;
-#define vfd_get(fd) (fd)
-#define vfd_open(fd) (fd)
-#define vfd_free(fd)
-#endif /* _WIN32 */
diff --git a/python/gevent/libev/stathelper.c b/python/gevent/libev/stathelper.c
deleted file mode 100644
index 1a70b55..0000000
--- a/python/gevent/libev/stathelper.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* copied from Python-2.7.2/Modules/posixmodule.c */
-#include "structseq.h"
-
-#define STRUCT_STAT struct stat
-
-#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
-#define ST_BLKSIZE_IDX 13
-#else
-#define ST_BLKSIZE_IDX 12
-#endif
-
-#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
-#define ST_BLOCKS_IDX (ST_BLKSIZE_IDX+1)
-#else
-#define ST_BLOCKS_IDX ST_BLKSIZE_IDX
-#endif
-
-#ifdef HAVE_STRUCT_STAT_ST_RDEV
-#define ST_RDEV_IDX (ST_BLOCKS_IDX+1)
-#else
-#define ST_RDEV_IDX ST_BLOCKS_IDX
-#endif
-
-#ifdef HAVE_STRUCT_STAT_ST_FLAGS
-#define ST_FLAGS_IDX (ST_RDEV_IDX+1)
-#else
-#define ST_FLAGS_IDX ST_RDEV_IDX
-#endif
-
-#ifdef HAVE_STRUCT_STAT_ST_GEN
-#define ST_GEN_IDX (ST_FLAGS_IDX+1)
-#else
-#define ST_GEN_IDX ST_FLAGS_IDX
-#endif
-
-#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
-#define ST_BIRTHTIME_IDX (ST_GEN_IDX+1)
-#else
-#define ST_BIRTHTIME_IDX ST_GEN_IDX
-#endif
-
-
-
-static PyObject* posixmodule = NULL;
-static PyTypeObject* pStatResultType = NULL;
-
-
-static PyObject* import_posixmodule(void)
-{
- if (!posixmodule) {
- posixmodule = PyImport_ImportModule("posix");
- }
- return posixmodule;
-}
-
-
-static PyObject* import_StatResultType(void)
-{
- PyObject* p = NULL;
- if (!pStatResultType) {
- PyObject* module;
- module = import_posixmodule();
- if (module) {
- p = PyObject_GetAttrString(module, "stat_result");
- }
- }
- return p;
-}
-
-static void
-fill_time(PyObject *v, int index, time_t sec, unsigned long nsec)
-{
- PyObject *fval,*ival;
-#if SIZEOF_TIME_T > SIZEOF_LONG
- ival = PyLong_FromLongLong((PY_LONG_LONG)sec);
-#else
- ival = PyInt_FromLong((long)sec);
-#endif
- if (!ival)
- return;
- fval = PyFloat_FromDouble(sec + 1e-9*nsec);
- PyStructSequence_SET_ITEM(v, index, ival);
- PyStructSequence_SET_ITEM(v, index+3, fval);
-}
-
-/* pack a system stat C structure into the Python stat tuple
- (used by posix_stat() and posix_fstat()) */
-static PyObject*
-_pystat_fromstructstat(STRUCT_STAT *st)
-{
- unsigned long ansec, mnsec, cnsec;
- PyObject *v;
-
- PyTypeObject* StatResultType = (PyTypeObject*)import_StatResultType();
- if (StatResultType == NULL) {
- return NULL;
- }
-
- v = PyStructSequence_New(StatResultType);
- if (v == NULL)
- return NULL;
-
- PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st->st_mode));
-#ifdef HAVE_LARGEFILE_SUPPORT
- PyStructSequence_SET_ITEM(v, 1,
- PyLong_FromLongLong((PY_LONG_LONG)st->st_ino));
-#else
- PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino));
-#endif
-#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
- PyStructSequence_SET_ITEM(v, 2,
- PyLong_FromLongLong((PY_LONG_LONG)st->st_dev));
-#else
- PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev));
-#endif
- PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink));
- PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid));
- PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid));
-#ifdef HAVE_LARGEFILE_SUPPORT
- PyStructSequence_SET_ITEM(v, 6,
- PyLong_FromLongLong((PY_LONG_LONG)st->st_size));
-#else
- PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st->st_size));
-#endif
-
-#if defined(HAVE_STAT_TV_NSEC)
- ansec = st->st_atim.tv_nsec;
- mnsec = st->st_mtim.tv_nsec;
- cnsec = st->st_ctim.tv_nsec;
-#elif defined(HAVE_STAT_TV_NSEC2)
- ansec = st->st_atimespec.tv_nsec;
- mnsec = st->st_mtimespec.tv_nsec;
- cnsec = st->st_ctimespec.tv_nsec;
-#elif defined(HAVE_STAT_NSEC)
- ansec = st->st_atime_nsec;
- mnsec = st->st_mtime_nsec;
- cnsec = st->st_ctime_nsec;
-#else
- ansec = mnsec = cnsec = 0;
-#endif
- fill_time(v, 7, st->st_atime, ansec);
- fill_time(v, 8, st->st_mtime, mnsec);
- fill_time(v, 9, st->st_ctime, cnsec);
-
-#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
- PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX,
- PyInt_FromLong((long)st->st_blksize));
-#endif
-#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
- PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX,
- PyInt_FromLong((long)st->st_blocks));
-#endif
-#ifdef HAVE_STRUCT_STAT_ST_RDEV
- PyStructSequence_SET_ITEM(v, ST_RDEV_IDX,
- PyInt_FromLong((long)st->st_rdev));
-#endif
-#ifdef HAVE_STRUCT_STAT_ST_GEN
- PyStructSequence_SET_ITEM(v, ST_GEN_IDX,
- PyInt_FromLong((long)st->st_gen));
-#endif
-#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
- {
- PyObject *val;
- unsigned long bsec,bnsec;
- bsec = (long)st->st_birthtime;
-#ifdef HAVE_STAT_TV_NSEC2
- bnsec = st->st_birthtimespec.tv_nsec;
-#else
- bnsec = 0;
-#endif
- val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
- PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX,
- val);
- }
-#endif
-#ifdef HAVE_STRUCT_STAT_ST_FLAGS
- PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX,
- PyInt_FromLong((long)st->st_flags));
-#endif
-
- if (PyErr_Occurred()) {
- Py_DECREF(v);
- return NULL;
- }
-
- return v;
-}
diff --git a/python/gevent/libev/watcher.py b/python/gevent/libev/watcher.py
deleted file mode 100644
index 8beaa1f..0000000
--- a/python/gevent/libev/watcher.py
+++ /dev/null
@@ -1,282 +0,0 @@
-# pylint: disable=too-many-lines, protected-access, redefined-outer-name, not-callable
-# pylint: disable=no-member
-from __future__ import absolute_import, print_function
-import sys
-
-from gevent.libev import _corecffi # pylint:disable=no-name-in-module,import-error
-
-ffi = _corecffi.ffi # pylint:disable=no-member
-libev = _corecffi.lib # pylint:disable=no-member
-
-if hasattr(libev, 'vfd_open'):
- # Must be on windows
- assert sys.platform.startswith("win"), "vfd functions only needed on windows"
- vfd_open = libev.vfd_open
- vfd_free = libev.vfd_free
- vfd_get = libev.vfd_get
-else:
- vfd_open = vfd_free = vfd_get = lambda fd: fd
-
-#####
-## NOTE on Windows:
-# The C implementation does several things specially for Windows;
-# a possibly incomplete list is:
-#
-# - the loop runs a periodic signal checker;
-# - the io watcher constructor is different and it has a destructor;
-# - the child watcher is not defined
-#
-# The CFFI implementation does none of these things, and so
-# is possibly NOT FUNCTIONALLY CORRECT on Win32
-#####
-_NOARGS = ()
-_events = [(libev.EV_READ, 'READ'),
- (libev.EV_WRITE, 'WRITE'),
- (libev.EV__IOFDSET, '_IOFDSET'),
- (libev.EV_PERIODIC, 'PERIODIC'),
- (libev.EV_SIGNAL, 'SIGNAL'),
- (libev.EV_CHILD, 'CHILD'),
- (libev.EV_STAT, 'STAT'),
- (libev.EV_IDLE, 'IDLE'),
- (libev.EV_PREPARE, 'PREPARE'),
- (libev.EV_CHECK, 'CHECK'),
- (libev.EV_EMBED, 'EMBED'),
- (libev.EV_FORK, 'FORK'),
- (libev.EV_CLEANUP, 'CLEANUP'),
- (libev.EV_ASYNC, 'ASYNC'),
- (libev.EV_CUSTOM, 'CUSTOM'),
- (libev.EV_ERROR, 'ERROR')]
-
-from gevent._ffi import watcher as _base
-
-def _events_to_str(events):
- return _base.events_to_str(events, _events)
-
-
-
-class watcher(_base.watcher):
- _FFI = ffi
- _LIB = libev
- _watcher_prefix = 'ev'
-
- # Flags is a bitfield with the following meaning:
- # 0000 -> default, referenced (when active)
- # 0010 -> ev_unref has been called
- # 0100 -> not referenced; independent of 0010
- _flags = 0
-
- def __init__(self, _loop, ref=True, priority=None, args=_base._NOARGS):
- if ref:
- self._flags = 0
- else:
- self._flags = 4
-
- super(watcher, self).__init__(_loop, ref=ref, priority=priority, args=args)
-
- def _watcher_ffi_set_priority(self, priority):
- libev.ev_set_priority(self._watcher, priority)
-
- def _watcher_ffi_init(self, args):
- self._watcher_init(self._watcher,
- self._watcher_callback,
- *args)
-
- def _watcher_ffi_start(self):
- self._watcher_start(self.loop._ptr, self._watcher)
-
- def _watcher_ffi_ref(self):
- if self._flags & 2: # we've told libev we're not referenced
- self.loop.ref()
- self._flags &= ~2
-
- def _watcher_ffi_unref(self):
- if self._flags & 6 == 4:
- # We're not referenced, but we haven't told libev that
- self.loop.unref()
- self._flags |= 2 # now we've told libev
-
- def _get_ref(self):
- return False if self._flags & 4 else True
-
- def _set_ref(self, value):
- if value:
- if not self._flags & 4:
- return # ref is already True
- if self._flags & 2: # ev_unref was called, undo
- self.loop.ref()
- self._flags &= ~6 # do not want unref, no outstanding unref
- else:
- if self._flags & 4:
- return # ref is already False
- self._flags |= 4 # we're not referenced
- if not self._flags & 2 and libev.ev_is_active(self._watcher):
- # we haven't told libev we're not referenced, but it thinks we're
- # active so we need to undo that
- self.loop.unref()
- self._flags |= 2 # libev knows we're not referenced
-
- ref = property(_get_ref, _set_ref)
-
-
- def _get_priority(self):
- return libev.ev_priority(self._watcher)
-
- @_base.not_while_active
- def _set_priority(self, priority):
- libev.ev_set_priority(self._watcher, priority)
-
- priority = property(_get_priority, _set_priority)
-
- def feed(self, revents, callback, *args):
- self.callback = callback
- self.args = args or _NOARGS
- if self._flags & 6 == 4:
- self.loop.unref()
- self._flags |= 2
- libev.ev_feed_event(self.loop._ptr, self._watcher, revents)
- if not self._flags & 1:
- # Py_INCREF(<PyObjectPtr>self)
- self._flags |= 1
-
- @property
- def pending(self):
- return True if self._watcher and libev.ev_is_pending(self._watcher) else False
-
-
-class io(_base.IoMixin, watcher):
-
- EVENT_MASK = libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE
-
- def _get_fd(self):
- return vfd_get(self._watcher.fd)
-
- @_base.not_while_active
- def _set_fd(self, fd):
- vfd = vfd_open(fd)
- vfd_free(self._watcher.fd)
- self._watcher_init(self._watcher, self._watcher_callback, vfd, self._watcher.events)
-
- fd = property(_get_fd, _set_fd)
-
- def _get_events(self):
- return self._watcher.events
-
- @_base.not_while_active
- def _set_events(self, events):
- self._watcher_init(self._watcher, self._watcher_callback, self._watcher.fd, events)
-
- events = property(_get_events, _set_events)
-
- @property
- def events_str(self):
- return _events_to_str(self._watcher.events)
-
- def _format(self):
- return ' fd=%s events=%s' % (self.fd, self.events_str)
-
-
-class timer(_base.TimerMixin, watcher):
-
- @property
- def at(self):
- return self._watcher.at
-
- def again(self, callback, *args, **kw):
- # Exactly the same as start(), just with a different initializer
- # function
- self._watcher_start = libev.ev_timer_again
- try:
- self.start(callback, *args, **kw)
- finally:
- del self._watcher_start
-
-
-class signal(_base.SignalMixin, watcher):
- pass
-
-class idle(_base.IdleMixin, watcher):
- pass
-
-class prepare(_base.PrepareMixin, watcher):
- pass
-
-class check(_base.CheckMixin, watcher):
- pass
-
-class fork(_base.ForkMixin, watcher):
- pass
-
-
-class async_(_base.AsyncMixin, watcher):
-
- def send(self):
- libev.ev_async_send(self.loop._ptr, self._watcher)
-
- @property
- def pending(self):
- return True if libev.ev_async_pending(self._watcher) else False
-
-# Provide BWC for those that have async
-locals()['async'] = async_
-
-class _ClosedWatcher(object):
- __slots__ = ('pid', 'rpid', 'rstatus')
-
- def __init__(self, other):
- self.pid = other.pid
- self.rpid = other.rpid
- self.rstatus = other.rstatus
-
- def __bool__(self):
- return False
- __nonzero__ = __bool__
-
-class child(_base.ChildMixin, watcher):
- _watcher_type = 'child'
-
- def close(self):
- # Capture the properties we defer to our _watcher, because
- # we're about to discard it.
- closed_watcher = _ClosedWatcher(self._watcher)
- super(child, self).close()
- self._watcher = closed_watcher
-
- @property
- def pid(self):
- return self._watcher.pid
-
- @property
- def rpid(self):
- return self._watcher.rpid
-
- @rpid.setter
- def rpid(self, value):
- self._watcher.rpid = value
-
- @property
- def rstatus(self):
- return self._watcher.rstatus
-
- @rstatus.setter
- def rstatus(self, value):
- self._watcher.rstatus = value
-
-
-class stat(_base.StatMixin, watcher):
- _watcher_type = 'stat'
-
- @property
- def attr(self):
- if not self._watcher.attr.st_nlink:
- return
- return self._watcher.attr
-
- @property
- def prev(self):
- if not self._watcher.prev.st_nlink:
- return
- return self._watcher.prev
-
- @property
- def interval(self):
- return self._watcher.interval
diff --git a/python/gevent/libuv/__init__.py b/python/gevent/libuv/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/python/gevent/libuv/__init__.py
+++ /dev/null
diff --git a/python/gevent/libuv/_corecffi.cp36-win32.pyd b/python/gevent/libuv/_corecffi.cp36-win32.pyd
deleted file mode 100644
index 0cc476a..0000000
--- a/python/gevent/libuv/_corecffi.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/libuv/_corecffi_build.py b/python/gevent/libuv/_corecffi_build.py
deleted file mode 100644
index 722157d..0000000
--- a/python/gevent/libuv/_corecffi_build.py
+++ /dev/null
@@ -1,253 +0,0 @@
-# pylint: disable=no-member
-
-# This module is only used to create and compile the gevent._corecffi module;
-# nothing should be directly imported from it except `ffi`, which should only be
-# used for `ffi.compile()`; programs should import gevent._corecfffi.
-# However, because we are using "out-of-line" mode, it is necessary to examine
-# this file to know what functions are created and available on the generated
-# module.
-from __future__ import absolute_import, print_function
-import sys
-import os
-import os.path # pylint:disable=no-name-in-module
-import struct
-
-__all__ = []
-
-WIN = sys.platform.startswith('win32')
-
-def system_bits():
- return struct.calcsize('P') * 8
-
-
-def st_nlink_type():
- if sys.platform == "darwin" or sys.platform.startswith("freebsd"):
- return "short"
- if system_bits() == 32:
- return "unsigned long"
- return "long long"
-
-
-from cffi import FFI
-ffi = FFI()
-
-thisdir = os.path.dirname(os.path.abspath(__file__))
-def read_source(name):
- with open(os.path.join(thisdir, name), 'r') as f:
- return f.read()
-
-_cdef = read_source('_corecffi_cdef.c')
-_source = read_source('_corecffi_source.c')
-
-_cdef = _cdef.replace('#define GEVENT_ST_NLINK_T int', '')
-_cdef = _cdef.replace('#define GEVENT_STRUCT_DONE int', '')
-_cdef = _cdef.replace('#define GEVENT_UV_OS_SOCK_T int', '')
-
-_cdef = _cdef.replace('GEVENT_ST_NLINK_T', st_nlink_type())
-_cdef = _cdef.replace("GEVENT_STRUCT_DONE _;", '...;')
-# uv_os_sock_t is int on POSIX and SOCKET on Win32, but socket is
-# just another name for handle, which is just another name for 'void*'
-# which we will treat as an 'unsigned long' or 'unsigned long long'
-# since it comes through 'fileno()' where it has been cast as an int.
-# See class watcher.io
-_void_pointer_as_integer = 'intptr_t'
-_cdef = _cdef.replace("GEVENT_UV_OS_SOCK_T", 'int' if not WIN else _void_pointer_as_integer)
-
-
-setup_py_dir = os.path.abspath(os.path.join(thisdir, '..', '..', '..'))
-libuv_dir = os.path.abspath(os.path.join(setup_py_dir, 'deps', 'libuv'))
-
-
-LIBUV_INCLUDE_DIRS = [
- thisdir, # libev_vfd.h
- os.path.join(libuv_dir, 'include'),
- os.path.join(libuv_dir, 'src'),
-]
-
-# Initially based on https://github.com/saghul/pyuv/blob/v1.x/setup_libuv.py
-
-def _libuv_source(rel_path):
- # Certain versions of setuptools, notably on windows, are *very*
- # picky about what we feed to sources= "setup() arguments must
- # *always* be /-separated paths relative to the setup.py
- # directory, *never* absolute paths." POSIX doesn't have that issue.
- path = os.path.join('deps', 'libuv', 'src', rel_path)
- return path
-
-LIBUV_SOURCES = [
- _libuv_source('fs-poll.c'),
- _libuv_source('inet.c'),
- _libuv_source('threadpool.c'),
- _libuv_source('uv-common.c'),
- _libuv_source('version.c'),
- _libuv_source('uv-data-getter-setters.c'),
- _libuv_source('timer.c'),
-]
-
-if WIN:
- LIBUV_SOURCES += [
- _libuv_source('win/async.c'),
- _libuv_source('win/core.c'),
- _libuv_source('win/detect-wakeup.c'),
- _libuv_source('win/dl.c'),
- _libuv_source('win/error.c'),
- _libuv_source('win/fs-event.c'),
- _libuv_source('win/fs.c'),
- # getaddrinfo.c refers to ConvertInterfaceIndexToLuid
- # and ConvertInterfaceLuidToNameA, which are supposedly in iphlpapi.h
- # and iphlpapi.lib/dll. But on Windows 10 with Python 3.5 and VC 14 (Visual Studio 2015),
- # I get an undefined warning from the compiler for those functions and
- # a link error from the linker, so this file can't be included.
- # This is possibly because the functions are defined for Windows Vista, and
- # Python 3.5 builds with at earlier SDK?
- # Fortunately we don't use those functions.
- #_libuv_source('win/getaddrinfo.c'),
- # getnameinfo.c refers to uv__getaddrinfo_translate_error from
- # getaddrinfo.c, which we don't have.
- #_libuv_source('win/getnameinfo.c'),
- _libuv_source('win/handle.c'),
- _libuv_source('win/loop-watcher.c'),
- _libuv_source('win/pipe.c'),
- _libuv_source('win/poll.c'),
- _libuv_source('win/process-stdio.c'),
- _libuv_source('win/process.c'),
- _libuv_source('win/req.c'),
- _libuv_source('win/signal.c'),
- _libuv_source('win/snprintf.c'),
- _libuv_source('win/stream.c'),
- _libuv_source('win/tcp.c'),
- _libuv_source('win/thread.c'),
- _libuv_source('win/tty.c'),
- _libuv_source('win/udp.c'),
- _libuv_source('win/util.c'),
- _libuv_source('win/winapi.c'),
- _libuv_source('win/winsock.c'),
- ]
-else:
- LIBUV_SOURCES += [
- _libuv_source('unix/async.c'),
- _libuv_source('unix/core.c'),
- _libuv_source('unix/dl.c'),
- _libuv_source('unix/fs.c'),
- _libuv_source('unix/getaddrinfo.c'),
- _libuv_source('unix/getnameinfo.c'),
- _libuv_source('unix/loop-watcher.c'),
- _libuv_source('unix/loop.c'),
- _libuv_source('unix/pipe.c'),
- _libuv_source('unix/poll.c'),
- _libuv_source('unix/process.c'),
- _libuv_source('unix/signal.c'),
- _libuv_source('unix/stream.c'),
- _libuv_source('unix/tcp.c'),
- _libuv_source('unix/thread.c'),
- _libuv_source('unix/tty.c'),
- _libuv_source('unix/udp.c'),
- ]
-
-
-if sys.platform.startswith('linux'):
- LIBUV_SOURCES += [
- _libuv_source('unix/linux-core.c'),
- _libuv_source('unix/linux-inotify.c'),
- _libuv_source('unix/linux-syscalls.c'),
- _libuv_source('unix/procfs-exepath.c'),
- _libuv_source('unix/proctitle.c'),
- _libuv_source('unix/sysinfo-loadavg.c'),
- _libuv_source('unix/sysinfo-memory.c'),
- ]
-elif sys.platform == 'darwin':
- LIBUV_SOURCES += [
- _libuv_source('unix/bsd-ifaddrs.c'),
- _libuv_source('unix/darwin.c'),
- _libuv_source('unix/darwin-proctitle.c'),
- _libuv_source('unix/fsevents.c'),
- _libuv_source('unix/kqueue.c'),
- _libuv_source('unix/proctitle.c'),
- ]
-elif sys.platform.startswith(('freebsd', 'dragonfly')):
- LIBUV_SOURCES += [
- _libuv_source('unix/bsd-ifaddrs.c'),
- _libuv_source('unix/freebsd.c'),
- _libuv_source('unix/kqueue.c'),
- _libuv_source('unix/posix-hrtime.c'),
- ]
-elif sys.platform.startswith('openbsd'):
- LIBUV_SOURCES += [
- _libuv_source('unix/bsd-ifaddrs.c'),
- _libuv_source('unix/kqueue.c'),
- _libuv_source('unix/openbsd.c'),
- _libuv_source('unix/posix-hrtime.c'),
- ]
-elif sys.platform.startswith('netbsd'):
- LIBUV_SOURCES += [
- _libuv_source('unix/bsd-ifaddrs.c'),
- _libuv_source('unix/kqueue.c'),
- _libuv_source('unix/netbsd.c'),
- _libuv_source('unix/posix-hrtime.c'),
- ]
-
-elif sys.platform.startswith('sunos'):
- LIBUV_SOURCES += [
- _libuv_source('unix/no-proctitle.c'),
- _libuv_source('unix/sunos.c'),
- ]
-
-
-LIBUV_MACROS = []
-
-def _define_macro(name, value):
- LIBUV_MACROS.append((name, value))
-
-LIBUV_LIBRARIES = []
-
-def _add_library(name):
- LIBUV_LIBRARIES.append(name)
-
-if sys.platform != 'win32':
- _define_macro('_LARGEFILE_SOURCE', 1)
- _define_macro('_FILE_OFFSET_BITS', 64)
-
-if sys.platform.startswith('linux'):
- _add_library('dl')
- _add_library('rt')
- _define_macro('_GNU_SOURCE', 1)
- _define_macro('_POSIX_C_SOURCE', '200112')
-elif sys.platform == 'darwin':
- _define_macro('_DARWIN_USE_64_BIT_INODE', 1)
- _define_macro('_DARWIN_UNLIMITED_SELECT', 1)
-elif sys.platform.startswith('netbsd'):
- _add_library('kvm')
-elif sys.platform.startswith('sunos'):
- _define_macro('__EXTENSIONS__', 1)
- _define_macro('_XOPEN_SOURCE', 500)
- _add_library('kstat')
- _add_library('nsl')
- _add_library('sendfile')
- _add_library('socket')
-elif WIN:
- _define_macro('_GNU_SOURCE', 1)
- _define_macro('WIN32', 1)
- _define_macro('_CRT_SECURE_NO_DEPRECATE', 1)
- _define_macro('_CRT_NONSTDC_NO_DEPRECATE', 1)
- _define_macro('_CRT_SECURE_NO_WARNINGS', 1)
- _define_macro('_WIN32_WINNT', '0x0600')
- _define_macro('WIN32_LEAN_AND_MEAN', 1)
- _add_library('advapi32')
- _add_library('iphlpapi')
- _add_library('psapi')
- _add_library('shell32')
- _add_library('user32')
- _add_library('userenv')
- _add_library('ws2_32')
-
-ffi.cdef(_cdef)
-ffi.set_source('gevent.libuv._corecffi',
- _source,
- sources=LIBUV_SOURCES,
- depends=LIBUV_SOURCES,
- include_dirs=LIBUV_INCLUDE_DIRS,
- libraries=list(LIBUV_LIBRARIES),
- define_macros=list(LIBUV_MACROS))
-
-if __name__ == '__main__':
- ffi.compile()
diff --git a/python/gevent/libuv/_corecffi_cdef.c b/python/gevent/libuv/_corecffi_cdef.c
deleted file mode 100644
index 0735aea..0000000
--- a/python/gevent/libuv/_corecffi_cdef.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* markers for the CFFI parser. Replaced when the string is read. */
-#define GEVENT_STRUCT_DONE int
-#define GEVENT_ST_NLINK_T int
-#define GEVENT_UV_OS_SOCK_T int
-
-#define UV_EBUSY ...
-
-#define UV_VERSION_MAJOR ...
-#define UV_VERSION_MINOR ...
-#define UV_VERSION_PATCH ...
-
-typedef enum {
- UV_RUN_DEFAULT = 0,
- UV_RUN_ONCE,
- UV_RUN_NOWAIT
-} uv_run_mode;
-
-typedef enum {
- UV_UNKNOWN_HANDLE = 0,
- UV_ASYNC,
- UV_CHECK,
- UV_FS_EVENT,
- UV_FS_POLL,
- UV_HANDLE,
- UV_IDLE,
- UV_NAMED_PIPE,
- UV_POLL,
- UV_PREPARE,
- UV_PROCESS,
- UV_STREAM,
- UV_TCP,
- UV_TIMER,
- UV_TTY,
- UV_UDP,
- UV_SIGNAL,
- UV_FILE,
- UV_HANDLE_TYPE_MAX
-} uv_handle_type;
-
-enum uv_poll_event {
- UV_READABLE = 1,
- UV_WRITABLE = 2,
- /* new in 1.9 */
- UV_DISCONNECT = 4,
- /* new in 1.14.0 */
- UV_PRIORITIZED = 8,
-};
-
-enum uv_fs_event {
- UV_RENAME = 1,
- UV_CHANGE = 2
-};
-
-enum uv_fs_event_flags {
- /*
- * By default, if the fs event watcher is given a directory name, we will
- * watch for all events in that directory. This flags overrides this behavior
- * and makes fs_event report only changes to the directory entry itself. This
- * flag does not affect individual files watched.
- * This flag is currently not implemented yet on any backend.
- */
- UV_FS_EVENT_WATCH_ENTRY = 1,
- /*
- * By default uv_fs_event will try to use a kernel interface such as inotify
- * or kqueue to detect events. This may not work on remote filesystems such
- * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
- * regular interval.
- * This flag is currently not implemented yet on any backend.
- */
- UV_FS_EVENT_STAT = 2,
- /*
- * By default, event watcher, when watching directory, is not registering
- * (is ignoring) changes in it's subdirectories.
- * This flag will override this behaviour on platforms that support it.
- */
- UV_FS_EVENT_RECURSIVE = 4
-};
-
-const char* uv_strerror(int);
-const char* uv_err_name(int);
-const char* uv_version_string(void);
-const char* uv_handle_type_name(uv_handle_type type);
-
-// handle structs and types
-struct uv_loop_s {
- void* data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_handle_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_idle_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_prepare_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_timer_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_signal_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-struct uv_poll_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct uv_check_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct uv_async_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- void (*async_cb)(struct uv_async_s *);
- GEVENT_STRUCT_DONE _;
-};
-
-struct uv_fs_event_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-
-struct uv_fs_poll_s {
- struct uv_loop_s* loop;
- uv_handle_type type;
- void *data;
- GEVENT_STRUCT_DONE _;
-};
-
-typedef struct uv_loop_s uv_loop_t;
-typedef struct uv_handle_s uv_handle_t;
-typedef struct uv_idle_s uv_idle_t;
-typedef struct uv_prepare_s uv_prepare_t;
-typedef struct uv_timer_s uv_timer_t;
-typedef struct uv_signal_s uv_signal_t;
-typedef struct uv_poll_s uv_poll_t;
-typedef struct uv_check_s uv_check_t;
-typedef struct uv_async_s uv_async_t;
-typedef struct uv_fs_event_s uv_fs_event_t;
-typedef struct uv_fs_poll_s uv_fs_poll_t;
-
-
-size_t uv_handle_size(uv_handle_type);
-
-// callbacks with the same signature
-typedef void (*uv_close_cb)(uv_handle_t *handle);
-typedef void (*uv_idle_cb)(uv_idle_t *handle);
-typedef void (*uv_timer_cb)(uv_timer_t *handle);
-typedef void (*uv_check_cb)(uv_check_t* handle);
-typedef void (*uv_async_cb)(uv_async_t* handle);
-typedef void (*uv_prepare_cb)(uv_prepare_t *handle);
-
-// callbacks with distinct sigs
-typedef void (*uv_walk_cb)(uv_handle_t *handle, void *arg);
-typedef void (*uv_poll_cb)(uv_poll_t *handle, int status, int events);
-typedef void (*uv_signal_cb)(uv_signal_t *handle, int signum);
-
-// Callback passed to uv_fs_event_start() which will be called
-// repeatedly after the handle is started. If the handle was started
-// with a directory the filename parameter will be a relative path to
-// a file contained in the directory. The events parameter is an ORed
-// mask of uv_fs_event elements.
-typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status);
-
-typedef struct {
- long tv_sec;
- long tv_nsec;
-} uv_timespec_t;
-
-typedef struct {
- uint64_t st_dev;
- uint64_t st_mode;
- uint64_t st_nlink;
- uint64_t st_uid;
- uint64_t st_gid;
- uint64_t st_rdev;
- uint64_t st_ino;
- uint64_t st_size;
- uint64_t st_blksize;
- uint64_t st_blocks;
- uint64_t st_flags;
- uint64_t st_gen;
- uv_timespec_t st_atim;
- uv_timespec_t st_mtim;
- uv_timespec_t st_ctim;
- uv_timespec_t st_birthtim;
-} uv_stat_t;
-
-typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, int status, const uv_stat_t* prev, const uv_stat_t* curr);
-
-// loop functions
-uv_loop_t *uv_default_loop();
-uv_loop_t* uv_loop_new(); // not documented; neither is uv_loop_delete
-int uv_loop_init(uv_loop_t* loop);
-int uv_loop_fork(uv_loop_t* loop);
-int uv_loop_alive(const uv_loop_t *loop);
-int uv_loop_close(uv_loop_t* loop);
-uint64_t uv_backend_timeout(uv_loop_t* loop);
-int uv_run(uv_loop_t *, uv_run_mode mode);
-int uv_backend_fd(const uv_loop_t* loop);
-// The narrative docs for the two time functions say 'const',
-// but the header does not.
-void uv_update_time(uv_loop_t* loop);
-uint64_t uv_now(uv_loop_t* loop);
-void uv_stop(uv_loop_t *);
-void uv_walk(uv_loop_t *loop, uv_walk_cb walk_cb, void *arg);
-
-// handle functions
-// uv_handle_t is the base type for all libuv handle types.
-
-void uv_ref(void *);
-void uv_unref(void *);
-int uv_has_ref(void *);
-void uv_close(void *handle, uv_close_cb close_cb);
-int uv_is_active(void *handle);
-int uv_is_closing(void *handle);
-
-// idle functions
-// Idle handles will run the given callback once per loop iteration, right
-// before the uv_prepare_t handles. Note: The notable difference with prepare
-// handles is that when there are active idle handles, the loop will perform a
-// zero timeout poll instead of blocking for i/o. Warning: Despite the name,
-// idle handles will get their callbacks called on every loop iteration, not
-// when the loop is actually "idle".
-int uv_idle_init(uv_loop_t *, uv_idle_t *idle);
-int uv_idle_start(uv_idle_t *idle, uv_idle_cb cb);
-int uv_idle_stop(uv_idle_t *idle);
-
-// prepare functions
-// Prepare handles will run the given callback once per loop iteration, right
-// before polling for i/o.
-int uv_prepare_init(uv_loop_t *, uv_prepare_t *prepare);
-int uv_prepare_start(uv_prepare_t *prepare, uv_prepare_cb cb);
-int uv_prepare_stop(uv_prepare_t *prepare);
-
-// check functions
-// Check handles will run the given callback once per loop iteration, right
-int uv_check_init(uv_loop_t *, uv_check_t *check);
-int uv_check_start(uv_check_t *check, uv_check_cb cb);
-int uv_check_stop(uv_check_t *check);
-
-// async functions
-// Async handles allow the user to "wakeup" the event loop and get a callback called from another thread.
-
-int uv_async_init(uv_loop_t *, uv_async_t*, uv_async_cb);
-int uv_async_send(uv_async_t*);
-
-// timer functions
-// Timer handles are used to schedule callbacks to be called in the future.
-int uv_timer_init(uv_loop_t *, uv_timer_t *handle);
-int uv_timer_start(uv_timer_t *handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat);
-int uv_timer_stop(uv_timer_t *handle);
-int uv_timer_again(uv_timer_t *handle);
-void uv_timer_set_repeat(uv_timer_t *handle, uint64_t repeat);
-uint64_t uv_timer_get_repeat(const uv_timer_t *handle);
-
-// signal functions
-// Signal handles implement Unix style signal handling on a per-event loop
-// bases.
-int uv_signal_init(uv_loop_t *loop, uv_signal_t *handle);
-int uv_signal_start(uv_signal_t *handle, uv_signal_cb signal_cb, int signum);
-int uv_signal_stop(uv_signal_t *handle);
-
-// poll functions Poll handles are used to watch file descriptors for
-// readability and writability, similar to the purpose of poll(2). It
-// is not okay to have multiple active poll handles for the same
-// socket, this can cause libuv to busyloop or otherwise malfunction.
-//
-// The purpose of poll handles is to enable integrating external
-// libraries that rely on the event loop to signal it about the socket
-// status changes, like c-ares or libssh2. Using uv_poll_t for any
-// other purpose is not recommended; uv_tcp_t, uv_udp_t, etc. provide
-// an implementation that is faster and more scalable than what can be
-// achieved with uv_poll_t, especially on Windows.
-//
-// Note On windows only sockets can be polled with poll handles. On
-// Unix any file descriptor that would be accepted by poll(2) can be
-// used.
-int uv_poll_init(uv_loop_t *loop, uv_poll_t *handle, int fd);
-
-// Initialize the handle using a socket descriptor. On Unix this is
-// identical to uv_poll_init(). On windows it takes a SOCKET handle;
-// SOCKET handles are another name for HANDLE objects in win32, and
-// those are defined as PVOID, even though they are not actually
-// pointers (they're small integers). CPython and PyPy both return
-// the SOCKET (as cast to an int) from the socket.fileno() method.
-// libuv uses ``uv_os_sock_t`` for this type, which is defined as an
-// int on unix.
-int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, GEVENT_UV_OS_SOCK_T socket);
-int uv_poll_start(uv_poll_t *handle, int events, uv_poll_cb cb);
-int uv_poll_stop(uv_poll_t *handle);
-
-// FS Event handles allow the user to monitor a given path for
-// changes, for example, if the file was renamed or there was a
-// generic change in it. This handle uses the best backend for the job
-// on each platform.
-//
-// Thereas also uv_fs_poll_t that uses stat for filesystems where
-// the kernel event isn't available.
-int uv_fs_event_init(uv_loop_t*, uv_fs_event_t*);
-int uv_fs_event_start(uv_fs_event_t*, uv_fs_event_cb, const char* path, unsigned int flags);
-int uv_fs_event_stop(uv_fs_event_t*);
-int uv_fs_event_getpath(uv_fs_event_t*, char* buffer, size_t* size);
-
-// FS Poll handles allow the user to monitor a given path for changes.
-// Unlike uv_fs_event_t, fs poll handles use stat to detect when a
-// file has changed so they can work on file systems where fs event
-// handles can't.
-//
-// This is a closer match to libev.
-int uv_fs_poll_init(void*, void*);
-int uv_fs_poll_start(void*, uv_fs_poll_cb, const char* path, unsigned int);
-int uv_fs_poll_stop(void*);
-
-
-/* Standard library */
-void* memset(void *b, int c, size_t len);
-
-
-/* gevent callbacks */
-// Implemented in Python code as 'def_extern'. In the case of poll callbacks and fs
-// callbacks, if *status* is less than 0, it will be passed in the revents
-// field. In cases of no extra arguments, revents will be 0.
-// These will be created as static functions at the end of the
-// _source.c and must be pre-declared at the top of that file if we
-// call them
-typedef void* GeventWatcherObject;
-extern "Python" {
- // Standard gevent._ffi.loop callbacks.
- int python_callback(GeventWatcherObject handle, int revents);
- void python_handle_error(GeventWatcherObject handle, int revents);
- void python_stop(GeventWatcherObject handle);
-
- void python_check_callback(uv_check_t* handle);
- void python_prepare_callback(uv_prepare_t* handle);
- void python_timer0_callback(uv_check_t* handle);
-
- // libuv specific callback
- void _uv_close_callback(uv_handle_t* handle);
- void python_sigchld_callback(uv_signal_t* handle, int signum);
- void python_queue_callback(uv_handle_t* handle, int revents);
-}
-// A variable we fill in.
-static void (*gevent_noop)(void* handle);
-
-static void _gevent_signal_callback1(uv_signal_t* handle, int arg);
-static void _gevent_async_callback0(uv_async_t* handle);
-static void _gevent_prepare_callback0(uv_prepare_t* handle);
-static void _gevent_timer_callback0(uv_timer_t* handle);
-static void _gevent_check_callback0(uv_check_t* handle);
-static void _gevent_idle_callback0(uv_idle_t* handle);
-static void _gevent_poll_callback2(uv_poll_t* handle, int status, int events);
-static void _gevent_fs_event_callback3(uv_fs_event_t* handle, const char* filename, int events, int status);
-
-typedef struct _gevent_fs_poll_s {
- uv_fs_poll_t handle;
- uv_stat_t curr;
- uv_stat_t prev;
-} gevent_fs_poll_t;
-
-static void _gevent_fs_poll_callback3(uv_fs_poll_t* handle, int status, const uv_stat_t* prev, const uv_stat_t* curr);
-
-static void gevent_uv_walk_callback_close(uv_handle_t* handle, void* arg);
-static void gevent_close_all_handles(uv_loop_t* loop);
-static void gevent_zero_timer(uv_timer_t* handle);
-static void gevent_zero_prepare(uv_prepare_t* handle);
-static void gevent_zero_check(uv_check_t* handle);
-static void gevent_zero_loop(uv_loop_t* handle);
diff --git a/python/gevent/libuv/_corecffi_source.c b/python/gevent/libuv/_corecffi_source.c
deleted file mode 100644
index 83fe82e..0000000
--- a/python/gevent/libuv/_corecffi_source.c
+++ /dev/null
@@ -1,181 +0,0 @@
-#include <string.h>
-#include "uv.h"
-
-typedef void* GeventWatcherObject;
-
-static int python_callback(GeventWatcherObject handle, int revents);
-static void python_queue_callback(uv_handle_t* watcher_ptr, int revents);
-static void python_handle_error(GeventWatcherObject handle, int revents);
-static void python_stop(GeventWatcherObject handle);
-
-static void _gevent_noop(void* handle) {}
-
-static void (*gevent_noop)(void* handle) = &_gevent_noop;
-
-static void _gevent_generic_callback1_unused(uv_handle_t* watcher, int arg)
-{
- // Python code may set this to NULL or even change it
- // out from under us, which would tend to break things.
- GeventWatcherObject handle = watcher->data;
- const int cb_result = python_callback(handle, arg);
- switch(cb_result) {
- case -1:
- // in case of exception, call self.loop.handle_error;
- // this function is also responsible for stopping the watcher
- // and allowing memory to be freed
- python_handle_error(handle, arg);
- break;
- case 1:
- // Code to stop the event IF NEEDED. Note that if python_callback
- // has disposed of the last reference to the handle,
- // `watcher` could now be invalid/disposed memory!
- if (!uv_is_active(watcher)) {
- if (watcher->data != handle) {
- if (watcher->data) {
- // If Python set the data to NULL, then they
- // expected to be stopped. That's fine.
- // Otherwise, something weird happened.
- fprintf(stderr,
- "WARNING: gevent: watcher handle changed in callback "
- "from %p to %p for watcher at %p of type %d\n",
- handle, watcher->data, watcher, watcher->type);
- // There's a very good chance that the object the
- // handle referred to has been changed and/or the
- // old handle has been deallocated (most common), so
- // passing the old handle will crash. Instead we
- // pass a sigil to let python distinguish this case.
- python_stop(NULL);
- }
- }
- else {
- python_stop(handle);
- }
- }
- break;
- case 2:
- // watcher is already stopped and dead, nothing to do.
- break;
- default:
- fprintf(stderr,
- "WARNING: gevent: Unexpected return value %d from Python callback "
- "for watcher %p (of type %d) and handle %p\n",
- cb_result,
- watcher, watcher->type, handle);
- // XXX: Possible leaking of resources here? Should we be
- // closing the watcher?
- }
-}
-
-
-static void _gevent_generic_callback1(uv_handle_t* watcher, int arg)
-{
- python_queue_callback(watcher, arg);
-}
-
-static void _gevent_generic_callback0(uv_handle_t* handle)
-{
- _gevent_generic_callback1(handle, 0);
-}
-
-static void _gevent_async_callback0(uv_async_t* handle)
-{
- _gevent_generic_callback0((uv_handle_t*)handle);
-}
-
-static void _gevent_timer_callback0(uv_timer_t* handle)
-{
- _gevent_generic_callback0((uv_handle_t*)handle);
-}
-
-static void _gevent_prepare_callback0(uv_prepare_t* handle)
-{
- _gevent_generic_callback0((uv_handle_t*)handle);
-}
-
-static void _gevent_check_callback0(uv_check_t* handle)
-{
- _gevent_generic_callback0((uv_handle_t*)handle);
-}
-
-static void _gevent_idle_callback0(uv_idle_t* handle)
-{
- _gevent_generic_callback0((uv_handle_t*)handle);
-}
-
-static void _gevent_signal_callback1(uv_signal_t* handle, int signum)
-{
- _gevent_generic_callback1((uv_handle_t*)handle, signum);
-}
-
-
-static void _gevent_poll_callback2(void* handle, int status, int events)
-{
- _gevent_generic_callback1(handle, status < 0 ? status : events);
-}
-
-static void _gevent_fs_event_callback3(void* handle, const char* filename, int events, int status)
-{
- _gevent_generic_callback1(handle, status < 0 ? status : events);
-}
-
-
-typedef struct _gevent_fs_poll_s {
- uv_fs_poll_t handle;
- uv_stat_t curr;
- uv_stat_t prev;
-} gevent_fs_poll_t;
-
-static void _gevent_fs_poll_callback3(void* handlep, int status, const uv_stat_t* prev, const uv_stat_t* curr)
-{
- // stat pointers are valid for this callback only.
- // if given, copy them into our structure, where they can be reached
- // from python, just like libev's watcher does, before calling
- // the callback.
-
- // The callback is invoked with status < 0 if path does not exist
- // or is inaccessible. The watcher is not stopped but your
- // callback is not called again until something changes (e.g. when
- // the file is created or the error reason changes).
- // In that case the fields will be 0 in curr/prev.
-
-
- gevent_fs_poll_t* handle = (gevent_fs_poll_t*)handlep;
- assert(status == 0);
-
- handle->curr = *curr;
- handle->prev = *prev;
-
- _gevent_generic_callback1((uv_handle_t*)handle, 0);
-}
-
-static void gevent_uv_walk_callback_close(uv_handle_t* handle, void* arg)
-{
- if( handle && !uv_is_closing(handle) ) {
- uv_close(handle, NULL);
- }
-}
-
-static void gevent_close_all_handles(uv_loop_t* loop)
-{
- uv_walk(loop, gevent_uv_walk_callback_close, NULL);
-}
-
-static void gevent_zero_timer(uv_timer_t* handle)
-{
- memset(handle, 0, sizeof(uv_timer_t));
-}
-
-static void gevent_zero_check(uv_check_t* handle)
-{
- memset(handle, 0, sizeof(uv_check_t));
-}
-
-static void gevent_zero_prepare(uv_prepare_t* handle)
-{
- memset(handle, 0, sizeof(uv_prepare_t));
-}
-
-static void gevent_zero_loop(uv_loop_t* handle)
-{
- memset(handle, 0, sizeof(uv_loop_t));
-}
diff --git a/python/gevent/libuv/loop.py b/python/gevent/libuv/loop.py
deleted file mode 100644
index 0f317c0..0000000
--- a/python/gevent/libuv/loop.py
+++ /dev/null
@@ -1,601 +0,0 @@
-"""
-libuv loop implementation
-"""
-# pylint: disable=no-member
-from __future__ import absolute_import, print_function
-
-import os
-from collections import defaultdict
-from collections import namedtuple
-from operator import delitem
-import signal
-
-from gevent._ffi import _dbg # pylint: disable=unused-import
-from gevent._ffi.loop import AbstractLoop
-from gevent.libuv import _corecffi # pylint:disable=no-name-in-module,import-error
-from gevent._ffi.loop import assign_standard_callbacks
-from gevent._ffi.loop import AbstractCallbacks
-from gevent._util import implementer
-from gevent._interfaces import ILoop
-
-ffi = _corecffi.ffi
-libuv = _corecffi.lib
-
-__all__ = [
-]
-
-
-class _Callbacks(AbstractCallbacks):
-
- def _find_loop_from_c_watcher(self, watcher_ptr):
- loop_handle = ffi.cast('uv_handle_t*', watcher_ptr).data
- return self.from_handle(loop_handle) if loop_handle else None
-
- def python_sigchld_callback(self, watcher_ptr, _signum):
- self.from_handle(ffi.cast('uv_handle_t*', watcher_ptr).data)._sigchld_callback()
-
- def python_timer0_callback(self, watcher_ptr):
- return self.python_prepare_callback(watcher_ptr)
-
- def python_queue_callback(self, watcher_ptr, revents):
- watcher_handle = watcher_ptr.data
- the_watcher = self.from_handle(watcher_handle)
-
- the_watcher.loop._queue_callback(watcher_ptr, revents)
-
-
-_callbacks = assign_standard_callbacks(
- ffi, libuv, _Callbacks,
- [('python_sigchld_callback', None),
- ('python_timer0_callback', None),
- ('python_queue_callback', None)])
-
-from gevent._ffi.loop import EVENTS
-GEVENT_CORE_EVENTS = EVENTS # export
-
-from gevent.libuv import watcher as _watchers # pylint:disable=no-name-in-module
-
-_events_to_str = _watchers._events_to_str # export
-
-READ = libuv.UV_READABLE
-WRITE = libuv.UV_WRITABLE
-
-def get_version():
- uv_bytes = ffi.string(libuv.uv_version_string())
- if not isinstance(uv_bytes, str):
- # Py3
- uv_str = uv_bytes.decode("ascii")
- else:
- uv_str = uv_bytes
-
- return 'libuv-' + uv_str
-
-def get_header_version():
- return 'libuv-%d.%d.%d' % (libuv.UV_VERSION_MAJOR, libuv.UV_VERSION_MINOR, libuv.UV_VERSION_PATCH)
-
-def supported_backends():
- return ['default']
-
-@implementer(ILoop)
-class loop(AbstractLoop):
-
- # XXX: Undocumented. Maybe better named 'timer_resolution'? We can't
- # know this in general on libev
- min_sleep_time = 0.001 # 1ms
-
- error_handler = None
-
- _CHECK_POINTER = 'uv_check_t *'
-
- _PREPARE_POINTER = 'uv_prepare_t *'
- _PREPARE_CALLBACK_SIG = "void(*)(void*)"
-
- _TIMER_POINTER = _CHECK_POINTER # This is poorly named. It's for the callback "timer"
-
- def __init__(self, flags=None, default=None):
- AbstractLoop.__init__(self, ffi, libuv, _watchers, flags, default)
- self.__loop_pid = os.getpid()
- self._child_watchers = defaultdict(list)
- self._io_watchers = dict()
- self._fork_watchers = set()
- self._pid = os.getpid()
- self._default = self._ptr == libuv.uv_default_loop()
- self._queued_callbacks = []
-
- def _queue_callback(self, watcher_ptr, revents):
- self._queued_callbacks.append((watcher_ptr, revents))
-
- def _init_loop(self, flags, default):
- if default is None:
- default = True
- # Unlike libev, libuv creates a new default
- # loop automatically if the old default loop was
- # closed.
-
- if default:
- # XXX: If the default loop had been destroyed, this
- # will create a new one, but we won't destroy it
- ptr = libuv.uv_default_loop()
- else:
- ptr = libuv.uv_loop_new()
-
-
- if not ptr:
- raise SystemError("Failed to get loop")
-
- # Track whether or not any object has destroyed
- # this loop. See _can_destroy_default_loop
- ptr.data = ptr
- return ptr
-
- _signal_idle = None
-
- def _init_and_start_check(self):
- libuv.uv_check_init(self._ptr, self._check)
- libuv.uv_check_start(self._check, libuv.python_check_callback)
- libuv.uv_unref(self._check)
-
- # We also have to have an idle watcher to be able to handle
- # signals in a timely manner. Without them, libuv won't loop again
- # and call into its check and prepare handlers.
- # Note that this basically forces us into a busy-loop
- # XXX: As predicted, using an idle watcher causes our process
- # to eat 100% CPU time. We instead use a timer with a max of a .3 second
- # delay to notice signals. Note that this timeout also implements fork
- # watchers, effectively.
-
- # XXX: Perhaps we could optimize this to notice when there are other
- # timers in the loop and start/stop it then. When we have a callback
- # scheduled, this should also be the same and unnecessary?
- # libev does takes this basic approach on Windows.
- self._signal_idle = ffi.new("uv_timer_t*")
- libuv.uv_timer_init(self._ptr, self._signal_idle)
- self._signal_idle.data = self._handle_to_self
- sig_cb = ffi.cast('void(*)(uv_timer_t*)', libuv.python_check_callback)
- libuv.uv_timer_start(self._signal_idle,
- sig_cb,
- 300,
- 300)
- libuv.uv_unref(self._signal_idle)
-
- def _run_callbacks(self):
- # Manually handle fork watchers.
- curpid = os.getpid()
- if curpid != self._pid:
- self._pid = curpid
- for watcher in self._fork_watchers:
- watcher._on_fork()
-
-
- # The contents of queued_callbacks at this point should be timers
- # that expired when the loop began along with any idle watchers.
- # We need to run them so that any manual callbacks they want to schedule
- # get added to the list and ran next before we go on to poll for IO.
- # This is critical for libuv on linux: closing a socket schedules some manual
- # callbacks to actually stop the watcher; if those don't run before
- # we poll for IO, then libuv can abort the process for the closed file descriptor.
-
- # XXX: There's still a race condition here because we may not run *all* the manual
- # callbacks. We need a way to prioritize those.
-
- # Running these before the manual callbacks lead to some
- # random test failures. In test__event.TestEvent_SetThenClear
- # we would get a LoopExit sometimes. The problem occurred when
- # a timer expired on entering the first loop; we would process
- # it there, and then process the callback that it created
- # below, leaving nothing for the loop to do. Having the
- # self.run() manually process manual callbacks before
- # continuing solves the problem. (But we must still run callbacks
- # here again.)
- self._prepare_ran_callbacks = self.__run_queued_callbacks()
-
- super(loop, self)._run_callbacks()
-
- def _init_and_start_prepare(self):
- libuv.uv_prepare_init(self._ptr, self._prepare)
- libuv.uv_prepare_start(self._prepare, libuv.python_prepare_callback)
- libuv.uv_unref(self._prepare)
-
- def _init_callback_timer(self):
- libuv.uv_check_init(self._ptr, self._timer0)
-
- def _stop_callback_timer(self):
- libuv.uv_check_stop(self._timer0)
-
- def _start_callback_timer(self):
- # The purpose of the callback timer is to ensure that we run
- # callbacks as soon as possible on the next iteration of the event loop.
-
- # In libev, we set a 0 duration timer with a no-op callback.
- # This executes immediately *after* the IO poll is done (it
- # actually determines the time that the IO poll will block
- # for), so having the timer present simply spins the loop, and
- # our normal prepare watcher kicks in to run the callbacks.
-
- # In libuv, however, timers are run *first*, before prepare
- # callbacks and before polling for IO. So a no-op 0 duration
- # timer actually does *nothing*. (Also note that libev queues all
- # watchers found during IO poll to run at the end (I think), while libuv
- # runs them in uv__io_poll itself.)
-
- # From the loop inside uv_run:
- # while True:
- # uv__update_time(loop);
- # uv__run_timers(loop);
- # # we don't use pending watchers. They are how libuv
- # # implements the pipe/udp/tcp streams.
- # ran_pending = uv__run_pending(loop);
- # uv__run_idle(loop);
- # uv__run_prepare(loop);
- # ...
- # uv__io_poll(loop, timeout); # <--- IO watchers run here!
- # uv__run_check(loop);
-
- # libev looks something like this (pseudo code because the real code is
- # hard to read):
- #
- # do {
- # run_fork_callbacks();
- # run_prepare_callbacks();
- # timeout = min(time of all timers or normal block time)
- # io_poll() # <--- Only queues IO callbacks
- # update_now(); calculate_expired_timers();
- # run callbacks in this order: (although specificying priorities changes it)
- # check
- # stat
- # child
- # signal
- # timer
- # io
- # }
-
- # So instead of running a no-op and letting the side-effect of spinning
- # the loop run the callbacks, we must explicitly run them here.
-
- # If we don't, test__systemerror:TestCallback will be flaky, failing
- # one time out of ~20, depending on timing.
-
- # To get them to run immediately after this current loop,
- # we use a check watcher, instead of a 0 duration timer entirely.
- # If we use a 0 duration timer, we can get stuck in a timer loop.
- # Python 3.6 fails in test_ftplib.py
-
- # As a final note, if we have not yet entered the loop *at
- # all*, and a timer was created with a duration shorter than
- # the amount of time it took for us to enter the loop in the
- # first place, it may expire and get called before our callback
- # does. This could also lead to test__systemerror:TestCallback
- # appearing to be flaky.
-
- # As yet another final note, if we are currently running a
- # timer callback, meaning we're inside uv__run_timers() in C,
- # and the Python starts a new timer, if the Python code then
- # update's the loop's time, it's possible that timer will
- # expire *and be run in the same iteration of the loop*. This
- # is trivial to do: In sequential code, anything after
- # `gevent.sleep(0.1)` is running in a timer callback. Starting
- # a new timer---e.g., another gevent.sleep() call---will
- # update the time, *before* uv__run_timers exits, meaning
- # other timers get a chance to run before our check or prepare
- # watcher callbacks do. Therefore, we do indeed have to have a 0
- # timer to run callbacks---it gets inserted before any other user
- # timers---ideally, this should be especially careful about how much time
- # it runs for.
-
- # AND YET: We can't actually do that. We get timeouts that I haven't fully
- # investigated if we do. Probably stuck in a timer loop.
-
- # As a partial remedy to this, unlike libev, our timer watcher
- # class doesn't update the loop time by default.
-
- libuv.uv_check_start(self._timer0, libuv.python_timer0_callback)
-
-
- def _stop_aux_watchers(self):
- assert self._prepare
- assert self._check
- assert self._signal_idle
- libuv.uv_prepare_stop(self._prepare)
- libuv.uv_ref(self._prepare) # Why are we doing this?
-
- libuv.uv_check_stop(self._check)
- libuv.uv_ref(self._check)
-
- libuv.uv_timer_stop(self._signal_idle)
- libuv.uv_ref(self._signal_idle)
-
- libuv.uv_check_stop(self._timer0)
-
- def _setup_for_run_callback(self):
- self._start_callback_timer()
- libuv.uv_ref(self._timer0)
-
-
- def _can_destroy_loop(self, ptr):
- # We're being asked to destroy a loop that's,
- # at the time it was constructed, was the default loop.
- # If loop objects were constructed more than once,
- # it may have already been destroyed, though.
- # We track this in the data member.
- return ptr.data
-
- def _destroy_loop(self, ptr):
- ptr.data = ffi.NULL
- libuv.uv_stop(ptr)
-
- libuv.gevent_close_all_handles(ptr)
-
- closed_failed = libuv.uv_loop_close(ptr)
- if closed_failed:
- assert closed_failed == libuv.UV_EBUSY
- # We already closed all the handles. Run the loop
- # once to let them be cut off from the loop.
- ran_has_more_callbacks = libuv.uv_run(ptr, libuv.UV_RUN_ONCE)
- if ran_has_more_callbacks:
- libuv.uv_run(ptr, libuv.UV_RUN_NOWAIT)
- closed_failed = libuv.uv_loop_close(ptr)
- assert closed_failed == 0, closed_failed
-
- # Destroy the native resources *after* we have closed
- # the loop. If we do it before, walking the handles
- # attached to the loop is likely to segfault.
-
- libuv.gevent_zero_check(self._check)
- libuv.gevent_zero_check(self._timer0)
- libuv.gevent_zero_prepare(self._prepare)
- libuv.gevent_zero_timer(self._signal_idle)
- del self._check
- del self._prepare
- del self._signal_idle
- del self._timer0
-
- libuv.gevent_zero_loop(ptr)
-
- # Destroy any watchers we're still holding on to.
- del self._io_watchers
- del self._fork_watchers
- del self._child_watchers
-
-
- def debug(self):
- """
- Return all the handles that are open and their ref status.
- """
- handle_state = namedtuple("HandleState",
- ['handle',
- 'type',
- 'watcher',
- 'ref',
- 'active',
- 'closing'])
- handles = []
-
- # XXX: Convert this to a modern callback.
- def walk(handle, _arg):
- data = handle.data
- if data:
- watcher = ffi.from_handle(data)
- else:
- watcher = None
- handles.append(handle_state(handle,
- ffi.string(libuv.uv_handle_type_name(handle.type)),
- watcher,
- libuv.uv_has_ref(handle),
- libuv.uv_is_active(handle),
- libuv.uv_is_closing(handle)))
-
- libuv.uv_walk(self._ptr,
- ffi.callback("void(*)(uv_handle_t*,void*)",
- walk),
- ffi.NULL)
- return handles
-
- def ref(self):
- pass
-
- def unref(self):
- # XXX: Called by _run_callbacks.
- pass
-
- def break_(self, how=None):
- libuv.uv_stop(self._ptr)
-
- def reinit(self):
- # TODO: How to implement? We probably have to simply
- # re-__init__ this whole class? Does it matter?
- # OR maybe we need to uv_walk() and close all the handles?
-
- # XXX: libuv < 1.12 simply CANNOT handle a fork unless you immediately
- # exec() in the child. There are multiple calls to abort() that
- # will kill the child process:
- # - The OS X poll implementation (kqueue) aborts on an error return
- # value; since kqueue FDs can't be inherited, then the next call
- # to kqueue in the child will fail and get aborted; fork() is likely
- # to be called during the gevent loop, meaning we're deep inside the
- # runloop already, so we can't even close the loop that we're in:
- # it's too late, the next call to kqueue is already scheduled.
- # - The threadpool, should it be in use, also aborts
- # (https://github.com/joyent/libuv/pull/1136)
- # - There global shared state that breaks signal handling
- # and leads to an abort() in the child, EVEN IF the loop in the parent
- # had already been closed
- # (https://github.com/joyent/libuv/issues/1405)
-
- # In 1.12, the uv_loop_fork function was added (by gevent!)
- libuv.uv_loop_fork(self._ptr)
-
- _prepare_ran_callbacks = False
-
- def __run_queued_callbacks(self):
- if not self._queued_callbacks:
- return False
-
- cbs = list(self._queued_callbacks)
- self._queued_callbacks = []
-
- for watcher_ptr, arg in cbs:
- handle = watcher_ptr.data
- if not handle:
- # It's been stopped and possibly closed
- assert not libuv.uv_is_active(watcher_ptr)
- continue
- val = _callbacks.python_callback(handle, arg)
- if val == -1:
- _callbacks.python_handle_error(handle, arg)
- elif val == 1:
- if not libuv.uv_is_active(watcher_ptr):
- if watcher_ptr.data != handle:
- if watcher_ptr.data:
- _callbacks.python_stop(None)
- else:
- _callbacks.python_stop(handle)
- return True
-
-
- def run(self, nowait=False, once=False):
- # we can only respect one flag or the other.
- # nowait takes precedence because it can't block
- mode = libuv.UV_RUN_DEFAULT
- if once:
- mode = libuv.UV_RUN_ONCE
- if nowait:
- mode = libuv.UV_RUN_NOWAIT
-
- if mode == libuv.UV_RUN_DEFAULT:
- while self._ptr and self._ptr.data:
- # This is here to better preserve order guarantees. See _run_callbacks
- # for details.
- # It may get run again from the prepare watcher, so potentially we
- # could take twice as long as the switch interval.
- self._run_callbacks()
- self._prepare_ran_callbacks = False
- ran_status = libuv.uv_run(self._ptr, libuv.UV_RUN_ONCE)
- # Note that we run queued callbacks when the prepare watcher runs,
- # thus accounting for timers that expired before polling for IO,
- # and idle watchers. This next call should get IO callbacks and
- # callbacks from timers that expired *after* polling for IO.
- ran_callbacks = self.__run_queued_callbacks()
-
- if not ran_status and not ran_callbacks and not self._prepare_ran_callbacks:
- # A return of 0 means there are no referenced and
- # active handles. The loop is over.
- # If we didn't run any callbacks, then we couldn't schedule
- # anything to switch in the future, so there's no point
- # running again.
- return ran_status
- return 0 # Somebody closed the loop
-
- result = libuv.uv_run(self._ptr, mode)
- self.__run_queued_callbacks()
- return result
-
- def now(self):
- # libuv's now is expressed as an integer number of
- # milliseconds, so to get it compatible with time.time units
- # that this method is supposed to return, we have to divide by 1000.0
- now = libuv.uv_now(self._ptr)
- return now / 1000.0
-
- def update_now(self):
- libuv.uv_update_time(self._ptr)
-
- def fileno(self):
- if self._ptr:
- fd = libuv.uv_backend_fd(self._ptr)
- if fd >= 0:
- return fd
-
- _sigchld_watcher = None
- _sigchld_callback_ffi = None
-
- def install_sigchld(self):
- if not self.default:
- return
-
- if self._sigchld_watcher:
- return
-
- self._sigchld_watcher = ffi.new('uv_signal_t*')
- libuv.uv_signal_init(self._ptr, self._sigchld_watcher)
- self._sigchld_watcher.data = self._handle_to_self
-
- libuv.uv_signal_start(self._sigchld_watcher,
- libuv.python_sigchld_callback,
- signal.SIGCHLD)
-
- def reset_sigchld(self):
- if not self.default or not self._sigchld_watcher:
- return
-
- libuv.uv_signal_stop(self._sigchld_watcher)
- # Must go through this to manage the memory lifetime
- # correctly. Alternately, we could just stop it and restart
- # it in install_sigchld?
- _watchers.watcher._watcher_ffi_close(self._sigchld_watcher)
- del self._sigchld_watcher
-
-
- def _sigchld_callback(self):
- # Signals can arrive at (relatively) any time. To eliminate
- # race conditions, and behave more like libev, we "queue"
- # sigchld to run when we run callbacks.
- while True:
- try:
- pid, status, _usage = os.wait3(os.WNOHANG)
- except OSError:
- # Python 3 raises ChildProcessError
- break
-
- if pid == 0:
- break
- children_watchers = self._child_watchers.get(pid, []) + self._child_watchers.get(0, [])
- for watcher in children_watchers:
- self.run_callback(watcher._set_waitpid_status, pid, status)
-
- # Don't invoke child watchers for 0 more than once
- self._child_watchers[0] = []
-
- def _register_child_watcher(self, watcher):
- self._child_watchers[watcher._pid].append(watcher)
-
- def _unregister_child_watcher(self, watcher):
- try:
- # stop() should be idempotent
- self._child_watchers[watcher._pid].remove(watcher)
- except ValueError:
- pass
-
- # Now's a good time to clean up any dead lists we don't need
- # anymore
- for pid in list(self._child_watchers):
- if not self._child_watchers[pid]:
- del self._child_watchers[pid]
-
- def io(self, fd, events, ref=True, priority=None):
- # We rely on hard references here and explicit calls to
- # close() on the returned object to correctly manage
- # the watcher lifetimes.
-
- io_watchers = self._io_watchers
- try:
- io_watcher = io_watchers[fd]
- assert io_watcher._multiplex_watchers, ("IO Watcher %s unclosed but should be dead" % io_watcher)
- except KeyError:
- # Start the watcher with just the events that we're interested in.
- # as multiplexers are added, the real event mask will be updated to keep in sync.
- # If we watch for too much, we get spurious wakeups and busy loops.
- io_watcher = self._watchers.io(self, fd, 0)
- io_watchers[fd] = io_watcher
- io_watcher._no_more_watchers = lambda: delitem(io_watchers, fd)
-
- return io_watcher.multiplex(events)
-
- def prepare(self, ref=True, priority=None):
- # We run arbitrary code in python_prepare_callback. That could switch
- # greenlets. If it does that while also manipulating the active prepare
- # watchers, we could corrupt the process state, since the prepare watcher
- # queue is iterated on the stack (on unix). We could workaround this by implementing
- # prepare watchers in pure Python.
- # See https://github.com/gevent/gevent/issues/1126
- raise TypeError("prepare watchers are not currently supported in libuv. "
- "If you need them, please contact the maintainers.")
diff --git a/python/gevent/libuv/watcher.py b/python/gevent/libuv/watcher.py
deleted file mode 100644
index 035cb43..0000000
--- a/python/gevent/libuv/watcher.py
+++ /dev/null
@@ -1,732 +0,0 @@
-# pylint: disable=too-many-lines, protected-access, redefined-outer-name, not-callable
-# pylint: disable=no-member
-from __future__ import absolute_import, print_function
-
-import functools
-import sys
-
-from gevent.libuv import _corecffi # pylint:disable=no-name-in-module,import-error
-
-ffi = _corecffi.ffi
-libuv = _corecffi.lib
-
-from gevent._ffi import watcher as _base
-from gevent._ffi import _dbg
-
-_closing_watchers = set()
-
-# In debug mode, it would be nice to be able to clear the memory of
-# the watcher (its size determined by
-# libuv.uv_handle_size(ffi_watcher.type)) using memset so that if we
-# are using it after it's supposedly been closed and deleted, we'd
-# catch it sooner. BUT doing so breaks test__threadpool. We get errors
-# about `pthread_mutex_lock[3]: Invalid argument` (and sometimes we
-# crash) suggesting either that we're writing on memory that doesn't
-# belong to us, somehow, or that we haven't actually lost all
-# references...
-_uv_close_callback = ffi.def_extern(name='_uv_close_callback')(_closing_watchers.remove)
-
-
-_events = [(libuv.UV_READABLE, "READ"),
- (libuv.UV_WRITABLE, "WRITE")]
-
-def _events_to_str(events): # export
- return _base.events_to_str(events, _events)
-
-class UVFuncallError(ValueError):
- pass
-
-class libuv_error_wrapper(object):
- # Makes sure that everything stored as a function
- # on the wrapper instances (classes, actually,
- # because this is used by the metaclass)
- # checks its return value and raises an error.
- # This expects that everything we call has an int
- # or void return value and follows the conventions
- # of error handling (that negative values are errors)
- def __init__(self, uv):
- self._libuv = uv
-
- def __getattr__(self, name):
- libuv_func = getattr(self._libuv, name)
-
- @functools.wraps(libuv_func)
- def wrap(*args, **kwargs):
- if args and isinstance(args[0], watcher):
- args = args[1:]
- res = libuv_func(*args, **kwargs)
- if res is not None and res < 0:
- raise UVFuncallError(
- str(ffi.string(libuv.uv_err_name(res)).decode('ascii')
- + ' '
- + ffi.string(libuv.uv_strerror(res)).decode('ascii'))
- + " Args: " + repr(args) + " KWARGS: " + repr(kwargs)
- )
- return res
-
- setattr(self, name, wrap)
-
- return wrap
-
-
-class ffi_unwrapper(object):
- # undoes the wrapping of libuv_error_wrapper for
- # the methods used by the metaclass that care
-
- def __init__(self, ff):
- self._ffi = ff
-
- def __getattr__(self, name):
- return getattr(self._ffi, name)
-
- def addressof(self, lib, name):
- assert isinstance(lib, libuv_error_wrapper)
- return self._ffi.addressof(libuv, name)
-
-
-class watcher(_base.watcher):
- _FFI = ffi_unwrapper(ffi)
- _LIB = libuv_error_wrapper(libuv)
-
- _watcher_prefix = 'uv'
- _watcher_struct_pattern = '%s_t'
-
- @classmethod
- def _watcher_ffi_close(cls, ffi_watcher):
- # Managing the lifetime of _watcher is tricky.
- # They have to be uv_close()'d, but that only
- # queues them to be closed in the *next* loop iteration.
- # The memory must stay valid for at least that long,
- # or assert errors are triggered. We can't use a ffi.gc()
- # pointer to queue the uv_close, because by the time the
- # destructor is called, there's no way to keep the memory alive
- # and it could be re-used.
- # So here we resort to resurrecting the pointer object out
- # of our scope, keeping it alive past this object's lifetime.
- # We then use the uv_close callback to handle removing that
- # reference. There's no context passed to the close callback,
- # so we have to do this globally.
-
- # Sadly, doing this causes crashes if there were multiple
- # watchers for a given FD, so we have to take special care
- # about that. See https://github.com/gevent/gevent/issues/790#issuecomment-208076604
-
- # Note that this cannot be a __del__ method, because we store
- # the CFFI handle to self on self, which is a cycle, and
- # objects with a __del__ method cannot be collected on CPython < 3.4
-
- # Instead, this is arranged as a callback to GC when the
- # watcher class dies. Obviously it's important to keep the ffi
- # watcher alive.
- # We can pass in "subclasses" if uv_handle_t that line up at the C level,
- # but that don't in CFFI without a cast. But be careful what we use the cast
- # for, don't pass it back to C.
- ffi_handle_watcher = cls._FFI.cast('uv_handle_t*', ffi_watcher)
- if ffi_handle_watcher.type and not libuv.uv_is_closing(ffi_watcher):
- # If the type isn't set, we were never properly initialized,
- # and trying to close it results in libuv terminating the process.
- # Sigh. Same thing if it's already in the process of being
- # closed.
- _closing_watchers.add(ffi_watcher)
- libuv.uv_close(ffi_watcher, libuv._uv_close_callback)
-
- ffi_handle_watcher.data = ffi.NULL
-
-
- def _watcher_ffi_set_init_ref(self, ref):
- self.ref = ref
-
- def _watcher_ffi_init(self, args):
- # TODO: we could do a better job chokepointing this
- return self._watcher_init(self.loop.ptr,
- self._watcher,
- *args)
-
- def _watcher_ffi_start(self):
- self._watcher_start(self._watcher, self._watcher_callback)
-
- def _watcher_ffi_stop(self):
- if self._watcher:
- # The multiplexed io watcher deletes self._watcher
- # when it closes down. If that's in the process of
- # an error handler, AbstractCallbacks.unhandled_onerror
- # will try to close us again.
- self._watcher_stop(self._watcher)
-
- @_base.only_if_watcher
- def _watcher_ffi_ref(self):
- libuv.uv_ref(self._watcher)
-
- @_base.only_if_watcher
- def _watcher_ffi_unref(self):
- libuv.uv_unref(self._watcher)
-
- def _watcher_ffi_start_unref(self):
- pass
-
- def _watcher_ffi_stop_ref(self):
- pass
-
- def _get_ref(self):
- # Convert 1/0 to True/False
- if self._watcher is None:
- return None
- return True if libuv.uv_has_ref(self._watcher) else False
-
- def _set_ref(self, value):
- if value:
- self._watcher_ffi_ref()
- else:
- self._watcher_ffi_unref()
-
- ref = property(_get_ref, _set_ref)
-
- def feed(self, _revents, _callback, *_args):
- raise Exception("Not implemented")
-
-class io(_base.IoMixin, watcher):
- _watcher_type = 'poll'
- _watcher_callback_name = '_gevent_poll_callback2'
-
- # On Windows is critical to be able to garbage collect these
- # objects in a timely fashion so that they don't get reused
- # for multiplexing completely different sockets. This is because
- # uv_poll_init_socket does a lot of setup for the socket to make
- # polling work. If get reused for another socket that has the same
- # fileno, things break badly. (In theory this could be a problem
- # on posix too, but in practice it isn't).
-
- # TODO: We should probably generalize this to all
- # ffi watchers. Avoiding GC cycles as much as possible
- # is a good thing, and potentially allocating new handles
- # as needed gets us better memory locality.
-
- # Especially on Windows, we must also account for the case that a
- # reference to this object has leaked (e.g., the socket object is
- # still around), but the fileno has been closed and a new one
- # opened. We must still get a new native watcher at that point. We
- # handle this case by simply making sure that we don't even have
- # a native watcher until the object is started, and we shut it down
- # when the object is stopped.
-
- # XXX: I was able to solve at least Windows test_ftplib.py issues
- # with more of a careful use of io objects in socket.py, so
- # delaying this entirely is at least temporarily on hold. Instead
- # sticking with the _watcher_create function override for the
- # moment.
-
- # XXX: Note 2: Moving to a deterministic close model, which was necessary
- # for PyPy, also seems to solve the Windows issues. So we're completely taking
- # this object out of the loop's registration; we don't want GC callbacks and
- # uv_close anywhere *near* this object.
-
- _watcher_registers_with_loop_on_create = False
-
- EVENT_MASK = libuv.UV_READABLE | libuv.UV_WRITABLE | libuv.UV_DISCONNECT
-
- _multiplex_watchers = ()
-
- def __init__(self, loop, fd, events, ref=True, priority=None):
- super(io, self).__init__(loop, fd, events, ref=ref, priority=priority, _args=(fd,))
- self._fd = fd
- self._events = events
- self._multiplex_watchers = []
-
- def _get_fd(self):
- return self._fd
-
- @_base.not_while_active
- def _set_fd(self, fd):
- self._fd = fd
- self._watcher_ffi_init((fd,))
-
- def _get_events(self):
- return self._events
-
- def _set_events(self, events):
- if events == self._events:
- return
- self._events = events
- if self.active:
- # We're running but libuv specifically says we can
- # call start again to change our event mask.
- assert self._handle is not None
- self._watcher_start(self._watcher, self._events, self._watcher_callback)
-
- events = property(_get_events, _set_events)
-
- def _watcher_ffi_start(self):
- self._watcher_start(self._watcher, self._events, self._watcher_callback)
-
- if sys.platform.startswith('win32'):
- # uv_poll can only handle sockets on Windows, but the plain
- # uv_poll_init we call on POSIX assumes that the fileno
- # argument is already a C fileno, as created by
- # _get_osfhandle. C filenos are limited resources, must be
- # closed with _close. So there are lifetime issues with that:
- # calling the C function _close to dispose of the fileno
- # *also* closes the underlying win32 handle, possibly
- # prematurely. (XXX: Maybe could do something with weak
- # references? But to what?)
-
- # All libuv wants to do with the fileno in uv_poll_init is
- # turn it back into a Win32 SOCKET handle.
-
- # Now, libuv provides uv_poll_init_socket, which instead of
- # taking a C fileno takes the SOCKET, avoiding the need to dance with
- # the C runtime.
-
- # It turns out that SOCKET (win32 handles in general) can be
- # represented with `intptr_t`. It further turns out that
- # CPython *directly* exposes the SOCKET handle as the value of
- # fileno (32-bit PyPy does some munging on it, which should
- # rarely matter). So we can pass socket.fileno() through
- # to uv_poll_init_socket.
-
- # See _corecffi_build.
- _watcher_init = watcher._LIB.uv_poll_init_socket
-
-
- class _multiplexwatcher(object):
-
- callback = None
- args = ()
- pass_events = False
- ref = True
-
- def __init__(self, events, watcher):
- self._events = events
-
- # References:
- # These objects must keep the original IO object alive;
- # the IO object SHOULD NOT keep these alive to avoid cycles
- # We MUST NOT rely on GC to clean up the IO objects, but the explicit
- # calls to close(); see _multiplex_closed.
- self._watcher_ref = watcher
-
- events = property(
- lambda self: self._events,
- _base.not_while_active(lambda self, nv: setattr(self, '_events', nv)))
-
- def start(self, callback, *args, **kwargs):
- self.pass_events = kwargs.get("pass_events")
- self.callback = callback
- self.args = args
-
- watcher = self._watcher_ref
- if watcher is not None:
- if not watcher.active:
- watcher._io_start()
- else:
- # Make sure we're in the event mask
- watcher._calc_and_update_events()
-
- def stop(self):
- self.callback = None
- self.pass_events = None
- self.args = None
- watcher = self._watcher_ref
- if watcher is not None:
- watcher._io_maybe_stop()
-
- def close(self):
- if self._watcher_ref is not None:
- self._watcher_ref._multiplex_closed(self)
- self._watcher_ref = None
-
- @property
- def active(self):
- return self.callback is not None
-
- @property
- def _watcher(self):
- # For testing.
- return self._watcher_ref._watcher
-
- # ares.pyx depends on this property,
- # and test__core uses it too
- fd = property(lambda self: getattr(self._watcher_ref, '_fd', -1),
- lambda self, nv: self._watcher_ref._set_fd(nv))
-
- def _io_maybe_stop(self):
- self._calc_and_update_events()
- for w in self._multiplex_watchers:
- if w.callback is not None:
- # There's still a reference to it, and it's started,
- # so we can't stop.
- return
- # If we get here, nothing was started
- # so we can take ourself out of the polling set
- self.stop()
-
- def _io_start(self):
- self._calc_and_update_events()
- self.start(self._io_callback, pass_events=True)
-
- def _calc_and_update_events(self):
- events = 0
- for watcher in self._multiplex_watchers:
- if watcher.callback is not None:
- # Only ask for events that are active.
- events |= watcher.events
- self._set_events(events)
-
-
- def multiplex(self, events):
- watcher = self._multiplexwatcher(events, self)
- self._multiplex_watchers.append(watcher)
- self._calc_and_update_events()
- return watcher
-
- def close(self):
- super(io, self).close()
- del self._multiplex_watchers
-
- def _multiplex_closed(self, watcher):
- self._multiplex_watchers.remove(watcher)
- if not self._multiplex_watchers:
- self.stop() # should already be stopped
- self._no_more_watchers()
- # It is absolutely critical that we control when the call
- # to uv_close() gets made. uv_close() of a uv_poll_t
- # handle winds up calling uv__platform_invalidate_fd,
- # which, as the name implies, destroys any outstanding
- # events for the *fd* that haven't been delivered yet, and also removes
- # the *fd* from the poll set. So if this happens later, at some
- # non-deterministic time when (cyclic or otherwise) GC runs,
- # *and* we've opened a new watcher for the fd, that watcher will
- # suddenly and mysteriously stop seeing events. So we do this now;
- # this method is smart enough not to close the handle twice.
- self.close()
- else:
- self._calc_and_update_events()
-
- def _no_more_watchers(self):
- # The loop sets this on an individual watcher to delete it from
- # the active list where it keeps hard references.
- pass
-
- def _io_callback(self, events):
- if events < 0:
- # actually a status error code
- _dbg("Callback error on", self._fd,
- ffi.string(libuv.uv_err_name(events)),
- ffi.string(libuv.uv_strerror(events)))
- # XXX: We've seen one half of a FileObjectPosix pair
- # (the read side of a pipe) report errno 11 'bad file descriptor'
- # after the write side was closed and its watcher removed. But
- # we still need to attempt to read from it to clear out what's in
- # its buffers--if we return with the watcher inactive before proceeding to wake up
- # the reader, we get a LoopExit. So we can't return here and arguably shouldn't print it
- # either. The negative events mask will match the watcher's mask.
- # See test__fileobject.py:Test.test_newlines for an example.
-
- # On Windows (at least with PyPy), we can get ENOTSOCK (socket operation on non-socket)
- # if a socket gets closed. If we don't pass the events on, we hang.
- # See test__makefile_ref.TestSSL for examples.
- # return
-
- for watcher in self._multiplex_watchers:
- if not watcher.callback:
- # Stopped
- continue
- assert watcher._watcher_ref is self, (self, watcher._watcher_ref)
-
- send_event = (events & watcher.events) or events < 0
- if send_event:
- if not watcher.pass_events:
- watcher.callback(*watcher.args)
- else:
- watcher.callback(events, *watcher.args)
-
-class _SimulatedWithAsyncMixin(object):
- _watcher_skip_ffi = True
-
- def __init__(self, loop, *args, **kwargs):
- self._async = loop.async_()
- try:
- super(_SimulatedWithAsyncMixin, self).__init__(loop, *args, **kwargs)
- except:
- self._async.close()
- raise
-
- def _watcher_create(self, _args):
- return
-
- @property
- def _watcher_handle(self):
- return None
-
- def _watcher_ffi_init(self, _args):
- return
-
- def _watcher_ffi_set_init_ref(self, ref):
- self._async.ref = ref
-
- @property
- def active(self):
- return self._async.active
-
- def start(self, cb, *args):
- self._register_loop_callback()
- self.callback = cb
- self.args = args
- self._async.start(cb, *args)
- #watcher.start(self, cb, *args)
-
- def stop(self):
- self._unregister_loop_callback()
- self.callback = None
- self.args = None
- self._async.stop()
-
- def close(self):
- if self._async is not None:
- a = self._async
- #self._async = None
- a.close()
-
- def _register_loop_callback(self):
- # called from start()
- raise NotImplementedError()
-
- def _unregister_loop_callback(self):
- # called from stop
- raise NotImplementedError()
-
-class fork(_SimulatedWithAsyncMixin,
- _base.ForkMixin,
- watcher):
- # We'll have to implement this one completely manually
- # Right now it doesn't matter much since libuv doesn't survive
- # a fork anyway. (That's a work in progress)
- _watcher_skip_ffi = False
-
- def _register_loop_callback(self):
- self.loop._fork_watchers.add(self)
-
- def _unregister_loop_callback(self):
- try:
- # stop() should be idempotent
- self.loop._fork_watchers.remove(self)
- except KeyError:
- pass
-
- def _on_fork(self):
- self._async.send()
-
-
-class child(_SimulatedWithAsyncMixin,
- _base.ChildMixin,
- watcher):
- _watcher_skip_ffi = True
- # We'll have to implement this one completely manually.
- # Our approach is to use a SIGCHLD handler and the original
- # os.waitpid call.
-
- # On Unix, libuv's uv_process_t and uv_spawn use SIGCHLD,
- # just like libev does for its child watchers. So
- # we're not adding any new SIGCHLD related issues not already
- # present in libev.
-
-
- def _register_loop_callback(self):
- self.loop._register_child_watcher(self)
-
- def _unregister_loop_callback(self):
- self.loop._unregister_child_watcher(self)
-
- def _set_waitpid_status(self, pid, status):
- self._rpid = pid
- self._rstatus = status
- self._async.send()
-
-
-class async_(_base.AsyncMixin, watcher):
- _watcher_callback_name = '_gevent_async_callback0'
-
- def _watcher_ffi_init(self, args):
- # It's dangerous to have a raw, non-initted struct
- # around; it will crash in uv_close() when we get GC'd,
- # and send() will also crash.
- # NOTE: uv_async_init is NOT idempotent. Calling it more than
- # once adds the uv_async_t to the internal queue multiple times,
- # and uv_close only cleans up one of them, meaning that we tend to
- # crash. Thus we have to be very careful not to allow that.
- return self._watcher_init(self.loop.ptr, self._watcher, ffi.NULL)
-
- def _watcher_ffi_start(self):
- # we're created in a started state, but we didn't provide a
- # callback (because if we did and we don't have a value in our
- # callback attribute, then python_callback would crash.) Note that
- # uv_async_t->async_cb is not technically documented as public.
- self._watcher.async_cb = self._watcher_callback
-
- def _watcher_ffi_stop(self):
- self._watcher.async_cb = ffi.NULL
- # We have to unref this because we're setting the cb behind libuv's
- # back, basically: once a async watcher is started, it can't ever be
- # stopped through libuv interfaces, so it would never lose its active
- # status, and thus if it stays reffed it would keep the event loop
- # from exiting.
- self._watcher_ffi_unref()
-
- def send(self):
- if libuv.uv_is_closing(self._watcher):
- raise Exception("Closing handle")
- libuv.uv_async_send(self._watcher)
-
- @property
- def pending(self):
- return None
-
-locals()['async'] = async_
-
-class timer(_base.TimerMixin, watcher):
-
- _watcher_callback_name = '_gevent_timer_callback0'
-
- # In libuv, timer callbacks continue running while any timer is
- # expired, including newly added timers. Newly added non-zero
- # timers (especially of small duration) can be seen to be expired
- # if the loop time is updated while we are in a timer callback.
- # This can lead to us being stuck running timers for a terribly
- # long time, which is not good. So default to not updating the
- # time.
-
- # Also, newly-added timers of 0 duration can *also* stall the
- # loop, because they'll be seen to be expired immediately.
- # Updating the time can prevent that, *if* there was already a
- # timer for a longer duration scheduled.
-
- # To mitigate the above problems, our loop implementation turns
- # zero duration timers into check watchers instead using OneShotCheck.
- # This ensures the loop cycles. Of course, the 'again' method does
- # nothing on them and doesn't exist. In practice that's not an issue.
-
- _again = False
-
- def _watcher_ffi_init(self, args):
- self._watcher_init(self.loop._ptr, self._watcher)
- self._after, self._repeat = args
- if self._after and self._after < 0.001:
- import warnings
- # XXX: The stack level is hard to determine, could be getting here
- # through a number of different ways.
- warnings.warn("libuv only supports millisecond timer resolution; "
- "all times less will be set to 1 ms",
- stacklevel=6)
- # The alternative is to effectively pass in int(0.1) == 0, which
- # means no sleep at all, which leads to excessive wakeups
- self._after = 0.001
- if self._repeat and self._repeat < 0.001:
- import warnings
- warnings.warn("libuv only supports millisecond timer resolution; "
- "all times less will be set to 1 ms",
- stacklevel=6)
- self._repeat = 0.001
-
- def _watcher_ffi_start(self):
- if self._again:
- libuv.uv_timer_again(self._watcher)
- else:
- try:
- self._watcher_start(self._watcher, self._watcher_callback,
- int(self._after * 1000),
- int(self._repeat * 1000))
- except ValueError:
- # in case of non-ints in _after/_repeat
- raise TypeError()
-
- def again(self, callback, *args, **kw):
- if not self.active:
- # If we've never been started, this is the same as starting us.
- # libuv makes the distinction, libev doesn't.
- self.start(callback, *args, **kw)
- return
-
- self._again = True
- try:
- self.start(callback, *args, **kw)
- finally:
- del self._again
-
-
-class stat(_base.StatMixin, watcher):
- _watcher_type = 'fs_poll'
- _watcher_struct_name = 'gevent_fs_poll_t'
- _watcher_callback_name = '_gevent_fs_poll_callback3'
-
- def _watcher_set_data(self, the_watcher, data):
- the_watcher.handle.data = data
- return data
-
- def _watcher_ffi_init(self, args):
- return self._watcher_init(self.loop._ptr, self._watcher)
-
- MIN_STAT_INTERVAL = 0.1074891 # match libev; 0.0 is default
-
- def _watcher_ffi_start(self):
- # libev changes this when the watcher is started
- if self._interval < self.MIN_STAT_INTERVAL:
- self._interval = self.MIN_STAT_INTERVAL
- self._watcher_start(self._watcher, self._watcher_callback,
- self._cpath,
- int(self._interval * 1000))
-
- @property
- def _watcher_handle(self):
- return self._watcher.handle.data
-
- @property
- def attr(self):
- if not self._watcher.curr.st_nlink:
- return
- return self._watcher.curr
-
- @property
- def prev(self):
- if not self._watcher.prev.st_nlink:
- return
- return self._watcher.prev
-
-
-class signal(_base.SignalMixin, watcher):
- _watcher_callback_name = '_gevent_signal_callback1'
-
- def _watcher_ffi_init(self, args):
- self._watcher_init(self.loop._ptr, self._watcher)
- self.ref = False # libev doesn't ref these by default
-
-
- def _watcher_ffi_start(self):
- self._watcher_start(self._watcher, self._watcher_callback,
- self._signalnum)
-
-
-class idle(_base.IdleMixin, watcher):
- # Because libuv doesn't support priorities, idle watchers are
- # potentially quite a bit different than under libev
- _watcher_callback_name = '_gevent_idle_callback0'
-
-
-class check(_base.CheckMixin, watcher):
- _watcher_callback_name = '_gevent_check_callback0'
-
-class OneShotCheck(check):
-
- _watcher_skip_ffi = True
-
- def __make_cb(self, func):
- stop = self.stop
- @functools.wraps(func)
- def cb(*args):
- stop()
- return func(*args)
- return cb
-
- def start(self, callback, *args):
- return check.start(self, self.__make_cb(callback), *args)
-
-class prepare(_base.PrepareMixin, watcher):
- _watcher_callback_name = '_gevent_prepare_callback0'
diff --git a/python/gevent/local.c b/python/gevent/local.c
deleted file mode 100644
index c656bd6..0000000
--- a/python/gevent/local.c
+++ /dev/null
@@ -1,13741 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/_local.pxd",
- "src\\gevent\\_local.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent._local",
- "sources": [
- "src/gevent/local.py"
- ]
- },
- "module_name": "gevent._local"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 0
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent___local
-#define __PYX_HAVE_API__gevent___local
-/* Early includes */
-#include "greenlet/greenlet.h"
-#include "frameobject.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\local.py",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
- "src\\gevent\\_greenlet.pxd",
- "src\\gevent\\_local.pxd",
- "src\\gevent\\__ident.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef;
-struct __pyx_obj_6gevent_7__ident_IdentRegistry;
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink;
-struct __pyx_obj_6gevent_9_greenlet__Frame;
-struct __pyx_obj_6gevent_9_greenlet_Greenlet;
-struct __pyx_obj_6gevent_9_greenlet__dummy_event;
-struct __pyx_obj_6gevent_6_local__wrefdict;
-struct __pyx_obj_6gevent_6_local__greenlet_deleted;
-struct __pyx_obj_6gevent_6_local__local_deleted;
-struct __pyx_obj_6gevent_6_local__localimpl;
-struct __pyx_obj_6gevent_6_local__localimpl_dict_entry;
-struct __pyx_obj_6gevent_6_local_local;
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join;
-struct __pyx_opt_args_6gevent_9_greenlet_joinall;
-
-/* "gevent/_greenlet.pxd":105
- *
- * cpdef bint has_links(self)
- * cpdef join(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint ready(self)
- * cpdef bint successful(self)
- */
-struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_greenlet.pxd":174
- *
- * @cython.locals(done=list)
- * cpdef joinall(greenlets, timeout=*, raise_error=*, count=*) # <<<<<<<<<<<<<<
- */
-struct __pyx_opt_args_6gevent_9_greenlet_joinall {
- int __pyx_n;
- PyObject *timeout;
- PyObject *raise_error;
- PyObject *count;
-};
-
-/* "gevent/__ident.pxd":15
- * @cython.internal
- * @cython.final
- * cdef class ValuedWeakRef(ref): # <<<<<<<<<<<<<<
- * cdef object value
- *
- */
-struct __pyx_obj_6gevent_7__ident_ValuedWeakRef {
- PyWeakReference __pyx_base;
- PyObject *value;
-};
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-struct __pyx_obj_6gevent_7__ident_IdentRegistry {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtab;
- PyObject *_registry;
- PyObject *_available_idents;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-/* "gevent/_greenlet.pxd":56
- * cdef void _init()
- *
- * cdef class SpawnedLink: # <<<<<<<<<<<<<<
- * cdef public object callback
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SpawnedLink {
- PyObject_HEAD
- PyObject *callback;
-};
-
-
-/* "gevent/_greenlet.pxd":61
- *
- * @cython.final
- * cdef class SuccessSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":65
- *
- * @cython.final
- * cdef class FailureSpawnedLink(SpawnedLink): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink {
- struct __pyx_obj_6gevent_9_greenlet_SpawnedLink __pyx_base;
-};
-
-
-/* "gevent/_greenlet.pxd":71
- * @cython.internal
- * @cython.freelist(1000)
- * cdef class _Frame: # <<<<<<<<<<<<<<
- * cdef readonly CodeType f_code
- * cdef readonly int f_lineno
- */
-struct __pyx_obj_6gevent_9_greenlet__Frame {
- PyObject_HEAD
- PyCodeObject *f_code;
- int f_lineno;
- struct __pyx_obj_6gevent_9_greenlet__Frame *f_back;
-};
-
-
-/* "gevent/_greenlet.pxd":86
- *
- *
- * cdef class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * cdef readonly object value
- * cdef readonly tuple args
- */
-struct __pyx_obj_6gevent_9_greenlet_Greenlet {
- PyGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtab;
- PyObject *value;
- PyObject *args;
- PyObject *kwargs;
- PyObject *spawning_greenlet;
- PyObject *spawn_tree_locals;
- PyObject *_spawning_stack_frames;
- PyObject *_links;
- PyObject *_exc_info;
- PyObject *_notifier;
- PyObject *_start_event;
- PyObject *_formatted_info;
- PyObject *_ident;
-};
-
-
-/* "gevent/_greenlet.pxd":157
- * @cython.final
- * @cython.internal
- * cdef class _dummy_event: # <<<<<<<<<<<<<<
- * cdef readonly bint pending
- * cdef readonly bint active
- */
-struct __pyx_obj_6gevent_9_greenlet__dummy_event {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtab;
- int pending;
- int active;
-};
-
-
-/* "gevent/_local.pxd":40
- * @cython.final
- * @cython.internal
- * cdef class _wrefdict(dict): # <<<<<<<<<<<<<<
- * cdef object __weakref__
- *
- */
-struct __pyx_obj_6gevent_6_local__wrefdict {
- PyDictObject __pyx_base;
- PyObject *__weakref__;
-};
-
-
-/* "gevent/_local.pxd":45
- * @cython.final
- * @cython.internal
- * cdef class _greenlet_deleted: # <<<<<<<<<<<<<<
- * cdef object idt
- * cdef object wrdicts
- */
-struct __pyx_obj_6gevent_6_local__greenlet_deleted {
- PyObject_HEAD
- PyObject *idt;
- PyObject *wrdicts;
-};
-
-
-/* "gevent/_local.pxd":52
- * @cython.final
- * @cython.internal
- * cdef class _local_deleted: # <<<<<<<<<<<<<<
- * cdef str key
- * cdef object wrthread
- */
-struct __pyx_obj_6gevent_6_local__local_deleted {
- PyObject_HEAD
- PyObject *key;
- PyObject *wrthread;
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *greenlet_deleted;
-};
-
-
-/* "gevent/_local.pxd":59
- * @cython.final
- * @cython.internal
- * cdef class _localimpl: # <<<<<<<<<<<<<<
- * cdef str key
- * cdef dict dicts
- */
-struct __pyx_obj_6gevent_6_local__localimpl {
- PyObject_HEAD
- PyObject *key;
- PyObject *dicts;
- PyObject *localargs;
- PyObject *localkwargs;
- PyObject *localtypeid;
- PyObject *__weakref__;
-};
-
-
-/* "gevent/_local.pxd":70
- * @cython.final
- * @cython.internal
- * cdef class _localimpl_dict_entry: # <<<<<<<<<<<<<<
- * cdef object wrgreenlet
- * cdef dict localdict
- */
-struct __pyx_obj_6gevent_6_local__localimpl_dict_entry {
- PyObject_HEAD
- PyObject *wrgreenlet;
- PyObject *localdict;
-};
-
-
-/* "gevent/_local.pxd":83
- * cdef set _local_attrs
- *
- * cdef class local: # <<<<<<<<<<<<<<
- * cdef _localimpl _local__impl
- * cdef set _local_type_get_descriptors
- */
-struct __pyx_obj_6gevent_6_local_local {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_local_local *__pyx_vtab;
- struct __pyx_obj_6gevent_6_local__localimpl *_local__impl;
- PyObject *_local_type_get_descriptors;
- PyObject *_local_type_set_or_del_descriptors;
- PyObject *_local_type_del_descriptors;
- PyObject *_local_type_set_descriptors;
- PyObject *_local_type_vars;
- PyTypeObject *_local_type;
-};
-
-
-
-/* "gevent/__ident.pxd":19
- *
- * @cython.final
- * cdef class IdentRegistry: # <<<<<<<<<<<<<<
- * cdef object _registry
- * cdef list _available_idents
- */
-
-struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry {
- PyObject *(*get_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_return_ident)(struct __pyx_obj_6gevent_7__ident_IdentRegistry *, struct __pyx_obj_6gevent_7__ident_ValuedWeakRef *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry *__pyx_vtabptr_6gevent_7__ident_IdentRegistry;
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-
-/* "gevent/_greenlet.pxd":86
- *
- *
- * cdef class Greenlet(greenlet): # <<<<<<<<<<<<<<
- * cdef readonly object value
- * cdef readonly tuple args
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet {
- int (*has_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*join)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_9_greenlet_8Greenlet_join *__pyx_optional_args);
- int (*ready)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- int (*successful)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_formatinfo)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
- PyObject *(*_get_minimal_ident)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___started_but_aborted)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_cancelled_by_kill)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_pending)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___never_started_or_killed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- int (*__pyx___start_completed)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*__pyx___handle_death_before_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*__pyx___cancel_start)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *);
- PyObject *(*_report_result)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_report_error)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, PyObject *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_9_greenlet_Greenlet *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet *__pyx_vtabptr_6gevent_9_greenlet_Greenlet;
-
-
-/* "gevent/_greenlet.pxd":157
- * @cython.final
- * @cython.internal
- * cdef class _dummy_event: # <<<<<<<<<<<<<<
- * cdef readonly bint pending
- * cdef readonly bint active
- */
-
-struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event {
- PyObject *(*stop)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
- PyObject *(*start)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*close)(struct __pyx_obj_6gevent_9_greenlet__dummy_event *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event *__pyx_vtabptr_6gevent_9_greenlet__dummy_event;
-
-
-/* "src/gevent/local.py":361
- * }
- *
- * class local(object): # <<<<<<<<<<<<<<
- * """
- * An object whose attributes are greenlet-local.
- */
-
-struct __pyx_vtabstruct_6gevent_6_local_local {
- struct __pyx_obj_6gevent_6_local_local *(*__pyx___copy__)(struct __pyx_obj_6gevent_6_local_local *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_6_local_local *__pyx_vtabptr_6gevent_6_local_local;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* py_dict_items.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod0.proto */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_CallUnboundCMethod0(cfunc, self)\
- (likely((cfunc)->func) ?\
- (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\
- (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
- (PY_VERSION_HEX >= 0x030700A0 ?\
- (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
- (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
- (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
- ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\
- __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
- __Pyx__CallUnboundCMethod0(cfunc, self))
-#else
-#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
-#endif
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* bytes_tailmatch.proto */
-static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
- Py_ssize_t start, Py_ssize_t end, int direction);
-static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction);
-
-/* unicode_tailmatch.proto */
-static int __Pyx_PyUnicode_Tailmatch(
- PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction);
-
-/* str_tailmatch.proto */
-static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
- Py_ssize_t end, int direction);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* dict_getitem_default.proto */
-static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);
-
-/* CallUnboundCMethod1.proto */
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#else
-#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
-#endif
-
-/* CallUnboundCMethod2.proto */
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
-#else
-#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
-#endif
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* DictGetItem.proto */
-#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
-static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
-#define __Pyx_PyObject_Dict_GetItem(obj, name)\
- (likely(PyDict_CheckExact(obj)) ?\
- __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
-#else
-#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
-#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* KeywordStringCheck.proto */
-static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* RaiseNoneIterError.proto */
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
-
-/* pyfrozenset_new.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);
-
-/* PySetContains.proto */
-static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);
-
-/* IncludeStringH.proto */
-#include <string.h>
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* StrEquals.proto */
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
-#else
-#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
-#endif
-
-/* PyDictContains.proto */
-static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
- int result = PyDict_Contains(dict, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* PySequenceContains.proto */
-static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
- int result = PySequence_Contains(seq, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* HasAttr.proto */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
-
-/* SliceTupleAndList.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
-static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
-#else
-#define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
-#define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
-#endif
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static struct __pyx_obj_6gevent_6_local_local *__pyx_f_6gevent_6_local_5local___copy__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'weakref' */
-
-/* Module declarations from 'gevent.__ident' */
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ref = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_ValuedWeakRef = 0;
-static PyTypeObject *__pyx_ptype_6gevent_7__ident_IdentRegistry = 0;
-static PyObject **__pyx_vp_6gevent_7__ident_heappop = 0;
-#define __pyx_v_6gevent_7__ident_heappop (*__pyx_vp_6gevent_7__ident_heappop)
-static PyObject **__pyx_vp_6gevent_7__ident_heappush = 0;
-#define __pyx_v_6gevent_7__ident_heappush (*__pyx_vp_6gevent_7__ident_heappush)
-static PyObject **__pyx_vp_6gevent_7__ident_WeakKeyDictionary = 0;
-#define __pyx_v_6gevent_7__ident_WeakKeyDictionary (*__pyx_vp_6gevent_7__ident_WeakKeyDictionary)
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject **__pyx_vp_6gevent_8__waiter_sys = 0;
-#define __pyx_v_6gevent_8__waiter_sys (*__pyx_vp_6gevent_8__waiter_sys)
-static PyObject **__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-#define __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError (*__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError)
-static int *__pyx_vp_6gevent_8__waiter__greenlet_imported = 0;
-#define __pyx_v_6gevent_8__waiter__greenlet_imported (*__pyx_vp_6gevent_8__waiter__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_8__waiter__NONE = 0;
-#define __pyx_v_6gevent_8__waiter__NONE (*__pyx_vp_6gevent_8__waiter__NONE)
-
-/* Module declarations from 'types' */
-
-/* Module declarations from 'gevent._greenlet' */
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_CodeType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FrameType = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__Frame = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet_Greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_9_greenlet__dummy_event = 0;
-static int *__pyx_vp_6gevent_9_greenlet__PYPY = 0;
-#define __pyx_v_6gevent_9_greenlet__PYPY (*__pyx_vp_6gevent_9_greenlet__PYPY)
-static PyObject **__pyx_vp_6gevent_9_greenlet_sys_getframe = 0;
-#define __pyx_v_6gevent_9_greenlet_sys_getframe (*__pyx_vp_6gevent_9_greenlet_sys_getframe)
-static PyObject **__pyx_vp_6gevent_9_greenlet_sys_exc_info = 0;
-#define __pyx_v_6gevent_9_greenlet_sys_exc_info (*__pyx_vp_6gevent_9_greenlet_sys_exc_info)
-static PyObject **__pyx_vp_6gevent_9_greenlet_Timeout = 0;
-#define __pyx_v_6gevent_9_greenlet_Timeout (*__pyx_vp_6gevent_9_greenlet_Timeout)
-static PyObject **__pyx_vp_6gevent_9_greenlet_GreenletExit = 0;
-#define __pyx_v_6gevent_9_greenlet_GreenletExit (*__pyx_vp_6gevent_9_greenlet_GreenletExit)
-static PyObject **__pyx_vp_6gevent_9_greenlet_InvalidSwitchError = 0;
-#define __pyx_v_6gevent_9_greenlet_InvalidSwitchError (*__pyx_vp_6gevent_9_greenlet_InvalidSwitchError)
-static int *__pyx_vp_6gevent_9_greenlet__greenlet_imported = 0;
-#define __pyx_v_6gevent_9_greenlet__greenlet_imported (*__pyx_vp_6gevent_9_greenlet__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_9_greenlet__greenlet__init__ = 0;
-#define __pyx_v_6gevent_9_greenlet__greenlet__init__ (*__pyx_vp_6gevent_9_greenlet__greenlet__init__)
-static PyObject **__pyx_vp_6gevent_9_greenlet__threadlocal = 0;
-#define __pyx_v_6gevent_9_greenlet__threadlocal (*__pyx_vp_6gevent_9_greenlet__threadlocal)
-static PyObject **__pyx_vp_6gevent_9_greenlet_get_hub_class = 0;
-#define __pyx_v_6gevent_9_greenlet_get_hub_class (*__pyx_vp_6gevent_9_greenlet_get_hub_class)
-static PyObject **__pyx_vp_6gevent_9_greenlet_wref = 0;
-#define __pyx_v_6gevent_9_greenlet_wref (*__pyx_vp_6gevent_9_greenlet_wref)
-static PyObject **__pyx_vp_6gevent_9_greenlet_dump_traceback = 0;
-#define __pyx_v_6gevent_9_greenlet_dump_traceback (*__pyx_vp_6gevent_9_greenlet_dump_traceback)
-static PyObject **__pyx_vp_6gevent_9_greenlet_load_traceback = 0;
-#define __pyx_v_6gevent_9_greenlet_load_traceback (*__pyx_vp_6gevent_9_greenlet_load_traceback)
-static PyObject **__pyx_vp_6gevent_9_greenlet_wait = 0;
-#define __pyx_v_6gevent_9_greenlet_wait (*__pyx_vp_6gevent_9_greenlet_wait)
-static PyObject **__pyx_vp_6gevent_9_greenlet_iwait = 0;
-#define __pyx_v_6gevent_9_greenlet_iwait (*__pyx_vp_6gevent_9_greenlet_iwait)
-static PyObject **__pyx_vp_6gevent_9_greenlet_reraise = 0;
-#define __pyx_v_6gevent_9_greenlet_reraise (*__pyx_vp_6gevent_9_greenlet_reraise)
-static PyObject **__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG = 0;
-#define __pyx_v_6gevent_9_greenlet_GEVENT_CONFIG (*__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG)
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event **__pyx_vp_6gevent_9_greenlet__cancelled_start_event = 0;
-#define __pyx_v_6gevent_9_greenlet__cancelled_start_event (*__pyx_vp_6gevent_9_greenlet__cancelled_start_event)
-static struct __pyx_obj_6gevent_9_greenlet__dummy_event **__pyx_vp_6gevent_9_greenlet__start_completed_event = 0;
-#define __pyx_v_6gevent_9_greenlet__start_completed_event (*__pyx_vp_6gevent_9_greenlet__start_completed_event)
-
-/* Module declarations from 'gevent._local' */
-static PyTypeObject *__pyx_ptype_6gevent_6_local_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local__wrefdict = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local__greenlet_deleted = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local__local_deleted = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local__localimpl = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local__localimpl_dict_entry = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_local_local = 0;
-static int __pyx_v_6gevent_6_local__PYPY;
-static PyObject *__pyx_v_6gevent_6_local_ref = 0;
-static PyObject *__pyx_v_6gevent_6_local_copy = 0;
-static PyObject *__pyx_v_6gevent_6_local__marker = 0;
-static PyObject *__pyx_v_6gevent_6_local_key_prefix = 0;
-static int __pyx_v_6gevent_6_local__greenlet_imported;
-static PyObject *__pyx_v_6gevent_6_local__local_attrs = 0;
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_local_getcurrent(void); /*proto*/
-static CYTHON_INLINE void __pyx_f_6gevent_6_local_greenlet_init(void); /*proto*/
-static void __pyx_f_6gevent_6_local__init(void); /*proto*/
-static PyObject *__pyx_f_6gevent_6_local__localimpl_create_dict(struct __pyx_obj_6gevent_6_local__localimpl *, PyGreenlet *, PyObject *); /*proto*/
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_6_local__local_get_dict(struct __pyx_obj_6gevent_6_local_local *); /*proto*/
-static PyObject *__pyx_f_6gevent_6_local__local__copy_dict_from(struct __pyx_obj_6gevent_6_local_local *, struct __pyx_obj_6gevent_6_local__localimpl *, PyObject *); /*proto*/
-static PyObject *__pyx_f_6gevent_6_local__local_find_descriptors(struct __pyx_obj_6gevent_6_local_local *); /*proto*/
-static PyObject *__pyx_f_6gevent_6_local_all_local_dicts_for_greenlet(PyGreenlet *, int __pyx_skip_dispatch); /*proto*/
-#define __Pyx_MODULE_NAME "gevent._local"
-extern int __pyx_module_is_main_gevent___local;
-int __pyx_module_is_main_gevent___local = 0;
-
-/* Implementation of 'gevent._local' */
-static PyObject *__pyx_builtin___import__;
-static PyObject *__pyx_builtin_object;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_classmethod;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_AttributeError;
-static PyObject *__pyx_builtin_KeyError;
-static PyObject *__pyx_builtin_super;
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_kw[] = "kw";
-static const char __pyx_k_PY2[] = "PY2";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_cls[] = "cls";
-static const char __pyx_k_get[] = "__get__";
-static const char __pyx_k_idt[] = "idt";
-static const char __pyx_k_key[] = "key";
-static const char __pyx_k_mro[] = "mro";
-static const char __pyx_k_new[] = "__new__";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_ref[] = "ref";
-static const char __pyx_k_set[] = "__set__";
-static const char __pyx_k_None[] = "None";
-static const char __pyx_k_PYPY[] = "_PYPY";
-static const char __pyx_k_args[] = "args";
-static const char __pyx_k_copy[] = "__copy__";
-static const char __pyx_k_dict[] = "__dict__";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_cinit[] = "__cinit__";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_dicts[] = "dicts";
-static const char __pyx_k_get_2[] = "get";
-static const char __pyx_k_items[] = "items";
-static const char __pyx_k_local[] = "local";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_super[] = "super";
-static const char __pyx_k_PYPY_2[] = "PYPY";
-static const char __pyx_k_copy_2[] = "copy";
-static const char __pyx_k_delete[] = "__delete__";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_kwargs[] = "kwargs";
-static const char __pyx_k_lambda[] = "<lambda>";
-static const char __pyx_k_marker[] = "_marker";
-static const char __pyx_k_object[] = "object";
-static const char __pyx_k_unlink[] = "unlink";
-static const char __pyx_k_unused[] = "_unused";
-static const char __pyx_k_getattr[] = "__getattr__";
-static const char __pyx_k_rawlink[] = "rawlink";
-static const char __pyx_k_setattr[] = "__setattr__";
-static const char __pyx_k_weakref[] = "weakref";
-static const char __pyx_k_wrdicts[] = "wrdicts";
-static const char __pyx_k_KeyError[] = "KeyError";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_id_local[] = "id_local";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_wrthread[] = "wrthread";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_localargs[] = "localargs";
-static const char __pyx_k_localdict[] = "localdict";
-static const char __pyx_k_weakref_2[] = "__weakref__";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_key_prefix[] = "key_prefix";
-static const char __pyx_k_local_type[] = "local_type";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_wrgreenlet[] = "wrgreenlet";
-static const char __pyx_k_classmethod[] = "classmethod";
-static const char __pyx_k_local__impl[] = "_local__impl";
-static const char __pyx_k_local_attrs[] = "_local_attrs";
-static const char __pyx_k_localkwargs[] = "localkwargs";
-static const char __pyx_k_localtypeid[] = "localtypeid";
-static const char __pyx_k_getattribute[] = "__getattribute__";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_local___copy[] = "local.__copy__";
-static const char __pyx_k_local_type_2[] = "_local_type";
-static const char __pyx_k_gevent__local[] = "gevent._local";
-static const char __pyx_k_greenlet_init[] = "greenlet_init";
-static const char __pyx_k_AttributeError[] = "AttributeError";
-static const char __pyx_k_gevent__compat[] = "gevent._compat";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_local_type_vars[] = "_local_type_vars";
-static const char __pyx_k_greenlet_deleted[] = "greenlet_deleted";
-static const char __pyx_k_greenlet_imported[] = "_greenlet_imported";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_src_gevent_local_py[] = "src\\gevent\\local.py";
-static const char __pyx_k_gevent_local_localimpl[] = "_gevent_local_localimpl_";
-static const char __pyx_k_local_type_del_descriptors[] = "_local_type_del_descriptors";
-static const char __pyx_k_local_type_get_descriptors[] = "_local_type_get_descriptors";
-static const char __pyx_k_local_type_set_descriptors[] = "_local_type_set_descriptors";
-static const char __pyx_k_r_object_has_no_attribute_s[] = "%r object has no attribute '%s'";
-static const char __pyx_k_all_local_dicts_for_greenlet[] = "all_local_dicts_for_greenlet";
-static const char __pyx_k_r_object_attribute___dict___is[] = "%r object attribute '__dict__' is read-only";
-static const char __pyx_k_Greenlet_local_objects_This_mod[] = "\nGreenlet-local objects.\n\nThis module is based on `_threading_local.py`__ from the standard\nlibrary of Python 3.4.\n\n__ https://github.com/python/cpython/blob/3.4/Lib/_threading_local.py\n\nGreenlet-local objects support the management of greenlet-local data.\nIf you have data that you want to be local to a greenlet, simply create\na greenlet-local object and use its attributes:\n\n >>> mydata = local()\n >>> mydata.number = 42\n >>> mydata.number\n 42\n\nYou can also access the local-object's dictionary:\n\n >>> mydata.__dict__\n {'number': 42}\n >>> mydata.__dict__.setdefault('widgets', [])\n []\n >>> mydata.widgets\n []\n\nWhat's important about greenlet-local objects is that their data are\nlocal to a greenlet. If we access the data in a different greenlet:\n\n >>> log = []\n >>> def f():\n ... items = list(mydata.__dict__.items())\n ... items.sort()\n ... log.append(items)\n ... mydata.number = 11\n ... log.append(mydata.number)\n >>> greenlet = gevent.spawn(f)\n >>> greenlet.join()\n >>> log\n [[], 11]\n\nwe get different data. Furthermore, changes made in the other greenlet\ndon't affect data seen in this greenlet:\n\n >>> mydata.number\n 42\n\nOf course, values you get from a local object, including a __dict__\nattribute, are for whatever greenlet was current at the time the\nattribute was read. For that reason, you generally don't want to save\nthese values across greenlets, as they apply only to the greenlet they\ncame from.\n\nYou can create custom local objects by subclassing the local class:\n\n >>> class MyLocal(local):\n ... number = 2\n ... initialized = False\n ... def __init__(self, **kw):\n ... if self.initialized:\n ... raise SystemError('__init__ called too many times')\n ... self.initialized = True\n ... self.__dict__.update(kw)\n ... def squared(self):\n ... return self.number ** 2\n\nThis can be useful to support default val""ues, methods and\ninitialization. Note that if you define an __init__ method, it will be\ncalled each time the local object is used in a separate greenlet. This\nis necessary to initialize each greenlet's dictionary.\n\nNow if we create a local object:\n\n >>> mydata = MyLocal(color='red')\n\nNow we have a default number:\n\n >>> mydata.number\n 2\n\nan initial color:\n\n >>> mydata.color\n 'red'\n >>> del mydata.color\n\nAnd a method that operates on the data:\n\n >>> mydata.squared()\n 4\n\nAs before, we can access the data in a separate greenlet:\n\n >>> log = []\n >>> greenlet = gevent.spawn(f)\n >>> greenlet.join()\n >>> log\n [[('color', 'red'), ('initialized', True)], 11]\n\nwithout affecting this greenlet's data:\n\n >>> mydata.number\n 2\n >>> mydata.color\n Traceback (most recent call last):\n ...\n AttributeError: 'MyLocal' object has no attribute 'color'\n\nNote that subclasses can define slots, but they are not greenlet\nlocal. They are shared across greenlets::\n\n >>> class MyLocal(local):\n ... __slots__ = 'number'\n\n >>> mydata = MyLocal()\n >>> mydata.number = 42\n >>> mydata.color = 'red'\n\nSo, the separate greenlet:\n\n >>> greenlet = gevent.spawn(f)\n >>> greenlet.join()\n\naffects what we see:\n\n >>> mydata.number\n 11\n\n>>> del mydata\n\n.. versionchanged:: 1.1a2\n Update the implementation to match Python 3.4 instead of Python 2.5.\n This results in locals being eligible for garbage collection as soon\n as their greenlet exits.\n\n.. versionchanged:: 1.2.3\n Use a weak-reference to clear the greenlet link we establish in case\n the local object dies before the greenlet does.\n\n.. versionchanged:: 1.3a1\n Implement the methods for attribute access directly, handling\n descriptors directly here. This allows removing the use of a lock\n and facilitates greatly improved performance.\n\n.. versionchanged:: 1.3a1\n The ``__init__`` method of subclasses of ``local`` is no longer\n called wit""h a lock held. CPython does not use such a lock in its\n native implementation. This could potentially show as a difference\n if code that uses multiple dependent attributes in ``__slots__``\n (which are shared across all greenlets) switches during ``__init__``.\n\n";
-static const char __pyx_k_local_type_set_or_del_descripto[] = "_local_type_set_or_del_descriptors";
-static const char __pyx_k_Initialization_arguments_are_not[] = "Initialization arguments are not supported";
-static PyObject *__pyx_n_s_AttributeError;
-static PyObject *__pyx_kp_s_Initialization_arguments_are_not;
-static PyObject *__pyx_n_s_KeyError;
-static PyObject *__pyx_n_s_None;
-static PyObject *__pyx_n_s_PY2;
-static PyObject *__pyx_n_s_PYPY;
-static PyObject *__pyx_n_s_PYPY_2;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_all_local_dicts_for_greenlet;
-static PyObject *__pyx_n_s_args;
-static PyObject *__pyx_n_s_cinit;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_classmethod;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_cls;
-static PyObject *__pyx_n_s_copy;
-static PyObject *__pyx_n_s_copy_2;
-static PyObject *__pyx_n_s_delete;
-static PyObject *__pyx_n_s_dict;
-static PyObject *__pyx_n_s_dicts;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_get_2;
-static PyObject *__pyx_n_s_getattr;
-static PyObject *__pyx_n_s_getattribute;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_gevent__compat;
-static PyObject *__pyx_n_s_gevent__local;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent_local_localimpl;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_greenlet_deleted;
-static PyObject *__pyx_n_s_greenlet_imported;
-static PyObject *__pyx_n_s_greenlet_init;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_n_s_id_local;
-static PyObject *__pyx_n_s_idt;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_items;
-static PyObject *__pyx_n_s_key;
-static PyObject *__pyx_n_s_key_prefix;
-static PyObject *__pyx_n_s_kw;
-static PyObject *__pyx_n_s_kwargs;
-static PyObject *__pyx_n_s_lambda;
-static PyObject *__pyx_n_s_local;
-static PyObject *__pyx_n_s_local___copy;
-static PyObject *__pyx_n_s_local__impl;
-static PyObject *__pyx_n_s_local_attrs;
-static PyObject *__pyx_n_s_local_type;
-static PyObject *__pyx_n_s_local_type_2;
-static PyObject *__pyx_n_s_local_type_del_descriptors;
-static PyObject *__pyx_n_s_local_type_get_descriptors;
-static PyObject *__pyx_n_s_local_type_set_descriptors;
-static PyObject *__pyx_n_s_local_type_set_or_del_descripto;
-static PyObject *__pyx_n_s_local_type_vars;
-static PyObject *__pyx_n_s_localargs;
-static PyObject *__pyx_n_s_localdict;
-static PyObject *__pyx_n_s_localkwargs;
-static PyObject *__pyx_n_s_localtypeid;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_marker;
-static PyObject *__pyx_n_s_mro;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_new;
-static PyObject *__pyx_n_s_object;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_kp_s_r_object_attribute___dict___is;
-static PyObject *__pyx_kp_s_r_object_has_no_attribute_s;
-static PyObject *__pyx_n_s_rawlink;
-static PyObject *__pyx_n_s_ref;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_set;
-static PyObject *__pyx_n_s_setattr;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_kp_s_src_gevent_local_py;
-static PyObject *__pyx_n_s_super;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_unlink;
-static PyObject *__pyx_n_s_unused;
-static PyObject *__pyx_n_s_weakref;
-static PyObject *__pyx_n_s_weakref_2;
-static PyObject *__pyx_n_s_wrdicts;
-static PyObject *__pyx_n_s_wrgreenlet;
-static PyObject *__pyx_n_s_wrthread;
-static PyObject *__pyx_lambda_funcdef_6gevent_6_local_lambda(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_all_local_dicts_for_greenlet(CYTHON_UNUSED PyObject *__pyx_self, PyGreenlet *__pyx_v_greenlet); /* proto */
-static int __pyx_pf_6gevent_6_local_17_greenlet_deleted___init__(struct __pyx_obj_6gevent_6_local__greenlet_deleted *__pyx_v_self, PyObject *__pyx_v_idt, PyObject *__pyx_v_wrdicts); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_17_greenlet_deleted_2__call__(struct __pyx_obj_6gevent_6_local__greenlet_deleted *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__unused); /* proto */
-static int __pyx_pf_6gevent_6_local_14_local_deleted___init__(struct __pyx_obj_6gevent_6_local__local_deleted *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_wrthread, PyObject *__pyx_v_greenlet_deleted); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_14_local_deleted_2__call__(struct __pyx_obj_6gevent_6_local__local_deleted *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__unused); /* proto */
-static int __pyx_pf_6gevent_6_local_10_localimpl___init__(struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, PyObject *__pyx_v_local_type, PyObject *__pyx_v_id_local); /* proto */
-static int __pyx_pf_6gevent_6_local_21_localimpl_dict_entry___init__(struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_self, PyObject *__pyx_v_wrgreenlet, PyObject *__pyx_v_localdict); /* proto */
-static int __pyx_pf_6gevent_6_local_5local___cinit__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kw); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_5local_2__getattribute__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
-static int __pyx_pf_6gevent_6_local_5local_4__setattr__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_6_local_5local_6__delattr__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_5local_8__copy__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_local_2__new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kw); /* proto */
-static PyObject *__pyx_tp_new_6gevent_6_local__wrefdict(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_local__greenlet_deleted(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_local__local_deleted(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_local__localimpl(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_local__localimpl_dict_entry(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_local_local(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get_2, 0, 0, 0};
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_codeobj__3;
-static PyObject *__pyx_codeobj__9;
-static PyObject *__pyx_codeobj__11;
-/* Late includes */
-
-/* "src/gevent/local.py":161
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_4lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_6_local_4lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_6_local_4lambda, METH_NOARGS, 0};
-static PyObject *__pyx_pw_6gevent_6_local_4lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda (wrapper)", 0);
- __pyx_r = __pyx_lambda_funcdef_6gevent_6_local_lambda(__pyx_self);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_lambda_funcdef_6gevent_6_local_lambda(CYTHON_UNUSED PyObject *__pyx_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("lambda", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":179
- * # That final tuple is actually a localimpl_dict_entry object.
- *
- * def all_local_dicts_for_greenlet(greenlet): # <<<<<<<<<<<<<<
- * """
- * Internal debug helper for getting the local values associated
- */
-
-static PyObject *__pyx_pw_6gevent_6_local_1all_local_dicts_for_greenlet(PyObject *__pyx_self, PyObject *__pyx_v_greenlet); /*proto*/
-static PyObject *__pyx_f_6gevent_6_local_all_local_dicts_for_greenlet(PyGreenlet *__pyx_v_greenlet, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_v_result = 0;
- struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_local_impl = 0;
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_entry = 0;
- PyObject *__pyx_v_k = 0;
- PyObject *__pyx_v_greenlet_dict = 0;
- PyObject *__pyx_v_id_greenlet = NULL;
- PyObject *__pyx_v_v = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *(*__pyx_t_8)(PyObject *);
- int __pyx_t_9;
- int __pyx_t_10;
- int __pyx_t_11;
- __Pyx_RefNannySetupContext("all_local_dicts_for_greenlet", 0);
-
- /* "src/gevent/local.py":191
- * """
- *
- * result = [] # <<<<<<<<<<<<<<
- * id_greenlet = id(greenlet)
- * greenlet_dict = greenlet.__dict__
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":192
- *
- * result = []
- * id_greenlet = id(greenlet) # <<<<<<<<<<<<<<
- * greenlet_dict = greenlet.__dict__
- * for k, v in greenlet_dict.items():
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_greenlet)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_id_greenlet = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":193
- * result = []
- * id_greenlet = id(greenlet)
- * greenlet_dict = greenlet.__dict__ # <<<<<<<<<<<<<<
- * for k, v in greenlet_dict.items():
- * if not k.startswith(key_prefix):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_greenlet), __pyx_n_s_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 193, __pyx_L1_error)
- __pyx_v_greenlet_dict = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":194
- * id_greenlet = id(greenlet)
- * greenlet_dict = greenlet.__dict__
- * for k, v in greenlet_dict.items(): # <<<<<<<<<<<<<<
- * if not k.startswith(key_prefix):
- * continue
- */
- if (unlikely(__pyx_v_greenlet_dict == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
- __PYX_ERR(0, 194, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_greenlet_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 194, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 194, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- #else
- __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
- index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_5);
- index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_6);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
- __pyx_t_8 = NULL;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 194, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 194, __pyx_L1_error)
- __Pyx_XDECREF_SET(__pyx_v_k, ((PyObject*)__pyx_t_5));
- __pyx_t_5 = 0;
- __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "src/gevent/local.py":195
- * greenlet_dict = greenlet.__dict__
- * for k, v in greenlet_dict.items():
- * if not k.startswith(key_prefix): # <<<<<<<<<<<<<<
- * continue
- * local_impl = v()
- */
- if (unlikely(__pyx_v_k == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
- __PYX_ERR(0, 195, __pyx_L1_error)
- }
- __pyx_t_9 = __Pyx_PyStr_Tailmatch(__pyx_v_k, __pyx_v_6gevent_6_local_key_prefix, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 195, __pyx_L1_error)
- __pyx_t_10 = ((!(__pyx_t_9 != 0)) != 0);
- if (__pyx_t_10) {
-
- /* "src/gevent/local.py":196
- * for k, v in greenlet_dict.items():
- * if not k.startswith(key_prefix):
- * continue # <<<<<<<<<<<<<<
- * local_impl = v()
- * if local_impl is None:
- */
- goto __pyx_L3_continue;
-
- /* "src/gevent/local.py":195
- * greenlet_dict = greenlet.__dict__
- * for k, v in greenlet_dict.items():
- * if not k.startswith(key_prefix): # <<<<<<<<<<<<<<
- * continue
- * local_impl = v()
- */
- }
-
- /* "src/gevent/local.py":197
- * if not k.startswith(key_prefix):
- * continue
- * local_impl = v() # <<<<<<<<<<<<<<
- * if local_impl is None:
- * continue
- */
- __Pyx_INCREF(__pyx_v_v);
- __pyx_t_6 = __pyx_v_v; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local__localimpl))))) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_XDECREF_SET(__pyx_v_local_impl, ((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":198
- * continue
- * local_impl = v()
- * if local_impl is None: # <<<<<<<<<<<<<<
- * continue
- * entry = local_impl.dicts.get(id_greenlet)
- */
- __pyx_t_10 = (((PyObject *)__pyx_v_local_impl) == Py_None);
- __pyx_t_9 = (__pyx_t_10 != 0);
- if (__pyx_t_9) {
-
- /* "src/gevent/local.py":199
- * local_impl = v()
- * if local_impl is None:
- * continue # <<<<<<<<<<<<<<
- * entry = local_impl.dicts.get(id_greenlet)
- * if entry is None:
- */
- goto __pyx_L3_continue;
-
- /* "src/gevent/local.py":198
- * continue
- * local_impl = v()
- * if local_impl is None: # <<<<<<<<<<<<<<
- * continue
- * entry = local_impl.dicts.get(id_greenlet)
- */
- }
-
- /* "src/gevent/local.py":200
- * if local_impl is None:
- * continue
- * entry = local_impl.dicts.get(id_greenlet) # <<<<<<<<<<<<<<
- * if entry is None:
- * # Not yet used in this greenlet.
- */
- if (unlikely(__pyx_v_local_impl->dicts == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
- __PYX_ERR(0, 200, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_local_impl->dicts, __pyx_v_id_greenlet, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local__localimpl_dict_entry))))) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_XDECREF_SET(__pyx_v_entry, ((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)__pyx_t_1));
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":201
- * continue
- * entry = local_impl.dicts.get(id_greenlet)
- * if entry is None: # <<<<<<<<<<<<<<
- * # Not yet used in this greenlet.
- * continue
- */
- __pyx_t_9 = (((PyObject *)__pyx_v_entry) == Py_None);
- __pyx_t_10 = (__pyx_t_9 != 0);
- if (__pyx_t_10) {
-
- /* "src/gevent/local.py":203
- * if entry is None:
- * # Not yet used in this greenlet.
- * continue # <<<<<<<<<<<<<<
- * assert entry.wrgreenlet() is greenlet
- * result.append((local_impl.localtypeid, entry.localdict))
- */
- goto __pyx_L3_continue;
-
- /* "src/gevent/local.py":201
- * continue
- * entry = local_impl.dicts.get(id_greenlet)
- * if entry is None: # <<<<<<<<<<<<<<
- * # Not yet used in this greenlet.
- * continue
- */
- }
-
- /* "src/gevent/local.py":204
- * # Not yet used in this greenlet.
- * continue
- * assert entry.wrgreenlet() is greenlet # <<<<<<<<<<<<<<
- * result.append((local_impl.localtypeid, entry.localdict))
- *
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __Pyx_INCREF(__pyx_v_entry->wrgreenlet);
- __pyx_t_6 = __pyx_v_entry->wrgreenlet; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_10 = (__pyx_t_1 == ((PyObject *)__pyx_v_greenlet));
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!(__pyx_t_10 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 204, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/local.py":205
- * continue
- * assert entry.wrgreenlet() is greenlet
- * result.append((local_impl.localtypeid, entry.localdict)) # <<<<<<<<<<<<<<
- *
- * return result
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_local_impl->localtypeid);
- __Pyx_GIVEREF(__pyx_v_local_impl->localtypeid);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_local_impl->localtypeid);
- __Pyx_INCREF(__pyx_v_entry->localdict);
- __Pyx_GIVEREF(__pyx_v_entry->localdict);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_entry->localdict);
- __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 205, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":194
- * id_greenlet = id(greenlet)
- * greenlet_dict = greenlet.__dict__
- * for k, v in greenlet_dict.items(): # <<<<<<<<<<<<<<
- * if not k.startswith(key_prefix):
- * continue
- */
- __pyx_L3_continue:;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":207
- * result.append((local_impl.localtypeid, entry.localdict))
- *
- * return result # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":179
- * # That final tuple is actually a localimpl_dict_entry object.
- *
- * def all_local_dicts_for_greenlet(greenlet): # <<<<<<<<<<<<<<
- * """
- * Internal debug helper for getting the local values associated
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._local.all_local_dicts_for_greenlet", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF((PyObject *)__pyx_v_local_impl);
- __Pyx_XDECREF((PyObject *)__pyx_v_entry);
- __Pyx_XDECREF(__pyx_v_k);
- __Pyx_XDECREF(__pyx_v_greenlet_dict);
- __Pyx_XDECREF(__pyx_v_id_greenlet);
- __Pyx_XDECREF(__pyx_v_v);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_1all_local_dicts_for_greenlet(PyObject *__pyx_self, PyObject *__pyx_v_greenlet); /*proto*/
-static char __pyx_doc_6gevent_6_local_all_local_dicts_for_greenlet[] = "all_local_dicts_for_greenlet(greenlet greenlet)\n\n Internal debug helper for getting the local values associated\n with a greenlet. This is subject to change or removal at any time.\n\n :return: A list of ((type, id), {}) pairs, where the first element\n is the type and id of the local object and the second object is its\n instance dictionary, as seen from this greenlet.\n\n .. versionadded:: 1.3a2\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_local_1all_local_dicts_for_greenlet = {"all_local_dicts_for_greenlet", (PyCFunction)__pyx_pw_6gevent_6_local_1all_local_dicts_for_greenlet, METH_O, __pyx_doc_6gevent_6_local_all_local_dicts_for_greenlet};
-static PyObject *__pyx_pw_6gevent_6_local_1all_local_dicts_for_greenlet(PyObject *__pyx_self, PyObject *__pyx_v_greenlet) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("all_local_dicts_for_greenlet (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_greenlet), __pyx_ptype_6gevent_6_local_greenlet, 1, "greenlet", 0))) __PYX_ERR(0, 179, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_6_local_all_local_dicts_for_greenlet(__pyx_self, ((PyGreenlet *)__pyx_v_greenlet));
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_all_local_dicts_for_greenlet(CYTHON_UNUSED PyObject *__pyx_self, PyGreenlet *__pyx_v_greenlet) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("all_local_dicts_for_greenlet", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_local_all_local_dicts_for_greenlet(__pyx_v_greenlet, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._local.all_local_dicts_for_greenlet", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":224
- * __slots__ = ('idt', 'wrdicts')
- *
- * def __init__(self, idt, wrdicts): # <<<<<<<<<<<<<<
- * self.idt = idt
- * self.wrdicts = wrdicts
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_17_greenlet_deleted_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_local_17_greenlet_deleted_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_idt = 0;
- PyObject *__pyx_v_wrdicts = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_idt,&__pyx_n_s_wrdicts,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_idt)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wrdicts)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 224, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 224, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_idt = values[0];
- __pyx_v_wrdicts = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 224, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._greenlet_deleted.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_17_greenlet_deleted___init__(((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)__pyx_v_self), __pyx_v_idt, __pyx_v_wrdicts);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_17_greenlet_deleted___init__(struct __pyx_obj_6gevent_6_local__greenlet_deleted *__pyx_v_self, PyObject *__pyx_v_idt, PyObject *__pyx_v_wrdicts) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/local.py":225
- *
- * def __init__(self, idt, wrdicts):
- * self.idt = idt # <<<<<<<<<<<<<<
- * self.wrdicts = wrdicts
- *
- */
- __Pyx_INCREF(__pyx_v_idt);
- __Pyx_GIVEREF(__pyx_v_idt);
- __Pyx_GOTREF(__pyx_v_self->idt);
- __Pyx_DECREF(__pyx_v_self->idt);
- __pyx_v_self->idt = __pyx_v_idt;
-
- /* "src/gevent/local.py":226
- * def __init__(self, idt, wrdicts):
- * self.idt = idt
- * self.wrdicts = wrdicts # <<<<<<<<<<<<<<
- *
- * def __call__(self, _unused):
- */
- __Pyx_INCREF(__pyx_v_wrdicts);
- __Pyx_GIVEREF(__pyx_v_wrdicts);
- __Pyx_GOTREF(__pyx_v_self->wrdicts);
- __Pyx_DECREF(__pyx_v_self->wrdicts);
- __pyx_v_self->wrdicts = __pyx_v_wrdicts;
-
- /* "src/gevent/local.py":224
- * __slots__ = ('idt', 'wrdicts')
- *
- * def __init__(self, idt, wrdicts): # <<<<<<<<<<<<<<
- * self.idt = idt
- * self.wrdicts = wrdicts
- */
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":228
- * self.wrdicts = wrdicts
- *
- * def __call__(self, _unused): # <<<<<<<<<<<<<<
- * dicts = self.wrdicts()
- * if dicts:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_17_greenlet_deleted_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_local_17_greenlet_deleted_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED PyObject *__pyx_v__unused = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unused,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unused)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 228, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v__unused = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 228, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._greenlet_deleted.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_17_greenlet_deleted_2__call__(((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)__pyx_v_self), __pyx_v__unused);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_17_greenlet_deleted_2__call__(struct __pyx_obj_6gevent_6_local__greenlet_deleted *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__unused) {
- PyObject *__pyx_v_dicts = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/local.py":229
- *
- * def __call__(self, _unused):
- * dicts = self.wrdicts() # <<<<<<<<<<<<<<
- * if dicts:
- * dicts.pop(self.idt, None)
- */
- __Pyx_INCREF(__pyx_v_self->wrdicts);
- __pyx_t_2 = __pyx_v_self->wrdicts; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_dicts = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":230
- * def __call__(self, _unused):
- * dicts = self.wrdicts()
- * if dicts: # <<<<<<<<<<<<<<
- * dicts.pop(self.idt, None)
- *
- */
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_dicts); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 230, __pyx_L1_error)
- if (__pyx_t_4) {
-
- /* "src/gevent/local.py":231
- * dicts = self.wrdicts()
- * if dicts:
- * dicts.pop(self.idt, None) # <<<<<<<<<<<<<<
- *
- * class _local_deleted(object):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dicts, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_self->idt, Py_None};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_self->idt, Py_None};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_self->idt);
- __Pyx_GIVEREF(__pyx_v_self->idt);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self->idt);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, Py_None);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":230
- * def __call__(self, _unused):
- * dicts = self.wrdicts()
- * if dicts: # <<<<<<<<<<<<<<
- * dicts.pop(self.idt, None)
- *
- */
- }
-
- /* "src/gevent/local.py":228
- * self.wrdicts = wrdicts
- *
- * def __call__(self, _unused): # <<<<<<<<<<<<<<
- * dicts = self.wrdicts()
- * if dicts:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._local._greenlet_deleted.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_dicts);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":236
- * __slots__ = ('key', 'wrthread', 'greenlet_deleted')
- *
- * def __init__(self, key, wrthread, greenlet_deleted): # <<<<<<<<<<<<<<
- * self.key = key
- * self.wrthread = wrthread
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_14_local_deleted_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_local_14_local_deleted_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_key = 0;
- PyObject *__pyx_v_wrthread = 0;
- PyObject *__pyx_v_greenlet_deleted = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_wrthread,&__pyx_n_s_greenlet_deleted,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wrthread)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 236, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_greenlet_deleted)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 236, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 236, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_key = values[0];
- __pyx_v_wrthread = values[1];
- __pyx_v_greenlet_deleted = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 236, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._local_deleted.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_14_local_deleted___init__(((struct __pyx_obj_6gevent_6_local__local_deleted *)__pyx_v_self), __pyx_v_key, __pyx_v_wrthread, __pyx_v_greenlet_deleted);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_14_local_deleted___init__(struct __pyx_obj_6gevent_6_local__local_deleted *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_wrthread, PyObject *__pyx_v_greenlet_deleted) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/local.py":237
- *
- * def __init__(self, key, wrthread, greenlet_deleted):
- * self.key = key # <<<<<<<<<<<<<<
- * self.wrthread = wrthread
- * self.greenlet_deleted = greenlet_deleted
- */
- if (!(likely(PyString_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_key)->tp_name), 0))) __PYX_ERR(0, 237, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_key;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->key);
- __Pyx_DECREF(__pyx_v_self->key);
- __pyx_v_self->key = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":238
- * def __init__(self, key, wrthread, greenlet_deleted):
- * self.key = key
- * self.wrthread = wrthread # <<<<<<<<<<<<<<
- * self.greenlet_deleted = greenlet_deleted
- *
- */
- __Pyx_INCREF(__pyx_v_wrthread);
- __Pyx_GIVEREF(__pyx_v_wrthread);
- __Pyx_GOTREF(__pyx_v_self->wrthread);
- __Pyx_DECREF(__pyx_v_self->wrthread);
- __pyx_v_self->wrthread = __pyx_v_wrthread;
-
- /* "src/gevent/local.py":239
- * self.key = key
- * self.wrthread = wrthread
- * self.greenlet_deleted = greenlet_deleted # <<<<<<<<<<<<<<
- *
- * def __call__(self, _unused):
- */
- if (!(likely(((__pyx_v_greenlet_deleted) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_greenlet_deleted, __pyx_ptype_6gevent_6_local__greenlet_deleted))))) __PYX_ERR(0, 239, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_greenlet_deleted;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->greenlet_deleted);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->greenlet_deleted));
- __pyx_v_self->greenlet_deleted = ((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":236
- * __slots__ = ('key', 'wrthread', 'greenlet_deleted')
- *
- * def __init__(self, key, wrthread, greenlet_deleted): # <<<<<<<<<<<<<<
- * self.key = key
- * self.wrthread = wrthread
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._local._local_deleted.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":241
- * self.greenlet_deleted = greenlet_deleted
- *
- * def __call__(self, _unused): # <<<<<<<<<<<<<<
- * thread = self.wrthread()
- * if thread is not None:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_14_local_deleted_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_local_14_local_deleted_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- CYTHON_UNUSED PyObject *__pyx_v__unused = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unused,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unused)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 241, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v__unused = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 241, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._local_deleted.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_14_local_deleted_2__call__(((struct __pyx_obj_6gevent_6_local__local_deleted *)__pyx_v_self), __pyx_v__unused);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_14_local_deleted_2__call__(struct __pyx_obj_6gevent_6_local__local_deleted *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__unused) {
- PyObject *__pyx_v_thread = NULL;
- PyObject *__pyx_v_unlink = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_t_10;
- __Pyx_RefNannySetupContext("__call__", 0);
-
- /* "src/gevent/local.py":242
- *
- * def __call__(self, _unused):
- * thread = self.wrthread() # <<<<<<<<<<<<<<
- * if thread is not None:
- * try:
- */
- __Pyx_INCREF(__pyx_v_self->wrthread);
- __pyx_t_2 = __pyx_v_self->wrthread; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_thread = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":243
- * def __call__(self, _unused):
- * thread = self.wrthread()
- * if thread is not None: # <<<<<<<<<<<<<<
- * try:
- * unlink = thread.unlink
- */
- __pyx_t_4 = (__pyx_v_thread != Py_None);
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/local.py":244
- * thread = self.wrthread()
- * if thread is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink = thread.unlink
- * except AttributeError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- /*try:*/ {
-
- /* "src/gevent/local.py":245
- * if thread is not None:
- * try:
- * unlink = thread.unlink # <<<<<<<<<<<<<<
- * except AttributeError:
- * pass
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_thread, __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_unlink = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":244
- * thread = self.wrthread()
- * if thread is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink = thread.unlink
- * except AttributeError:
- */
- }
-
- /* "src/gevent/local.py":249
- * pass
- * else:
- * unlink(self.greenlet_deleted) # <<<<<<<<<<<<<<
- * del thread.__dict__[self.key]
- *
- */
- /*else:*/ {
- __Pyx_INCREF(__pyx_v_unlink);
- __pyx_t_2 = __pyx_v_unlink; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self->greenlet_deleted)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self->greenlet_deleted)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self->greenlet_deleted)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L6_except_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 249, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self->greenlet_deleted));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->greenlet_deleted));
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, ((PyObject *)__pyx_v_self->greenlet_deleted));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L9_try_end;
- __pyx_L4_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":246
- * try:
- * unlink = thread.unlink
- * except AttributeError: # <<<<<<<<<<<<<<
- * pass
- * else:
- */
- __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
- if (__pyx_t_10) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L5_exception_handled;
- }
- goto __pyx_L6_except_error;
- __pyx_L6_except_error:;
-
- /* "src/gevent/local.py":244
- * thread = self.wrthread()
- * if thread is not None:
- * try: # <<<<<<<<<<<<<<
- * unlink = thread.unlink
- * except AttributeError:
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- goto __pyx_L1_error;
- __pyx_L5_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
- __pyx_L9_try_end:;
- }
-
- /* "src/gevent/local.py":250
- * else:
- * unlink(self.greenlet_deleted)
- * del thread.__dict__[self.key] # <<<<<<<<<<<<<<
- *
- * class _localimpl(object):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_thread, __pyx_n_s_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyObject_DelItem(__pyx_t_1, __pyx_v_self->key) < 0)) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":243
- * def __call__(self, _unused):
- * thread = self.wrthread()
- * if thread is not None: # <<<<<<<<<<<<<<
- * try:
- * unlink = thread.unlink
- */
- }
-
- /* "src/gevent/local.py":241
- * self.greenlet_deleted = greenlet_deleted
- *
- * def __call__(self, _unused): # <<<<<<<<<<<<<<
- * thread = self.wrthread()
- * if thread is not None:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._local._local_deleted.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_thread);
- __Pyx_XDECREF(__pyx_v_unlink);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":259
- * '__weakref__',)
- *
- * def __init__(self, args, kwargs, local_type, id_local): # <<<<<<<<<<<<<<
- * self.key = key_prefix + str(id(self))
- * # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_10_localimpl_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_local_10_localimpl_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kwargs = 0;
- PyObject *__pyx_v_local_type = 0;
- PyObject *__pyx_v_id_local = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_local_type,&__pyx_n_s_id_local,0};
- PyObject* values[4] = {0,0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); __PYX_ERR(0, 259, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_local_type)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(0, 259, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id_local)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); __PYX_ERR(0, 259, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 259, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- }
- __pyx_v_args = values[0];
- __pyx_v_kwargs = values[1];
- __pyx_v_local_type = values[2];
- __pyx_v_id_local = values[3];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 259, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._localimpl.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_10_localimpl___init__(((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs, __pyx_v_local_type, __pyx_v_id_local);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_10_localimpl___init__(struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, PyObject *__pyx_v_local_type, PyObject *__pyx_v_id_local) {
- PyGreenlet *__pyx_v_greenlet = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/local.py":260
- *
- * def __init__(self, args, kwargs, local_type, id_local):
- * self.key = key_prefix + str(id(self)) # <<<<<<<<<<<<<<
- * # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- * self.dicts = _wrefdict()
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyNumber_Add(__pyx_v_6gevent_6_local_key_prefix, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->key);
- __Pyx_DECREF(__pyx_v_self->key);
- __pyx_v_self->key = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":262
- * self.key = key_prefix + str(id(self))
- * # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- * self.dicts = _wrefdict() # <<<<<<<<<<<<<<
- * self.localargs = args
- * self.localkwargs = kwargs
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_6_local__wrefdict)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->dicts);
- __Pyx_DECREF(__pyx_v_self->dicts);
- __pyx_v_self->dicts = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":263
- * # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- * self.dicts = _wrefdict()
- * self.localargs = args # <<<<<<<<<<<<<<
- * self.localkwargs = kwargs
- * self.localtypeid = local_type, id_local
- */
- if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 263, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_args;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->localargs);
- __Pyx_DECREF(__pyx_v_self->localargs);
- __pyx_v_self->localargs = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":264
- * self.dicts = _wrefdict()
- * self.localargs = args
- * self.localkwargs = kwargs # <<<<<<<<<<<<<<
- * self.localtypeid = local_type, id_local
- *
- */
- if (!(likely(PyDict_CheckExact(__pyx_v_kwargs))||((__pyx_v_kwargs) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_kwargs)->tp_name), 0))) __PYX_ERR(0, 264, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_kwargs;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->localkwargs);
- __Pyx_DECREF(__pyx_v_self->localkwargs);
- __pyx_v_self->localkwargs = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":265
- * self.localargs = args
- * self.localkwargs = kwargs
- * self.localtypeid = local_type, id_local # <<<<<<<<<<<<<<
- *
- * # We need to create the thread dict in anticipation of
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_local_type);
- __Pyx_GIVEREF(__pyx_v_local_type);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_local_type);
- __Pyx_INCREF(__pyx_v_id_local);
- __Pyx_GIVEREF(__pyx_v_id_local);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_id_local);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->localtypeid);
- __Pyx_DECREF(__pyx_v_self->localtypeid);
- __pyx_v_self->localtypeid = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":270
- * # __init__ being called, to make sure we don't call it
- * # again ourselves. MUST do this before setting any attributes.
- * greenlet = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * _localimpl_create_dict(self, greenlet, id(greenlet))
- *
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_local_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_greenlet = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":271
- * # again ourselves. MUST do this before setting any attributes.
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- * _localimpl_create_dict(self, greenlet, id(greenlet)) # <<<<<<<<<<<<<<
- *
- * class _localimpl_dict_entry(object):
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_greenlet)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6_local__localimpl_create_dict(__pyx_v_self, __pyx_v_greenlet, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":259
- * '__weakref__',)
- *
- * def __init__(self, args, kwargs, local_type, id_local): # <<<<<<<<<<<<<<
- * self.key = key_prefix + str(id(self))
- * # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._local._localimpl.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_greenlet);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":282
- * __slots__ = ('wrgreenlet', 'localdict')
- *
- * def __init__(self, wrgreenlet, localdict): # <<<<<<<<<<<<<<
- * self.wrgreenlet = wrgreenlet
- * self.localdict = localdict
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_21_localimpl_dict_entry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_local_21_localimpl_dict_entry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_wrgreenlet = 0;
- PyObject *__pyx_v_localdict = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wrgreenlet,&__pyx_n_s_localdict,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wrgreenlet)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_localdict)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 282, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 282, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_wrgreenlet = values[0];
- __pyx_v_localdict = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 282, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._local._localimpl_dict_entry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_21_localimpl_dict_entry___init__(((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)__pyx_v_self), __pyx_v_wrgreenlet, __pyx_v_localdict);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_21_localimpl_dict_entry___init__(struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_self, PyObject *__pyx_v_wrgreenlet, PyObject *__pyx_v_localdict) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/local.py":283
- *
- * def __init__(self, wrgreenlet, localdict):
- * self.wrgreenlet = wrgreenlet # <<<<<<<<<<<<<<
- * self.localdict = localdict
- *
- */
- __Pyx_INCREF(__pyx_v_wrgreenlet);
- __Pyx_GIVEREF(__pyx_v_wrgreenlet);
- __Pyx_GOTREF(__pyx_v_self->wrgreenlet);
- __Pyx_DECREF(__pyx_v_self->wrgreenlet);
- __pyx_v_self->wrgreenlet = __pyx_v_wrgreenlet;
-
- /* "src/gevent/local.py":284
- * def __init__(self, wrgreenlet, localdict):
- * self.wrgreenlet = wrgreenlet
- * self.localdict = localdict # <<<<<<<<<<<<<<
- *
- * # We use functions instead of methods so that they can be cdef'd in
- */
- if (!(likely(PyDict_CheckExact(__pyx_v_localdict))||((__pyx_v_localdict) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_localdict)->tp_name), 0))) __PYX_ERR(0, 284, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_localdict;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->localdict);
- __Pyx_DECREF(__pyx_v_self->localdict);
- __pyx_v_self->localdict = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":282
- * __slots__ = ('wrgreenlet', 'localdict')
- *
- * def __init__(self, wrgreenlet, localdict): # <<<<<<<<<<<<<<
- * self.wrgreenlet = wrgreenlet
- * self.localdict = localdict
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._local._localimpl_dict_entry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":294
- *
- *
- * def _localimpl_create_dict(self, greenlet, id_greenlet): # <<<<<<<<<<<<<<
- * """Create a new dict for the current thread, and return it."""
- * localdict = {}
- */
-
-static PyObject *__pyx_f_6gevent_6_local__localimpl_create_dict(struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_self, PyGreenlet *__pyx_v_greenlet, PyObject *__pyx_v_id_greenlet) {
- PyObject *__pyx_v_localdict = 0;
- PyObject *__pyx_v_key = 0;
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *__pyx_v_greenlet_deleted = 0;
- struct __pyx_obj_6gevent_6_local__local_deleted *__pyx_v_local_deleted = 0;
- PyObject *__pyx_v_wrdicts = NULL;
- PyObject *__pyx_v_rawlink = NULL;
- PyObject *__pyx_v_wrthread = NULL;
- PyObject *__pyx_v_wrlocal = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("_localimpl_create_dict", 0);
-
- /* "src/gevent/local.py":296
- * def _localimpl_create_dict(self, greenlet, id_greenlet):
- * """Create a new dict for the current thread, and return it."""
- * localdict = {} # <<<<<<<<<<<<<<
- * key = self.key
- *
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_localdict = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":297
- * """Create a new dict for the current thread, and return it."""
- * localdict = {}
- * key = self.key # <<<<<<<<<<<<<<
- *
- * wrdicts = ref(self.dicts)
- */
- __pyx_t_1 = __pyx_v_self->key;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_key = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":299
- * key = self.key
- *
- * wrdicts = ref(self.dicts) # <<<<<<<<<<<<<<
- *
- * # When the greenlet is deleted, remove the local dict.
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_local_ref);
- __pyx_t_2 = __pyx_v_6gevent_6_local_ref; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->dicts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->dicts};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->dicts};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_self->dicts);
- __Pyx_GIVEREF(__pyx_v_self->dicts);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->dicts);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_wrdicts = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":310
- * # issue described above. Use rawlink to avoid spawning any
- * # more greenlets.
- * greenlet_deleted = _greenlet_deleted(id_greenlet, wrdicts) # <<<<<<<<<<<<<<
- *
- * rawlink = getattr(greenlet, 'rawlink', None)
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_id_greenlet);
- __Pyx_GIVEREF(__pyx_v_id_greenlet);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_id_greenlet);
- __Pyx_INCREF(__pyx_v_wrdicts);
- __Pyx_GIVEREF(__pyx_v_wrdicts);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_wrdicts);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_local__greenlet_deleted), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_greenlet_deleted = ((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":312
- * greenlet_deleted = _greenlet_deleted(id_greenlet, wrdicts)
- *
- * rawlink = getattr(greenlet, 'rawlink', None) # <<<<<<<<<<<<<<
- * if rawlink is not None:
- * rawlink(greenlet_deleted)
- */
- __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_greenlet), __pyx_n_s_rawlink, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_rawlink = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":313
- *
- * rawlink = getattr(greenlet, 'rawlink', None)
- * if rawlink is not None: # <<<<<<<<<<<<<<
- * rawlink(greenlet_deleted)
- * wrthread = ref(greenlet)
- */
- __pyx_t_5 = (__pyx_v_rawlink != Py_None);
- __pyx_t_6 = (__pyx_t_5 != 0);
- if (__pyx_t_6) {
-
- /* "src/gevent/local.py":314
- * rawlink = getattr(greenlet, 'rawlink', None)
- * if rawlink is not None:
- * rawlink(greenlet_deleted) # <<<<<<<<<<<<<<
- * wrthread = ref(greenlet)
- * else:
- */
- __Pyx_INCREF(__pyx_v_rawlink);
- __pyx_t_1 = __pyx_v_rawlink; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_greenlet_deleted)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_greenlet_deleted)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_greenlet_deleted)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_greenlet_deleted));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_greenlet_deleted));
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_greenlet_deleted));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":315
- * if rawlink is not None:
- * rawlink(greenlet_deleted)
- * wrthread = ref(greenlet) # <<<<<<<<<<<<<<
- * else:
- * wrthread = ref(greenlet, greenlet_deleted)
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_local_ref);
- __pyx_t_1 = __pyx_v_6gevent_6_local_ref; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_greenlet)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_greenlet)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_greenlet)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_greenlet));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_greenlet));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_wrthread = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":313
- *
- * rawlink = getattr(greenlet, 'rawlink', None)
- * if rawlink is not None: # <<<<<<<<<<<<<<
- * rawlink(greenlet_deleted)
- * wrthread = ref(greenlet)
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/local.py":317
- * wrthread = ref(greenlet)
- * else:
- * wrthread = ref(greenlet, greenlet_deleted) # <<<<<<<<<<<<<<
- *
- *
- */
- /*else*/ {
- __Pyx_INCREF(__pyx_v_6gevent_6_local_ref);
- __pyx_t_1 = __pyx_v_6gevent_6_local_ref; __pyx_t_4 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_greenlet), ((PyObject *)__pyx_v_greenlet_deleted)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_greenlet), ((PyObject *)__pyx_v_greenlet_deleted)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_greenlet));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_greenlet));
- PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, ((PyObject *)__pyx_v_greenlet));
- __Pyx_INCREF(((PyObject *)__pyx_v_greenlet_deleted));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_greenlet_deleted));
- PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, ((PyObject *)__pyx_v_greenlet_deleted));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_wrthread = __pyx_t_2;
- __pyx_t_2 = 0;
- }
- __pyx_L3:;
-
- /* "src/gevent/local.py":321
- *
- * # When the localimpl is deleted, remove the thread attribute.
- * local_deleted = _local_deleted(key, wrthread, greenlet_deleted) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_key);
- __Pyx_GIVEREF(__pyx_v_key);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
- __Pyx_INCREF(__pyx_v_wrthread);
- __Pyx_GIVEREF(__pyx_v_wrthread);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_wrthread);
- __Pyx_INCREF(((PyObject *)__pyx_v_greenlet_deleted));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_greenlet_deleted));
- PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_greenlet_deleted));
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_local__local_deleted), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_local_deleted = ((struct __pyx_obj_6gevent_6_local__local_deleted *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":324
- *
- *
- * wrlocal = ref(self, local_deleted) # <<<<<<<<<<<<<<
- * greenlet.__dict__[key] = wrlocal
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_local_ref);
- __pyx_t_2 = __pyx_v_6gevent_6_local_ref; __pyx_t_3 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_local_deleted)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_local_deleted)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_local_deleted));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_local_deleted));
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, ((PyObject *)__pyx_v_local_deleted));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_wrlocal = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":325
- *
- * wrlocal = ref(self, local_deleted)
- * greenlet.__dict__[key] = wrlocal # <<<<<<<<<<<<<<
- *
- * self.dicts[id_greenlet] = _localimpl_dict_entry(wrthread, localdict)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_greenlet), __pyx_n_s_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_key, __pyx_v_wrlocal) < 0)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":327
- * greenlet.__dict__[key] = wrlocal
- *
- * self.dicts[id_greenlet] = _localimpl_dict_entry(wrthread, localdict) # <<<<<<<<<<<<<<
- * return localdict
- *
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_wrthread);
- __Pyx_GIVEREF(__pyx_v_wrthread);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_wrthread);
- __Pyx_INCREF(__pyx_v_localdict);
- __Pyx_GIVEREF(__pyx_v_localdict);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_localdict);
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_local__localimpl_dict_entry), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(__pyx_v_self->dicts == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 327, __pyx_L1_error)
- }
- if (unlikely(PyDict_SetItem(__pyx_v_self->dicts, __pyx_v_id_greenlet, __pyx_t_2) < 0)) __PYX_ERR(0, 327, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":328
- *
- * self.dicts[id_greenlet] = _localimpl_dict_entry(wrthread, localdict)
- * return localdict # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_localdict);
- __pyx_r = __pyx_v_localdict;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":294
- *
- *
- * def _localimpl_create_dict(self, greenlet, id_greenlet): # <<<<<<<<<<<<<<
- * """Create a new dict for the current thread, and return it."""
- * localdict = {}
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._local._localimpl_create_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_localdict);
- __Pyx_XDECREF(__pyx_v_key);
- __Pyx_XDECREF((PyObject *)__pyx_v_greenlet_deleted);
- __Pyx_XDECREF((PyObject *)__pyx_v_local_deleted);
- __Pyx_XDECREF(__pyx_v_wrdicts);
- __Pyx_XDECREF(__pyx_v_rawlink);
- __Pyx_XDECREF(__pyx_v_wrthread);
- __Pyx_XDECREF(__pyx_v_wrlocal);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":333
- * _marker = object()
- *
- * def _local_get_dict(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * # Cython can optimize dict[], but not dict.get()
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_6_local__local_get_dict(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self) {
- struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_impl = 0;
- PyObject *__pyx_v_dct = 0;
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_entry = 0;
- PyGreenlet *__pyx_v_greenlet = NULL;
- PyObject *__pyx_v_idg = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- __Pyx_RefNannySetupContext("_local_get_dict", 0);
-
- /* "src/gevent/local.py":334
- *
- * def _local_get_dict(self):
- * impl = self._local__impl # <<<<<<<<<<<<<<
- * # Cython can optimize dict[], but not dict.get()
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_self->_local__impl);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":336
- * impl = self._local__impl
- * # Cython can optimize dict[], but not dict.get()
- * greenlet = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * idg = id(greenlet)
- * try:
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_local_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_greenlet = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":337
- * # Cython can optimize dict[], but not dict.get()
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- * idg = id(greenlet) # <<<<<<<<<<<<<<
- * try:
- * entry = impl.dicts[idg]
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_greenlet)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_idg = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":338
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- * idg = id(greenlet)
- * try: # <<<<<<<<<<<<<<
- * entry = impl.dicts[idg]
- * dct = entry.localdict
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- /*try:*/ {
-
- /* "src/gevent/local.py":339
- * idg = id(greenlet)
- * try:
- * entry = impl.dicts[idg] # <<<<<<<<<<<<<<
- * dct = entry.localdict
- * except KeyError:
- */
- if (unlikely(__pyx_v_impl->dicts == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 339, __pyx_L3_error)
- }
- __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_impl->dicts, __pyx_v_idg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local__localimpl_dict_entry))))) __PYX_ERR(0, 339, __pyx_L3_error)
- __pyx_v_entry = ((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":340
- * try:
- * entry = impl.dicts[idg]
- * dct = entry.localdict # <<<<<<<<<<<<<<
- * except KeyError:
- * dct = _localimpl_create_dict(impl, greenlet, idg)
- */
- __pyx_t_1 = __pyx_v_entry->localdict;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_dct = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":338
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- * idg = id(greenlet)
- * try: # <<<<<<<<<<<<<<
- * entry = impl.dicts[idg]
- * dct = entry.localdict
- */
- }
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":341
- * entry = impl.dicts[idg]
- * dct = entry.localdict
- * except KeyError: # <<<<<<<<<<<<<<
- * dct = _localimpl_create_dict(impl, greenlet, idg)
- * self.__init__(*impl.localargs, **impl.localkwargs)
- */
- __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_5) {
- __Pyx_AddTraceback("gevent._local._local_get_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 341, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "src/gevent/local.py":342
- * dct = entry.localdict
- * except KeyError:
- * dct = _localimpl_create_dict(impl, greenlet, idg) # <<<<<<<<<<<<<<
- * self.__init__(*impl.localargs, **impl.localkwargs)
- * return dct
- */
- __pyx_t_8 = __pyx_f_6gevent_6_local__localimpl_create_dict(__pyx_v_impl, __pyx_v_greenlet, __pyx_v_idg); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 342, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_XDECREF_SET(__pyx_v_dct, ((PyObject*)__pyx_t_8));
- __pyx_t_8 = 0;
-
- /* "src/gevent/local.py":343
- * except KeyError:
- * dct = _localimpl_create_dict(impl, greenlet, idg)
- * self.__init__(*impl.localargs, **impl.localkwargs) # <<<<<<<<<<<<<<
- * return dct
- *
- */
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 343, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (unlikely(__pyx_v_impl->localargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 343, __pyx_L5_except_error)
- }
- if (unlikely(__pyx_v_impl->localkwargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
- __PYX_ERR(0, 343, __pyx_L5_except_error)
- }
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_v_impl->localargs, __pyx_v_impl->localkwargs); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 343, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/local.py":338
- * greenlet = getcurrent() # pylint:disable=undefined-variable
- * idg = id(greenlet)
- * try: # <<<<<<<<<<<<<<
- * entry = impl.dicts[idg]
- * dct = entry.localdict
- */
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/local.py":344
- * dct = _localimpl_create_dict(impl, greenlet, idg)
- * self.__init__(*impl.localargs, **impl.localkwargs)
- * return dct # <<<<<<<<<<<<<<
- *
- * def _init():
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_dct);
- __pyx_r = __pyx_v_dct;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":333
- * _marker = object()
- *
- * def _local_get_dict(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * # Cython can optimize dict[], but not dict.get()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._local._local_get_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_impl);
- __Pyx_XDECREF(__pyx_v_dct);
- __Pyx_XDECREF((PyObject *)__pyx_v_entry);
- __Pyx_XDECREF((PyObject *)__pyx_v_greenlet);
- __Pyx_XDECREF(__pyx_v_idg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":346
- * return dct
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
-static void __pyx_f_6gevent_6_local__init(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_init", 0);
-
- /* "src/gevent/local.py":347
- *
- * def _init():
- * greenlet_init() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * _local_attrs = {
- */
- __pyx_f_6gevent_6_local_greenlet_init();
-
- /* "src/gevent/local.py":346
- * return dct
- *
- * def _init(): # <<<<<<<<<<<<<<
- * greenlet_init() # pylint:disable=undefined-variable
- *
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "src/gevent/local.py":367
- * __slots__ = tuple(_local_attrs - {'__class__', '__cinit__'})
- *
- * def __cinit__(self, *args, **kw): # <<<<<<<<<<<<<<
- * if args or kw:
- * if type(self).__init__ == object.__init__:
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_5local_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_local_5local_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kw = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
- __pyx_v_kw = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kw)) return -1;
- __Pyx_GOTREF(__pyx_v_kw);
- __Pyx_INCREF(__pyx_args);
- __pyx_v_args = __pyx_args;
- __pyx_r = __pyx_pf_6gevent_6_local_5local___cinit__(((struct __pyx_obj_6gevent_6_local_local *)__pyx_v_self), __pyx_v_args, __pyx_v_kw);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kw);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_5local___cinit__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kw) {
- struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_impl = NULL;
- PyObject *__pyx_v_get = NULL;
- PyObject *__pyx_v_dels = NULL;
- PyObject *__pyx_v_sets_or_dels = NULL;
- PyObject *__pyx_v_sets = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- /* "src/gevent/local.py":368
- *
- * def __cinit__(self, *args, **kw):
- * if args or kw: # <<<<<<<<<<<<<<
- * if type(self).__init__ == object.__init__:
- * raise TypeError("Initialization arguments are not supported", args, kw)
- */
- __pyx_t_2 = (PyTuple_GET_SIZE(__pyx_v_args) != 0);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_kw); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 368, __pyx_L1_error)
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":369
- * def __cinit__(self, *args, **kw):
- * if args or kw:
- * if type(self).__init__ == object.__init__: # <<<<<<<<<<<<<<
- * raise TypeError("Initialization arguments are not supported", args, kw)
- * impl = _localimpl(args, kw, type(self), id(self))
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_init); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 369, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 369, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/local.py":370
- * if args or kw:
- * if type(self).__init__ == object.__init__:
- * raise TypeError("Initialization arguments are not supported", args, kw) # <<<<<<<<<<<<<<
- * impl = _localimpl(args, kw, type(self), id(self))
- * # pylint:disable=attribute-defined-outside-init
- */
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_kp_s_Initialization_arguments_are_not);
- __Pyx_GIVEREF(__pyx_kp_s_Initialization_arguments_are_not);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_s_Initialization_arguments_are_not);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_args);
- __Pyx_INCREF(__pyx_v_kw);
- __Pyx_GIVEREF(__pyx_v_kw);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_kw);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 370, __pyx_L1_error)
-
- /* "src/gevent/local.py":369
- * def __cinit__(self, *args, **kw):
- * if args or kw:
- * if type(self).__init__ == object.__init__: # <<<<<<<<<<<<<<
- * raise TypeError("Initialization arguments are not supported", args, kw)
- * impl = _localimpl(args, kw, type(self), id(self))
- */
- }
-
- /* "src/gevent/local.py":368
- *
- * def __cinit__(self, *args, **kw):
- * if args or kw: # <<<<<<<<<<<<<<
- * if type(self).__init__ == object.__init__:
- * raise TypeError("Initialization arguments are not supported", args, kw)
- */
- }
-
- /* "src/gevent/local.py":371
- * if type(self).__init__ == object.__init__:
- * raise TypeError("Initialization arguments are not supported", args, kw)
- * impl = _localimpl(args, kw, type(self), id(self)) # <<<<<<<<<<<<<<
- * # pylint:disable=attribute-defined-outside-init
- * self._local__impl = impl
- */
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_args);
- __Pyx_GIVEREF(__pyx_v_args);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_args);
- __Pyx_INCREF(__pyx_v_kw);
- __Pyx_GIVEREF(__pyx_v_kw);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_kw);
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_local__localimpl), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":373
- * impl = _localimpl(args, kw, type(self), id(self))
- * # pylint:disable=attribute-defined-outside-init
- * self._local__impl = impl # <<<<<<<<<<<<<<
- * get, dels, sets_or_dels, sets = _local_find_descriptors(self)
- * self._local_type_get_descriptors = get
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_impl));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_impl));
- __Pyx_GOTREF(__pyx_v_self->_local__impl);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_local__impl));
- __pyx_v_self->_local__impl = __pyx_v_impl;
-
- /* "src/gevent/local.py":374
- * # pylint:disable=attribute-defined-outside-init
- * self._local__impl = impl
- * get, dels, sets_or_dels, sets = _local_find_descriptors(self) # <<<<<<<<<<<<<<
- * self._local_type_get_descriptors = get
- * self._local_type_set_or_del_descriptors = sets_or_dels
- */
- __pyx_t_4 = __pyx_f_6gevent_6_local__local_find_descriptors(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (likely(__pyx_t_4 != Py_None)) {
- PyObject* sequence = __pyx_t_4;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 4)) {
- if (size > 4) __Pyx_RaiseTooManyValuesError(4);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 374, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2);
- __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- #else
- {
- Py_ssize_t i;
- PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_3,&__pyx_t_6,&__pyx_t_7};
- for (i=0; i < 4; i++) {
- PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 374, __pyx_L1_error)
- __Pyx_GOTREF(item);
- *(temps[i]) = item;
- }
- }
- #endif
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 374, __pyx_L1_error)
- }
- __pyx_v_get = __pyx_t_5;
- __pyx_t_5 = 0;
- __pyx_v_dels = __pyx_t_3;
- __pyx_t_3 = 0;
- __pyx_v_sets_or_dels = __pyx_t_6;
- __pyx_t_6 = 0;
- __pyx_v_sets = __pyx_t_7;
- __pyx_t_7 = 0;
-
- /* "src/gevent/local.py":375
- * self._local__impl = impl
- * get, dels, sets_or_dels, sets = _local_find_descriptors(self)
- * self._local_type_get_descriptors = get # <<<<<<<<<<<<<<
- * self._local_type_set_or_del_descriptors = sets_or_dels
- * self._local_type_del_descriptors = dels
- */
- if (!(likely(PySet_CheckExact(__pyx_v_get))||((__pyx_v_get) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_get)->tp_name), 0))) __PYX_ERR(0, 375, __pyx_L1_error)
- __pyx_t_4 = __pyx_v_get;
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_local_type_get_descriptors);
- __Pyx_DECREF(__pyx_v_self->_local_type_get_descriptors);
- __pyx_v_self->_local_type_get_descriptors = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":376
- * get, dels, sets_or_dels, sets = _local_find_descriptors(self)
- * self._local_type_get_descriptors = get
- * self._local_type_set_or_del_descriptors = sets_or_dels # <<<<<<<<<<<<<<
- * self._local_type_del_descriptors = dels
- * self._local_type_set_descriptors = sets
- */
- if (!(likely(PySet_CheckExact(__pyx_v_sets_or_dels))||((__pyx_v_sets_or_dels) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_sets_or_dels)->tp_name), 0))) __PYX_ERR(0, 376, __pyx_L1_error)
- __pyx_t_4 = __pyx_v_sets_or_dels;
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_local_type_set_or_del_descriptors);
- __Pyx_DECREF(__pyx_v_self->_local_type_set_or_del_descriptors);
- __pyx_v_self->_local_type_set_or_del_descriptors = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":377
- * self._local_type_get_descriptors = get
- * self._local_type_set_or_del_descriptors = sets_or_dels
- * self._local_type_del_descriptors = dels # <<<<<<<<<<<<<<
- * self._local_type_set_descriptors = sets
- * self._local_type = type(self)
- */
- if (!(likely(PySet_CheckExact(__pyx_v_dels))||((__pyx_v_dels) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_dels)->tp_name), 0))) __PYX_ERR(0, 377, __pyx_L1_error)
- __pyx_t_4 = __pyx_v_dels;
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_local_type_del_descriptors);
- __Pyx_DECREF(__pyx_v_self->_local_type_del_descriptors);
- __pyx_v_self->_local_type_del_descriptors = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":378
- * self._local_type_set_or_del_descriptors = sets_or_dels
- * self._local_type_del_descriptors = dels
- * self._local_type_set_descriptors = sets # <<<<<<<<<<<<<<
- * self._local_type = type(self)
- * self._local_type_vars = set(dir(self._local_type))
- */
- if (!(likely(PySet_CheckExact(__pyx_v_sets))||((__pyx_v_sets) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_sets)->tp_name), 0))) __PYX_ERR(0, 378, __pyx_L1_error)
- __pyx_t_4 = __pyx_v_sets;
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_local_type_set_descriptors);
- __Pyx_DECREF(__pyx_v_self->_local_type_set_descriptors);
- __pyx_v_self->_local_type_set_descriptors = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":379
- * self._local_type_del_descriptors = dels
- * self._local_type_set_descriptors = sets
- * self._local_type = type(self) # <<<<<<<<<<<<<<
- * self._local_type_vars = set(dir(self._local_type))
- *
- */
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GOTREF(__pyx_v_self->_local_type);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_local_type));
- __pyx_v_self->_local_type = ((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
-
- /* "src/gevent/local.py":380
- * self._local_type_set_descriptors = sets
- * self._local_type = type(self)
- * self._local_type_vars = set(dir(self._local_type)) # <<<<<<<<<<<<<<
- *
- * def __getattribute__(self, name): # pylint:disable=too-many-return-statements
- */
- __pyx_t_4 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_7 = PyObject_Dir(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 380, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PySet_New(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_v_self->_local_type_vars);
- __Pyx_DECREF(__pyx_v_self->_local_type_vars);
- __pyx_v_self->_local_type_vars = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":367
- * __slots__ = tuple(_local_attrs - {'__class__', '__cinit__'})
- *
- * def __cinit__(self, *args, **kw): # <<<<<<<<<<<<<<
- * if args or kw:
- * if type(self).__init__ == object.__init__:
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._local.local.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_impl);
- __Pyx_XDECREF(__pyx_v_get);
- __Pyx_XDECREF(__pyx_v_dels);
- __Pyx_XDECREF(__pyx_v_sets_or_dels);
- __Pyx_XDECREF(__pyx_v_sets);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":382
- * self._local_type_vars = set(dir(self._local_type))
- *
- * def __getattribute__(self, name): # pylint:disable=too-many-return-statements # <<<<<<<<<<<<<<
- * if name in _local_attrs:
- * # The _local__impl, __cinit__, etc, won't be hit by the
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_5local_3__getattribute__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_local_5local_3__getattribute__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getattribute__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_local_5local_2__getattribute__(((struct __pyx_obj_6gevent_6_local_local *)__pyx_v_self), ((PyObject *)__pyx_v_name));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_5local_2__getattribute__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name) {
- PyObject *__pyx_v_dct = NULL;
- PyObject *__pyx_v_type_attr = NULL;
- PyObject *__pyx_v_base = NULL;
- PyObject *__pyx_v_bd = NULL;
- PyObject *__pyx_v_attr_on_type = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- Py_ssize_t __pyx_t_9;
- PyObject *(*__pyx_t_10)(PyObject *);
- __Pyx_RefNannySetupContext("__getattribute__", 0);
-
- /* "src/gevent/local.py":383
- *
- * def __getattribute__(self, name): # pylint:disable=too-many-return-statements
- * if name in _local_attrs: # <<<<<<<<<<<<<<
- * # The _local__impl, __cinit__, etc, won't be hit by the
- * # Cython version, if we've done things right. If we haven't,
- */
- if (unlikely(__pyx_v_6gevent_6_local__local_attrs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 383, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_6gevent_6_local__local_attrs, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":387
- * # Cython version, if we've done things right. If we haven't,
- * # they will be, and this will produce an error.
- * return object.__getattribute__(self, name) # <<<<<<<<<<<<<<
- *
- * dct = _local_get_dict(self)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":383
- *
- * def __getattribute__(self, name): # pylint:disable=too-many-return-statements
- * if name in _local_attrs: # <<<<<<<<<<<<<<
- * # The _local__impl, __cinit__, etc, won't be hit by the
- * # Cython version, if we've done things right. If we haven't,
- */
- }
-
- /* "src/gevent/local.py":389
- * return object.__getattribute__(self, name)
- *
- * dct = _local_get_dict(self) # <<<<<<<<<<<<<<
- *
- * if name == '__dict__':
- */
- __pyx_t_3 = __pyx_f_6gevent_6_local__local_get_dict(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_dct = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":391
- * dct = _local_get_dict(self)
- *
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * return dct
- * # If there's no possible way we can switch, because this
- */
- __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_name, __pyx_n_s_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 391, __pyx_L1_error)
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":392
- *
- * if name == '__dict__':
- * return dct # <<<<<<<<<<<<<<
- * # If there's no possible way we can switch, because this
- * # attribute is *not* found in the class where it might be a
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_dct);
- __pyx_r = __pyx_v_dct;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":391
- * dct = _local_get_dict(self)
- *
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * return dct
- * # If there's no possible way we can switch, because this
- */
- }
-
- /* "src/gevent/local.py":407
- * # there can be no descriptors except for methods, which will
- * # never need to use __dict__.
- * if self._local_type is local: # <<<<<<<<<<<<<<
- * return dct[name] if name in dct else object.__getattribute__(self, name)
- *
- */
- __pyx_t_2 = (__pyx_v_self->_local_type == __pyx_ptype_6gevent_6_local_local);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":408
- * # never need to use __dict__.
- * if self._local_type is local:
- * return dct[name] if name in dct else object.__getattribute__(self, name) # <<<<<<<<<<<<<<
- *
- * # NOTE: If this is a descriptor, this will invoke its __get__.
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 408, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_dct, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 408, __pyx_L1_error)
- if ((__pyx_t_1 != 0)) {
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 408, __pyx_L1_error)
- }
- __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_dct, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __pyx_t_4;
- __pyx_t_4 = 0;
- } else {
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattribute); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_v_name);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 408, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_3 = __pyx_t_4;
- __pyx_t_4 = 0;
- }
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":407
- * # there can be no descriptors except for methods, which will
- * # never need to use __dict__.
- * if self._local_type is local: # <<<<<<<<<<<<<<
- * return dct[name] if name in dct else object.__getattribute__(self, name)
- *
- */
- }
-
- /* "src/gevent/local.py":415
- * # But this is faster than a loop over mro() checking each class __dict__
- * # manually.
- * if name in dct: # <<<<<<<<<<<<<<
- * if name not in self._local_type_vars:
- * # If there is a dict value, and nothing in the type,
- */
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 415, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_dct, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 415, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":416
- * # manually.
- * if name in dct:
- * if name not in self._local_type_vars: # <<<<<<<<<<<<<<
- * # If there is a dict value, and nothing in the type,
- * # it can't possibly be a descriptor, so it is just returned.
- */
- if (unlikely(__pyx_v_self->_local_type_vars == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 416, __pyx_L1_error)
- }
- __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_vars, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 416, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":419
- * # If there is a dict value, and nothing in the type,
- * # it can't possibly be a descriptor, so it is just returned.
- * return dct[name] # <<<<<<<<<<<<<<
- *
- * # It's in the type *and* in the dict. If the type value is
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 419, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_dct, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":416
- * # manually.
- * if name in dct:
- * if name not in self._local_type_vars: # <<<<<<<<<<<<<<
- * # If there is a dict value, and nothing in the type,
- * # it can't possibly be a descriptor, so it is just returned.
- */
- }
-
- /* "src/gevent/local.py":428
- * # NOTE that the docs for descriptors say that these methods must be
- * # defined on the *class* of the object in the type.
- * if name not in self._local_type_get_descriptors: # <<<<<<<<<<<<<<
- * # Entirely not a descriptor. Instance wins.
- * return dct[name]
- */
- if (unlikely(__pyx_v_self->_local_type_get_descriptors == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 428, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_get_descriptors, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 428, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":430
- * if name not in self._local_type_get_descriptors:
- * # Entirely not a descriptor. Instance wins.
- * return dct[name] # <<<<<<<<<<<<<<
- * if name in self._local_type_set_or_del_descriptors:
- * # A data descriptor.
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 430, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_dct, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":428
- * # NOTE that the docs for descriptors say that these methods must be
- * # defined on the *class* of the object in the type.
- * if name not in self._local_type_get_descriptors: # <<<<<<<<<<<<<<
- * # Entirely not a descriptor. Instance wins.
- * return dct[name]
- */
- }
-
- /* "src/gevent/local.py":431
- * # Entirely not a descriptor. Instance wins.
- * return dct[name]
- * if name in self._local_type_set_or_del_descriptors: # <<<<<<<<<<<<<<
- * # A data descriptor.
- * # arbitrary code execution while these run. If they touch self again,
- */
- if (unlikely(__pyx_v_self->_local_type_set_or_del_descriptors == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 431, __pyx_L1_error)
- }
- __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_set_or_del_descriptors, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 431, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":435
- * # arbitrary code execution while these run. If they touch self again,
- * # they'll call back into us and we'll repeat the dance.
- * type_attr = getattr(self._local_type, name) # <<<<<<<<<<<<<<
- * return type(type_attr).__get__(type_attr, self, self._local_type)
- * # Last case is a non-data descriptor. Instance wins.
- */
- __pyx_t_3 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_GetAttr(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_type_attr = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":436
- * # they'll call back into us and we'll repeat the dance.
- * type_attr = getattr(self._local_type, name)
- * return type(type_attr).__get__(type_attr, self, self._local_type) # <<<<<<<<<<<<<<
- * # Last case is a non-data descriptor. Instance wins.
- * return dct[name]
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_type_attr)), __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_7 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_type_attr, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_self->_local_type)};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_type_attr, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_self->_local_type)};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_7) {
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
- }
- __Pyx_INCREF(__pyx_v_type_attr);
- __Pyx_GIVEREF(__pyx_v_type_attr);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_v_type_attr);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_self->_local_type));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_local_type));
- PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_6, ((PyObject *)__pyx_v_self->_local_type));
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":431
- * # Entirely not a descriptor. Instance wins.
- * return dct[name]
- * if name in self._local_type_set_or_del_descriptors: # <<<<<<<<<<<<<<
- * # A data descriptor.
- * # arbitrary code execution while these run. If they touch self again,
- */
- }
-
- /* "src/gevent/local.py":438
- * return type(type_attr).__get__(type_attr, self, self._local_type)
- * # Last case is a non-data descriptor. Instance wins.
- * return dct[name] # <<<<<<<<<<<<<<
- *
- * if name in self._local_type_vars:
- */
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 438, __pyx_L1_error)
- }
- __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_dct, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":415
- * # But this is faster than a loop over mro() checking each class __dict__
- * # manually.
- * if name in dct: # <<<<<<<<<<<<<<
- * if name not in self._local_type_vars:
- * # If there is a dict value, and nothing in the type,
- */
- }
-
- /* "src/gevent/local.py":440
- * return dct[name]
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * # Not in the dictionary, but is found in the type. It could be
- * # a non-data descriptor still. Some descriptors, like @staticmethod,
- */
- if (unlikely(__pyx_v_self->_local_type_vars == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 440, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_vars, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 440, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":447
- * # So we can't rely on getattr() on the type for them, we have to
- * # look through the MRO dicts ourself.
- * if name not in self._local_type_get_descriptors: # <<<<<<<<<<<<<<
- * # Not a descriptor, can't execute code. So all we need is
- * # the return value of getattr() on our type.
- */
- if (unlikely(__pyx_v_self->_local_type_get_descriptors == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 447, __pyx_L1_error)
- }
- __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_get_descriptors, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 447, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":450
- * # Not a descriptor, can't execute code. So all we need is
- * # the return value of getattr() on our type.
- * return getattr(self._local_type, name) # <<<<<<<<<<<<<<
- *
- * for base in self._local_type.mro():
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_GetAttr(__pyx_t_4, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":447
- * # So we can't rely on getattr() on the type for them, we have to
- * # look through the MRO dicts ourself.
- * if name not in self._local_type_get_descriptors: # <<<<<<<<<<<<<<
- * # Not a descriptor, can't execute code. So all we need is
- * # the return value of getattr() on our type.
- */
- }
-
- /* "src/gevent/local.py":452
- * return getattr(self._local_type, name)
- *
- * for base in self._local_type.mro(): # <<<<<<<<<<<<<<
- * bd = base.__dict__
- * if name in bd:
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_local_type), __pyx_n_s_mro); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_8) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
- __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
- __pyx_t_10 = NULL;
- } else {
- __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 452, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- for (;;) {
- if (likely(!__pyx_t_10)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 452, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- } else {
- if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 452, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- }
- } else {
- __pyx_t_3 = __pyx_t_10(__pyx_t_4);
- if (unlikely(!__pyx_t_3)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 452, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_3);
- }
- __Pyx_XDECREF_SET(__pyx_v_base, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":453
- *
- * for base in self._local_type.mro():
- * bd = base.__dict__ # <<<<<<<<<<<<<<
- * if name in bd:
- * attr_on_type = bd[name]
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_base, __pyx_n_s_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_XDECREF_SET(__pyx_v_bd, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":454
- * for base in self._local_type.mro():
- * bd = base.__dict__
- * if name in bd: # <<<<<<<<<<<<<<
- * attr_on_type = bd[name]
- * result = type(attr_on_type).__get__(attr_on_type, self, self._local_type)
- */
- __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_v_bd, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 454, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/local.py":455
- * bd = base.__dict__
- * if name in bd:
- * attr_on_type = bd[name] # <<<<<<<<<<<<<<
- * result = type(attr_on_type).__get__(attr_on_type, self, self._local_type)
- * return result
- */
- __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_bd, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_attr_on_type = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":456
- * if name in bd:
- * attr_on_type = bd[name]
- * result = type(attr_on_type).__get__(attr_on_type, self, self._local_type) # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_attr_on_type)), __pyx_n_s_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_attr_on_type, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_self->_local_type)};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_attr_on_type, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_self->_local_type)};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_7) {
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
- }
- __Pyx_INCREF(__pyx_v_attr_on_type);
- __Pyx_GIVEREF(__pyx_v_attr_on_type);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_attr_on_type);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(((PyObject *)__pyx_v_self->_local_type));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_local_type));
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, ((PyObject *)__pyx_v_self->_local_type));
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_v_result = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":457
- * attr_on_type = bd[name]
- * result = type(attr_on_type).__get__(attr_on_type, self, self._local_type)
- * return result # <<<<<<<<<<<<<<
- *
- * # It wasn't in the dict and it wasn't in the type.
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":454
- * for base in self._local_type.mro():
- * bd = base.__dict__
- * if name in bd: # <<<<<<<<<<<<<<
- * attr_on_type = bd[name]
- * result = type(attr_on_type).__get__(attr_on_type, self, self._local_type)
- */
- }
-
- /* "src/gevent/local.py":452
- * return getattr(self._local_type, name)
- *
- * for base in self._local_type.mro(): # <<<<<<<<<<<<<<
- * bd = base.__dict__
- * if name in bd:
- */
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":440
- * return dct[name]
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * # Not in the dictionary, but is found in the type. It could be
- * # a non-data descriptor still. Some descriptors, like @staticmethod,
- */
- }
-
- /* "src/gevent/local.py":463
- * # exists, otherwise raise an AttributeError.
- * # we will invoke type(self).__getattr__ or raise an attribute error.
- * if hasattr(self._local_type, '__getattr__'): # <<<<<<<<<<<<<<
- * return self._local_type.__getattr__(self, name)
- * raise AttributeError("%r object has no attribute '%s'"
- */
- __pyx_t_4 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_HasAttr(__pyx_t_4, __pyx_n_s_getattr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 463, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":464
- * # we will invoke type(self).__getattr__ or raise an attribute error.
- * if hasattr(self._local_type, '__getattr__'):
- * return self._local_type.__getattr__(self, name) # <<<<<<<<<<<<<<
- * raise AttributeError("%r object has no attribute '%s'"
- * % (self._local_type.__name__, name))
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_local_type), __pyx_n_s_getattr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_8 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_name};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_8) {
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":463
- * # exists, otherwise raise an AttributeError.
- * # we will invoke type(self).__getattr__ or raise an attribute error.
- * if hasattr(self._local_type, '__getattr__'): # <<<<<<<<<<<<<<
- * return self._local_type.__getattr__(self, name)
- * raise AttributeError("%r object has no attribute '%s'"
- */
- }
-
- /* "src/gevent/local.py":466
- * return self._local_type.__getattr__(self, name)
- * raise AttributeError("%r object has no attribute '%s'"
- * % (self._local_type.__name__, name)) # <<<<<<<<<<<<<<
- *
- * def __setattr__(self, name, value):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_local_type), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_name);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_r_object_has_no_attribute_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 466, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":465
- * if hasattr(self._local_type, '__getattr__'):
- * return self._local_type.__getattr__(self, name)
- * raise AttributeError("%r object has no attribute '%s'" # <<<<<<<<<<<<<<
- * % (self._local_type.__name__, name))
- *
- */
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 465, __pyx_L1_error)
-
- /* "src/gevent/local.py":382
- * self._local_type_vars = set(dir(self._local_type))
- *
- * def __getattribute__(self, name): # pylint:disable=too-many-return-statements # <<<<<<<<<<<<<<
- * if name in _local_attrs:
- * # The _local__impl, __cinit__, etc, won't be hit by the
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._local.local.__getattribute__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_dct);
- __Pyx_XDECREF(__pyx_v_type_attr);
- __Pyx_XDECREF(__pyx_v_base);
- __Pyx_XDECREF(__pyx_v_bd);
- __Pyx_XDECREF(__pyx_v_attr_on_type);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":468
- * % (self._local_type.__name__, name))
- *
- * def __setattr__(self, name, value): # <<<<<<<<<<<<<<
- * if name == '__dict__':
- * raise AttributeError(
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_5local_5__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_6_local_5local_5__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setattr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_local_5local_4__setattr__(((struct __pyx_obj_6gevent_6_local_local *)__pyx_v_self), ((PyObject *)__pyx_v_name), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_5local_4__setattr__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
- PyObject *__pyx_v_dct = NULL;
- PyObject *__pyx_v_type_attr = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__setattr__", 0);
-
- /* "src/gevent/local.py":469
- *
- * def __setattr__(self, name, value):
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- */
- __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_name, __pyx_n_s_dict, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 469, __pyx_L1_error)
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/local.py":472
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- * % type(self)) # <<<<<<<<<<<<<<
- *
- * if name in _local_attrs:
- */
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_r_object_attribute___dict___is, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "src/gevent/local.py":470
- * def __setattr__(self, name, value):
- * if name == '__dict__':
- * raise AttributeError( # <<<<<<<<<<<<<<
- * "%r object attribute '__dict__' is read-only"
- * % type(self))
- */
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 470, __pyx_L1_error)
-
- /* "src/gevent/local.py":469
- *
- * def __setattr__(self, name, value):
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- */
- }
-
- /* "src/gevent/local.py":474
- * % type(self))
- *
- * if name in _local_attrs: # <<<<<<<<<<<<<<
- * object.__setattr__(self, name, value)
- * return
- */
- if (unlikely(__pyx_v_6gevent_6_local__local_attrs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 474, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_6gevent_6_local__local_attrs, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 474, __pyx_L1_error)
- __pyx_t_4 = (__pyx_t_1 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/local.py":475
- *
- * if name in _local_attrs:
- * object.__setattr__(self, name, value) # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 475, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_value);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":476
- * if name in _local_attrs:
- * object.__setattr__(self, name, value)
- * return # <<<<<<<<<<<<<<
- *
- * dct = _local_get_dict(self)
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":474
- * % type(self))
- *
- * if name in _local_attrs: # <<<<<<<<<<<<<<
- * object.__setattr__(self, name, value)
- * return
- */
- }
-
- /* "src/gevent/local.py":478
- * return
- *
- * dct = _local_get_dict(self) # <<<<<<<<<<<<<<
- *
- * if self._local_type is local:
- */
- __pyx_t_3 = __pyx_f_6gevent_6_local__local_get_dict(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 478, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_dct = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":480
- * dct = _local_get_dict(self)
- *
- * if self._local_type is local: # <<<<<<<<<<<<<<
- * # Optimization: If we're not subclassed, we can't
- * # have data descriptors, so this goes right in the dict.
- */
- __pyx_t_4 = (__pyx_v_self->_local_type == __pyx_ptype_6gevent_6_local_local);
- __pyx_t_1 = (__pyx_t_4 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":483
- * # Optimization: If we're not subclassed, we can't
- * # have data descriptors, so this goes right in the dict.
- * dct[name] = value # <<<<<<<<<<<<<<
- * return
- *
- */
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 483, __pyx_L1_error)
- }
- if (unlikely(PyDict_SetItem(__pyx_v_dct, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(0, 483, __pyx_L1_error)
-
- /* "src/gevent/local.py":484
- * # have data descriptors, so this goes right in the dict.
- * dct[name] = value
- * return # <<<<<<<<<<<<<<
- *
- * if name in self._local_type_vars:
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":480
- * dct = _local_get_dict(self)
- *
- * if self._local_type is local: # <<<<<<<<<<<<<<
- * # Optimization: If we're not subclassed, we can't
- * # have data descriptors, so this goes right in the dict.
- */
- }
-
- /* "src/gevent/local.py":486
- * return
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * if name in self._local_type_set_descriptors:
- * type_attr = getattr(self._local_type, name, _marker)
- */
- if (unlikely(__pyx_v_self->_local_type_vars == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 486, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_vars, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
- __pyx_t_4 = (__pyx_t_1 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/local.py":487
- *
- * if name in self._local_type_vars:
- * if name in self._local_type_set_descriptors: # <<<<<<<<<<<<<<
- * type_attr = getattr(self._local_type, name, _marker)
- * # A data descriptor, like a property or a slot.
- */
- if (unlikely(__pyx_v_self->_local_type_set_descriptors == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 487, __pyx_L1_error)
- }
- __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_set_descriptors, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 487, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_4 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":488
- * if name in self._local_type_vars:
- * if name in self._local_type_set_descriptors:
- * type_attr = getattr(self._local_type, name, _marker) # <<<<<<<<<<<<<<
- * # A data descriptor, like a property or a slot.
- * type(type_attr).__set__(type_attr, self, value)
- */
- __pyx_t_3 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_2 = __pyx_v_6gevent_6_local__marker;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_7 = __Pyx_GetAttr3(__pyx_t_3, __pyx_v_name, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 488, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_type_attr = __pyx_t_7;
- __pyx_t_7 = 0;
-
- /* "src/gevent/local.py":490
- * type_attr = getattr(self._local_type, name, _marker)
- * # A data descriptor, like a property or a slot.
- * type(type_attr).__set__(type_attr, self, value) # <<<<<<<<<<<<<<
- * return
- * # Otherwise it goes directly in the dict
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_type_attr)), __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_type_attr, ((PyObject *)__pyx_v_self), __pyx_v_value};
- __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 490, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_type_attr, ((PyObject *)__pyx_v_self), __pyx_v_value};
- __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 490, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 490, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_type_attr);
- __Pyx_GIVEREF(__pyx_v_type_attr);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_type_attr);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_value);
- __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 490, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "src/gevent/local.py":491
- * # A data descriptor, like a property or a slot.
- * type(type_attr).__set__(type_attr, self, value)
- * return # <<<<<<<<<<<<<<
- * # Otherwise it goes directly in the dict
- * dct[name] = value
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":487
- *
- * if name in self._local_type_vars:
- * if name in self._local_type_set_descriptors: # <<<<<<<<<<<<<<
- * type_attr = getattr(self._local_type, name, _marker)
- * # A data descriptor, like a property or a slot.
- */
- }
-
- /* "src/gevent/local.py":486
- * return
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * if name in self._local_type_set_descriptors:
- * type_attr = getattr(self._local_type, name, _marker)
- */
- }
-
- /* "src/gevent/local.py":493
- * return
- * # Otherwise it goes directly in the dict
- * dct[name] = value # <<<<<<<<<<<<<<
- *
- * def __delattr__(self, name):
- */
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 493, __pyx_L1_error)
- }
- if (unlikely(PyDict_SetItem(__pyx_v_dct, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
-
- /* "src/gevent/local.py":468
- * % (self._local_type.__name__, name))
- *
- * def __setattr__(self, name, value): # <<<<<<<<<<<<<<
- * if name == '__dict__':
- * raise AttributeError(
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._local.local.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_dct);
- __Pyx_XDECREF(__pyx_v_type_attr);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":495
- * dct[name] = value
- *
- * def __delattr__(self, name): # <<<<<<<<<<<<<<
- * if name == '__dict__':
- * raise AttributeError(
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_local_5local_7__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
-static int __pyx_pw_6gevent_6_local_5local_7__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__delattr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_local_5local_6__delattr__(((struct __pyx_obj_6gevent_6_local_local *)__pyx_v_self), ((PyObject *)__pyx_v_name));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_local_5local_6__delattr__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, PyObject *__pyx_v_name) {
- PyObject *__pyx_v_type_attr = NULL;
- PyObject *__pyx_v_dct = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- __Pyx_RefNannySetupContext("__delattr__", 0);
-
- /* "src/gevent/local.py":496
- *
- * def __delattr__(self, name):
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- */
- __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_name, __pyx_n_s_dict, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 496, __pyx_L1_error)
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/local.py":499
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- * % self.__class__.__name__) # <<<<<<<<<<<<<<
- *
- * if name in self._local_type_vars:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 499, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_r_object_attribute___dict___is, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":497
- * def __delattr__(self, name):
- * if name == '__dict__':
- * raise AttributeError( # <<<<<<<<<<<<<<
- * "%r object attribute '__dict__' is read-only"
- * % self.__class__.__name__)
- */
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 497, __pyx_L1_error)
-
- /* "src/gevent/local.py":496
- *
- * def __delattr__(self, name):
- * if name == '__dict__': # <<<<<<<<<<<<<<
- * raise AttributeError(
- * "%r object attribute '__dict__' is read-only"
- */
- }
-
- /* "src/gevent/local.py":501
- * % self.__class__.__name__)
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * if name in self._local_type_del_descriptors:
- * # A data descriptor, like a property or a slot.
- */
- if (unlikely(__pyx_v_self->_local_type_vars == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 501, __pyx_L1_error)
- }
- __pyx_t_1 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_vars, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 501, __pyx_L1_error)
- __pyx_t_4 = (__pyx_t_1 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/local.py":502
- *
- * if name in self._local_type_vars:
- * if name in self._local_type_del_descriptors: # <<<<<<<<<<<<<<
- * # A data descriptor, like a property or a slot.
- * type_attr = getattr(self._local_type, name, _marker)
- */
- if (unlikely(__pyx_v_self->_local_type_del_descriptors == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 502, __pyx_L1_error)
- }
- __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_v_name, __pyx_v_self->_local_type_del_descriptors, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 502, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_4 != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/local.py":504
- * if name in self._local_type_del_descriptors:
- * # A data descriptor, like a property or a slot.
- * type_attr = getattr(self._local_type, name, _marker) # <<<<<<<<<<<<<<
- * type(type_attr).__delete__(type_attr, self)
- * return
- */
- __pyx_t_3 = ((PyObject *)__pyx_v_self->_local_type);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_2 = __pyx_v_6gevent_6_local__marker;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_3, __pyx_v_name, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_type_attr = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "src/gevent/local.py":505
- * # A data descriptor, like a property or a slot.
- * type_attr = getattr(self._local_type, name, _marker)
- * type(type_attr).__delete__(type_attr, self) # <<<<<<<<<<<<<<
- * return
- * # Otherwise it goes directly in the dict
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_type_attr)), __pyx_n_s_delete); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 505, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_type_attr, ((PyObject *)__pyx_v_self)};
- __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 505, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_type_attr, ((PyObject *)__pyx_v_self)};
- __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 505, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 505, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_type_attr);
- __Pyx_GIVEREF(__pyx_v_type_attr);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_type_attr);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 505, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/local.py":506
- * type_attr = getattr(self._local_type, name, _marker)
- * type(type_attr).__delete__(type_attr, self)
- * return # <<<<<<<<<<<<<<
- * # Otherwise it goes directly in the dict
- *
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":502
- *
- * if name in self._local_type_vars:
- * if name in self._local_type_del_descriptors: # <<<<<<<<<<<<<<
- * # A data descriptor, like a property or a slot.
- * type_attr = getattr(self._local_type, name, _marker)
- */
- }
-
- /* "src/gevent/local.py":501
- * % self.__class__.__name__)
- *
- * if name in self._local_type_vars: # <<<<<<<<<<<<<<
- * if name in self._local_type_del_descriptors:
- * # A data descriptor, like a property or a slot.
- */
- }
-
- /* "src/gevent/local.py":510
- *
- * # Begin inlined function _get_dict()
- * dct = _local_get_dict(self) # <<<<<<<<<<<<<<
- *
- * try:
- */
- __pyx_t_5 = __pyx_f_6gevent_6_local__local_get_dict(__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_v_dct = ((PyObject*)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/local.py":512
- * dct = _local_get_dict(self)
- *
- * try: # <<<<<<<<<<<<<<
- * del dct[name]
- * except KeyError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- /*try:*/ {
-
- /* "src/gevent/local.py":513
- *
- * try:
- * del dct[name] # <<<<<<<<<<<<<<
- * except KeyError:
- * raise AttributeError(name)
- */
- if (unlikely(__pyx_v_dct == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 513, __pyx_L6_error)
- }
- if (unlikely(PyDict_DelItem(__pyx_v_dct, __pyx_v_name) < 0)) __PYX_ERR(0, 513, __pyx_L6_error)
-
- /* "src/gevent/local.py":512
- * dct = _local_get_dict(self)
- *
- * try: # <<<<<<<<<<<<<<
- * del dct[name]
- * except KeyError:
- */
- }
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- goto __pyx_L11_try_end;
- __pyx_L6_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "src/gevent/local.py":514
- * try:
- * del dct[name]
- * except KeyError: # <<<<<<<<<<<<<<
- * raise AttributeError(name)
- *
- */
- __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
- if (__pyx_t_6) {
- __Pyx_AddTraceback("gevent._local.local.__delattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_2, &__pyx_t_7) < 0) __PYX_ERR(0, 514, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "src/gevent/local.py":515
- * del dct[name]
- * except KeyError:
- * raise AttributeError(name) # <<<<<<<<<<<<<<
- *
- * def __copy__(self):
- */
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L8_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 515, __pyx_L8_except_error)
- }
- goto __pyx_L8_except_error;
- __pyx_L8_except_error:;
-
- /* "src/gevent/local.py":512
- * dct = _local_get_dict(self)
- *
- * try: # <<<<<<<<<<<<<<
- * del dct[name]
- * except KeyError:
- */
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
- goto __pyx_L1_error;
- __pyx_L11_try_end:;
- }
-
- /* "src/gevent/local.py":495
- * dct[name] = value
- *
- * def __delattr__(self, name): # <<<<<<<<<<<<<<
- * if name == '__dict__':
- * raise AttributeError(
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._local.local.__delattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_type_attr);
- __Pyx_XDECREF(__pyx_v_dct);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":517
- * raise AttributeError(name)
- *
- * def __copy__(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- */
-
-static PyObject *__pyx_pw_6gevent_6_local_5local_9__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static struct __pyx_obj_6gevent_6_local_local *__pyx_f_6gevent_6_local_5local___copy__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, int __pyx_skip_dispatch) {
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_entry = 0;
- PyObject *__pyx_v_dct = 0;
- PyObject *__pyx_v_duplicate = 0;
- struct __pyx_obj_6gevent_6_local_local *__pyx_v_instance = 0;
- struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_impl = NULL;
- PyTypeObject *__pyx_v_cls = NULL;
- struct __pyx_obj_6gevent_6_local_local *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__copy__", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_local_5local_9__copy__)) {
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_6_local_local))))) __PYX_ERR(0, 517, __pyx_L1_error)
- __pyx_r = ((struct __pyx_obj_6gevent_6_local_local *)__pyx_t_2);
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/local.py":518
- *
- * def __copy__(self):
- * impl = self._local__impl # <<<<<<<<<<<<<<
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- *
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_self->_local__impl);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":519
- * def __copy__(self):
- * impl = self._local__impl
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- *
- * dct = entry.localdict
- */
- if (unlikely(__pyx_v_impl->dicts == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 519, __pyx_L1_error)
- }
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_local_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 519, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_impl->dicts, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local__localimpl_dict_entry))))) __PYX_ERR(0, 519, __pyx_L1_error)
- __pyx_v_entry = ((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":521
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- *
- * dct = entry.localdict # <<<<<<<<<<<<<<
- * duplicate = copy(dct)
- *
- */
- __pyx_t_1 = __pyx_v_entry->localdict;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_dct = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":522
- *
- * dct = entry.localdict
- * duplicate = copy(dct) # <<<<<<<<<<<<<<
- *
- * cls = type(self)
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_local_copy);
- __pyx_t_2 = __pyx_v_6gevent_6_local_copy; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_dct); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_dct};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_dct};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_dct);
- __Pyx_GIVEREF(__pyx_v_dct);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_dct);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 522, __pyx_L1_error)
- __pyx_v_duplicate = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":524
- * duplicate = copy(dct)
- *
- * cls = type(self) # <<<<<<<<<<<<<<
- * instance = cls(*impl.localargs, **impl.localkwargs)
- * _local__copy_dict_from(instance, impl, duplicate)
- */
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __pyx_v_cls = ((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
-
- /* "src/gevent/local.py":525
- *
- * cls = type(self)
- * instance = cls(*impl.localargs, **impl.localkwargs) # <<<<<<<<<<<<<<
- * _local__copy_dict_from(instance, impl, duplicate)
- * return instance
- */
- if (unlikely(__pyx_v_impl->localargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 525, __pyx_L1_error)
- }
- if (unlikely(__pyx_v_impl->localkwargs == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
- __PYX_ERR(0, 525, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_v_impl->localargs, __pyx_v_impl->localkwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local_local))))) __PYX_ERR(0, 525, __pyx_L1_error)
- __pyx_v_instance = ((struct __pyx_obj_6gevent_6_local_local *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":526
- * cls = type(self)
- * instance = cls(*impl.localargs, **impl.localkwargs)
- * _local__copy_dict_from(instance, impl, duplicate) # <<<<<<<<<<<<<<
- * return instance
- *
- */
- __pyx_t_1 = __pyx_f_6gevent_6_local__local__copy_dict_from(__pyx_v_instance, __pyx_v_impl, __pyx_v_duplicate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":527
- * instance = cls(*impl.localargs, **impl.localkwargs)
- * _local__copy_dict_from(instance, impl, duplicate)
- * return instance # <<<<<<<<<<<<<<
- *
- * def _local__copy_dict_from(self, impl, duplicate):
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __Pyx_INCREF(((PyObject *)__pyx_v_instance));
- __pyx_r = __pyx_v_instance;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":517
- * raise AttributeError(name)
- *
- * def __copy__(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._local.local.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_entry);
- __Pyx_XDECREF(__pyx_v_dct);
- __Pyx_XDECREF(__pyx_v_duplicate);
- __Pyx_XDECREF((PyObject *)__pyx_v_instance);
- __Pyx_XDECREF((PyObject *)__pyx_v_impl);
- __Pyx_XDECREF(__pyx_v_cls);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_5local_9__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_local_5local_8__copy__[] = "local.__copy__(self) -> local";
-static PyMethodDef __pyx_mdef_6gevent_6_local_5local_9__copy__ = {"__copy__", (PyCFunction)__pyx_pw_6gevent_6_local_5local_9__copy__, METH_NOARGS, __pyx_doc_6gevent_6_local_5local_8__copy__};
-static PyObject *__pyx_pw_6gevent_6_local_5local_9__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_local_5local_8__copy__(((struct __pyx_obj_6gevent_6_local_local *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_5local_8__copy__(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__copy__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_local_5local___copy__(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._local.local.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":529
- * return instance
- *
- * def _local__copy_dict_from(self, impl, duplicate): # <<<<<<<<<<<<<<
- * current = getcurrent() # pylint:disable=undefined-variable
- * currentId = id(current)
- */
-
-static PyObject *__pyx_f_6gevent_6_local__local__copy_dict_from(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self, struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_impl, PyObject *__pyx_v_duplicate) {
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *__pyx_v_entry = 0;
- PyGreenlet *__pyx_v_current = NULL;
- PyObject *__pyx_v_currentId = NULL;
- struct __pyx_obj_6gevent_6_local__localimpl *__pyx_v_new_impl = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("_local__copy_dict_from", 0);
-
- /* "src/gevent/local.py":530
- *
- * def _local__copy_dict_from(self, impl, duplicate):
- * current = getcurrent() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * currentId = id(current)
- * new_impl = self._local__impl
- */
- __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_6_local_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_current = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":531
- * def _local__copy_dict_from(self, impl, duplicate):
- * current = getcurrent() # pylint:disable=undefined-variable
- * currentId = id(current) # <<<<<<<<<<<<<<
- * new_impl = self._local__impl
- * assert new_impl is not impl
- */
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_current)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_currentId = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":532
- * current = getcurrent() # pylint:disable=undefined-variable
- * currentId = id(current)
- * new_impl = self._local__impl # <<<<<<<<<<<<<<
- * assert new_impl is not impl
- * entry = new_impl.dicts[currentId]
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_self->_local__impl);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_v_new_impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":533
- * currentId = id(current)
- * new_impl = self._local__impl
- * assert new_impl is not impl # <<<<<<<<<<<<<<
- * entry = new_impl.dicts[currentId]
- * new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate)
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- __pyx_t_2 = (__pyx_v_new_impl != __pyx_v_impl);
- if (unlikely(!(__pyx_t_2 != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(0, 533, __pyx_L1_error)
- }
- }
- #endif
-
- /* "src/gevent/local.py":534
- * new_impl = self._local__impl
- * assert new_impl is not impl
- * entry = new_impl.dicts[currentId] # <<<<<<<<<<<<<<
- * new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate)
- *
- */
- if (unlikely(__pyx_v_new_impl->dicts == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 534, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_new_impl->dicts, __pyx_v_currentId); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6gevent_6_local__localimpl_dict_entry))))) __PYX_ERR(0, 534, __pyx_L1_error)
- __pyx_v_entry = ((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":535
- * assert new_impl is not impl
- * entry = new_impl.dicts[currentId]
- * new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate) # <<<<<<<<<<<<<<
- *
- * def _local_find_descriptors(self):
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_entry->wrgreenlet);
- __Pyx_GIVEREF(__pyx_v_entry->wrgreenlet);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_entry->wrgreenlet);
- __Pyx_INCREF(__pyx_v_duplicate);
- __Pyx_GIVEREF(__pyx_v_duplicate);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_duplicate);
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_local__localimpl_dict_entry), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(__pyx_v_new_impl->dicts == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 535, __pyx_L1_error)
- }
- if (unlikely(PyDict_SetItem(__pyx_v_new_impl->dicts, __pyx_v_currentId, __pyx_t_3) < 0)) __PYX_ERR(0, 535, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":529
- * return instance
- *
- * def _local__copy_dict_from(self, impl, duplicate): # <<<<<<<<<<<<<<
- * current = getcurrent() # pylint:disable=undefined-variable
- * currentId = id(current)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._local._local__copy_dict_from", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_entry);
- __Pyx_XDECREF((PyObject *)__pyx_v_current);
- __Pyx_XDECREF(__pyx_v_currentId);
- __Pyx_XDECREF((PyObject *)__pyx_v_new_impl);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":537
- * new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate)
- *
- * def _local_find_descriptors(self): # <<<<<<<<<<<<<<
- * type_self = type(self)
- * gets = set()
- */
-
-static PyObject *__pyx_f_6gevent_6_local__local_find_descriptors(struct __pyx_obj_6gevent_6_local_local *__pyx_v_self) {
- PyObject *__pyx_v_mro = 0;
- PyObject *__pyx_v_gets = 0;
- PyObject *__pyx_v_dels = 0;
- PyObject *__pyx_v_set_or_del = 0;
- PyTypeObject *__pyx_v_type_self = 0;
- PyTypeObject *__pyx_v_type_attr = 0;
- PyObject *__pyx_v_sets = 0;
- PyObject *__pyx_v_attr_name = NULL;
- PyObject *__pyx_v_base = NULL;
- PyObject *__pyx_v_bd = NULL;
- PyObject *__pyx_v_attr = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- Py_ssize_t __pyx_t_4;
- PyObject *(*__pyx_t_5)(PyObject *);
- Py_ssize_t __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("_local_find_descriptors", 0);
-
- /* "src/gevent/local.py":538
- *
- * def _local_find_descriptors(self):
- * type_self = type(self) # <<<<<<<<<<<<<<
- * gets = set()
- * dels = set()
- */
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __pyx_v_type_self = ((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
-
- /* "src/gevent/local.py":539
- * def _local_find_descriptors(self):
- * type_self = type(self)
- * gets = set() # <<<<<<<<<<<<<<
- * dels = set()
- * set_or_del = set()
- */
- __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_gets = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":540
- * type_self = type(self)
- * gets = set()
- * dels = set() # <<<<<<<<<<<<<<
- * set_or_del = set()
- * sets = set()
- */
- __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_dels = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":541
- * gets = set()
- * dels = set()
- * set_or_del = set() # <<<<<<<<<<<<<<
- * sets = set()
- * mro = list(type_self.mro())
- */
- __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_set_or_del = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":542
- * dels = set()
- * set_or_del = set()
- * sets = set() # <<<<<<<<<<<<<<
- * mro = list(type_self.mro())
- *
- */
- __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_sets = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":543
- * set_or_del = set()
- * sets = set()
- * mro = list(type_self.mro()) # <<<<<<<<<<<<<<
- *
- * for attr_name in dir(type_self):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_type_self), __pyx_n_s_mro); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_mro = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":545
- * mro = list(type_self.mro())
- *
- * for attr_name in dir(type_self): # <<<<<<<<<<<<<<
- * # Conventionally, descriptors when called on a class
- * # return themself, but not all do. Notable exceptions are
- */
- __pyx_t_2 = PyObject_Dir(((PyObject *)__pyx_v_type_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
- __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
- __pyx_t_5 = NULL;
- } else {
- __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 545, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- for (;;) {
- if (likely(!__pyx_t_5)) {
- if (likely(PyList_CheckExact(__pyx_t_1))) {
- if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 545, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- } else {
- if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 545, __pyx_L1_error)
- #else
- __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- #endif
- }
- } else {
- __pyx_t_2 = __pyx_t_5(__pyx_t_1);
- if (unlikely(!__pyx_t_2)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 545, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_2);
- }
- __Pyx_XDECREF_SET(__pyx_v_attr_name, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":551
- * # return other class attributes. So we can't use getattr, and instead
- * # walk up the dicts
- * for base in mro: # <<<<<<<<<<<<<<
- * bd = base.__dict__
- * if attr_name in bd:
- */
- __pyx_t_2 = __pyx_v_mro; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
- for (;;) {
- if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 551, __pyx_L1_error)
- #else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 551, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_XDECREF_SET(__pyx_v_base, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":552
- * # walk up the dicts
- * for base in mro:
- * bd = base.__dict__ # <<<<<<<<<<<<<<
- * if attr_name in bd:
- * attr = bd[attr_name]
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_base, __pyx_n_s_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_XDECREF_SET(__pyx_v_bd, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":553
- * for base in mro:
- * bd = base.__dict__
- * if attr_name in bd: # <<<<<<<<<<<<<<
- * attr = bd[attr_name]
- * break
- */
- __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_attr_name, __pyx_v_bd, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 553, __pyx_L1_error)
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/local.py":554
- * bd = base.__dict__
- * if attr_name in bd:
- * attr = bd[attr_name] # <<<<<<<<<<<<<<
- * break
- * else:
- */
- __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_bd, __pyx_v_attr_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_XDECREF_SET(__pyx_v_attr, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/local.py":555
- * if attr_name in bd:
- * attr = bd[attr_name]
- * break # <<<<<<<<<<<<<<
- * else:
- * raise AttributeError(attr_name)
- */
- goto __pyx_L6_break;
-
- /* "src/gevent/local.py":553
- * for base in mro:
- * bd = base.__dict__
- * if attr_name in bd: # <<<<<<<<<<<<<<
- * attr = bd[attr_name]
- * break
- */
- }
-
- /* "src/gevent/local.py":551
- * # return other class attributes. So we can't use getattr, and instead
- * # walk up the dicts
- * for base in mro: # <<<<<<<<<<<<<<
- * bd = base.__dict__
- * if attr_name in bd:
- */
- }
- /*else*/ {
-
- /* "src/gevent/local.py":557
- * break
- * else:
- * raise AttributeError(attr_name) # <<<<<<<<<<<<<<
- *
- * type_attr = type(attr)
- */
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_v_attr_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 557, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 557, __pyx_L1_error)
- }
-
- /* "src/gevent/local.py":551
- * # return other class attributes. So we can't use getattr, and instead
- * # walk up the dicts
- * for base in mro: # <<<<<<<<<<<<<<
- * bd = base.__dict__
- * if attr_name in bd:
- */
- __pyx_L6_break:;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":559
- * raise AttributeError(attr_name)
- *
- * type_attr = type(attr) # <<<<<<<<<<<<<<
- * if hasattr(type_attr, '__get__'):
- * gets.add(attr_name)
- */
- __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_attr)));
- __Pyx_XDECREF_SET(__pyx_v_type_attr, ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_attr))));
-
- /* "src/gevent/local.py":560
- *
- * type_attr = type(attr)
- * if hasattr(type_attr, '__get__'): # <<<<<<<<<<<<<<
- * gets.add(attr_name)
- * if hasattr(type_attr, '__delete__'):
- */
- __pyx_t_8 = __Pyx_HasAttr(((PyObject *)__pyx_v_type_attr), __pyx_n_s_get); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 560, __pyx_L1_error)
- __pyx_t_7 = (__pyx_t_8 != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/local.py":561
- * type_attr = type(attr)
- * if hasattr(type_attr, '__get__'):
- * gets.add(attr_name) # <<<<<<<<<<<<<<
- * if hasattr(type_attr, '__delete__'):
- * dels.add(attr_name)
- */
- __pyx_t_9 = PySet_Add(__pyx_v_gets, __pyx_v_attr_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 561, __pyx_L1_error)
-
- /* "src/gevent/local.py":560
- *
- * type_attr = type(attr)
- * if hasattr(type_attr, '__get__'): # <<<<<<<<<<<<<<
- * gets.add(attr_name)
- * if hasattr(type_attr, '__delete__'):
- */
- }
-
- /* "src/gevent/local.py":562
- * if hasattr(type_attr, '__get__'):
- * gets.add(attr_name)
- * if hasattr(type_attr, '__delete__'): # <<<<<<<<<<<<<<
- * dels.add(attr_name)
- * set_or_del.add(attr_name)
- */
- __pyx_t_7 = __Pyx_HasAttr(((PyObject *)__pyx_v_type_attr), __pyx_n_s_delete); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 562, __pyx_L1_error)
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/local.py":563
- * gets.add(attr_name)
- * if hasattr(type_attr, '__delete__'):
- * dels.add(attr_name) # <<<<<<<<<<<<<<
- * set_or_del.add(attr_name)
- * if hasattr(type_attr, '__set__'):
- */
- __pyx_t_9 = PySet_Add(__pyx_v_dels, __pyx_v_attr_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 563, __pyx_L1_error)
-
- /* "src/gevent/local.py":564
- * if hasattr(type_attr, '__delete__'):
- * dels.add(attr_name)
- * set_or_del.add(attr_name) # <<<<<<<<<<<<<<
- * if hasattr(type_attr, '__set__'):
- * sets.add(attr_name)
- */
- __pyx_t_9 = PySet_Add(__pyx_v_set_or_del, __pyx_v_attr_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 564, __pyx_L1_error)
-
- /* "src/gevent/local.py":562
- * if hasattr(type_attr, '__get__'):
- * gets.add(attr_name)
- * if hasattr(type_attr, '__delete__'): # <<<<<<<<<<<<<<
- * dels.add(attr_name)
- * set_or_del.add(attr_name)
- */
- }
-
- /* "src/gevent/local.py":565
- * dels.add(attr_name)
- * set_or_del.add(attr_name)
- * if hasattr(type_attr, '__set__'): # <<<<<<<<<<<<<<
- * sets.add(attr_name)
- *
- */
- __pyx_t_8 = __Pyx_HasAttr(((PyObject *)__pyx_v_type_attr), __pyx_n_s_set); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 565, __pyx_L1_error)
- __pyx_t_7 = (__pyx_t_8 != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/local.py":566
- * set_or_del.add(attr_name)
- * if hasattr(type_attr, '__set__'):
- * sets.add(attr_name) # <<<<<<<<<<<<<<
- *
- * return (gets, dels, set_or_del, sets)
- */
- __pyx_t_9 = PySet_Add(__pyx_v_sets, __pyx_v_attr_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 566, __pyx_L1_error)
-
- /* "src/gevent/local.py":565
- * dels.add(attr_name)
- * set_or_del.add(attr_name)
- * if hasattr(type_attr, '__set__'): # <<<<<<<<<<<<<<
- * sets.add(attr_name)
- *
- */
- }
-
- /* "src/gevent/local.py":545
- * mro = list(type_self.mro())
- *
- * for attr_name in dir(type_self): # <<<<<<<<<<<<<<
- * # Conventionally, descriptors when called on a class
- * # return themself, but not all do. Notable exceptions are
- */
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":568
- * sets.add(attr_name)
- *
- * return (gets, dels, set_or_del, sets) # <<<<<<<<<<<<<<
- *
- * # Cython doesn't let us use __new__, it requires
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 568, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_gets);
- __Pyx_GIVEREF(__pyx_v_gets);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_gets);
- __Pyx_INCREF(__pyx_v_dels);
- __Pyx_GIVEREF(__pyx_v_dels);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_dels);
- __Pyx_INCREF(__pyx_v_set_or_del);
- __Pyx_GIVEREF(__pyx_v_set_or_del);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_set_or_del);
- __Pyx_INCREF(__pyx_v_sets);
- __Pyx_GIVEREF(__pyx_v_sets);
- PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_sets);
- __pyx_r = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":537
- * new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate)
- *
- * def _local_find_descriptors(self): # <<<<<<<<<<<<<<
- * type_self = type(self)
- * gets = set()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._local._local_find_descriptors", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_mro);
- __Pyx_XDECREF(__pyx_v_gets);
- __Pyx_XDECREF(__pyx_v_dels);
- __Pyx_XDECREF(__pyx_v_set_or_del);
- __Pyx_XDECREF(__pyx_v_type_self);
- __Pyx_XDECREF(__pyx_v_type_attr);
- __Pyx_XDECREF(__pyx_v_sets);
- __Pyx_XDECREF(__pyx_v_attr_name);
- __Pyx_XDECREF(__pyx_v_base);
- __Pyx_XDECREF(__pyx_v_bd);
- __Pyx_XDECREF(__pyx_v_attr);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/local.py":574
- * # (e.g., on PyPy). So we set it at runtime. Cython
- * # will raise an error if we're compiled.
- * def __new__(cls, *args, **kw): # <<<<<<<<<<<<<<
- * self = super(local, cls).__new__(cls)
- * # We get the cls in *args for some reason
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_local_3__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_local_2__new__[] = "__new__(cls, *args, **kw)";
-static PyMethodDef __pyx_mdef_6gevent_6_local_3__new__ = {"__new__", (PyCFunction)__pyx_pw_6gevent_6_local_3__new__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_local_2__new__};
-static PyObject *__pyx_pw_6gevent_6_local_3__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_cls = 0;
- PyObject *__pyx_v_args = 0;
- PyObject *__pyx_v_kw = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
- __pyx_v_kw = PyDict_New(); if (unlikely(!__pyx_v_kw)) return NULL;
- __Pyx_GOTREF(__pyx_v_kw);
- if (PyTuple_GET_SIZE(__pyx_args) > 1) {
- __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
- if (unlikely(!__pyx_v_args)) {
- __Pyx_DECREF(__pyx_v_kw); __pyx_v_kw = 0;
- __Pyx_RefNannyFinishContext();
- return NULL;
- }
- __Pyx_GOTREF(__pyx_v_args);
- } else {
- __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
- }
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- default:
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kw, values, used_pos_args, "__new__") < 0)) __PYX_ERR(0, 574, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_cls = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__new__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 574, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
- __Pyx_DECREF(__pyx_v_kw); __pyx_v_kw = 0;
- __Pyx_AddTraceback("gevent._local.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_local_2__new__(__pyx_self, __pyx_v_cls, __pyx_v_args, __pyx_v_kw);
-
- /* function exit code */
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XDECREF(__pyx_v_kw);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_local_2__new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kw) {
- PyObject *__pyx_v_self = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__new__", 0);
-
- /* "src/gevent/local.py":575
- * # will raise an error if we're compiled.
- * def __new__(cls, *args, **kw):
- * self = super(local, cls).__new__(cls) # <<<<<<<<<<<<<<
- * # We get the cls in *args for some reason
- * # too when we do it this way....except on PyPy3, which does
- */
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_6_local_local));
- __Pyx_GIVEREF(((PyObject *)__pyx_ptype_6gevent_6_local_local));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_6gevent_6_local_local));
- __Pyx_INCREF(__pyx_v_cls);
- __Pyx_GIVEREF(__pyx_v_cls);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_cls);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_cls); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_cls};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_cls};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_cls);
- __Pyx_GIVEREF(__pyx_v_cls);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_cls);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_self = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":579
- * # too when we do it this way....except on PyPy3, which does
- * # not *unless* it's wrapped in a classmethod (which it is)
- * self.__cinit__(*args[1:], **kw) # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cinit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyTuple_GetSlice(__pyx_v_args, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_v_kw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/local.py":580
- * # not *unless* it's wrapped in a classmethod (which it is)
- * self.__cinit__(*args[1:], **kw)
- * return self # <<<<<<<<<<<<<<
- *
- * try:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self);
- __pyx_r = __pyx_v_self;
- goto __pyx_L0;
-
- /* "src/gevent/local.py":574
- * # (e.g., on PyPy). So we set it at runtime. Cython
- * # will raise an error if we're compiled.
- * def __new__(cls, *args, **kw): # <<<<<<<<<<<<<<
- * self = super(local, cls).__new__(cls)
- * # We get the cls in *args for some reason
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._local.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_self);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_9_greenlet_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_greenlet.pxd":28
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_greenlet.pxd":27
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._greenlet.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_9_greenlet_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_9_greenlet__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_greenlet.pxd":35
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_greenlet.pxd":36
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef extern from "Python.h":
- */
- __pyx_v_6gevent_9_greenlet__greenlet_imported = 1;
-
- /* "gevent/_greenlet.pxd":34
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_greenlet.pxd":32
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_local.pxd":26
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_local_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_local.pxd":27
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_local.pxd":26
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._local.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_local.pxd":29
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_6_local_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_local.pxd":31
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_6_local__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_local.pxd":32
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_local.pxd":33
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_6gevent_6_local__greenlet_imported = 1;
-
- /* "gevent/_local.pxd":31
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_local.pxd":29
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static PyObject *__pyx_tp_new_6gevent_6_local__wrefdict(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = (&PyDict_Type)->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local__wrefdict(PyObject *o) {
- struct __pyx_obj_6gevent_6_local__wrefdict *p = (struct __pyx_obj_6gevent_6_local__wrefdict *)o;
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- PyObject_GC_Track(o);
- (&PyDict_Type)->tp_dealloc(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local__wrefdict(PyObject *o, visitproc v, void *a) {
- int e;
- if (!(&PyDict_Type)->tp_traverse); else { e = (&PyDict_Type)->tp_traverse(o,v,a); if (e) return e; }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local__wrefdict(PyObject *o) {
- if (!(&PyDict_Type)->tp_clear); else (&PyDict_Type)->tp_clear(o);
- return 0;
-}
-
-static PyTypeObject __pyx_type_6gevent_6_local__wrefdict = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local._wrefdict", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local__wrefdict), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local__wrefdict, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "A dict that can be weak referenced", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local__wrefdict, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local__wrefdict, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local__wrefdict, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_6_local__greenlet_deleted(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)o);
- p->idt = Py_None; Py_INCREF(Py_None);
- p->wrdicts = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local__greenlet_deleted(PyObject *o) {
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *p = (struct __pyx_obj_6gevent_6_local__greenlet_deleted *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->idt);
- Py_CLEAR(p->wrdicts);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local__greenlet_deleted(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *p = (struct __pyx_obj_6gevent_6_local__greenlet_deleted *)o;
- if (p->idt) {
- e = (*v)(p->idt, a); if (e) return e;
- }
- if (p->wrdicts) {
- e = (*v)(p->wrdicts, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local__greenlet_deleted(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_local__greenlet_deleted *p = (struct __pyx_obj_6gevent_6_local__greenlet_deleted *)o;
- tmp = ((PyObject*)p->idt);
- p->idt = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->wrdicts);
- p->wrdicts = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_local__greenlet_deleted[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_local__greenlet_deleted = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local._greenlet_deleted", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local__greenlet_deleted), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local__greenlet_deleted, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_6_local_17_greenlet_deleted_3__call__, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_greenlet_deleted(idt, wrdicts)\n\n A weakref callback for when the greenlet\n is deleted.\n\n If the greenlet is a `gevent.greenlet.Greenlet` and\n supplies ``rawlink``, that will be used instead of a\n weakref.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local__greenlet_deleted, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local__greenlet_deleted, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_local__greenlet_deleted, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_local_17_greenlet_deleted_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local__greenlet_deleted, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_6_local__local_deleted(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_local__local_deleted *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_local__local_deleted *)o);
- p->key = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->wrthread = Py_None; Py_INCREF(Py_None);
- p->greenlet_deleted = ((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local__local_deleted(PyObject *o) {
- struct __pyx_obj_6gevent_6_local__local_deleted *p = (struct __pyx_obj_6gevent_6_local__local_deleted *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->key);
- Py_CLEAR(p->wrthread);
- Py_CLEAR(p->greenlet_deleted);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local__local_deleted(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_local__local_deleted *p = (struct __pyx_obj_6gevent_6_local__local_deleted *)o;
- if (p->wrthread) {
- e = (*v)(p->wrthread, a); if (e) return e;
- }
- if (p->greenlet_deleted) {
- e = (*v)(((PyObject *)p->greenlet_deleted), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local__local_deleted(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_local__local_deleted *p = (struct __pyx_obj_6gevent_6_local__local_deleted *)o;
- tmp = ((PyObject*)p->wrthread);
- p->wrthread = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->greenlet_deleted);
- p->greenlet_deleted = ((struct __pyx_obj_6gevent_6_local__greenlet_deleted *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_local__local_deleted[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_local__local_deleted = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local._local_deleted", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local__local_deleted), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local__local_deleted, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- __pyx_pw_6gevent_6_local_14_local_deleted_3__call__, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_local_deleted(key, wrthread, greenlet_deleted)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local__local_deleted, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local__local_deleted, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_local__local_deleted, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_local_14_local_deleted_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local__local_deleted, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_6_local__localimpl(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_local__localimpl *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_local__localimpl *)o);
- p->key = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->dicts = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->localargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->localkwargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->localtypeid = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local__localimpl(PyObject *o) {
- struct __pyx_obj_6gevent_6_local__localimpl *p = (struct __pyx_obj_6gevent_6_local__localimpl *)o;
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- Py_CLEAR(p->key);
- Py_CLEAR(p->dicts);
- Py_CLEAR(p->localargs);
- Py_CLEAR(p->localkwargs);
- Py_CLEAR(p->localtypeid);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local__localimpl(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_local__localimpl *p = (struct __pyx_obj_6gevent_6_local__localimpl *)o;
- if (p->dicts) {
- e = (*v)(p->dicts, a); if (e) return e;
- }
- if (p->localargs) {
- e = (*v)(p->localargs, a); if (e) return e;
- }
- if (p->localkwargs) {
- e = (*v)(p->localkwargs, a); if (e) return e;
- }
- if (p->localtypeid) {
- e = (*v)(p->localtypeid, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local__localimpl(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_local__localimpl *p = (struct __pyx_obj_6gevent_6_local__localimpl *)o;
- tmp = ((PyObject*)p->dicts);
- p->dicts = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->localargs);
- p->localargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->localkwargs);
- p->localkwargs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->localtypeid);
- p->localtypeid = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_local__localimpl[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_local__localimpl = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local._localimpl", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local__localimpl), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local__localimpl, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_localimpl(args, kwargs, local_type, id_local)\nA class managing thread-local dicts", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local__localimpl, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local__localimpl, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_local__localimpl, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_local_10_localimpl_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local__localimpl, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_6gevent_6_local__localimpl_dict_entry(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *p;
- PyObject *o;
- o = (*t->tp_alloc)(t, 0);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)o);
- p->wrgreenlet = Py_None; Py_INCREF(Py_None);
- p->localdict = ((PyObject*)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local__localimpl_dict_entry(PyObject *o) {
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *p = (struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->wrgreenlet);
- Py_CLEAR(p->localdict);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local__localimpl_dict_entry(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *p = (struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)o;
- if (p->wrgreenlet) {
- e = (*v)(p->wrgreenlet, a); if (e) return e;
- }
- if (p->localdict) {
- e = (*v)(p->localdict, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local__localimpl_dict_entry(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *p = (struct __pyx_obj_6gevent_6_local__localimpl_dict_entry *)o;
- tmp = ((PyObject*)p->wrgreenlet);
- p->wrgreenlet = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->localdict);
- p->localdict = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_local__localimpl_dict_entry[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_local__localimpl_dict_entry = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local._localimpl_dict_entry", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local__localimpl_dict_entry), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local__localimpl_dict_entry, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "_localimpl_dict_entry(wrgreenlet, localdict)\n\n The object that goes in the ``dicts`` of ``_localimpl``\n object for each thread.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local__localimpl_dict_entry, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local__localimpl_dict_entry, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_local__localimpl_dict_entry, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_local_21_localimpl_dict_entry_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local__localimpl_dict_entry, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_local_local __pyx_vtable_6gevent_6_local_local;
-
-static PyObject *__pyx_tp_new_6gevent_6_local_local(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_local_local *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_local_local *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_6_local_local;
- p->_local__impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)Py_None); Py_INCREF(Py_None);
- p->_local_type_get_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_local_type_set_or_del_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_local_type_del_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_local_type_set_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_local_type_vars = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_local_type = ((PyTypeObject*)Py_None); Py_INCREF(Py_None);
- if (unlikely(__pyx_pw_6gevent_6_local_5local_1__cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_local_local(PyObject *o) {
- struct __pyx_obj_6gevent_6_local_local *p = (struct __pyx_obj_6gevent_6_local_local *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_local__impl);
- Py_CLEAR(p->_local_type_get_descriptors);
- Py_CLEAR(p->_local_type_set_or_del_descriptors);
- Py_CLEAR(p->_local_type_del_descriptors);
- Py_CLEAR(p->_local_type_set_descriptors);
- Py_CLEAR(p->_local_type_vars);
- Py_CLEAR(p->_local_type);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_local_local(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_local_local *p = (struct __pyx_obj_6gevent_6_local_local *)o;
- if (p->_local__impl) {
- e = (*v)(((PyObject *)p->_local__impl), a); if (e) return e;
- }
- if (p->_local_type_get_descriptors) {
- e = (*v)(p->_local_type_get_descriptors, a); if (e) return e;
- }
- if (p->_local_type_set_or_del_descriptors) {
- e = (*v)(p->_local_type_set_or_del_descriptors, a); if (e) return e;
- }
- if (p->_local_type_del_descriptors) {
- e = (*v)(p->_local_type_del_descriptors, a); if (e) return e;
- }
- if (p->_local_type_set_descriptors) {
- e = (*v)(p->_local_type_set_descriptors, a); if (e) return e;
- }
- if (p->_local_type_vars) {
- e = (*v)(p->_local_type_vars, a); if (e) return e;
- }
- if (p->_local_type) {
- e = (*v)(((PyObject *)p->_local_type), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_local_local(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_local_local *p = (struct __pyx_obj_6gevent_6_local_local *)o;
- tmp = ((PyObject*)p->_local__impl);
- p->_local__impl = ((struct __pyx_obj_6gevent_6_local__localimpl *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type_get_descriptors);
- p->_local_type_get_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type_set_or_del_descriptors);
- p->_local_type_set_or_del_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type_del_descriptors);
- p->_local_type_del_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type_set_descriptors);
- p->_local_type_set_descriptors = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type_vars);
- p->_local_type_vars = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_local_type);
- p->_local_type = ((PyTypeObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_tp_getattro_6gevent_6_local_local(PyObject *o, PyObject *n) {
- PyObject *v = __pyx_pw_6gevent_6_local_5local_3__getattribute__(o, n);
- return v;
-}
-
-static int __pyx_tp_setattro_6gevent_6_local_local(PyObject *o, PyObject *n, PyObject *v) {
- if (v) {
- return __pyx_pw_6gevent_6_local_5local_5__setattr__(o, n, v);
- }
- else {
- return __pyx_pw_6gevent_6_local_5local_7__delattr__(o, n);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_local_local[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_local_local = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._local.local", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_local_local), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_local_local, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- __pyx_tp_getattro_6gevent_6_local_local, /*tp_getattro*/
- __pyx_tp_setattro_6gevent_6_local_local, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "\n An object whose attributes are greenlet-local.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_local_local, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_local_local, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_local_local, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_local_local, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec__local(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec__local},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "_local",
- __pyx_k_Greenlet_local_objects_This_mod, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
- {&__pyx_kp_s_Initialization_arguments_are_not, __pyx_k_Initialization_arguments_are_not, sizeof(__pyx_k_Initialization_arguments_are_not), 0, 0, 1, 0},
- {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
- {&__pyx_n_s_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 0, 1, 1},
- {&__pyx_n_s_PY2, __pyx_k_PY2, sizeof(__pyx_k_PY2), 0, 0, 1, 1},
- {&__pyx_n_s_PYPY, __pyx_k_PYPY, sizeof(__pyx_k_PYPY), 0, 0, 1, 1},
- {&__pyx_n_s_PYPY_2, __pyx_k_PYPY_2, sizeof(__pyx_k_PYPY_2), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_all_local_dicts_for_greenlet, __pyx_k_all_local_dicts_for_greenlet, sizeof(__pyx_k_all_local_dicts_for_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
- {&__pyx_n_s_cinit, __pyx_k_cinit, sizeof(__pyx_k_cinit), 0, 0, 1, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_classmethod, __pyx_k_classmethod, sizeof(__pyx_k_classmethod), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
- {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
- {&__pyx_n_s_copy_2, __pyx_k_copy_2, sizeof(__pyx_k_copy_2), 0, 0, 1, 1},
- {&__pyx_n_s_delete, __pyx_k_delete, sizeof(__pyx_k_delete), 0, 0, 1, 1},
- {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
- {&__pyx_n_s_dicts, __pyx_k_dicts, sizeof(__pyx_k_dicts), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_get_2, __pyx_k_get_2, sizeof(__pyx_k_get_2), 0, 0, 1, 1},
- {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1},
- {&__pyx_n_s_getattribute, __pyx_k_getattribute, sizeof(__pyx_k_getattribute), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__compat, __pyx_k_gevent__compat, sizeof(__pyx_k_gevent__compat), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__local, __pyx_k_gevent__local, sizeof(__pyx_k_gevent__local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_local_localimpl, __pyx_k_gevent_local_localimpl, sizeof(__pyx_k_gevent_local_localimpl), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_deleted, __pyx_k_greenlet_deleted, sizeof(__pyx_k_greenlet_deleted), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_imported, __pyx_k_greenlet_imported, sizeof(__pyx_k_greenlet_imported), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet_init, __pyx_k_greenlet_init, sizeof(__pyx_k_greenlet_init), 0, 0, 1, 1},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_n_s_id_local, __pyx_k_id_local, sizeof(__pyx_k_id_local), 0, 0, 1, 1},
- {&__pyx_n_s_idt, __pyx_k_idt, sizeof(__pyx_k_idt), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
- {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
- {&__pyx_n_s_key_prefix, __pyx_k_key_prefix, sizeof(__pyx_k_key_prefix), 0, 0, 1, 1},
- {&__pyx_n_s_kw, __pyx_k_kw, sizeof(__pyx_k_kw), 0, 0, 1, 1},
- {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
- {&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
- {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1},
- {&__pyx_n_s_local___copy, __pyx_k_local___copy, sizeof(__pyx_k_local___copy), 0, 0, 1, 1},
- {&__pyx_n_s_local__impl, __pyx_k_local__impl, sizeof(__pyx_k_local__impl), 0, 0, 1, 1},
- {&__pyx_n_s_local_attrs, __pyx_k_local_attrs, sizeof(__pyx_k_local_attrs), 0, 0, 1, 1},
- {&__pyx_n_s_local_type, __pyx_k_local_type, sizeof(__pyx_k_local_type), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_2, __pyx_k_local_type_2, sizeof(__pyx_k_local_type_2), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_del_descriptors, __pyx_k_local_type_del_descriptors, sizeof(__pyx_k_local_type_del_descriptors), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_get_descriptors, __pyx_k_local_type_get_descriptors, sizeof(__pyx_k_local_type_get_descriptors), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_set_descriptors, __pyx_k_local_type_set_descriptors, sizeof(__pyx_k_local_type_set_descriptors), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_set_or_del_descripto, __pyx_k_local_type_set_or_del_descripto, sizeof(__pyx_k_local_type_set_or_del_descripto), 0, 0, 1, 1},
- {&__pyx_n_s_local_type_vars, __pyx_k_local_type_vars, sizeof(__pyx_k_local_type_vars), 0, 0, 1, 1},
- {&__pyx_n_s_localargs, __pyx_k_localargs, sizeof(__pyx_k_localargs), 0, 0, 1, 1},
- {&__pyx_n_s_localdict, __pyx_k_localdict, sizeof(__pyx_k_localdict), 0, 0, 1, 1},
- {&__pyx_n_s_localkwargs, __pyx_k_localkwargs, sizeof(__pyx_k_localkwargs), 0, 0, 1, 1},
- {&__pyx_n_s_localtypeid, __pyx_k_localtypeid, sizeof(__pyx_k_localtypeid), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_marker, __pyx_k_marker, sizeof(__pyx_k_marker), 0, 0, 1, 1},
- {&__pyx_n_s_mro, __pyx_k_mro, sizeof(__pyx_k_mro), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
- {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_kp_s_r_object_attribute___dict___is, __pyx_k_r_object_attribute___dict___is, sizeof(__pyx_k_r_object_attribute___dict___is), 0, 0, 1, 0},
- {&__pyx_kp_s_r_object_has_no_attribute_s, __pyx_k_r_object_has_no_attribute_s, sizeof(__pyx_k_r_object_has_no_attribute_s), 0, 0, 1, 0},
- {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1},
- {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
- {&__pyx_n_s_setattr, __pyx_k_setattr, sizeof(__pyx_k_setattr), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_local_py, __pyx_k_src_gevent_local_py, sizeof(__pyx_k_src_gevent_local_py), 0, 0, 1, 0},
- {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
- {&__pyx_n_s_unused, __pyx_k_unused, sizeof(__pyx_k_unused), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {&__pyx_n_s_weakref_2, __pyx_k_weakref_2, sizeof(__pyx_k_weakref_2), 0, 0, 1, 1},
- {&__pyx_n_s_wrdicts, __pyx_k_wrdicts, sizeof(__pyx_k_wrdicts), 0, 0, 1, 1},
- {&__pyx_n_s_wrgreenlet, __pyx_k_wrgreenlet, sizeof(__pyx_k_wrgreenlet), 0, 0, 1, 1},
- {&__pyx_n_s_wrthread, __pyx_k_wrthread, sizeof(__pyx_k_wrthread), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 160, __pyx_L1_error)
- __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 331, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 588, __pyx_L1_error)
- __pyx_builtin_classmethod = __Pyx_GetBuiltinName(__pyx_n_s_classmethod); if (!__pyx_builtin_classmethod) __PYX_ERR(0, 597, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 192, __pyx_L1_error)
- __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 246, __pyx_L1_error)
- __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 341, __pyx_L1_error)
- __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 575, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/local.py":160
- *
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/local.py":179
- * # That final tuple is actually a localimpl_dict_entry object.
- *
- * def all_local_dicts_for_greenlet(greenlet): # <<<<<<<<<<<<<<
- * """
- * Internal debug helper for getting the local values associated
- */
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
- __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_local_py, __pyx_n_s_all_local_dicts_for_greenlet, 179, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 179, __pyx_L1_error)
-
- /* "src/gevent/local.py":222
- * weakref.
- * """
- * __slots__ = ('idt', 'wrdicts') # <<<<<<<<<<<<<<
- *
- * def __init__(self, idt, wrdicts):
- */
- __pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_idt, __pyx_n_s_wrdicts); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "src/gevent/local.py":234
- *
- * class _local_deleted(object):
- * __slots__ = ('key', 'wrthread', 'greenlet_deleted') # <<<<<<<<<<<<<<
- *
- * def __init__(self, key, wrthread, greenlet_deleted):
- */
- __pyx_tuple__5 = PyTuple_Pack(3, __pyx_n_s_key, __pyx_n_s_wrthread, __pyx_n_s_greenlet_deleted); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
-
- /* "src/gevent/local.py":254
- * class _localimpl(object):
- * """A class managing thread-local dicts"""
- * __slots__ = ('key', 'dicts', # <<<<<<<<<<<<<<
- * 'localargs', 'localkwargs',
- * 'localtypeid',
- */
- __pyx_tuple__6 = PyTuple_Pack(6, __pyx_n_s_key, __pyx_n_s_dicts, __pyx_n_s_localargs, __pyx_n_s_localkwargs, __pyx_n_s_localtypeid, __pyx_n_s_weakref_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
-
- /* "src/gevent/local.py":280
- * # This is a class, not just a tuple, so that cython can optimize
- * # attribute access
- * __slots__ = ('wrgreenlet', 'localdict') # <<<<<<<<<<<<<<
- *
- * def __init__(self, wrgreenlet, localdict):
- */
- __pyx_tuple__7 = PyTuple_Pack(2, __pyx_n_s_wrgreenlet, __pyx_n_s_localdict); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 280, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
-
- /* "src/gevent/local.py":517
- * raise AttributeError(name)
- *
- * def __copy__(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- */
- __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_local_py, __pyx_n_s_copy, 517, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 517, __pyx_L1_error)
-
- /* "src/gevent/local.py":574
- * # (e.g., on PyPy). So we set it at runtime. Cython
- * # will raise an error if we're compiled.
- * def __new__(cls, *args, **kw): # <<<<<<<<<<<<<<
- * self = super(local, cls).__new__(cls)
- * # We get the cls in *args for some reason
- */
- __pyx_tuple__10 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_args, __pyx_n_s_kw, __pyx_n_s_self); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
- __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_local_py, __pyx_n_s_new, 574, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
- __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_6_local_ref = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_local_copy = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_local__marker = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_local_key_prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
- __pyx_v_6gevent_6_local__local_attrs = ((PyObject*)Py_None); Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_PYPY, (void *)&__pyx_v_6gevent_6_local__PYPY, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_ref, (void *)&__pyx_v_6gevent_6_local_ref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_copy_2, (void *)&__pyx_v_6gevent_6_local_copy, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_marker, (void *)&__pyx_v_6gevent_6_local__marker, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_key_prefix, (void *)&__pyx_v_6gevent_6_local_key_prefix, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_greenlet_imported, (void *)&__pyx_v_6gevent_6_local__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_local_attrs, (void *)&__pyx_v_6gevent_6_local__local_attrs, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_init", (void (*)(void))__pyx_f_6gevent_6_local__init, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_localimpl_create_dict", (void (*)(void))__pyx_f_6gevent_6_local__localimpl_create_dict, "PyObject *(struct __pyx_obj_6gevent_6_local__localimpl *, PyGreenlet *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_local_get_dict", (void (*)(void))__pyx_f_6gevent_6_local__local_get_dict, "PyObject *(struct __pyx_obj_6gevent_6_local_local *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_local__copy_dict_from", (void (*)(void))__pyx_f_6gevent_6_local__local__copy_dict_from, "PyObject *(struct __pyx_obj_6gevent_6_local_local *, struct __pyx_obj_6gevent_6_local__localimpl *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("_local_find_descriptors", (void (*)(void))__pyx_f_6gevent_6_local__local_find_descriptors, "PyObject *(struct __pyx_obj_6gevent_6_local_local *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportFunction("all_local_dicts_for_greenlet", (void (*)(void))__pyx_f_6gevent_6_local_all_local_dicts_for_greenlet, "PyObject *(PyGreenlet *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_6_local_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_6_local_greenlet)) __PYX_ERR(4, 17, __pyx_L1_error)
- __pyx_type_6gevent_6_local__wrefdict.tp_base = (&PyDict_Type);
- if (PyType_Ready(&__pyx_type_6gevent_6_local__wrefdict) < 0) __PYX_ERR(0, 210, __pyx_L1_error)
- __pyx_type_6gevent_6_local__wrefdict.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_local__wrefdict.tp_dictoffset && __pyx_type_6gevent_6_local__wrefdict.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_local__wrefdict.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_wrefdict", (PyObject *)&__pyx_type_6gevent_6_local__wrefdict) < 0) __PYX_ERR(0, 210, __pyx_L1_error)
- if (__pyx_type_6gevent_6_local__wrefdict.tp_weaklistoffset == 0) __pyx_type_6gevent_6_local__wrefdict.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_local__wrefdict, __weakref__);
- __pyx_ptype_6gevent_6_local__wrefdict = &__pyx_type_6gevent_6_local__wrefdict;
- if (PyType_Ready(&__pyx_type_6gevent_6_local__greenlet_deleted) < 0) __PYX_ERR(0, 213, __pyx_L1_error)
- __pyx_type_6gevent_6_local__greenlet_deleted.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_local__greenlet_deleted.tp_dictoffset && __pyx_type_6gevent_6_local__greenlet_deleted.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_local__greenlet_deleted.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_greenlet_deleted", (PyObject *)&__pyx_type_6gevent_6_local__greenlet_deleted) < 0) __PYX_ERR(0, 213, __pyx_L1_error)
- __pyx_ptype_6gevent_6_local__greenlet_deleted = &__pyx_type_6gevent_6_local__greenlet_deleted;
- if (PyType_Ready(&__pyx_type_6gevent_6_local__local_deleted) < 0) __PYX_ERR(0, 233, __pyx_L1_error)
- __pyx_type_6gevent_6_local__local_deleted.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_local__local_deleted.tp_dictoffset && __pyx_type_6gevent_6_local__local_deleted.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_local__local_deleted.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_local_deleted", (PyObject *)&__pyx_type_6gevent_6_local__local_deleted) < 0) __PYX_ERR(0, 233, __pyx_L1_error)
- __pyx_ptype_6gevent_6_local__local_deleted = &__pyx_type_6gevent_6_local__local_deleted;
- if (PyType_Ready(&__pyx_type_6gevent_6_local__localimpl) < 0) __PYX_ERR(0, 252, __pyx_L1_error)
- __pyx_type_6gevent_6_local__localimpl.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_local__localimpl.tp_dictoffset && __pyx_type_6gevent_6_local__localimpl.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_local__localimpl.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_localimpl", (PyObject *)&__pyx_type_6gevent_6_local__localimpl) < 0) __PYX_ERR(0, 252, __pyx_L1_error)
- if (__pyx_type_6gevent_6_local__localimpl.tp_weaklistoffset == 0) __pyx_type_6gevent_6_local__localimpl.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_local__localimpl, __weakref__);
- __pyx_ptype_6gevent_6_local__localimpl = &__pyx_type_6gevent_6_local__localimpl;
- if (PyType_Ready(&__pyx_type_6gevent_6_local__localimpl_dict_entry) < 0) __PYX_ERR(0, 273, __pyx_L1_error)
- __pyx_type_6gevent_6_local__localimpl_dict_entry.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_local__localimpl_dict_entry.tp_dictoffset && __pyx_type_6gevent_6_local__localimpl_dict_entry.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_local__localimpl_dict_entry.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (PyObject_SetAttrString(__pyx_m, "_localimpl_dict_entry", (PyObject *)&__pyx_type_6gevent_6_local__localimpl_dict_entry) < 0) __PYX_ERR(0, 273, __pyx_L1_error)
- __pyx_ptype_6gevent_6_local__localimpl_dict_entry = &__pyx_type_6gevent_6_local__localimpl_dict_entry;
- __pyx_vtabptr_6gevent_6_local_local = &__pyx_vtable_6gevent_6_local_local;
- __pyx_vtable_6gevent_6_local_local.__pyx___copy__ = (struct __pyx_obj_6gevent_6_local_local *(*)(struct __pyx_obj_6gevent_6_local_local *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_local_5local___copy__;
- if (PyType_Ready(&__pyx_type_6gevent_6_local_local) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
- __pyx_type_6gevent_6_local_local.tp_print = 0;
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_local_local.tp_dict, __pyx_vtabptr_6gevent_6_local_local) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "local", (PyObject *)&__pyx_type_6gevent_6_local_local) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
- __pyx_ptype_6gevent_6_local_local = &__pyx_type_6gevent_6_local_local;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_7__ident_ref = __Pyx_ImportType("weakref", "ref", sizeof(PyWeakReference), 0); if (unlikely(!__pyx_ptype_6gevent_7__ident_ref)) __PYX_ERR(5, 5, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_ValuedWeakRef = __Pyx_ImportType("gevent.__ident", "ValuedWeakRef", sizeof(struct __pyx_obj_6gevent_7__ident_ValuedWeakRef), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_ValuedWeakRef)) __PYX_ERR(5, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_7__ident_IdentRegistry = __Pyx_ImportType("gevent.__ident", "IdentRegistry", sizeof(struct __pyx_obj_6gevent_7__ident_IdentRegistry), 1); if (unlikely(!__pyx_ptype_6gevent_7__ident_IdentRegistry)) __PYX_ERR(5, 19, __pyx_L1_error)
- __pyx_vtabptr_6gevent_7__ident_IdentRegistry = (struct __pyx_vtabstruct_6gevent_7__ident_IdentRegistry*)__Pyx_GetVtable(__pyx_ptype_6gevent_7__ident_IdentRegistry->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_7__ident_IdentRegistry)) __PYX_ERR(5, 19, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(1, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(1, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(1, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(2, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_Waiter = __Pyx_ImportType("gevent.__waiter", "Waiter", sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_Waiter)) __PYX_ERR(2, 33, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_Waiter)) __PYX_ERR(2, 33, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = __Pyx_ImportType("gevent.__waiter", "MultipleWaiter", sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(2, 47, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = (struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(2, 47, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_greenlet)) __PYX_ERR(3, 17, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_CodeType = __Pyx_ImportType("types", "CodeType", sizeof(PyCodeObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_CodeType)) __PYX_ERR(3, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FrameType = __Pyx_ImportType("types", "FrameType", sizeof(PyFrameObject), 0); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_FrameType)) __PYX_ERR(3, 45, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SpawnedLink = __Pyx_ImportType("gevent._greenlet", "SpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_SpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_SpawnedLink)) __PYX_ERR(3, 56, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink = __Pyx_ImportType("gevent._greenlet", "SuccessSpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_SuccessSpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_SuccessSpawnedLink)) __PYX_ERR(3, 61, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink = __Pyx_ImportType("gevent._greenlet", "FailureSpawnedLink", sizeof(struct __pyx_obj_6gevent_9_greenlet_FailureSpawnedLink), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_FailureSpawnedLink)) __PYX_ERR(3, 65, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__Frame = __Pyx_ImportType("gevent._greenlet", "_Frame", sizeof(struct __pyx_obj_6gevent_9_greenlet__Frame), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet__Frame)) __PYX_ERR(3, 71, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet_Greenlet = __Pyx_ImportType("gevent._greenlet", "Greenlet", sizeof(struct __pyx_obj_6gevent_9_greenlet_Greenlet), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet_Greenlet)) __PYX_ERR(3, 86, __pyx_L1_error)
- __pyx_vtabptr_6gevent_9_greenlet_Greenlet = (struct __pyx_vtabstruct_6gevent_9_greenlet_Greenlet*)__Pyx_GetVtable(__pyx_ptype_6gevent_9_greenlet_Greenlet->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_9_greenlet_Greenlet)) __PYX_ERR(3, 86, __pyx_L1_error)
- __pyx_ptype_6gevent_9_greenlet__dummy_event = __Pyx_ImportType("gevent._greenlet", "_dummy_event", sizeof(struct __pyx_obj_6gevent_9_greenlet__dummy_event), 1); if (unlikely(!__pyx_ptype_6gevent_9_greenlet__dummy_event)) __PYX_ERR(3, 157, __pyx_L1_error)
- __pyx_vtabptr_6gevent_9_greenlet__dummy_event = (struct __pyx_vtabstruct_6gevent_9_greenlet__dummy_event*)__Pyx_GetVtable(__pyx_ptype_6gevent_9_greenlet__dummy_event->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_9_greenlet__dummy_event)) __PYX_ERR(3, 157, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__ident"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappop", (void **)&__pyx_vp_6gevent_7__ident_heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "heappush", (void **)&__pyx_vp_6gevent_7__ident_heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "WeakKeyDictionary", (void **)&__pyx_vp_6gevent_7__ident_WeakKeyDictionary, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = __Pyx_ImportModule("gevent.__waiter"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "sys", (void **)&__pyx_vp_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "ConcurrentObjectUseError", (void **)&__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_greenlet_imported", (void **)&__pyx_vp_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_NONE", (void **)&__pyx_vp_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_5 = __Pyx_ImportModule("gevent._greenlet"); if (!__pyx_t_5) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_PYPY", (void **)&__pyx_vp_6gevent_9_greenlet__PYPY, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "sys_getframe", (void **)&__pyx_vp_6gevent_9_greenlet_sys_getframe, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "sys_exc_info", (void **)&__pyx_vp_6gevent_9_greenlet_sys_exc_info, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "Timeout", (void **)&__pyx_vp_6gevent_9_greenlet_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "GreenletExit", (void **)&__pyx_vp_6gevent_9_greenlet_GreenletExit, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "InvalidSwitchError", (void **)&__pyx_vp_6gevent_9_greenlet_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_greenlet_imported", (void **)&__pyx_vp_6gevent_9_greenlet__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_greenlet__init__", (void **)&__pyx_vp_6gevent_9_greenlet__greenlet__init__, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_threadlocal", (void **)&__pyx_vp_6gevent_9_greenlet__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "get_hub_class", (void **)&__pyx_vp_6gevent_9_greenlet_get_hub_class, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "wref", (void **)&__pyx_vp_6gevent_9_greenlet_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "dump_traceback", (void **)&__pyx_vp_6gevent_9_greenlet_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "load_traceback", (void **)&__pyx_vp_6gevent_9_greenlet_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "wait", (void **)&__pyx_vp_6gevent_9_greenlet_wait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "iwait", (void **)&__pyx_vp_6gevent_9_greenlet_iwait, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "reraise", (void **)&__pyx_vp_6gevent_9_greenlet_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "GEVENT_CONFIG", (void **)&__pyx_vp_6gevent_9_greenlet_GEVENT_CONFIG, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_cancelled_start_event", (void **)&__pyx_vp_6gevent_9_greenlet__cancelled_start_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_5, "_start_completed_event", (void **)&__pyx_vp_6gevent_9_greenlet__start_completed_event, "struct __pyx_obj_6gevent_9_greenlet__dummy_event *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init_local(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init_local(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit__local(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit__local(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec__local(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__local(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("_local", __pyx_methods, __pyx_k_Greenlet_local_objects_This_mod, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent___local) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent._local")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent._local", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/local.py":156
- * from __future__ import print_function
- *
- * from copy import copy # <<<<<<<<<<<<<<
- * from weakref import ref
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_copy_2);
- __Pyx_GIVEREF(__pyx_n_s_copy_2);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_copy_2);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_copy_2, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_copy_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_local_copy);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_local_copy, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":157
- *
- * from copy import copy
- * from weakref import ref # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ref);
- __Pyx_GIVEREF(__pyx_n_s_ref);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ref);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ref); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_local_ref);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_local_ref, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":160
- *
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent # <<<<<<<<<<<<<<
- * locals()['greenlet_init'] = lambda: None
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_getcurrent, __pyx_t_2) < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":161
- *
- * locals()['getcurrent'] = __import__('greenlet').getcurrent
- * locals()['greenlet_init'] = lambda: None # <<<<<<<<<<<<<<
- *
- * __all__ = [
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_local_4lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent__local, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_greenlet_init, __pyx_t_2) < 0)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":163
- * locals()['greenlet_init'] = lambda: None
- *
- * __all__ = [ # <<<<<<<<<<<<<<
- * "local",
- * ]
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_local);
- __Pyx_GIVEREF(__pyx_n_s_local);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_local);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":170
- * # We keep it a string for speed but make it unlikely to clash with
- * # a "real" attribute.
- * key_prefix = '_gevent_local_localimpl_' # <<<<<<<<<<<<<<
- *
- * # The overall structure is as follows:
- */
- __Pyx_INCREF(__pyx_n_s_gevent_local_localimpl);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_local_key_prefix);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_local_key_prefix, __pyx_n_s_gevent_local_localimpl);
- __Pyx_GIVEREF(__pyx_n_s_gevent_local_localimpl);
-
- /* "src/gevent/local.py":179
- * # That final tuple is actually a localimpl_dict_entry object.
- *
- * def all_local_dicts_for_greenlet(greenlet): # <<<<<<<<<<<<<<
- * """
- * Internal debug helper for getting the local values associated
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_local_1all_local_dicts_for_greenlet, 0, __pyx_n_s_all_local_dicts_for_greenlet, NULL, __pyx_n_s_gevent__local, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all_local_dicts_for_greenlet, __pyx_t_2) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":222
- * weakref.
- * """
- * __slots__ = ('idt', 'wrdicts') # <<<<<<<<<<<<<<
- *
- * def __init__(self, idt, wrdicts):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local__greenlet_deleted->tp_dict, __pyx_n_s_slots, __pyx_tuple__4) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_local__greenlet_deleted);
-
- /* "src/gevent/local.py":234
- *
- * class _local_deleted(object):
- * __slots__ = ('key', 'wrthread', 'greenlet_deleted') # <<<<<<<<<<<<<<
- *
- * def __init__(self, key, wrthread, greenlet_deleted):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local__local_deleted->tp_dict, __pyx_n_s_slots, __pyx_tuple__5) < 0) __PYX_ERR(0, 234, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_local__local_deleted);
-
- /* "src/gevent/local.py":254
- * class _localimpl(object):
- * """A class managing thread-local dicts"""
- * __slots__ = ('key', 'dicts', # <<<<<<<<<<<<<<
- * 'localargs', 'localkwargs',
- * 'localtypeid',
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local__localimpl->tp_dict, __pyx_n_s_slots, __pyx_tuple__6) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_local__localimpl);
-
- /* "src/gevent/local.py":280
- * # This is a class, not just a tuple, so that cython can optimize
- * # attribute access
- * __slots__ = ('wrgreenlet', 'localdict') # <<<<<<<<<<<<<<
- *
- * def __init__(self, wrgreenlet, localdict):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local__localimpl_dict_entry->tp_dict, __pyx_n_s_slots, __pyx_tuple__7) < 0) __PYX_ERR(0, 280, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_local__localimpl_dict_entry);
-
- /* "src/gevent/local.py":331
- *
- *
- * _marker = object() # <<<<<<<<<<<<<<
- *
- * def _local_get_dict(self):
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_local__marker);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_local__marker, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":350
- *
- * _local_attrs = {
- * '_local__impl', # <<<<<<<<<<<<<<
- * '_local_type_get_descriptors',
- * '_local_type_set_or_del_descriptors',
- */
- __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local__impl) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_get_descriptors) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_set_or_del_descripto) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_del_descriptors) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_set_descriptors) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_2) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_local_type_vars) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_class) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_cinit) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
- __Pyx_XGOTREF(__pyx_v_6gevent_6_local__local_attrs);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_local__local_attrs, ((PyObject*)__pyx_t_2));
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":365
- * An object whose attributes are greenlet-local.
- * """
- * __slots__ = tuple(_local_attrs - {'__class__', '__cinit__'}) # <<<<<<<<<<<<<<
- *
- * def __cinit__(self, *args, **kw):
- */
- __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PySet_Add(__pyx_t_2, __pyx_n_s_class) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
- if (PySet_Add(__pyx_t_2, __pyx_n_s_cinit) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
- __pyx_t_1 = PyNumber_Subtract(__pyx_v_6gevent_6_local__local_attrs, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local_local->tp_dict, __pyx_n_s_slots, __pyx_t_2) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_local_local);
-
- /* "src/gevent/local.py":517
- * raise AttributeError(name)
- *
- * def __copy__(self): # <<<<<<<<<<<<<<
- * impl = self._local__impl
- * entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_local_5local_9__copy__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_local___copy, NULL, __pyx_n_s_gevent__local, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_local_local->tp_dict, __pyx_n_s_copy, __pyx_t_2) < 0) __PYX_ERR(0, 517, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_local_local);
-
- /* "src/gevent/local.py":574
- * # (e.g., on PyPy). So we set it at runtime. Cython
- * # will raise an error if we're compiled.
- * def __new__(cls, *args, **kw): # <<<<<<<<<<<<<<
- * self = super(local, cls).__new__(cls)
- * # We get the cls in *args for some reason
- */
- __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_local_3__new__, 0, __pyx_n_s_new, NULL, __pyx_n_s_gevent__local, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_new, __pyx_t_2) < 0) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":582
- * return self
- *
- * try: # <<<<<<<<<<<<<<
- * # PyPy2/3 and CPython handle adding a __new__ to the class
- * # in different ways. In CPython and PyPy3, it must be wrapped with classmethod;
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- /*try:*/ {
-
- /* "src/gevent/local.py":587
- * # in PyPy2, it must not. In either case, the args that get passed to
- * # it are stil wrong.
- * local.__new__ = 'None' # <<<<<<<<<<<<<<
- * except TypeError: # pragma: no cover
- * # Must be compiled
- */
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_local_local), __pyx_n_s_new, __pyx_n_s_None) < 0) __PYX_ERR(0, 587, __pyx_L2_error)
-
- /* "src/gevent/local.py":582
- * return self
- *
- * try: # <<<<<<<<<<<<<<
- * # PyPy2/3 and CPython handle adding a __new__ to the class
- * # in different ways. In CPython and PyPy3, it must be wrapped with classmethod;
- */
- }
-
- /* "src/gevent/local.py":592
- * pass
- * else:
- * from gevent._compat import PYPY # <<<<<<<<<<<<<<
- * from gevent._compat import PY2
- * if PYPY and PY2:
- */
- /*else:*/ {
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_PYPY_2);
- __Pyx_GIVEREF(__pyx_n_s_PYPY_2);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PYPY_2);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_PYPY_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_PYPY_2, __pyx_t_2) < 0) __PYX_ERR(0, 592, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":593
- * else:
- * from gevent._compat import PYPY
- * from gevent._compat import PY2 # <<<<<<<<<<<<<<
- * if PYPY and PY2:
- * local.__new__ = __new__
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_PY2);
- __Pyx_GIVEREF(__pyx_n_s_PY2);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PY2);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_PY2, __pyx_t_1) < 0) __PYX_ERR(0, 593, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":594
- * from gevent._compat import PYPY
- * from gevent._compat import PY2
- * if PYPY and PY2: # <<<<<<<<<<<<<<
- * local.__new__ = __new__
- * else:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PYPY_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 594, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__pyx_t_7) {
- } else {
- __pyx_t_6 = __pyx_t_7;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 594, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_6 = __pyx_t_7;
- __pyx_L9_bool_binop_done:;
- if (__pyx_t_6) {
-
- /* "src/gevent/local.py":595
- * from gevent._compat import PY2
- * if PYPY and PY2:
- * local.__new__ = __new__ # <<<<<<<<<<<<<<
- * else:
- * local.__new__ = classmethod(__new__)
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_local_local), __pyx_n_s_new, __pyx_t_2) < 0) __PYX_ERR(0, 595, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":594
- * from gevent._compat import PYPY
- * from gevent._compat import PY2
- * if PYPY and PY2: # <<<<<<<<<<<<<<
- * local.__new__ = __new__
- * else:
- */
- goto __pyx_L8;
- }
-
- /* "src/gevent/local.py":597
- * local.__new__ = __new__
- * else:
- * local.__new__ = classmethod(__new__) # <<<<<<<<<<<<<<
- *
- * del PYPY
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 597, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_classmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L4_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_local_local), __pyx_n_s_new, __pyx_t_1) < 0) __PYX_ERR(0, 597, __pyx_L4_except_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L8:;
-
- /* "src/gevent/local.py":599
- * local.__new__ = classmethod(__new__)
- *
- * del PYPY # <<<<<<<<<<<<<<
- * del PY2
- *
- */
- if (__Pyx_PyObject_DelAttrStr(__pyx_m, __pyx_n_s_PYPY_2) < 0) __PYX_ERR(0, 599, __pyx_L4_except_error)
-
- /* "src/gevent/local.py":600
- *
- * del PYPY
- * del PY2 # <<<<<<<<<<<<<<
- *
- * _init()
- */
- if (__Pyx_PyObject_DelAttrStr(__pyx_m, __pyx_n_s_PY2) < 0) __PYX_ERR(0, 600, __pyx_L4_except_error)
- }
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- goto __pyx_L7_try_end;
- __pyx_L2_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":588
- * # it are stil wrong.
- * local.__new__ = 'None'
- * except TypeError: # pragma: no cover # <<<<<<<<<<<<<<
- * # Must be compiled
- * pass
- */
- __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
- if (__pyx_t_8) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L3_exception_handled;
- }
- goto __pyx_L4_except_error;
- __pyx_L4_except_error:;
-
- /* "src/gevent/local.py":582
- * return self
- *
- * try: # <<<<<<<<<<<<<<
- * # PyPy2/3 and CPython handle adding a __new__ to the class
- * # in different ways. In CPython and PyPy3, it must be wrapped with classmethod;
- */
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L1_error;
- __pyx_L3_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- __pyx_L7_try_end:;
- }
-
- /* "src/gevent/local.py":602
- * del PY2
- *
- * _init() # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __pyx_f_6gevent_6_local__init();
-
- /* "src/gevent/local.py":604
- * _init()
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent._local')
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_import_c_accel);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_1) < 0) __PYX_ERR(0, 604, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/local.py":605
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent._local') # <<<<<<<<<<<<<<
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_gevent__local);
- __Pyx_GIVEREF(__pyx_n_s_gevent__local);
- PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_gevent__local);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/local.py":1
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False # <<<<<<<<<<<<<<
- * """
- * Greenlet-local objects.
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/_local.pxd":29
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_9);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent._local", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent._local");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* UnpackUnboundCMethod */
-static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod0 */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_ASSUME_SAFE_MACROS
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
-#else
- args = PyTuple_Pack(1, self);
- if (unlikely(!args)) goto bad;
-#endif
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- Py_DECREF(args);
-bad:
- return result;
-}
-
-/* py_dict_items */
-static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
- if (PY_MAJOR_VERSION >= 3)
- return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
- else
- return PyDict_Items(d);
-}
-
-/* RaiseTooManyValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
-static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* bytes_tailmatch */
-static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- const char* self_ptr = PyBytes_AS_STRING(self);
- Py_ssize_t self_len = PyBytes_GET_SIZE(self);
- const char* sub_ptr;
- Py_ssize_t sub_len;
- int retval;
- Py_buffer view;
- view.obj = NULL;
- if ( PyBytes_Check(arg) ) {
- sub_ptr = PyBytes_AS_STRING(arg);
- sub_len = PyBytes_GET_SIZE(arg);
- }
-#if PY_MAJOR_VERSION < 3
- else if ( PyUnicode_Check(arg) ) {
- return (int) PyUnicode_Tailmatch(self, arg, start, end, direction);
- }
-#endif
- else {
- if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1))
- return -1;
- sub_ptr = (const char*) view.buf;
- sub_len = view.len;
- }
- if (end > self_len)
- end = self_len;
- else if (end < 0)
- end += self_len;
- if (end < 0)
- end = 0;
- if (start < 0)
- start += self_len;
- if (start < 0)
- start = 0;
- if (direction > 0) {
- if (end-sub_len > start)
- start = end - sub_len;
- }
- if (start + sub_len <= end)
- retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len);
- else
- retval = 0;
- if (view.obj)
- PyBuffer_Release(&view);
- return retval;
-}
-static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
- for (i = 0; i < count; i++) {
- int result;
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
- start, end, direction);
-#else
- PyObject* sub = PySequence_ITEM(substrings, i);
- if (unlikely(!sub)) return -1;
- result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
- Py_DECREF(sub);
-#endif
- if (result) {
- return result;
- }
- }
- return 0;
-}
-static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- if (unlikely(PyTuple_Check(substr))) {
- return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
- }
- return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
-}
-
-/* unicode_tailmatch */
-static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
- for (i = 0; i < count; i++) {
- Py_ssize_t result;
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
- start, end, direction);
-#else
- PyObject* sub = PySequence_ITEM(substrings, i);
- if (unlikely(!sub)) return -1;
- result = PyUnicode_Tailmatch(s, sub, start, end, direction);
- Py_DECREF(sub);
-#endif
- if (result) {
- return (int) result;
- }
- }
- return 0;
-}
-static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- if (unlikely(PyTuple_Check(substr))) {
- return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
- }
- return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
-}
-
-/* str_tailmatch */
-static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
- Py_ssize_t end, int direction)
-{
- if (PY_MAJOR_VERSION < 3)
- return __Pyx_PyBytes_Tailmatch(self, arg, start, end, direction);
- else
- return __Pyx_PyUnicode_Tailmatch(self, arg, start, end, direction);
-}
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* CallUnboundCMethod1 */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
- if (likely(cfunc->func)) {
- int flag = cfunc->flag;
- if (flag == METH_O) {
- return (*(cfunc->func))(self, arg);
- } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
- if (PY_VERSION_HEX >= 0x030700A0) {
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
- } else {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- }
- return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(2, self, arg);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* CallUnboundCMethod2 */
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
- if (likely(cfunc->func)) {
- PyObject *args[2] = {arg1, arg2};
- if (cfunc->flag == METH_FASTCALL) {
- #if PY_VERSION_HEX >= 0x030700A0
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
- #else
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- #if PY_VERSION_HEX >= 0x030700A0
- if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(3);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 1, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 2, arg2);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(3, self, arg1, arg2);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* dict_getitem_default */
- static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
- PyObject* value;
-#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
- value = PyDict_GetItemWithError(d, key);
- if (unlikely(!value)) {
- if (unlikely(PyErr_Occurred()))
- return NULL;
- value = default_value;
- }
- Py_INCREF(value);
- if ((1));
-#else
- if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
- value = PyDict_GetItem(d, key);
- if (unlikely(!value)) {
- value = default_value;
- }
- Py_INCREF(value);
- }
-#endif
- else {
- if (default_value == Py_None)
- value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
- else
- value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
- }
- return value;
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* RaiseArgTupleInvalid */
- static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* PyErrFetchRestore */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* DictGetItem */
- #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
-static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
- PyObject *value;
- value = PyDict_GetItemWithError(d, key);
- if (unlikely(!value)) {
- if (!PyErr_Occurred()) {
- PyObject* args = PyTuple_Pack(1, key);
- if (likely(args))
- PyErr_SetObject(PyExc_KeyError, args);
- Py_XDECREF(args);
- }
- return NULL;
- }
- Py_INCREF(value);
- return value;
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* KeywordStringCheck */
- static int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
-#if CYTHON_COMPILING_IN_PYPY
- if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
- goto invalid_keyword;
- return 1;
-#else
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_Check(key)))
- #endif
- if (unlikely(!PyUnicode_Check(key)))
- goto invalid_keyword_type;
- }
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- return 0;
-#endif
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
-}
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* RaiseNoneIterError */
- static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
-}
-
-/* pyfrozenset_new */
- static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
- if (it) {
- PyObject* result;
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* args;
- args = PyTuple_Pack(1, it);
- if (unlikely(!args))
- return NULL;
- result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
- Py_DECREF(args);
- return result;
-#else
- if (PyFrozenSet_CheckExact(it)) {
- Py_INCREF(it);
- return it;
- }
- result = PyFrozenSet_New(it);
- if (unlikely(!result))
- return NULL;
- if (likely(PySet_GET_SIZE(result)))
- return result;
- Py_DECREF(result);
-#endif
- }
-#if CYTHON_USE_TYPE_SLOTS
- return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
-#else
- return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
-#endif
-}
-
-/* PySetContains */
- static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
- int result = -1;
- if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
- PyObject *tmpkey;
- PyErr_Clear();
- tmpkey = __Pyx_PyFrozenSet_New(key);
- if (tmpkey != NULL) {
- result = PySet_Contains(set, tmpkey);
- Py_DECREF(tmpkey);
- }
- }
- return result;
-}
-static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
- int result = PySet_Contains(set, key);
- if (unlikely(result < 0)) {
- result = __Pyx_PySet_ContainsUnhashable(set, key);
- }
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* BytesEquals */
- static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
- static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* ObjectGetItem */
- #if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* HasAttr */
- static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
- PyObject *r;
- if (unlikely(!__Pyx_PyBaseString_Check(n))) {
- PyErr_SetString(PyExc_TypeError,
- "hasattr(): attribute name must be string");
- return -1;
- }
- r = __Pyx_GetAttr(o, n);
- if (unlikely(!r)) {
- PyErr_Clear();
- return 0;
- } else {
- Py_DECREF(r);
- return 1;
- }
-}
-
-/* SliceTupleAndList */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
- Py_ssize_t start = *_start, stop = *_stop, length = *_length;
- if (start < 0) {
- start += length;
- if (start < 0)
- start = 0;
- }
- if (stop < 0)
- stop += length;
- else if (stop > length)
- stop = length;
- *_length = stop - start;
- *_start = start;
- *_stop = stop;
-}
-static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
- PyObject *v;
- Py_ssize_t i;
- for (i = 0; i < length; i++) {
- v = dest[i] = src[i];
- Py_INCREF(v);
- }
-}
-static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
- PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
- PyObject* dest;
- Py_ssize_t length = PyList_GET_SIZE(src);
- __Pyx_crop_slice(&start, &stop, &length);
- if (unlikely(length <= 0))
- return PyList_New(0);
- dest = PyList_New(length);
- if (unlikely(!dest))
- return NULL;
- __Pyx_copy_object_array(
- ((PyListObject*)src)->ob_item + start,
- ((PyListObject*)dest)->ob_item,
- length);
- return dest;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
- PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
- PyObject* dest;
- Py_ssize_t length = PyTuple_GET_SIZE(src);
- __Pyx_crop_slice(&start, &stop, &length);
- if (unlikely(length <= 0))
- return PyTuple_New(0);
- dest = PyTuple_New(length);
- if (unlikely(!dest))
- return NULL;
- __Pyx_copy_object_array(
- ((PyTupleObject*)src)->ob_item + start,
- ((PyTupleObject*)dest)->ob_item,
- length);
- return dest;
-}
-#endif
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* Import */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* GetModuleGlobalName */
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/local.py b/python/gevent/local.py
deleted file mode 100644
index f29bb23..0000000
--- a/python/gevent/local.py
+++ /dev/null
@@ -1,605 +0,0 @@
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-"""
-Greenlet-local objects.
-
-This module is based on `_threading_local.py`__ from the standard
-library of Python 3.4.
-
-__ https://github.com/python/cpython/blob/3.4/Lib/_threading_local.py
-
-Greenlet-local objects support the management of greenlet-local data.
-If you have data that you want to be local to a greenlet, simply create
-a greenlet-local object and use its attributes:
-
- >>> mydata = local()
- >>> mydata.number = 42
- >>> mydata.number
- 42
-
-You can also access the local-object's dictionary:
-
- >>> mydata.__dict__
- {'number': 42}
- >>> mydata.__dict__.setdefault('widgets', [])
- []
- >>> mydata.widgets
- []
-
-What's important about greenlet-local objects is that their data are
-local to a greenlet. If we access the data in a different greenlet:
-
- >>> log = []
- >>> def f():
- ... items = list(mydata.__dict__.items())
- ... items.sort()
- ... log.append(items)
- ... mydata.number = 11
- ... log.append(mydata.number)
- >>> greenlet = gevent.spawn(f)
- >>> greenlet.join()
- >>> log
- [[], 11]
-
-we get different data. Furthermore, changes made in the other greenlet
-don't affect data seen in this greenlet:
-
- >>> mydata.number
- 42
-
-Of course, values you get from a local object, including a __dict__
-attribute, are for whatever greenlet was current at the time the
-attribute was read. For that reason, you generally don't want to save
-these values across greenlets, as they apply only to the greenlet they
-came from.
-
-You can create custom local objects by subclassing the local class:
-
- >>> class MyLocal(local):
- ... number = 2
- ... initialized = False
- ... def __init__(self, **kw):
- ... if self.initialized:
- ... raise SystemError('__init__ called too many times')
- ... self.initialized = True
- ... self.__dict__.update(kw)
- ... def squared(self):
- ... return self.number ** 2
-
-This can be useful to support default values, methods and
-initialization. Note that if you define an __init__ method, it will be
-called each time the local object is used in a separate greenlet. This
-is necessary to initialize each greenlet's dictionary.
-
-Now if we create a local object:
-
- >>> mydata = MyLocal(color='red')
-
-Now we have a default number:
-
- >>> mydata.number
- 2
-
-an initial color:
-
- >>> mydata.color
- 'red'
- >>> del mydata.color
-
-And a method that operates on the data:
-
- >>> mydata.squared()
- 4
-
-As before, we can access the data in a separate greenlet:
-
- >>> log = []
- >>> greenlet = gevent.spawn(f)
- >>> greenlet.join()
- >>> log
- [[('color', 'red'), ('initialized', True)], 11]
-
-without affecting this greenlet's data:
-
- >>> mydata.number
- 2
- >>> mydata.color
- Traceback (most recent call last):
- ...
- AttributeError: 'MyLocal' object has no attribute 'color'
-
-Note that subclasses can define slots, but they are not greenlet
-local. They are shared across greenlets::
-
- >>> class MyLocal(local):
- ... __slots__ = 'number'
-
- >>> mydata = MyLocal()
- >>> mydata.number = 42
- >>> mydata.color = 'red'
-
-So, the separate greenlet:
-
- >>> greenlet = gevent.spawn(f)
- >>> greenlet.join()
-
-affects what we see:
-
- >>> mydata.number
- 11
-
->>> del mydata
-
-.. versionchanged:: 1.1a2
- Update the implementation to match Python 3.4 instead of Python 2.5.
- This results in locals being eligible for garbage collection as soon
- as their greenlet exits.
-
-.. versionchanged:: 1.2.3
- Use a weak-reference to clear the greenlet link we establish in case
- the local object dies before the greenlet does.
-
-.. versionchanged:: 1.3a1
- Implement the methods for attribute access directly, handling
- descriptors directly here. This allows removing the use of a lock
- and facilitates greatly improved performance.
-
-.. versionchanged:: 1.3a1
- The ``__init__`` method of subclasses of ``local`` is no longer
- called with a lock held. CPython does not use such a lock in its
- native implementation. This could potentially show as a difference
- if code that uses multiple dependent attributes in ``__slots__``
- (which are shared across all greenlets) switches during ``__init__``.
-
-"""
-from __future__ import print_function
-
-from copy import copy
-from weakref import ref
-
-
-locals()['getcurrent'] = __import__('greenlet').getcurrent
-locals()['greenlet_init'] = lambda: None
-
-__all__ = [
- "local",
-]
-
-# The key used in the Thread objects' attribute dicts.
-# We keep it a string for speed but make it unlikely to clash with
-# a "real" attribute.
-key_prefix = '_gevent_local_localimpl_'
-
-# The overall structure is as follows:
-# For each local() object:
-# greenlet.__dict__[key_prefix + str(id(local))]
-# => _localimpl.dicts[id(greenlet)] => (ref(greenlet), {})
-
-# That final tuple is actually a localimpl_dict_entry object.
-
-def all_local_dicts_for_greenlet(greenlet):
- """
- Internal debug helper for getting the local values associated
- with a greenlet. This is subject to change or removal at any time.
-
- :return: A list of ((type, id), {}) pairs, where the first element
- is the type and id of the local object and the second object is its
- instance dictionary, as seen from this greenlet.
-
- .. versionadded:: 1.3a2
- """
-
- result = []
- id_greenlet = id(greenlet)
- greenlet_dict = greenlet.__dict__
- for k, v in greenlet_dict.items():
- if not k.startswith(key_prefix):
- continue
- local_impl = v()
- if local_impl is None:
- continue
- entry = local_impl.dicts.get(id_greenlet)
- if entry is None:
- # Not yet used in this greenlet.
- continue
- assert entry.wrgreenlet() is greenlet
- result.append((local_impl.localtypeid, entry.localdict))
-
- return result
-
-
-class _wrefdict(dict):
- """A dict that can be weak referenced"""
-
-class _greenlet_deleted(object):
- """
- A weakref callback for when the greenlet
- is deleted.
-
- If the greenlet is a `gevent.greenlet.Greenlet` and
- supplies ``rawlink``, that will be used instead of a
- weakref.
- """
- __slots__ = ('idt', 'wrdicts')
-
- def __init__(self, idt, wrdicts):
- self.idt = idt
- self.wrdicts = wrdicts
-
- def __call__(self, _unused):
- dicts = self.wrdicts()
- if dicts:
- dicts.pop(self.idt, None)
-
-class _local_deleted(object):
- __slots__ = ('key', 'wrthread', 'greenlet_deleted')
-
- def __init__(self, key, wrthread, greenlet_deleted):
- self.key = key
- self.wrthread = wrthread
- self.greenlet_deleted = greenlet_deleted
-
- def __call__(self, _unused):
- thread = self.wrthread()
- if thread is not None:
- try:
- unlink = thread.unlink
- except AttributeError:
- pass
- else:
- unlink(self.greenlet_deleted)
- del thread.__dict__[self.key]
-
-class _localimpl(object):
- """A class managing thread-local dicts"""
- __slots__ = ('key', 'dicts',
- 'localargs', 'localkwargs',
- 'localtypeid',
- '__weakref__',)
-
- def __init__(self, args, kwargs, local_type, id_local):
- self.key = key_prefix + str(id(self))
- # { id(greenlet) -> _localimpl_dict_entry(ref(greenlet), greenlet-local dict) }
- self.dicts = _wrefdict()
- self.localargs = args
- self.localkwargs = kwargs
- self.localtypeid = local_type, id_local
-
- # We need to create the thread dict in anticipation of
- # __init__ being called, to make sure we don't call it
- # again ourselves. MUST do this before setting any attributes.
- greenlet = getcurrent() # pylint:disable=undefined-variable
- _localimpl_create_dict(self, greenlet, id(greenlet))
-
-class _localimpl_dict_entry(object):
- """
- The object that goes in the ``dicts`` of ``_localimpl``
- object for each thread.
- """
- # This is a class, not just a tuple, so that cython can optimize
- # attribute access
- __slots__ = ('wrgreenlet', 'localdict')
-
- def __init__(self, wrgreenlet, localdict):
- self.wrgreenlet = wrgreenlet
- self.localdict = localdict
-
-# We use functions instead of methods so that they can be cdef'd in
-# local.pxd; if they were cdef'd as methods, they would cause
-# the creation of a pointer and a vtable. This happens
-# even if we declare the class @cython.final. functions thus save memory overhead
-# (but not pointer chasing overhead; the vtable isn't used when we declare
-# the class final).
-
-
-def _localimpl_create_dict(self, greenlet, id_greenlet):
- """Create a new dict for the current thread, and return it."""
- localdict = {}
- key = self.key
-
- wrdicts = ref(self.dicts)
-
- # When the greenlet is deleted, remove the local dict.
- # Note that this is suboptimal if the greenlet object gets
- # caught in a reference loop. We would like to be called
- # as soon as the OS-level greenlet ends instead.
-
- # If we are working with a gevent.greenlet.Greenlet, we
- # can pro-actively clear out with a link, avoiding the
- # issue described above. Use rawlink to avoid spawning any
- # more greenlets.
- greenlet_deleted = _greenlet_deleted(id_greenlet, wrdicts)
-
- rawlink = getattr(greenlet, 'rawlink', None)
- if rawlink is not None:
- rawlink(greenlet_deleted)
- wrthread = ref(greenlet)
- else:
- wrthread = ref(greenlet, greenlet_deleted)
-
-
- # When the localimpl is deleted, remove the thread attribute.
- local_deleted = _local_deleted(key, wrthread, greenlet_deleted)
-
-
- wrlocal = ref(self, local_deleted)
- greenlet.__dict__[key] = wrlocal
-
- self.dicts[id_greenlet] = _localimpl_dict_entry(wrthread, localdict)
- return localdict
-
-
-_marker = object()
-
-def _local_get_dict(self):
- impl = self._local__impl
- # Cython can optimize dict[], but not dict.get()
- greenlet = getcurrent() # pylint:disable=undefined-variable
- idg = id(greenlet)
- try:
- entry = impl.dicts[idg]
- dct = entry.localdict
- except KeyError:
- dct = _localimpl_create_dict(impl, greenlet, idg)
- self.__init__(*impl.localargs, **impl.localkwargs)
- return dct
-
-def _init():
- greenlet_init() # pylint:disable=undefined-variable
-
-_local_attrs = {
- '_local__impl',
- '_local_type_get_descriptors',
- '_local_type_set_or_del_descriptors',
- '_local_type_del_descriptors',
- '_local_type_set_descriptors',
- '_local_type',
- '_local_type_vars',
- '__class__',
- '__cinit__',
-}
-
-class local(object):
- """
- An object whose attributes are greenlet-local.
- """
- __slots__ = tuple(_local_attrs - {'__class__', '__cinit__'})
-
- def __cinit__(self, *args, **kw):
- if args or kw:
- if type(self).__init__ == object.__init__:
- raise TypeError("Initialization arguments are not supported", args, kw)
- impl = _localimpl(args, kw, type(self), id(self))
- # pylint:disable=attribute-defined-outside-init
- self._local__impl = impl
- get, dels, sets_or_dels, sets = _local_find_descriptors(self)
- self._local_type_get_descriptors = get
- self._local_type_set_or_del_descriptors = sets_or_dels
- self._local_type_del_descriptors = dels
- self._local_type_set_descriptors = sets
- self._local_type = type(self)
- self._local_type_vars = set(dir(self._local_type))
-
- def __getattribute__(self, name): # pylint:disable=too-many-return-statements
- if name in _local_attrs:
- # The _local__impl, __cinit__, etc, won't be hit by the
- # Cython version, if we've done things right. If we haven't,
- # they will be, and this will produce an error.
- return object.__getattribute__(self, name)
-
- dct = _local_get_dict(self)
-
- if name == '__dict__':
- return dct
- # If there's no possible way we can switch, because this
- # attribute is *not* found in the class where it might be a
- # data descriptor (property), and it *is* in the dict
- # then we don't need to swizzle the dict and take the lock.
-
- # We don't have to worry about people overriding __getattribute__
- # because if they did, the dict-swizzling would only last as
- # long as we were in here anyway.
- # Similarly, a __getattr__ will still be called by _oga() if needed
- # if it's not in the dict.
-
- # Optimization: If we're not subclassed, then
- # there can be no descriptors except for methods, which will
- # never need to use __dict__.
- if self._local_type is local:
- return dct[name] if name in dct else object.__getattribute__(self, name)
-
- # NOTE: If this is a descriptor, this will invoke its __get__.
- # A broken descriptor that doesn't return itself when called with
- # a None for the instance argument could mess us up here.
- # But this is faster than a loop over mro() checking each class __dict__
- # manually.
- if name in dct:
- if name not in self._local_type_vars:
- # If there is a dict value, and nothing in the type,
- # it can't possibly be a descriptor, so it is just returned.
- return dct[name]
-
- # It's in the type *and* in the dict. If the type value is
- # a data descriptor (defines __get__ *and* either __set__ or
- # __delete__), then the type wins. If it's a non-data descriptor
- # (defines just __get__), then the instance wins. If it's not a
- # descriptor at all (doesn't have __get__), the instance wins.
- # NOTE that the docs for descriptors say that these methods must be
- # defined on the *class* of the object in the type.
- if name not in self._local_type_get_descriptors:
- # Entirely not a descriptor. Instance wins.
- return dct[name]
- if name in self._local_type_set_or_del_descriptors:
- # A data descriptor.
- # arbitrary code execution while these run. If they touch self again,
- # they'll call back into us and we'll repeat the dance.
- type_attr = getattr(self._local_type, name)
- return type(type_attr).__get__(type_attr, self, self._local_type)
- # Last case is a non-data descriptor. Instance wins.
- return dct[name]
-
- if name in self._local_type_vars:
- # Not in the dictionary, but is found in the type. It could be
- # a non-data descriptor still. Some descriptors, like @staticmethod,
- # return objects (functions, in this case), that are *themselves*
- # descriptors, which when invoked, again, would do the wrong thing.
- # So we can't rely on getattr() on the type for them, we have to
- # look through the MRO dicts ourself.
- if name not in self._local_type_get_descriptors:
- # Not a descriptor, can't execute code. So all we need is
- # the return value of getattr() on our type.
- return getattr(self._local_type, name)
-
- for base in self._local_type.mro():
- bd = base.__dict__
- if name in bd:
- attr_on_type = bd[name]
- result = type(attr_on_type).__get__(attr_on_type, self, self._local_type)
- return result
-
- # It wasn't in the dict and it wasn't in the type.
- # So the next step is to invoke type(self)__getattr__, if it
- # exists, otherwise raise an AttributeError.
- # we will invoke type(self).__getattr__ or raise an attribute error.
- if hasattr(self._local_type, '__getattr__'):
- return self._local_type.__getattr__(self, name)
- raise AttributeError("%r object has no attribute '%s'"
- % (self._local_type.__name__, name))
-
- def __setattr__(self, name, value):
- if name == '__dict__':
- raise AttributeError(
- "%r object attribute '__dict__' is read-only"
- % type(self))
-
- if name in _local_attrs:
- object.__setattr__(self, name, value)
- return
-
- dct = _local_get_dict(self)
-
- if self._local_type is local:
- # Optimization: If we're not subclassed, we can't
- # have data descriptors, so this goes right in the dict.
- dct[name] = value
- return
-
- if name in self._local_type_vars:
- if name in self._local_type_set_descriptors:
- type_attr = getattr(self._local_type, name, _marker)
- # A data descriptor, like a property or a slot.
- type(type_attr).__set__(type_attr, self, value)
- return
- # Otherwise it goes directly in the dict
- dct[name] = value
-
- def __delattr__(self, name):
- if name == '__dict__':
- raise AttributeError(
- "%r object attribute '__dict__' is read-only"
- % self.__class__.__name__)
-
- if name in self._local_type_vars:
- if name in self._local_type_del_descriptors:
- # A data descriptor, like a property or a slot.
- type_attr = getattr(self._local_type, name, _marker)
- type(type_attr).__delete__(type_attr, self)
- return
- # Otherwise it goes directly in the dict
-
- # Begin inlined function _get_dict()
- dct = _local_get_dict(self)
-
- try:
- del dct[name]
- except KeyError:
- raise AttributeError(name)
-
- def __copy__(self):
- impl = self._local__impl
- entry = impl.dicts[id(getcurrent())] # pylint:disable=undefined-variable
-
- dct = entry.localdict
- duplicate = copy(dct)
-
- cls = type(self)
- instance = cls(*impl.localargs, **impl.localkwargs)
- _local__copy_dict_from(instance, impl, duplicate)
- return instance
-
-def _local__copy_dict_from(self, impl, duplicate):
- current = getcurrent() # pylint:disable=undefined-variable
- currentId = id(current)
- new_impl = self._local__impl
- assert new_impl is not impl
- entry = new_impl.dicts[currentId]
- new_impl.dicts[currentId] = _localimpl_dict_entry(entry.wrgreenlet, duplicate)
-
-def _local_find_descriptors(self):
- type_self = type(self)
- gets = set()
- dels = set()
- set_or_del = set()
- sets = set()
- mro = list(type_self.mro())
-
- for attr_name in dir(type_self):
- # Conventionally, descriptors when called on a class
- # return themself, but not all do. Notable exceptions are
- # in the zope.interface package, where things like __provides__
- # return other class attributes. So we can't use getattr, and instead
- # walk up the dicts
- for base in mro:
- bd = base.__dict__
- if attr_name in bd:
- attr = bd[attr_name]
- break
- else:
- raise AttributeError(attr_name)
-
- type_attr = type(attr)
- if hasattr(type_attr, '__get__'):
- gets.add(attr_name)
- if hasattr(type_attr, '__delete__'):
- dels.add(attr_name)
- set_or_del.add(attr_name)
- if hasattr(type_attr, '__set__'):
- sets.add(attr_name)
-
- return (gets, dels, set_or_del, sets)
-
-# Cython doesn't let us use __new__, it requires
-# __cinit__. But we need __new__ if we're not compiled
-# (e.g., on PyPy). So we set it at runtime. Cython
-# will raise an error if we're compiled.
-def __new__(cls, *args, **kw):
- self = super(local, cls).__new__(cls)
- # We get the cls in *args for some reason
- # too when we do it this way....except on PyPy3, which does
- # not *unless* it's wrapped in a classmethod (which it is)
- self.__cinit__(*args[1:], **kw)
- return self
-
-try:
- # PyPy2/3 and CPython handle adding a __new__ to the class
- # in different ways. In CPython and PyPy3, it must be wrapped with classmethod;
- # in PyPy2, it must not. In either case, the args that get passed to
- # it are stil wrong.
- local.__new__ = 'None'
-except TypeError: # pragma: no cover
- # Must be compiled
- pass
-else:
- from gevent._compat import PYPY
- from gevent._compat import PY2
- if PYPY and PY2:
- local.__new__ = __new__
- else:
- local.__new__ = classmethod(__new__)
-
- del PYPY
- del PY2
-
-_init()
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent._local')
diff --git a/python/gevent/lock.py b/python/gevent/lock.py
deleted file mode 100644
index 00bf68c..0000000
--- a/python/gevent/lock.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-"""Locking primitives"""
-from __future__ import absolute_import
-
-from gevent.hub import getcurrent
-from gevent._compat import PYPY
-from gevent._semaphore import Semaphore, BoundedSemaphore # pylint:disable=no-name-in-module,import-error
-
-
-__all__ = [
- 'Semaphore',
- 'DummySemaphore',
- 'BoundedSemaphore',
- 'RLock',
-]
-
-# On PyPy, we don't compile the Semaphore class with Cython. Under
-# Cython, each individual method holds the GIL for its entire
-# duration, ensuring that no other thread can interrupt us in an
-# unsafe state (only when we _do_wait do we call back into Python and
-# allow switching threads). Simulate that here through the use of a manual
-# lock. (We use a separate lock for each semaphore to allow sys.settrace functions
-# to use locks *other* than the one being traced.)
-if PYPY:
- # TODO: Need to use monkey.get_original?
- try:
- from _thread import allocate_lock as _allocate_lock # pylint:disable=import-error,useless-suppression
- from _thread import get_ident as _get_ident # pylint:disable=import-error,useless-suppression
- except ImportError:
- # Python 2
- from thread import allocate_lock as _allocate_lock # pylint:disable=import-error,useless-suppression
- from thread import get_ident as _get_ident # pylint:disable=import-error,useless-suppression
- _sem_lock = _allocate_lock()
-
- def untraceable(f):
- # Don't allow re-entry to these functions in a single thread, as can
- # happen if a sys.settrace is used
- def wrapper(self):
- me = _get_ident()
- try:
- count = self._locking[me]
- except KeyError:
- count = self._locking[me] = 1
- else:
- count = self._locking[me] = count + 1
- if count:
- return
-
- try:
- return f(self)
- finally:
- count = count - 1
- if not count:
- del self._locking[me]
- else:
- self._locking[me] = count
- return wrapper
-
- class _OwnedLock(object):
-
- def __init__(self):
- self._owner = None
- self._block = _allocate_lock()
- self._locking = {}
- self._count = 0
-
- @untraceable
- def acquire(self):
- me = _get_ident()
- if self._owner == me:
- self._count += 1
- return
-
- self._owner = me
- self._block.acquire()
- self._count = 1
-
- @untraceable
- def release(self):
- self._count = count = self._count - 1
- if not count:
- self._block.release()
- self._owner = None
-
- # acquire, wait, and release all acquire the lock on entry and release it
- # on exit. acquire and wait can call _do_wait, which must release it on entry
- # and re-acquire it for them on exit.
- class _around(object):
- __slots__ = ('before', 'after')
-
- def __init__(self, before, after):
- self.before = before
- self.after = after
-
- def __enter__(self):
- self.before()
-
- def __exit__(self, t, v, tb):
- self.after()
-
- def _decorate(func, cmname):
- # functools.wrap?
- def wrapped(self, *args, **kwargs):
- with getattr(self, cmname):
- return func(self, *args, **kwargs)
- return wrapped
-
- Semaphore._py3k_acquire = Semaphore.acquire = _decorate(Semaphore.acquire, '_lock_locked')
- Semaphore.release = _decorate(Semaphore.release, '_lock_locked')
- Semaphore.wait = _decorate(Semaphore.wait, '_lock_locked')
- Semaphore._do_wait = _decorate(Semaphore._do_wait, '_lock_unlocked')
-
- _Sem_init = Semaphore.__init__
-
- def __init__(self, *args, **kwargs):
- l = self._lock_lock = _OwnedLock()
- self._lock_locked = _around(l.acquire, l.release)
- self._lock_unlocked = _around(l.release, l.acquire)
-
- _Sem_init(self, *args, **kwargs)
-
- Semaphore.__init__ = __init__
-
- del _decorate
- del untraceable
-
-
-class DummySemaphore(object):
- """
- DummySemaphore(value=None) -> DummySemaphore
-
- A Semaphore initialized with "infinite" initial value. None of its
- methods ever block.
-
- This can be used to parameterize on whether or not to actually
- guard access to a potentially limited resource. If the resource is
- actually limited, such as a fixed-size thread pool, use a real
- :class:`Semaphore`, but if the resource is unbounded, use an
- instance of this class. In that way none of the supporting code
- needs to change.
-
- Similarly, it can be used to parameterize on whether or not to
- enforce mutual exclusion to some underlying object. If the
- underlying object is known to be thread-safe itself mutual
- exclusion is not needed and a ``DummySemaphore`` can be used, but
- if that's not true, use a real ``Semaphore``.
- """
-
- # Internally this is used for exactly the purpose described in the
- # documentation. gevent.pool.Pool uses it instead of a Semaphore
- # when the pool size is unlimited, and
- # gevent.fileobject.FileObjectThread takes a parameter that
- # determines whether it should lock around IO to the underlying
- # file object.
-
- def __init__(self, value=None):
- """
- .. versionchanged:: 1.1rc3
- Accept and ignore a *value* argument for compatibility with Semaphore.
- """
- pass
-
- def __str__(self):
- return '<%s>' % self.__class__.__name__
-
- def locked(self):
- """A DummySemaphore is never locked so this always returns False."""
- return False
-
- def release(self):
- """Releasing a dummy semaphore does nothing."""
- pass
-
- def rawlink(self, callback):
- # XXX should still work and notify?
- pass
-
- def unlink(self, callback):
- pass
-
- def wait(self, timeout=None):
- """Waiting for a DummySemaphore returns immediately."""
- pass
-
- def acquire(self, blocking=True, timeout=None):
- """
- A DummySemaphore can always be acquired immediately so this always
- returns True and ignores its arguments.
-
- .. versionchanged:: 1.1a1
- Always return *true*.
- """
- # pylint:disable=unused-argument
- return True
-
- def __enter__(self):
- pass
-
- def __exit__(self, typ, val, tb):
- pass
-
-
-class RLock(object):
- """
- A mutex that can be acquired more than once by the same greenlet.
- """
-
- def __init__(self):
- self._block = Semaphore(1)
- self._owner = None
- self._count = 0
-
- def __repr__(self):
- return "<%s at 0x%x _block=%s _count=%r _owner=%r)>" % (
- self.__class__.__name__,
- id(self),
- self._block,
- self._count,
- self._owner)
-
- def acquire(self, blocking=1):
- me = getcurrent()
- if self._owner is me:
- self._count = self._count + 1
- return 1
- rc = self._block.acquire(blocking)
- if rc:
- self._owner = me
- self._count = 1
- return rc
-
- def __enter__(self):
- return self.acquire()
-
- def release(self):
- if self._owner is not getcurrent():
- raise RuntimeError("cannot release un-acquired lock")
- self._count = count = self._count - 1
- if not count:
- self._owner = None
- self._block.release()
-
- def __exit__(self, typ, value, tb):
- self.release()
-
- # Internal methods used by condition variables
-
- def _acquire_restore(self, count_owner):
- count, owner = count_owner
- self._block.acquire()
- self._count = count
- self._owner = owner
-
- def _release_save(self):
- count = self._count
- self._count = 0
- owner = self._owner
- self._owner = None
- self._block.release()
- return (count, owner)
-
- def _is_owned(self):
- return self._owner is getcurrent()
diff --git a/python/gevent/monkey.py b/python/gevent/monkey.py
deleted file mode 100644
index 6c1fa00..0000000
--- a/python/gevent/monkey.py
+++ /dev/null
@@ -1,1079 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-# pylint: disable=redefined-outer-name
-"""
-Make the standard library cooperative.
-
-The primary purpose of this module is to carefully patch, in place,
-portions of the standard library with gevent-friendly functions that
-behave in the same way as the original (at least as closely as possible).
-
-The primary interface to this is the :func:`patch_all` function, which
-performs all the available patches. It accepts arguments to limit the
-patching to certain modules, but most programs **should** use the
-default values as they receive the most wide-spread testing, and some monkey
-patches have dependencies on others.
-
-Patching **should be done as early as possible** in the lifecycle of the
-program. For example, the main module (the one that tests against
-``__main__`` or is otherwise the first imported) should begin with
-this code, ideally before any other imports::
-
- from gevent import monkey
- monkey.patch_all()
-
-A corollary of the above is that patching **should be done on the main
-thread** and **should be done while the program is single-threaded**.
-
-.. tip::
-
- Some frameworks, such as gunicorn, handle monkey-patching for you.
- Check their documentation to be sure.
-
-.. warning::
-
- Patching too late can lead to unreliable behaviour (for example, some
- modules may still use blocking sockets) or even errors.
-
-Querying
-========
-
-Sometimes it is helpful to know if objects have been monkey-patched, and in
-advanced cases even to have access to the original standard library functions. This
-module provides functions for that purpose.
-
-- :func:`is_module_patched`
-- :func:`is_object_patched`
-- :func:`get_original`
-
-Plugins
-=======
-
-Beginning in gevent 1.3, events are emitted during the monkey patching process.
-These events are delivered first to :mod:`gevent.events` subscribers, and then
-to `setuptools entry points`_.
-
-The following events are defined. They are listed in (roughly) the order
-that a call to :func:`patch_all` will emit them.
-
-- :class:`gevent.events.GeventWillPatchAllEvent`
-- :class:`gevent.events.GeventWillPatchModuleEvent`
-- :class:`gevent.events.GeventDidPatchModuleEvent`
-- :class:`gevent.events.GeventDidPatchBuiltinModulesEvent`
-- :class:`gevent.events.GeventDidPatchAllEvent`
-
-Each event class documents the corresponding setuptools entry point name. The
-entry points will be called with a single argument, the same instance of
-the class that was sent to the subscribers.
-
-You can subscribe to the events to monitor the monkey-patching process and
-to manipulate it, for example by raising :exc:`gevent.events.DoNotPatch`.
-
-You can also subscribe to the events to provide additional patching beyond what
-gevent distributes, either for additional standard library modules, or
-for third-party packages. The suggested time to do this patching is in
-the subscriber for :class:`gevent.events.GeventDidPatchBuiltinModulesEvent`.
-For example, to automatically patch `psycopg2`_ using `psycogreen`_
-when the call to :func:`patch_all` is made, you could write code like this::
-
- # mypackage.py
- def patch_psycopg(event):
- from psycogreen.gevent import patch_psycopg
- patch_psycopg()
-
-In your ``setup.py`` you would register it like this::
-
- from setuptools import setup
- setup(
- ...
- entry_points={
- 'gevent.plugins.monkey.did_patch_builtins': [
- 'psycopg2 = mypackage:patch_psycopg',
- ],
- },
- ...
- )
-
-For more complex patching, gevent provides a helper method
-that you can call to replace attributes of modules with attributes of your
-own modules. This function also takes care of emitting the appropriate events.
-
-- :func:`patch_module`
-
-.. _setuptools entry points: http://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins
-.. _psycopg2: https://pypi.python.org/pypi/psycopg2
-.. _psycogreen: https://pypi.python.org/pypi/psycogreen
-
-Use as a module
-===============
-
-Sometimes it is useful to run existing python scripts or modules that
-were not built to be gevent aware under gevent. To do so, this module
-can be run as the main module, passing the script and its arguments.
-For details, see the :func:`main` function.
-
-.. versionchanged:: 1.3b1
- Added support for plugins and began emitting will/did patch events.
-"""
-from __future__ import absolute_import
-from __future__ import print_function
-import sys
-
-__all__ = [
- 'patch_all',
- 'patch_builtins',
- 'patch_dns',
- 'patch_os',
- 'patch_queue',
- 'patch_select',
- 'patch_signal',
- 'patch_socket',
- 'patch_ssl',
- 'patch_subprocess',
- 'patch_sys',
- 'patch_thread',
- 'patch_time',
- # query functions
- 'get_original',
- 'is_module_patched',
- 'is_object_patched',
- # plugin API
- 'patch_module',
- # module functions
- 'main',
-]
-
-
-if sys.version_info[0] >= 3:
- string_types = (str,)
- PY3 = True
-else:
- import __builtin__ # pylint:disable=import-error
- string_types = (__builtin__.basestring,)
- PY3 = False
-
-WIN = sys.platform.startswith("win")
-
-class MonkeyPatchWarning(RuntimeWarning):
- """
- The type of warnings we issue.
-
- .. versionadded:: 1.3a2
- """
-
-def _notify_patch(event, _warnings=None):
- # Raises DoNotPatch if we're not supposed to patch
- from gevent.events import notify_and_call_entry_points
-
- event._warnings = _warnings
- notify_and_call_entry_points(event)
-
-def _ignores_DoNotPatch(func):
-
- from functools import wraps
-
- @wraps(func)
- def ignores(*args, **kwargs):
- from gevent.events import DoNotPatch
- try:
- return func(*args, **kwargs)
- except DoNotPatch:
- return False
-
- return ignores
-
-
-# maps module name -> {attribute name: original item}
-# e.g. "time" -> {"sleep": built-in function sleep}
-saved = {}
-
-
-def is_module_patched(mod_name):
- """
- Check if a module has been replaced with a cooperative version.
-
- :param str mod_name: The name of the standard library module,
- e.g., ``'socket'``.
-
- """
- return mod_name in saved
-
-
-def is_object_patched(mod_name, item_name):
- """
- Check if an object in a module has been replaced with a
- cooperative version.
-
- :param str mod_name: The name of the standard library module,
- e.g., ``'socket'``.
- :param str item_name: The name of the attribute in the module,
- e.g., ``'create_connection'``.
-
- """
- return is_module_patched(mod_name) and item_name in saved[mod_name]
-
-
-def _get_original(name, items):
- d = saved.get(name, {})
- values = []
- module = None
- for item in items:
- if item in d:
- values.append(d[item])
- else:
- if module is None:
- module = __import__(name)
- values.append(getattr(module, item))
- return values
-
-
-def get_original(mod_name, item_name):
- """
- Retrieve the original object from a module.
-
- If the object has not been patched, then that object will still be
- retrieved.
-
- :param str mod_name: The name of the standard library module,
- e.g., ``'socket'``.
- :param item_name: A string or sequence of strings naming the
- attribute(s) on the module ``mod_name`` to return.
-
- :return: The original value if a string was given for
- ``item_name`` or a sequence of original values if a
- sequence was passed.
- """
- if isinstance(item_name, string_types):
- return _get_original(mod_name, [item_name])[0]
- return _get_original(mod_name, item_name)
-
-
-_NONE = object()
-
-
-def patch_item(module, attr, newitem):
- olditem = getattr(module, attr, _NONE)
- if olditem is not _NONE:
- saved.setdefault(module.__name__, {}).setdefault(attr, olditem)
- setattr(module, attr, newitem)
-
-
-def remove_item(module, attr):
- olditem = getattr(module, attr, _NONE)
- if olditem is _NONE:
- return
- saved.setdefault(module.__name__, {}).setdefault(attr, olditem)
- delattr(module, attr)
-
-
-def __call_module_hook(gevent_module, name, module, items, _warnings):
- # This function can raise DoNotPatch on 'will'
-
- def warn(message):
- _queue_warning(message, _warnings)
-
- func_name = '_gevent_' + name + '_monkey_patch'
- try:
- func = getattr(gevent_module, func_name)
- except AttributeError:
- func = lambda *args: None
-
-
- func(module, items, warn)
-
-
-def patch_module(target_module, source_module, items=None,
- _warnings=None,
- _notify_did_subscribers=True):
- """
- patch_module(target_module, source_module, items=None)
-
- Replace attributes in *target_module* with the attributes of the
- same name in *source_module*.
-
- The *source_module* can provide some attributes to customize the process:
-
- * ``__implements__`` is a list of attribute names to copy; if not present,
- the *items* keyword argument is mandatory.
- * ``_gevent_will_monkey_patch(target_module, items, warn, **kwargs)``
- * ``_gevent_did_monkey_patch(target_module, items, warn, **kwargs)``
- These two functions in the *source_module* are called *if* they exist,
- before and after copying attributes, respectively. The "will" function
- may modify *items*. The value of *warn* is a function that should be called
- with a single string argument to issue a warning to the user. If the "will"
- function raises :exc:`gevent.events.DoNotPatch`, no patching will be done. These functions
- are called before any event subscribers or plugins.
-
- :keyword list items: A list of attribute names to replace. If
- not given, this will be taken from the *source_module* ``__implements__``
- attribute.
- :return: A true value if patching was done, a false value if patching was canceled.
-
- .. versionadded:: 1.3b1
- """
- from gevent import events
-
- if items is None:
- items = getattr(source_module, '__implements__', None)
- if items is None:
- raise AttributeError('%r does not have __implements__' % source_module)
-
- try:
- __call_module_hook(source_module, 'will', target_module, items, _warnings)
- _notify_patch(
- events.GeventWillPatchModuleEvent(target_module.__name__, source_module,
- target_module, items),
- _warnings)
- except events.DoNotPatch:
- return False
-
- for attr in items:
- patch_item(target_module, attr, getattr(source_module, attr))
-
- __call_module_hook(source_module, 'did', target_module, items, _warnings)
-
- if _notify_did_subscribers:
- # We allow turning off the broadcast of the 'did' event for the benefit
- # of our internal functions which need to do additional work (besides copying
- # attributes) before their patch can be considered complete.
- _notify_patch(
- events.GeventDidPatchModuleEvent(target_module.__name__, source_module,
- target_module)
- )
-
- return True
-
-def _patch_module(name, items=None, _warnings=None, _notify_did_subscribers=True):
-
- gevent_module = getattr(__import__('gevent.' + name), name)
- module_name = getattr(gevent_module, '__target__', name)
- target_module = __import__(module_name)
-
- patch_module(target_module, gevent_module, items=items,
- _warnings=_warnings,
- _notify_did_subscribers=_notify_did_subscribers)
-
- return gevent_module, target_module
-
-
-def _queue_warning(message, _warnings):
- # Queues a warning to show after the monkey-patching process is all done.
- # Done this way to avoid extra imports during the process itself, just
- # in case. If we're calling a function one-off (unusual) go ahead and do it
- if _warnings is None:
- _process_warnings([message])
- else:
- _warnings.append(message)
-
-
-def _process_warnings(_warnings):
- import warnings
- for warning in _warnings:
- warnings.warn(warning, MonkeyPatchWarning, stacklevel=3)
-
-
-def _patch_sys_std(name):
- from gevent.fileobject import FileObjectThread
- orig = getattr(sys, name)
- if not isinstance(orig, FileObjectThread):
- patch_item(sys, name, FileObjectThread(orig))
-
-@_ignores_DoNotPatch
-def patch_sys(stdin=True, stdout=True, stderr=True):
- """
- Patch sys.std[in,out,err] to use a cooperative IO via a
- threadpool.
-
- This is relatively dangerous and can have unintended consequences
- such as hanging the process or `misinterpreting control keys`_
- when :func:`input` and :func:`raw_input` are used. :func:`patch_all`
- does *not* call this function by default.
-
- This method does nothing on Python 3. The Python 3 interpreter
- wants to flush the TextIOWrapper objects that make up
- stderr/stdout at shutdown time, but using a threadpool at that
- time leads to a hang.
-
- .. _`misinterpreting control keys`: https://github.com/gevent/gevent/issues/274
- """
- # test__issue6.py demonstrates the hang if these lines are removed;
- # strangely enough that test passes even without monkey-patching sys
- if PY3:
- items = None
- else:
- items = set([('stdin' if stdin else None),
- ('stdout' if stdout else None),
- ('stderr' if stderr else None)])
- items.discard(None)
- items = list(items)
-
- if not items:
- return
-
- from gevent import events
- _notify_patch(events.GeventWillPatchModuleEvent('sys', None, sys,
- items))
-
- for item in items:
- _patch_sys_std(item)
-
- _notify_patch(events.GeventDidPatchModuleEvent('sys', None, sys))
-
-@_ignores_DoNotPatch
-def patch_os():
- """
- Replace :func:`os.fork` with :func:`gevent.fork`, and, on POSIX,
- :func:`os.waitpid` with :func:`gevent.os.waitpid` (if the
- environment variable ``GEVENT_NOWAITPID`` is not defined). Does
- nothing if fork is not available.
-
- .. caution:: This method must be used with :func:`patch_signal` to have proper `SIGCHLD`
- handling and thus correct results from ``waitpid``.
- :func:`patch_all` calls both by default.
-
- .. caution:: For `SIGCHLD` handling to work correctly, the event loop must run.
- The easiest way to help ensure this is to use :func:`patch_all`.
- """
- _patch_module('os')
-
-
-@_ignores_DoNotPatch
-def patch_queue():
- """
- On Python 3.7 and above, replace :class:`queue.SimpleQueue` (implemented
- in C) with its Python counterpart.
-
- .. versionadded:: 1.3.5
- """
-
- import gevent.queue
- if 'SimpleQueue' in gevent.queue.__all__:
- _patch_module('queue', items=['SimpleQueue'])
-
-
-@_ignores_DoNotPatch
-def patch_time():
- """
- Replace :func:`time.sleep` with :func:`gevent.sleep`.
- """
- _patch_module('time')
-
-
-def _patch_existing_locks(threading):
- if len(list(threading.enumerate())) != 1:
- return
- try:
- tid = threading.get_ident()
- except AttributeError:
- tid = threading._get_ident()
- rlock_type = type(threading.RLock())
- try:
- import importlib._bootstrap
- except ImportError:
- class _ModuleLock(object):
- pass
- else:
- _ModuleLock = importlib._bootstrap._ModuleLock # python 2 pylint: disable=no-member
- # It might be possible to walk up all the existing stack frames to find
- # locked objects...at least if they use `with`. To be sure, we look at every object
- # Since we're supposed to be done very early in the process, there shouldn't be
- # too many.
-
- # By definition there's only one thread running, so the various
- # owner attributes were the old (native) thread id. Make it our
- # current greenlet id so that when it wants to unlock and compare
- # self.__owner with _get_ident(), they match.
- gc = __import__('gc')
- for o in gc.get_objects():
- if isinstance(o, rlock_type):
- if hasattr(o, '_owner'): # Py3
- if o._owner is not None:
- o._owner = tid
- else:
- if o._RLock__owner is not None:
- o._RLock__owner = tid
- elif isinstance(o, _ModuleLock):
- if o.owner is not None:
- o.owner = tid
-
-@_ignores_DoNotPatch
-def patch_thread(threading=True, _threading_local=True, Event=True, logging=True,
- existing_locks=True,
- _warnings=None):
- """
- patch_thread(threading=True, _threading_local=True, Event=True, logging=True, existing_locks=True) -> None
-
- Replace the standard :mod:`thread` module to make it greenlet-based.
-
- :keyword bool threading: When True (the default),
- also patch :mod:`threading`.
- :keyword bool _threading_local: When True (the default),
- also patch :class:`_threading_local.local`.
- :keyword bool logging: When True (the default), also patch locks
- taken if the logging module has been configured.
-
- :keyword bool existing_locks: When True (the default), and the
- process is still single threaded, make sure that any
- :class:`threading.RLock` (and, under Python 3, :class:`importlib._bootstrap._ModuleLock`)
- instances that are currently locked can be properly unlocked.
-
- .. caution::
- Monkey-patching :mod:`thread` and using
- :class:`multiprocessing.Queue` or
- :class:`concurrent.futures.ProcessPoolExecutor` (which uses a
- ``Queue``) will hang the process.
-
- .. versionchanged:: 1.1b1
- Add *logging* and *existing_locks* params.
- .. versionchanged:: 1.3a2
- ``Event`` defaults to True.
- """
- # XXX: Simplify
- # pylint:disable=too-many-branches,too-many-locals,too-many-statements
-
- # Description of the hang:
- # There is an incompatibility with patching 'thread' and the 'multiprocessing' module:
- # The problem is that multiprocessing.queues.Queue uses a half-duplex multiprocessing.Pipe,
- # which is implemented with os.pipe() and _multiprocessing.Connection. os.pipe isn't patched
- # by gevent, as it returns just a fileno. _multiprocessing.Connection is an internal implementation
- # class implemented in C, which exposes a 'poll(timeout)' method; under the covers, this issues a
- # (blocking) select() call: hence the need for a real thread. Except for that method, we could
- # almost replace Connection with gevent.fileobject.SocketAdapter, plus a trivial
- # patch to os.pipe (below). Sigh, so close. (With a little work, we could replicate that method)
-
- # import os
- # import fcntl
- # os_pipe = os.pipe
- # def _pipe():
- # r, w = os_pipe()
- # fcntl.fcntl(r, fcntl.F_SETFL, os.O_NONBLOCK)
- # fcntl.fcntl(w, fcntl.F_SETFL, os.O_NONBLOCK)
- # return r, w
- # os.pipe = _pipe
-
- # The 'threading' module copies some attributes from the
- # thread module the first time it is imported. If we patch 'thread'
- # before that happens, then we store the wrong values in 'saved',
- # So if we're going to patch threading, we either need to import it
- # before we patch thread, or manually clean up the attributes that
- # are in trouble. The latter is tricky because of the different names
- # on different versions.
- if threading:
- threading_mod = __import__('threading')
- # Capture the *real* current thread object before
- # we start returning DummyThread objects, for comparison
- # to the main thread.
- orig_current_thread = threading_mod.current_thread()
- else:
- threading_mod = None
- gevent_threading_mod = None
- orig_current_thread = None
-
- gevent_thread_mod, thread_mod = _patch_module('thread',
- _warnings=_warnings, _notify_did_subscribers=False)
-
- if threading:
- gevent_threading_mod, _ = _patch_module('threading',
- _warnings=_warnings, _notify_did_subscribers=False)
-
- if Event:
- from gevent.event import Event
- patch_item(threading_mod, 'Event', Event)
- # Python 2 had `Event` as a function returning
- # the private class `_Event`. Some code may be relying
- # on that.
- if hasattr(threading_mod, '_Event'):
- patch_item(threading_mod, '_Event', Event)
-
- if existing_locks:
- _patch_existing_locks(threading_mod)
-
- if logging and 'logging' in sys.modules:
- logging = __import__('logging')
- patch_item(logging, '_lock', threading_mod.RLock())
- for wr in logging._handlerList:
- # In py26, these are actual handlers, not weakrefs
- handler = wr() if callable(wr) else wr
- if handler is None:
- continue
- if not hasattr(handler, 'lock'):
- raise TypeError("Unknown/unsupported handler %r" % handler)
- handler.lock = threading_mod.RLock()
-
- if _threading_local:
- _threading_local = __import__('_threading_local')
- from gevent.local import local
- patch_item(_threading_local, 'local', local)
-
- def make_join_func(thread, thread_greenlet):
- from gevent.hub import sleep
- from time import time
-
- def join(timeout=None):
- end = None
- if threading_mod.current_thread() is thread:
- raise RuntimeError("Cannot join current thread")
- if thread_greenlet is not None and thread_greenlet.dead:
- return
- if not thread.is_alive():
- return
-
- if timeout:
- end = time() + timeout
-
- while thread.is_alive():
- if end is not None and time() > end:
- return
- sleep(0.01)
- return join
-
- if threading:
- from gevent.threading import main_native_thread
-
- for thread in threading_mod._active.values():
- if thread == main_native_thread():
- continue
- thread.join = make_join_func(thread, None)
-
- if sys.version_info[:2] >= (3, 4):
-
- # Issue 18808 changes the nature of Thread.join() to use
- # locks. This means that a greenlet spawned in the main thread
- # (which is already running) cannot wait for the main thread---it
- # hangs forever. We patch around this if possible. See also
- # gevent.threading.
- greenlet = __import__('greenlet')
-
- if orig_current_thread == threading_mod.main_thread():
- main_thread = threading_mod.main_thread()
- _greenlet = main_thread._greenlet = greenlet.getcurrent()
-
- main_thread.join = make_join_func(main_thread, _greenlet)
-
- # Patch up the ident of the main thread to match. This
- # matters if threading was imported before monkey-patching
- # thread
- oldid = main_thread.ident
- main_thread._ident = threading_mod.get_ident()
- if oldid in threading_mod._active:
- threading_mod._active[main_thread.ident] = threading_mod._active[oldid]
- if oldid != main_thread.ident:
- del threading_mod._active[oldid]
- else:
- _queue_warning("Monkey-patching not on the main thread; "
- "threading.main_thread().join() will hang from a greenlet",
- _warnings)
-
- from gevent import events
- _notify_patch(events.GeventDidPatchModuleEvent('thread', gevent_thread_mod, thread_mod))
- _notify_patch(events.GeventDidPatchModuleEvent('threading', gevent_threading_mod, threading_mod))
-
-@_ignores_DoNotPatch
-def patch_socket(dns=True, aggressive=True):
- """
- Replace the standard socket object with gevent's cooperative
- sockets.
-
- :keyword bool dns: When true (the default), also patch address
- resolution functions in :mod:`socket`. See :doc:`/dns` for details.
- """
- from gevent import socket
- # Note: although it seems like it's not strictly necessary to monkey patch 'create_connection',
- # it's better to do it. If 'create_connection' was not monkey patched, but the rest of socket module
- # was, create_connection would still use "green" getaddrinfo and "green" socket.
- # However, because gevent.socket.socket.connect is a Python function, the exception raised by it causes
- # _socket object to be referenced by the frame, thus causing the next invocation of bind(source_address) to fail.
- if dns:
- items = socket.__implements__ # pylint:disable=no-member
- else:
- items = set(socket.__implements__) - set(socket.__dns__) # pylint:disable=no-member
- _patch_module('socket', items=items)
- if aggressive:
- if 'ssl' not in socket.__implements__: # pylint:disable=no-member
- remove_item(socket, 'ssl')
-
-@_ignores_DoNotPatch
-def patch_dns():
- """
- Replace :doc:`DNS functions </dns>` in :mod:`socket` with
- cooperative versions.
-
- This is only useful if :func:`patch_socket` has been called and is
- done automatically by that method if requested.
- """
- from gevent import socket
- _patch_module('socket', items=socket.__dns__) # pylint:disable=no-member
-
-
-def _find_module_refs(to, excluding_names=()):
- # Looks specifically for module-level references,
- # i.e., 'from foo import Bar'. We define a module reference
- # as a dict (subclass) that also has a __name__ attribute.
- # This does not handle subclasses, but it does find them.
- # Returns two sets. The first is modules (name, file) that were
- # found. The second is subclasses that were found.
- gc = __import__('gc')
- direct_ref_modules = set()
- subclass_modules = set()
-
- def report(mod):
- return mod['__name__'], mod.get('__file__', '<unknown>')
-
- for r in gc.get_referrers(to):
- if isinstance(r, dict) and '__name__' in r:
- if r['__name__'] in excluding_names:
- continue
-
- for v in r.values():
- if v is to:
- direct_ref_modules.add(report(r))
- elif isinstance(r, type) and to in r.__bases__ and 'gevent.' not in r.__module__:
- subclass_modules.add(r)
-
- return direct_ref_modules, subclass_modules
-
-@_ignores_DoNotPatch
-def patch_ssl(_warnings=None, _first_time=True):
- """
- patch_ssl() -> None
-
- Replace :class:`ssl.SSLSocket` object and socket wrapping functions in
- :mod:`ssl` with cooperative versions.
-
- This is only useful if :func:`patch_socket` has been called.
- """
- may_need_warning = (
- _first_time
- and sys.version_info[:2] >= (3, 6)
- and 'ssl' in sys.modules
- and hasattr(sys.modules['ssl'], 'SSLContext'))
- # Previously, we didn't warn on Python 2 if pkg_resources has been imported
- # because that imports ssl and it's commonly used for namespace packages,
- # which typically means we're still in some early part of the import cycle.
- # However, with our new more discriminating check, that no longer seems to be a problem.
- # Prior to 3.6, we don't have the RecursionError problem, and prior to 3.7 we don't have the
- # SSLContext.sslsocket_class/SSLContext.sslobject_class problem.
-
- gevent_mod, _ = _patch_module('ssl', _warnings=_warnings)
- if may_need_warning:
- direct_ref_modules, subclass_modules = _find_module_refs(
- gevent_mod.orig_SSLContext,
- excluding_names=('ssl', 'gevent.ssl', 'gevent._ssl3', 'gevent._sslgte279'))
- if direct_ref_modules or subclass_modules:
- # Normally you don't want to have dynamic warning strings, because
- # the cache in the warning module is based on the string. But we
- # specifically only do this the first time we patch ourself, so it's
- # ok.
- direct_ref_mod_str = subclass_str = ''
- if direct_ref_modules:
- direct_ref_mod_str = 'Modules that had direct imports (NOT patched): %s. ' % ([
- "%s (%s)" % (name, fname)
- for name, fname in direct_ref_modules
- ])
- if subclass_modules:
- subclass_str = 'Subclasses (NOT patched): %s. ' % ([
- str(t) for t in subclass_modules
- ])
- _queue_warning(
- 'Monkey-patching ssl after ssl has already been imported '
- 'may lead to errors, including RecursionError on Python 3.6. '
- 'It may also silently lead to incorrect behaviour on Python 3.7. '
- 'Please monkey-patch earlier. '
- 'See https://github.com/gevent/gevent/issues/1016. '
- + direct_ref_mod_str + subclass_str,
- _warnings)
-
-
-@_ignores_DoNotPatch
-def patch_select(aggressive=True):
- """
- Replace :func:`select.select` with :func:`gevent.select.select`
- and :func:`select.poll` with :class:`gevent.select.poll` (where available).
-
- If ``aggressive`` is true (the default), also remove other
- blocking functions from :mod:`select` and (on Python 3.4 and
- above) :mod:`selectors`:
-
- - :func:`select.epoll`
- - :func:`select.kqueue`
- - :func:`select.kevent`
- - :func:`select.devpoll` (Python 3.5+)
- - :class:`selectors.EpollSelector`
- - :class:`selectors.KqueueSelector`
- - :class:`selectors.DevpollSelector` (Python 3.5+)
- """
-
- source_mod, target_mod = _patch_module('select', _notify_did_subscribers=False)
- if aggressive:
- select = target_mod
- # since these are blocking we're removing them here. This makes some other
- # modules (e.g. asyncore) non-blocking, as they use select that we provide
- # when none of these are available.
- remove_item(select, 'epoll')
- remove_item(select, 'kqueue')
- remove_item(select, 'kevent')
- remove_item(select, 'devpoll')
-
- if sys.version_info[:2] >= (3, 4):
- # Python 3 wants to use `select.select` as a member function,
- # leading to this error in selectors.py (because gevent.select.select is
- # not a builtin and doesn't get the magic auto-static that they do)
- # r, w, _ = self._select(self._readers, self._writers, [], timeout)
- # TypeError: select() takes from 3 to 4 positional arguments but 5 were given
- # Note that this obviously only happens if selectors was imported after we had patched
- # select; but there is a code path that leads to it being imported first (but now we've
- # patched select---so we can't compare them identically)
- select = target_mod # Should be gevent-patched now
- orig_select_select = get_original('select', 'select')
- assert select.select is not orig_select_select
- selectors = __import__('selectors')
- if selectors.SelectSelector._select in (select.select, orig_select_select):
- def _select(self, *args, **kwargs): # pylint:disable=unused-argument
- return select.select(*args, **kwargs)
- selectors.SelectSelector._select = _select
- _select._gevent_monkey = True
-
- # Python 3.7 refactors the poll-like selectors to use a common
- # base class and capture a reference to select.poll, etc, at
- # import time. selectors tends to get imported early
- # (importing 'platform' does it: platform -> subprocess -> selectors),
- # so we need to clean that up.
- if hasattr(selectors, 'PollSelector') and hasattr(selectors.PollSelector, '_selector_cls'):
- selectors.PollSelector._selector_cls = select.poll
-
- if aggressive:
- # If `selectors` had already been imported before we removed
- # select.epoll|kqueue|devpoll, these may have been defined in terms
- # of those functions. They'll fail at runtime.
- remove_item(selectors, 'EpollSelector')
- remove_item(selectors, 'KqueueSelector')
- remove_item(selectors, 'DevpollSelector')
- selectors.DefaultSelector = selectors.SelectSelector
-
- from gevent import events
- _notify_patch(events.GeventDidPatchModuleEvent('select', source_mod, target_mod))
-
-@_ignores_DoNotPatch
-def patch_subprocess():
- """
- Replace :func:`subprocess.call`, :func:`subprocess.check_call`,
- :func:`subprocess.check_output` and :class:`subprocess.Popen` with
- :mod:`cooperative versions <gevent.subprocess>`.
-
- .. note::
- On Windows under Python 3, the API support may not completely match
- the standard library.
-
- """
- _patch_module('subprocess')
-
-@_ignores_DoNotPatch
-def patch_builtins():
- """
- Make the builtin :func:`__import__` function `greenlet safe`_ under Python 2.
-
- .. note::
- This does nothing under Python 3 as it is not necessary. Python 3 features
- improved import locks that are per-module, not global.
-
- .. _greenlet safe: https://github.com/gevent/gevent/issues/108
-
- """
- if sys.version_info[:2] < (3, 3):
- _patch_module('builtins')
-
-@_ignores_DoNotPatch
-def patch_signal():
- """
- Make the :func:`signal.signal` function work with a :func:`monkey-patched os <patch_os>`.
-
- .. caution:: This method must be used with :func:`patch_os` to have proper ``SIGCHLD``
- handling. :func:`patch_all` calls both by default.
-
- .. caution:: For proper ``SIGCHLD`` handling, you must yield to the event loop.
- Using :func:`patch_all` is the easiest way to ensure this.
-
- .. seealso:: :mod:`gevent.signal`
- """
- _patch_module("signal")
-
-
-def _check_repatching(**module_settings):
- _warnings = []
- key = '_gevent_saved_patch_all'
- del module_settings['kwargs']
- if saved.get(key, module_settings) != module_settings:
- _queue_warning("Patching more than once will result in the union of all True"
- " parameters being patched",
- _warnings)
-
- first_time = key not in saved
- saved[key] = module_settings
- return _warnings, first_time, module_settings
-
-
-def _subscribe_signal_os(will_patch_all):
- if will_patch_all.will_patch_module('signal') and not will_patch_all.will_patch_module('os'):
- warnings = will_patch_all._warnings # Internal
- _queue_warning('Patching signal but not os will result in SIGCHLD handlers'
- ' installed after this not being called and os.waitpid may not'
- ' function correctly if gevent.subprocess is used. This may raise an'
- ' error in the future.',
- warnings)
-
-def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True,
- httplib=False, # Deprecated, to be removed.
- subprocess=True, sys=False, aggressive=True, Event=True,
- builtins=True, signal=True,
- queue=True,
- **kwargs):
- """
- Do all of the default monkey patching (calls every other applicable
- function in this module).
-
- :return: A true value if patching all modules wasn't cancelled, a false
- value if it was.
-
- .. versionchanged:: 1.1
- Issue a :mod:`warning <warnings>` if this function is called multiple times
- with different arguments. The second and subsequent calls will only add more
- patches, they can never remove existing patches by setting an argument to ``False``.
- .. versionchanged:: 1.1
- Issue a :mod:`warning <warnings>` if this function is called with ``os=False``
- and ``signal=True``. This will cause SIGCHLD handlers to not be called. This may
- be an error in the future.
- .. versionchanged:: 1.3a2
- ``Event`` defaults to True.
- .. versionchanged:: 1.3b1
- Defined the return values.
- .. versionchanged:: 1.3b1
- Add ``**kwargs`` for the benefit of event subscribers. CAUTION: gevent may add
- and interpret additional arguments in the future, so it is suggested to use prefixes
- for kwarg values to be interpreted by plugins, for example, `patch_all(mylib_futures=True)`.
- .. versionchanged:: 1.3.5
- Add *queue*, defaulting to True, for Python 3.7.
- """
- # pylint:disable=too-many-locals,too-many-branches
-
- # Check to see if they're changing the patched list
- _warnings, first_time, modules_to_patch = _check_repatching(**locals())
- if not _warnings and not first_time:
- # Nothing to do, identical args to what we just
- # did
- return
-
- from gevent import events
- try:
- _notify_patch(events.GeventWillPatchAllEvent(modules_to_patch, kwargs), _warnings)
- except events.DoNotPatch:
- return False
-
- # order is important
- if os:
- patch_os()
- if time:
- patch_time()
- if thread:
- patch_thread(Event=Event, _warnings=_warnings)
- # sys must be patched after thread. in other cases threading._shutdown will be
- # initiated to _MainThread with real thread ident
- if sys:
- patch_sys()
- if socket:
- patch_socket(dns=dns, aggressive=aggressive)
- if select:
- patch_select(aggressive=aggressive)
- if ssl:
- patch_ssl(_warnings=_warnings, _first_time=first_time)
- if httplib:
- raise ValueError('gevent.httplib is no longer provided, httplib must be False')
- if subprocess:
- patch_subprocess()
- if builtins:
- patch_builtins()
- if signal:
- patch_signal()
- if queue:
- patch_queue()
-
- _notify_patch(events.GeventDidPatchBuiltinModulesEvent(modules_to_patch, kwargs), _warnings)
- _notify_patch(events.GeventDidPatchAllEvent(modules_to_patch, kwargs), _warnings)
-
- _process_warnings(_warnings)
- return True
-
-
-def main():
- args = {}
- argv = sys.argv[1:]
- verbose = False
- script_help, patch_all_args, modules = _get_script_help()
- while argv and argv[0].startswith('--'):
- option = argv[0][2:]
- if option == 'verbose':
- verbose = True
- elif option.startswith('no-') and option.replace('no-', '') in patch_all_args:
- args[option[3:]] = False
- elif option in patch_all_args:
- args[option] = True
- if option in modules:
- for module in modules:
- args.setdefault(module, False)
- else:
- sys.exit(script_help + '\n\n' + 'Cannot patch %r' % option)
- del argv[0]
- # TODO: break on --
- if verbose:
- import pprint
- import os
- print('gevent.monkey.patch_all(%s)' % ', '.join('%s=%s' % item for item in args.items()))
- print('sys.version=%s' % (sys.version.strip().replace('\n', ' '), ))
- print('sys.path=%s' % pprint.pformat(sys.path))
- print('sys.modules=%s' % pprint.pformat(sorted(sys.modules.keys())))
- print('cwd=%s' % os.getcwd())
-
- patch_all(**args)
- if argv:
- sys.argv = argv
- import runpy
- # Use runpy.run_path to closely (exactly) match what the
- # interpreter does given 'python <path>'. This includes allowing
- # passing .pyc/.pyo files and packages with a __main__ and
- # potentially even zip files. Previously we used exec, which only
- # worked if we directly read a python source file.
- runpy.run_path(sys.argv[0],
- run_name='__main__')
- else:
- print(script_help)
-
-
-def _get_script_help():
- # pylint:disable=deprecated-method
- import inspect
- try:
- getter = inspect.getfullargspec # deprecated in 3.5, un-deprecated in 3.6
- except AttributeError:
- getter = inspect.getargspec
- patch_all_args = getter(patch_all)[0]
- modules = [x for x in patch_all_args if 'patch_' + x in globals()]
- script_help = """gevent.monkey - monkey patch the standard modules to use gevent.
-
-USAGE: ``python -m gevent.monkey [MONKEY OPTIONS] script [SCRIPT OPTIONS]``
-
-If no OPTIONS present, monkey patches all the modules it can patch.
-You can exclude a module with --no-module, e.g. --no-thread. You can
-specify a module to patch with --module, e.g. --socket. In the latter
-case only the modules specified on the command line will be patched.
-
-.. versionchanged:: 1.3b1
- The *script* argument can now be any argument that can be passed to `runpy.run_path`,
- just like the interpreter itself does, for example a package directory containing ``__main__.py``.
- Previously it had to be the path to
- a .py source file.
-
-MONKEY OPTIONS: ``--verbose %s``""" % ', '.join('--[no-]%s' % m for m in modules)
- return script_help, patch_all_args, modules
-
-main.__doc__ = _get_script_help()[0]
-
-if __name__ == '__main__':
- main()
diff --git a/python/gevent/os.py b/python/gevent/os.py
deleted file mode 100644
index 3980f32..0000000
--- a/python/gevent/os.py
+++ /dev/null
@@ -1,510 +0,0 @@
-"""
-Low-level operating system functions from :mod:`os`.
-
-Cooperative I/O
-===============
-
-This module provides cooperative versions of :func:`os.read` and
-:func:`os.write`. These functions are *not* monkey-patched; you
-must explicitly call them or monkey patch them yourself.
-
-POSIX functions
----------------
-
-On POSIX, non-blocking IO is available.
-
-- :func:`nb_read`
-- :func:`nb_write`
-- :func:`make_nonblocking`
-
-All Platforms
--------------
-
-On non-POSIX platforms (e.g., Windows), non-blocking IO is not
-available. On those platforms (and on POSIX), cooperative IO can
-be done with the threadpool.
-
-- :func:`tp_read`
-- :func:`tp_write`
-
-Child Processes
-===============
-
-The functions :func:`fork` and (on POSIX) :func:`forkpty` and :func:`waitpid` can be used
-to manage child processes.
-
-.. warning::
-
- Forking a process that uses greenlets does not eliminate all non-running
- greenlets. Any that were scheduled in the hub of the forking thread in the parent
- remain scheduled in the child; compare this to how normal threads operate. (This behaviour
- may change is a subsequent major release.)
-"""
-
-from __future__ import absolute_import
-
-import os
-import sys
-from gevent.hub import _get_hub_noargs as get_hub
-from gevent.hub import reinit
-from gevent._config import config
-from gevent._compat import PY3
-from gevent._util import copy_globals
-import errno
-
-EAGAIN = getattr(errno, 'EAGAIN', 11)
-
-try:
- import fcntl
-except ImportError:
- fcntl = None
-
-__implements__ = ['fork']
-__extensions__ = ['tp_read', 'tp_write']
-
-_read = os.read
-_write = os.write
-
-
-ignored_errors = [EAGAIN, errno.EINTR]
-
-
-if fcntl:
-
- __extensions__ += ['make_nonblocking', 'nb_read', 'nb_write']
-
- def make_nonblocking(fd):
- """Put the file descriptor *fd* into non-blocking mode if
- possible.
-
- :return: A boolean value that evaluates to True if successful.
- """
- flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
- if not bool(flags & os.O_NONBLOCK):
- fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- return True
-
- def nb_read(fd, n):
- """
- Read up to *n* bytes from file descriptor *fd*. Return a
- byte string containing the bytes read, which may be shorter than
- *n*. If end-of-file is reached, an empty string is returned.
-
- The descriptor must be in non-blocking mode.
- """
- hub = None
- event = None
- try:
- while 1:
- try:
- result = _read(fd, n)
- return result
- except OSError as e:
- if e.errno not in ignored_errors:
- raise
- if not PY3:
- sys.exc_clear()
- if hub is None:
- hub = get_hub()
- event = hub.loop.io(fd, 1)
- hub.wait(event)
- finally:
- if event is not None:
- event.close()
- event = None
- hub = None
-
-
- def nb_write(fd, buf):
- """
- Write some number of bytes from buffer *buf* to file
- descriptor *fd*. Return the number of bytes written, which may
- be less than the length of *buf*.
-
- The file descriptor must be in non-blocking mode.
- """
- hub = None
- event = None
- try:
- while 1:
- try:
- result = _write(fd, buf)
- return result
- except OSError as e:
- if e.errno not in ignored_errors:
- raise
- if not PY3:
- sys.exc_clear()
- if hub is None:
- hub = get_hub()
- event = hub.loop.io(fd, 2)
- hub.wait(event)
- finally:
- if event is not None:
- event.close()
- event = None
- hub = None
-
-
-def tp_read(fd, n):
- """Read up to *n* bytes from file descriptor *fd*. Return a string
- containing the bytes read. If end-of-file is reached, an empty string
- is returned.
-
- Reading is done using the threadpool.
- """
- return get_hub().threadpool.apply(_read, (fd, n))
-
-
-def tp_write(fd, buf):
- """Write bytes from buffer *buf* to file descriptor *fd*. Return the
- number of bytes written.
-
- Writing is done using the threadpool.
- """
- return get_hub().threadpool.apply(_write, (fd, buf))
-
-
-if hasattr(os, 'fork'):
- # pylint:disable=function-redefined,redefined-outer-name
-
- _raw_fork = os.fork
-
- def fork_gevent():
- """
- Forks the process using :func:`os.fork` and prepares the
- child process to continue using gevent before returning.
-
- .. note::
-
- The PID returned by this function may not be waitable with
- either the original :func:`os.waitpid` or this module's
- :func:`waitpid` and it may not generate SIGCHLD signals if
- libev child watchers are or ever have been in use. For
- example, the :mod:`gevent.subprocess` module uses libev
- child watchers (which parts of gevent use libev child
- watchers is subject to change at any time). Most
- applications should use :func:`fork_and_watch`, which is
- monkey-patched as the default replacement for
- :func:`os.fork` and implements the ``fork`` function of
- this module by default, unless the environment variable
- ``GEVENT_NOWAITPID`` is defined before this module is
- imported.
-
- .. versionadded:: 1.1b2
- """
- result = _raw_fork()
- if not result:
- reinit()
- return result
-
- def fork():
- """
- A wrapper for :func:`fork_gevent` for non-POSIX platforms.
- """
- return fork_gevent()
-
- if hasattr(os, 'forkpty'):
- _raw_forkpty = os.forkpty
-
- def forkpty_gevent():
- """
- Forks the process using :func:`os.forkpty` and prepares the
- child process to continue using gevent before returning.
-
- Returns a tuple (pid, master_fd). The `master_fd` is *not* put into
- non-blocking mode.
-
- Availability: Some Unix systems.
-
- .. seealso:: This function has the same limitations as :func:`fork_gevent`.
-
- .. versionadded:: 1.1b5
- """
- pid, master_fd = _raw_forkpty()
- if not pid:
- reinit()
- return pid, master_fd
-
- forkpty = forkpty_gevent
-
- __implements__.append('forkpty')
- __extensions__.append("forkpty_gevent")
-
- if hasattr(os, 'WNOWAIT') or hasattr(os, 'WNOHANG'):
- # We can only do this on POSIX
- import time
-
- _waitpid = os.waitpid
- _WNOHANG = os.WNOHANG
-
- # replaced by the signal module.
- _on_child_hook = lambda: None
-
- # {pid -> watcher or tuple(pid, rstatus, timestamp)}
- _watched_children = {}
-
- def _on_child(watcher, callback):
- # XXX: Could handle tracing here by not stopping
- # until the pid is terminated
- watcher.stop()
- try:
- _watched_children[watcher.pid] = (watcher.pid, watcher.rstatus, time.time())
- if callback:
- callback(watcher)
- # dispatch an "event"; used by gevent.signal.signal
- _on_child_hook()
- # now is as good a time as any to reap children
- _reap_children()
- finally:
- watcher.close()
-
- def _reap_children(timeout=60):
- # Remove all the dead children that haven't been waited on
- # for the *timeout* seconds.
- # Some platforms queue delivery of SIGCHLD for all children that die;
- # in that case, a well-behaved application should call waitpid() for each
- # signal.
- # Some platforms (linux) only guarantee one delivery if multiple children
- # die. On that platform, the well-behave application calls waitpid() in a loop
- # until it gets back -1, indicating no more dead children need to be waited for.
- # In either case, waitpid should be called the same number of times as dead children,
- # thus removing all the watchers when a SIGCHLD arrives. The (generous) timeout
- # is to work with applications that neglect to call waitpid and prevent "unlimited"
- # growth.
- # Note that we don't watch for the case of pid wraparound. That is, we fork a new
- # child with the same pid as an existing watcher, but the child is already dead,
- # just not waited on yet.
- now = time.time()
- oldest_allowed = now - timeout
- dead = [pid for pid, val
- in _watched_children.items()
- if isinstance(val, tuple) and val[2] < oldest_allowed]
- for pid in dead:
- del _watched_children[pid]
-
- def waitpid(pid, options):
- """
- Wait for a child process to finish.
-
- If the child process was spawned using
- :func:`fork_and_watch`, then this function behaves
- cooperatively. If not, it *may* have race conditions; see
- :func:`fork_gevent` for more information.
-
- The arguments are as for the underlying
- :func:`os.waitpid`. Some combinations of *options* may not
- be supported cooperatively (as of 1.1 that includes
- WUNTRACED). Using a *pid* of 0 to request waiting on only processes
- from the current process group is not cooperative.
-
- Availability: POSIX.
-
- .. versionadded:: 1.1b1
- .. versionchanged:: 1.2a1
- More cases are handled in a cooperative manner.
- """
- # pylint: disable=too-many-return-statements
- # XXX Does not handle tracing children
-
- # So long as libev's loop doesn't run, it's OK to add
- # child watchers. The SIGCHLD handler only feeds events
- # for the next iteration of the loop to handle. (And the
- # signal handler itself is only called from the next loop
- # iteration.)
-
- if pid <= 0:
- # magic functions for multiple children.
- if pid == -1:
- # Any child. If we have one that we're watching and that finished,
- # we will use that one. Otherwise, let the OS take care of it.
- for k, v in _watched_children.items():
- if isinstance(v, tuple):
- pid = k
- break
- if pid <= 0:
- # We didn't have one that was ready. If there are
- # no funky options set, and the pid was -1
- # (meaning any process, not 0, which means process
- # group--- libev doesn't know about process
- # groups) then we can use a child watcher of pid 0; otherwise,
- # pass through to the OS.
- if pid == -1 and options == 0:
- hub = get_hub()
- with hub.loop.child(0, False) as watcher:
- hub.wait(watcher)
- return watcher.rpid, watcher.rstatus
- # There were funky options/pid, so we must go to the OS.
- return _waitpid(pid, options)
-
- if pid in _watched_children:
- # yes, we're watching it
-
- # Note that the remainder of this code must be careful to NOT
- # yield to the event loop except at well known times, or
- # we have a race condition between the _on_child callback and the
- # code here that could lead to a process to hang.
- if options & _WNOHANG or isinstance(_watched_children[pid], tuple):
- # We're either asked not to block, or it already finished, in which
- # case blocking doesn't matter
- result = _watched_children[pid]
- if isinstance(result, tuple):
- # it finished. libev child watchers
- # are one-shot
- del _watched_children[pid]
- return result[:2]
- # it's not finished
- return (0, 0)
-
- # Ok, we need to "block". Do so via a watcher so that we're
- # cooperative. We know it's our child, etc, so this should work.
- watcher = _watched_children[pid]
- # We can't start a watcher that's already started,
- # so we can't reuse the existing watcher. Notice that the
- # old watcher must not have fired already, or during this time, but
- # only after we successfully `start()` the watcher. So this must
- # not yield to the event loop.
- with watcher.loop.child(pid, False) as new_watcher:
- get_hub().wait(new_watcher)
- # Ok, so now the new watcher is done. That means
- # the old watcher's callback (_on_child) should
- # have fired, potentially taking this child out of
- # _watched_children (but that could depend on how
- # many callbacks there were to run, so use the
- # watcher object directly; libev sets all the
- # watchers at the same time).
- return watcher.rpid, watcher.rstatus
-
- # we're not watching it and it may not even be our child,
- # so we must go to the OS to be sure to get the right semantics (exception)
- # XXX
- # libuv has a race condition because the signal
- # handler is a Python function, so the InterruptedError
- # is raised before the signal handler runs and calls the
- # child watcher
- # we're not watching it
- return _waitpid(pid, options)
-
- def fork_and_watch(callback=None, loop=None, ref=False, fork=fork_gevent):
- """
- Fork a child process and start a child watcher for it in the parent process.
-
- This call cooperates with :func:`waitpid` to enable cooperatively waiting
- for children to finish. When monkey-patching, these functions are patched in as
- :func:`os.fork` and :func:`os.waitpid`, respectively.
-
- In the child process, this function calls :func:`gevent.hub.reinit` before returning.
-
- Availability: POSIX.
-
- :keyword callback: If given, a callable that will be called with the child watcher
- when the child finishes.
- :keyword loop: The loop to start the watcher in. Defaults to the
- loop of the current hub.
- :keyword fork: The fork function. Defaults to :func:`the one defined in this
- module <gevent.os.fork_gevent>` (which automatically calls :func:`gevent.hub.reinit`).
- Pass the builtin :func:`os.fork` function if you do not need to
- initialize gevent in the child process.
-
- .. versionadded:: 1.1b1
- .. seealso::
- :func:`gevent.monkey.get_original` To access the builtin :func:`os.fork`.
- """
- pid = fork()
- if pid:
- # parent
- loop = loop or get_hub().loop
- watcher = loop.child(pid, ref=ref)
- _watched_children[pid] = watcher
- watcher.start(_on_child, watcher, callback)
- return pid
-
- __extensions__.append('fork_and_watch')
- __extensions__.append('fork_gevent')
-
- if 'forkpty' in __implements__:
- def forkpty_and_watch(callback=None, loop=None, ref=False, forkpty=forkpty_gevent):
- """
- Like :func:`fork_and_watch`, except using :func:`forkpty_gevent`.
-
- Availability: Some Unix systems.
-
- .. versionadded:: 1.1b5
- """
- result = []
-
- def _fork():
- pid_and_fd = forkpty()
- result.append(pid_and_fd)
- return pid_and_fd[0]
- fork_and_watch(callback, loop, ref, _fork)
- return result[0]
-
- __extensions__.append('forkpty_and_watch')
-
- # Watch children by default
- if not config.disable_watch_children:
- # Broken out into separate functions instead of simple name aliases
- # for documentation purposes.
- def fork(*args, **kwargs):
- """
- Forks a child process and starts a child watcher for it in the
- parent process so that ``waitpid`` and SIGCHLD work as expected.
-
- This implementation of ``fork`` is a wrapper for :func:`fork_and_watch`
- when the environment variable ``GEVENT_NOWAITPID`` is *not* defined.
- This is the default and should be used by most applications.
-
- .. versionchanged:: 1.1b2
- """
- # take any args to match fork_and_watch
- return fork_and_watch(*args, **kwargs)
-
- if 'forkpty' in __implements__:
- def forkpty(*args, **kwargs):
- """
- Like :func:`fork`, but using :func:`forkpty_gevent`.
-
- This implementation of ``forkpty`` is a wrapper for :func:`forkpty_and_watch`
- when the environment variable ``GEVENT_NOWAITPID`` is *not* defined.
- This is the default and should be used by most applications.
-
- .. versionadded:: 1.1b5
- """
- # take any args to match fork_and_watch
- return forkpty_and_watch(*args, **kwargs)
- __implements__.append("waitpid")
- else:
- def fork():
- """
- Forks a child process, initializes gevent in the child,
- but *does not* prepare the parent to wait for the child or receive SIGCHLD.
-
- This implementation of ``fork`` is a wrapper for :func:`fork_gevent`
- when the environment variable ``GEVENT_NOWAITPID`` *is* defined.
- This is not recommended for most applications.
- """
- return fork_gevent()
-
- if 'forkpty' in __implements__:
- def forkpty():
- """
- Like :func:`fork`, but using :func:`os.forkpty`
-
- This implementation of ``forkpty`` is a wrapper for :func:`forkpty_gevent`
- when the environment variable ``GEVENT_NOWAITPID`` *is* defined.
- This is not recommended for most applications.
-
- .. versionadded:: 1.1b5
- """
- return forkpty_gevent()
- __extensions__.append("waitpid")
-
-else:
- __implements__.remove('fork')
-
-__imports__ = copy_globals(os, globals(),
- names_to_ignore=__implements__ + __extensions__,
- dunder_names_to_keep=())
-
-__all__ = list(set(__implements__ + __extensions__))
diff --git a/python/gevent/pool.py b/python/gevent/pool.py
deleted file mode 100644
index 48e6a7a..0000000
--- a/python/gevent/pool.py
+++ /dev/null
@@ -1,667 +0,0 @@
-# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details.
-"""
-Managing greenlets in a group.
-
-The :class:`Group` class in this module abstracts a group of running
-greenlets. When a greenlet dies, it's automatically removed from the
-group. All running greenlets in a group can be waited on with
-:meth:`Group.join`, or all running greenlets can be killed with
-:meth:`Group.kill`.
-
-The :class:`Pool` class, which is a subclass of :class:`Group`,
-provides a way to limit concurrency: its :meth:`spawn <Pool.spawn>`
-method blocks if the number of greenlets in the pool has already
-reached the limit, until there is a free slot.
-"""
-from __future__ import print_function, absolute_import, division
-
-
-from gevent.hub import GreenletExit, getcurrent, kill as _kill
-from gevent.greenlet import joinall, Greenlet
-from gevent.queue import Full as QueueFull
-from gevent.timeout import Timeout
-from gevent.event import Event
-from gevent.lock import Semaphore, DummySemaphore
-
-from gevent._compat import izip
-from gevent._imap import IMap
-from gevent._imap import IMapUnordered
-
-__all__ = [
- 'Group',
- 'Pool',
- 'PoolFull',
-]
-
-
-
-
-class GroupMappingMixin(object):
- # Internal, non-public API class.
- # Provides mixin methods for implementing mapping pools. Subclasses must define:
-
- def spawn(self, func, *args, **kwargs):
- """
- A function that runs *func* with *args* and *kwargs*, potentially
- asynchronously. Return a value with a ``get`` method that blocks
- until the results of func are available, and a ``rawlink`` method
- that calls a callback when the results are available.
-
- If this object has an upper bound on how many asyncronously executing
- tasks can exist, this method may block until a slot becomes available.
- """
- raise NotImplementedError()
-
- def _apply_immediately(self):
- """
- should the function passed to apply be called immediately,
- synchronously?
- """
- raise NotImplementedError()
-
- def _apply_async_use_greenlet(self):
- """
- Should apply_async directly call Greenlet.spawn(), bypassing
- `spawn`?
-
- Return true when self.spawn would block.
- """
- raise NotImplementedError()
-
- def _apply_async_cb_spawn(self, callback, result):
- """
- Run the given callback function, possibly
- asynchronously, possibly synchronously.
- """
- raise NotImplementedError()
-
- def apply_cb(self, func, args=None, kwds=None, callback=None):
- """
- :meth:`apply` the given *func(\\*args, \\*\\*kwds)*, and, if a *callback* is given, run it with the
- results of *func* (unless an exception was raised.)
-
- The *callback* may be called synchronously or asynchronously. If called
- asynchronously, it will not be tracked by this group. (:class:`Group` and :class:`Pool`
- call it asynchronously in a new greenlet; :class:`~gevent.threadpool.ThreadPool` calls
- it synchronously in the current greenlet.)
- """
- result = self.apply(func, args, kwds)
- if callback is not None:
- self._apply_async_cb_spawn(callback, result)
- return result
-
- def apply_async(self, func, args=None, kwds=None, callback=None):
- """
- A variant of the :meth:`apply` method which returns a :class:`~.Greenlet` object.
-
- When the returned greenlet gets to run, it *will* call :meth:`apply`,
- passing in *func*, *args* and *kwds*.
-
- If *callback* is specified, then it should be a callable which
- accepts a single argument. When the result becomes ready
- callback is applied to it (unless the call failed).
-
- This method will never block, even if this group is full (that is,
- even if :meth:`spawn` would block, this method will not).
-
- .. caution:: The returned greenlet may or may not be tracked
- as part of this group, so :meth:`joining <join>` this group is
- not a reliable way to wait for the results to be available or
- for the returned greenlet to run; instead, join the returned
- greenlet.
-
- .. tip:: Because :class:`~.ThreadPool` objects do not track greenlets, the returned
- greenlet will never be a part of it. To reduce overhead and improve performance,
- :class:`Group` and :class:`Pool` may choose to track the returned
- greenlet. These are implementation details that may change.
- """
- if args is None:
- args = ()
- if kwds is None:
- kwds = {}
- if self._apply_async_use_greenlet():
- # cannot call self.spawn() directly because it will block
- # XXX: This is always the case for ThreadPool, but for Group/Pool
- # of greenlets, this is only the case when they are full...hence
- # the weasely language about "may or may not be tracked". Should we make
- # Group/Pool always return true as well so it's never tracked by any
- # implementation? That would simplify that logic, but could increase
- # the total number of greenlets in the system and add a layer of
- # overhead for the simple cases when the pool isn't full.
- return Greenlet.spawn(self.apply_cb, func, args, kwds, callback)
-
- greenlet = self.spawn(func, *args, **kwds)
- if callback is not None:
- greenlet.link(pass_value(callback))
- return greenlet
-
- def apply(self, func, args=None, kwds=None):
- """
- Rough quivalent of the :func:`apply()` builtin function blocking until
- the result is ready and returning it.
-
- The ``func`` will *usually*, but not *always*, be run in a way
- that allows the current greenlet to switch out (for example,
- in a new greenlet or thread, depending on implementation). But
- if the current greenlet or thread is already one that was
- spawned by this pool, the pool may choose to immediately run
- the `func` synchronously.
-
- Any exception ``func`` raises will be propagated to the caller of ``apply`` (that is,
- this method will raise the exception that ``func`` raised).
- """
- if args is None:
- args = ()
- if kwds is None:
- kwds = {}
- if self._apply_immediately():
- return func(*args, **kwds)
- return self.spawn(func, *args, **kwds).get()
-
- def __map(self, func, iterable):
- return [g.get() for g in
- [self.spawn(func, i) for i in iterable]]
-
- def map(self, func, iterable):
- """Return a list made by applying the *func* to each element of
- the iterable.
-
- .. seealso:: :meth:`imap`
- """
- # We can't return until they're all done and in order. It
- # wouldn't seem to much matter what order we wait on them in,
- # so the simple, fast (50% faster than imap) solution would be:
-
- # return [g.get() for g in
- # [self.spawn(func, i) for i in iterable]]
-
- # If the pool size is unlimited (or more than the len(iterable)), this
- # is equivalent to imap (spawn() will never block, all of them run concurrently,
- # we call get() in the order the iterable was given).
-
- # Now lets imagine the pool if is limited size. Suppose the
- # func is time.sleep, our pool is limited to 3 threads, and
- # our input is [10, 1, 10, 1, 1] We would start three threads,
- # one to sleep for 10, one to sleep for 1, and the last to
- # sleep for 10. We would block starting the fourth thread. At
- # time 1, we would finish the second thread and start another
- # one for time 1. At time 2, we would finish that one and
- # start the last thread, and then begin executing get() on the first
- # thread.
-
- # Because it's spawn that blocks, this is *also* equivalent to what
- # imap would do.
-
- # The one remaining difference is that imap runs in its own
- # greenlet, potentially changing the way the event loop runs.
- # That's easy enough to do.
-
- g = Greenlet.spawn(self.__map, func, iterable)
- return g.get()
-
- def map_cb(self, func, iterable, callback=None):
- result = self.map(func, iterable)
- if callback is not None:
- callback(result)
- return result
-
- def map_async(self, func, iterable, callback=None):
- """
- A variant of the map() method which returns a Greenlet object that is executing
- the map function.
-
- If callback is specified then it should be a callable which accepts a
- single argument.
- """
- return Greenlet.spawn(self.map_cb, func, iterable, callback)
-
- def __imap(self, cls, func, *iterables, **kwargs):
- # Python 2 doesn't support the syntax that lets us mix varargs and
- # a named kwarg, so we have to unpack manually
- maxsize = kwargs.pop('maxsize', None)
- if kwargs:
- raise TypeError("Unsupported keyword arguments")
- return cls.spawn(func, izip(*iterables), spawn=self.spawn,
- _zipped=True, maxsize=maxsize)
-
- def imap(self, func, *iterables, **kwargs):
- """
- imap(func, *iterables, maxsize=None) -> iterable
-
- An equivalent of :func:`itertools.imap`, operating in parallel.
- The *func* is applied to each element yielded from each
- iterable in *iterables* in turn, collecting the result.
-
- If this object has a bound on the number of active greenlets it can
- contain (such as :class:`Pool`), then at most that number of tasks will operate
- in parallel.
-
- :keyword int maxsize: If given and not-None, specifies the maximum number of
- finished results that will be allowed to accumulate awaiting the reader;
- more than that number of results will cause map function greenlets to begin
- to block. This is most useful if there is a great disparity in the speed of
- the mapping code and the consumer and the results consume a great deal of resources.
-
- .. note:: This is separate from any bound on the number of active parallel
- tasks, though they may have some interaction (for example, limiting the
- number of parallel tasks to the smallest bound).
-
- .. note:: Using a bound is slightly more computationally expensive than not using a bound.
-
- .. tip:: The :meth:`imap_unordered` method makes much better
- use of this parameter. Some additional, unspecified,
- number of objects may be required to be kept in memory
- to maintain order by this function.
-
- :return: An iterable object.
-
- .. versionchanged:: 1.1b3
- Added the *maxsize* keyword parameter.
- .. versionchanged:: 1.1a1
- Accept multiple *iterables* to iterate in parallel.
- """
- return self.__imap(IMap, func, *iterables, **kwargs)
-
- def imap_unordered(self, func, *iterables, **kwargs):
- """
- imap_unordered(func, *iterables, maxsize=None) -> iterable
-
- The same as :meth:`imap` except that the ordering of the results
- from the returned iterator should be considered in arbitrary
- order.
-
- This is lighter weight than :meth:`imap` and should be preferred if order
- doesn't matter.
-
- .. seealso:: :meth:`imap` for more details.
- """
- return self.__imap(IMapUnordered, func, *iterables, **kwargs)
-
-
-class Group(GroupMappingMixin):
- """
- Maintain a group of greenlets that are still running, without
- limiting their number.
-
- Links to each item and removes it upon notification.
-
- Groups can be iterated to discover what greenlets they are tracking,
- they can be tested to see if they contain a greenlet, and they know the
- number (len) of greenlets they are tracking. If they are not tracking any
- greenlets, they are False in a boolean context.
- """
-
- #: The type of Greenlet object we will :meth:`spawn`. This can be changed
- #: on an instance or in a subclass.
- greenlet_class = Greenlet
-
- def __init__(self, *args):
- assert len(args) <= 1, args
- self.greenlets = set(*args)
- if args:
- for greenlet in args[0]:
- greenlet.rawlink(self._discard)
- # each item we kill we place in dying, to avoid killing the same greenlet twice
- self.dying = set()
- self._empty_event = Event()
- self._empty_event.set()
-
- def __repr__(self):
- return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self.greenlets)
-
- def __len__(self):
- """
- Answer how many greenlets we are tracking. Note that if we are empty,
- we are False in a boolean context.
- """
- return len(self.greenlets)
-
- def __contains__(self, item):
- """
- Answer if we are tracking the given greenlet.
- """
- return item in self.greenlets
-
- def __iter__(self):
- """
- Iterate across all the greenlets we are tracking, in no particular order.
- """
- return iter(self.greenlets)
-
- def add(self, greenlet):
- """
- Begin tracking the *greenlet*.
-
- If this group is :meth:`full`, then this method may block
- until it is possible to track the greenlet.
-
- Typically the *greenlet* should **not** be started when
- it is added because if this object blocks in this method,
- then the *greenlet* may run to completion before it is tracked.
- """
- try:
- rawlink = greenlet.rawlink
- except AttributeError:
- pass # non-Greenlet greenlet, like MAIN
- else:
- rawlink(self._discard)
- self.greenlets.add(greenlet)
- self._empty_event.clear()
-
- def _discard(self, greenlet):
- self.greenlets.discard(greenlet)
- self.dying.discard(greenlet)
- if not self.greenlets:
- self._empty_event.set()
-
- def discard(self, greenlet):
- """
- Stop tracking the greenlet.
- """
- self._discard(greenlet)
- try:
- unlink = greenlet.unlink
- except AttributeError:
- pass # non-Greenlet greenlet, like MAIN
- else:
- unlink(self._discard)
-
- def start(self, greenlet):
- """
- Add the **unstarted** *greenlet* to the collection of greenlets
- this group is monitoring, and then start it.
- """
- self.add(greenlet)
- greenlet.start()
-
- def spawn(self, *args, **kwargs): # pylint:disable=arguments-differ
- """
- Begin a new greenlet with the given arguments (which are passed
- to the greenlet constructor) and add it to the collection of greenlets
- this group is monitoring.
-
- :return: The newly started greenlet.
- """
- greenlet = self.greenlet_class(*args, **kwargs)
- self.start(greenlet)
- return greenlet
-
-# def close(self):
-# """Prevents any more tasks from being submitted to the pool"""
-# self.add = RaiseException("This %s has been closed" % self.__class__.__name__)
-
- def join(self, timeout=None, raise_error=False):
- """
- Wait for this group to become empty *at least once*.
-
- If there are no greenlets in the group, returns immediately.
-
- .. note:: By the time the waiting code (the caller of this
- method) regains control, a greenlet may have been added to
- this group, and so this object may no longer be empty. (That
- is, ``group.join(); assert len(group) == 0`` is not
- guaranteed to hold.) This method only guarantees that the group
- reached a ``len`` of 0 at some point.
-
- :keyword bool raise_error: If True (*not* the default), if any
- greenlet that finished while the join was in progress raised
- an exception, that exception will be raised to the caller of
- this method. If multiple greenlets raised exceptions, which
- one gets re-raised is not determined. Only greenlets currently
- in the group when this method is called are guaranteed to
- be checked for exceptions.
-
- :return bool: A value indicating whether this group became empty.
- If the timeout is specified and the group did not become empty
- during that timeout, then this will be a false value. Otherwise
- it will be a true value.
-
- .. versionchanged:: 1.2a1
- Add the return value.
- """
- greenlets = list(self.greenlets) if raise_error else ()
- result = self._empty_event.wait(timeout=timeout)
-
- for greenlet in greenlets:
- if greenlet.exception is not None:
- if hasattr(greenlet, '_raise_exception'):
- greenlet._raise_exception()
- raise greenlet.exception
-
- return result
-
- def kill(self, exception=GreenletExit, block=True, timeout=None):
- """
- Kill all greenlets being tracked by this group.
- """
- timer = Timeout._start_new_or_dummy(timeout)
- try:
- while self.greenlets:
- for greenlet in list(self.greenlets):
- if greenlet in self.dying:
- continue
- try:
- kill = greenlet.kill
- except AttributeError:
- _kill(greenlet, exception)
- else:
- kill(exception, block=False)
- self.dying.add(greenlet)
- if not block:
- break
- joinall(self.greenlets)
- except Timeout as ex:
- if ex is not timer:
- raise
- finally:
- timer.cancel()
-
- def killone(self, greenlet, exception=GreenletExit, block=True, timeout=None):
- """
- If the given *greenlet* is running and being tracked by this group,
- kill it.
- """
- if greenlet not in self.dying and greenlet in self.greenlets:
- greenlet.kill(exception, block=False)
- self.dying.add(greenlet)
- if block:
- greenlet.join(timeout)
-
- def full(self):
- """
- Return a value indicating whether this group can track more greenlets.
-
- In this implementation, because there are no limits on the number of
- tracked greenlets, this will always return a ``False`` value.
- """
- return False
-
- def wait_available(self, timeout=None):
- """
- Block until it is possible to :meth:`spawn` a new greenlet.
-
- In this implementation, because there are no limits on the number
- of tracked greenlets, this will always return immediately.
- """
- pass
-
- # MappingMixin methods
-
- def _apply_immediately(self):
- # If apply() is called from one of our own
- # worker greenlets, don't spawn a new one---if we're full, that
- # could deadlock.
- return getcurrent() in self
-
- def _apply_async_cb_spawn(self, callback, result):
- Greenlet.spawn(callback, result)
-
- def _apply_async_use_greenlet(self):
- # cannot call self.spawn() because it will block, so
- # use a fresh, untracked greenlet that when run will
- # (indirectly) call self.spawn() for us.
- return self.full()
-
-
-
-class PoolFull(QueueFull):
- """
- Raised when a Pool is full and an attempt was made to
- add a new greenlet to it in non-blocking mode.
- """
-
-
-class Pool(Group):
-
- def __init__(self, size=None, greenlet_class=None):
- """
- Create a new pool.
-
- A pool is like a group, but the maximum number of members
- is governed by the *size* parameter.
-
- :keyword int size: If given, this non-negative integer is the
- maximum count of active greenlets that will be allowed in
- this pool. A few values have special significance:
-
- * ``None`` (the default) places no limit on the number of
- greenlets. This is useful when you need to track, but not limit,
- greenlets, as with :class:`gevent.pywsgi.WSGIServer`. A :class:`Group`
- may be a more efficient way to achieve the same effect.
- * ``0`` creates a pool that can never have any active greenlets. Attempting
- to spawn in this pool will block forever. This is only useful
- if an application uses :meth:`wait_available` with a timeout and checks
- :meth:`free_count` before attempting to spawn.
- """
- if size is not None and size < 0:
- raise ValueError('size must not be negative: %r' % (size, ))
- Group.__init__(self)
- self.size = size
- if greenlet_class is not None:
- self.greenlet_class = greenlet_class
- if size is None:
- factory = DummySemaphore
- else:
- factory = Semaphore
- self._semaphore = factory(size)
-
- def wait_available(self, timeout=None):
- """
- Wait until it's possible to spawn a greenlet in this pool.
-
- :param float timeout: If given, only wait the specified number
- of seconds.
-
- .. warning:: If the pool was initialized with a size of 0, this
- method will block forever unless a timeout is given.
-
- :return: A number indicating how many new greenlets can be put into
- the pool without blocking.
-
- .. versionchanged:: 1.1a3
- Added the ``timeout`` parameter.
- """
- return self._semaphore.wait(timeout=timeout)
-
- def full(self):
- """
- Return a boolean indicating whether this pool is full, e.g. if
- :meth:`add` would block.
-
- :return: False if there is room for new members, True if there isn't.
- """
- return self.free_count() <= 0
-
- def free_count(self):
- """
- Return a number indicating *approximately* how many more members
- can be added to this pool.
- """
- if self.size is None:
- return 1
- return max(0, self.size - len(self))
-
- def start(self, greenlet, *args, **kwargs): # pylint:disable=arguments-differ
- """
- start(greenlet, blocking=True, timeout=None) -> None
-
- Add the **unstarted** *greenlet* to the collection of greenlets
- this group is monitoring and then start it.
-
- Parameters are as for :meth:`add`.
- """
- self.add(greenlet, *args, **kwargs)
- greenlet.start()
-
- def add(self, greenlet, blocking=True, timeout=None): # pylint:disable=arguments-differ
- """
- Begin tracking the given **unstarted** greenlet, possibly blocking
- until space is available.
-
- Usually you should call :meth:`start` to track and start the greenlet
- instead of using this lower-level method, or :meth:`spawn` to
- also create the greenlet.
-
- :keyword bool blocking: If True (the default), this function
- will block until the pool has space or a timeout occurs. If
- False, this function will immediately raise a Timeout if the
- pool is currently full.
- :keyword float timeout: The maximum number of seconds this
- method will block, if ``blocking`` is True. (Ignored if
- ``blocking`` is False.)
- :raises PoolFull: if either ``blocking`` is False and the pool
- was full, or if ``blocking`` is True and ``timeout`` was
- exceeded.
-
- .. caution:: If the *greenlet* has already been started and
- *blocking* is true, then the greenlet may run to completion
- while the current greenlet blocks waiting to track it. This would
- enable higher concurrency than desired.
-
- .. seealso:: :meth:`Group.add`
-
- .. versionchanged:: 1.3.0 Added the ``blocking`` and
- ``timeout`` parameters.
- """
- if not self._semaphore.acquire(blocking=blocking, timeout=timeout):
- # We failed to acquire the semaphore.
- # If blocking was True, then there was a timeout. If blocking was
- # False, then there was no capacity. Either way, raise PoolFull.
- raise PoolFull()
-
- try:
- Group.add(self, greenlet)
- except:
- self._semaphore.release()
- raise
-
- def _discard(self, greenlet):
- Group._discard(self, greenlet)
- self._semaphore.release()
-
-
-class pass_value(object):
- __slots__ = ['callback']
-
- def __init__(self, callback):
- self.callback = callback
-
- def __call__(self, source):
- if source.successful():
- self.callback(source.value)
-
- def __hash__(self):
- return hash(self.callback)
-
- def __eq__(self, other):
- return self.callback == getattr(other, 'callback', other)
-
- def __str__(self):
- return str(self.callback)
-
- def __repr__(self):
- return repr(self.callback)
-
- def __getattr__(self, item):
- assert item != 'callback'
- return getattr(self.callback, item)
diff --git a/python/gevent/pywsgi.py b/python/gevent/pywsgi.py
deleted file mode 100644
index 8d0b5b8..0000000
--- a/python/gevent/pywsgi.py
+++ /dev/null
@@ -1,1545 +0,0 @@
-# Copyright (c) 2005-2009, eventlet contributors
-# Copyright (c) 2009-2018, gevent contributors
-"""
-A pure-Python, gevent-friendly WSGI server.
-
-The server is provided in :class:`WSGIServer`, but most of the actual
-WSGI work is handled by :class:`WSGIHandler` --- a new instance is
-created for each request. The server can be customized to use
-different subclasses of :class:`WSGIHandler`.
-
-"""
-from __future__ import absolute_import
-
-# FIXME: Can we refactor to make smallor?
-# pylint:disable=too-many-lines
-
-import errno
-from io import BytesIO
-import string
-import sys
-import time
-import traceback
-from datetime import datetime
-
-try:
- from urllib import unquote
-except ImportError:
- from urllib.parse import unquote # python 2 pylint:disable=import-error,no-name-in-module
-
-from gevent import socket
-import gevent
-from gevent.server import StreamServer
-from gevent.hub import GreenletExit
-from gevent._compat import PY3, reraise
-
-from functools import partial
-if PY3:
- unquote_latin1 = partial(unquote, encoding='latin-1')
-else:
- unquote_latin1 = unquote
-
-_no_undoc_members = True # Don't put undocumented things into sphinx
-
-__all__ = [
- 'WSGIServer',
- 'WSGIHandler',
- 'LoggingLogAdapter',
- 'Environ',
- 'SecureEnviron',
- 'WSGISecureEnviron',
-]
-
-
-MAX_REQUEST_LINE = 8192
-# Weekday and month names for HTTP date/time formatting; always English!
-_WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
-_MONTHNAME = [None, # Dummy so we can use 1-based month numbers
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
-
-# The contents of the "HEX" grammar rule for HTTP, upper and lowercase A-F plus digits,
-# in byte form for comparing to the network.
-_HEX = string.hexdigits.encode('ascii')
-
-# Errors
-_ERRORS = dict()
-_INTERNAL_ERROR_STATUS = '500 Internal Server Error'
-_INTERNAL_ERROR_BODY = b'Internal Server Error'
-_INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'),
- ('Connection', 'close'),
- ('Content-Length', str(len(_INTERNAL_ERROR_BODY)))]
-_ERRORS[500] = (_INTERNAL_ERROR_STATUS, _INTERNAL_ERROR_HEADERS, _INTERNAL_ERROR_BODY)
-
-_BAD_REQUEST_STATUS = '400 Bad Request'
-_BAD_REQUEST_BODY = ''
-_BAD_REQUEST_HEADERS = [('Content-Type', 'text/plain'),
- ('Connection', 'close'),
- ('Content-Length', str(len(_BAD_REQUEST_BODY)))]
-_ERRORS[400] = (_BAD_REQUEST_STATUS, _BAD_REQUEST_HEADERS, _BAD_REQUEST_BODY)
-
-_REQUEST_TOO_LONG_RESPONSE = b"HTTP/1.1 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
-_BAD_REQUEST_RESPONSE = b"HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
-_CONTINUE_RESPONSE = b"HTTP/1.1 100 Continue\r\n\r\n"
-
-
-def format_date_time(timestamp):
- # Return a byte-string of the date and time in HTTP format
- # .. versionchanged:: 1.1b5
- # Return a byte string, not a native string
- year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp)
- value = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (_WEEKDAYNAME[wd], day, _MONTHNAME[month], year, hh, mm, ss)
- if PY3:
- value = value.encode("latin-1")
- return value
-
-
-class _InvalidClientInput(IOError):
- # Internal exception raised by Input indicating that the client
- # sent invalid data at the lowest level of the stream. The result
- # *should* be a HTTP 400 error.
- pass
-
-
-class _InvalidClientRequest(ValueError):
- # Internal exception raised by WSGIHandler.read_request
- # indicating that the client sent an HTTP request that cannot
- # be parsed (e.g., invalid grammar). The result *should* be an
- # HTTP 400 error
- pass
-
-
-class Input(object):
-
- __slots__ = ('rfile', 'content_length', 'socket', 'position',
- 'chunked_input', 'chunk_length', '_chunked_input_error')
-
- def __init__(self, rfile, content_length, socket=None, chunked_input=False):
- # pylint:disable=redefined-outer-name
- self.rfile = rfile
- self.content_length = content_length
- self.socket = socket
- self.position = 0
- self.chunked_input = chunked_input
- self.chunk_length = -1
- self._chunked_input_error = False
-
- def _discard(self):
- if self._chunked_input_error:
- # We are in an unknown state, so we can't necessarily discard
- # the body (e.g., if the client keeps the socket open, we could hang
- # here forever).
- # In this case, we've raised an exception and the user of this object
- # is going to close the socket, so we don't have to discard
- return
-
- if self.socket is None and (self.position < (self.content_length or 0) or self.chunked_input):
- # ## Read and discard body
- while 1:
- d = self.read(16384)
- if not d:
- break
-
- def _send_100_continue(self):
- if self.socket is not None:
- self.socket.sendall(_CONTINUE_RESPONSE)
- self.socket = None
-
- def _do_read(self, length=None, use_readline=False):
- if use_readline:
- reader = self.rfile.readline
- else:
- reader = self.rfile.read
- content_length = self.content_length
- if content_length is None:
- # Either Content-Length or "Transfer-Encoding: chunked" must be present in a request with a body
- # if it was chunked, then this function would have not been called
- return b''
-
- self._send_100_continue()
- left = content_length - self.position
- if length is None:
- length = left
- elif length > left:
- length = left
- if not length:
- return b''
-
- # On Python 2, self.rfile is usually socket.makefile(), which
- # uses cStringIO.StringIO. If *length* is greater than the C
- # sizeof(int) (typically 32 bits signed), parsing the argument to
- # readline raises OverflowError. StringIO.read(), OTOH, uses
- # PySize_t, typically a long (64 bits). In a bare readline()
- # case, because the header lines we're trying to read with
- # readline are typically expected to be small, we can correct
- # that failure by simply doing a smaller call to readline and
- # appending; failures in read we let propagate.
- try:
- read = reader(length)
- except OverflowError:
- if not use_readline:
- # Expecting to read more than 64 bits of data. Ouch!
- raise
- # We could loop on calls to smaller readline(), appending them
- # until we actually get a newline. For uses in this module,
- # we expect the actual length to be small, but WSGI applications
- # are allowed to pass in an arbitrary length. (This loop isn't optimal,
- # but even client applications *probably* have short lines.)
- read = b''
- while len(read) < length and not read.endswith(b'\n'):
- read += reader(MAX_REQUEST_LINE)
-
- self.position += len(read)
- if len(read) < length:
- if (use_readline and not read.endswith(b"\n")) or not use_readline:
- raise IOError("unexpected end of file while reading request at position %s" % (self.position,))
-
- return read
-
- def __read_chunk_length(self, rfile):
- # Read and return the next integer chunk length. If no
- # chunk length can be read, raises _InvalidClientInput.
-
- # Here's the production for a chunk:
- # (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html)
- # chunk = chunk-size [ chunk-extension ] CRLF
- # chunk-data CRLF
- # chunk-size = 1*HEX
- # chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
- # chunk-ext-name = token
- # chunk-ext-val = token | quoted-string
-
- # To cope with malicious or broken clients that fail to send valid
- # chunk lines, the strategy is to read character by character until we either reach
- # a ; or newline. If at any time we read a non-HEX digit, we bail. If we hit a
- # ;, indicating an chunk-extension, we'll read up to the next
- # MAX_REQUEST_LINE characters
- # looking for the CRLF, and if we don't find it, we bail. If we read more than 16 hex characters,
- # (the number needed to represent a 64-bit chunk size), we bail (this protects us from
- # a client that sends an infinite stream of `F`, for example).
-
- buf = BytesIO()
- while 1:
- char = rfile.read(1)
- if not char:
- self._chunked_input_error = True
- raise _InvalidClientInput("EOF before chunk end reached")
- if char == b'\r':
- break
- if char == b';':
- break
-
- if char not in _HEX:
- self._chunked_input_error = True
- raise _InvalidClientInput("Non-hex data", char)
- buf.write(char)
- if buf.tell() > 16:
- self._chunked_input_error = True
- raise _InvalidClientInput("Chunk-size too large.")
-
- if char == b';':
- i = 0
- while i < MAX_REQUEST_LINE:
- char = rfile.read(1)
- if char == b'\r':
- break
- i += 1
- else:
- # we read more than MAX_REQUEST_LINE without
- # hitting CR
- self._chunked_input_error = True
- raise _InvalidClientInput("Too large chunk extension")
-
- if char == b'\r':
- # We either got here from the main loop or from the
- # end of an extension
- char = rfile.read(1)
- if char != b'\n':
- self._chunked_input_error = True
- raise _InvalidClientInput("Line didn't end in CRLF")
- return int(buf.getvalue(), 16)
-
- def _chunked_read(self, length=None, use_readline=False):
- # pylint:disable=too-many-branches
- rfile = self.rfile
- self._send_100_continue()
-
- if length == 0:
- return b""
-
- if length is not None and length < 0:
- length = None
-
- if use_readline:
- reader = self.rfile.readline
- else:
- reader = self.rfile.read
-
- response = []
- while self.chunk_length != 0:
- maxreadlen = self.chunk_length - self.position
- if length is not None and length < maxreadlen:
- maxreadlen = length
-
- if maxreadlen > 0:
- data = reader(maxreadlen)
- if not data:
- self.chunk_length = 0
- self._chunked_input_error = True
- raise IOError("unexpected end of file while parsing chunked data")
-
- datalen = len(data)
- response.append(data)
-
- self.position += datalen
- if self.chunk_length == self.position:
- rfile.readline()
-
- if length is not None:
- length -= datalen
- if length == 0:
- break
- if use_readline and data[-1] == b"\n"[0]:
- break
- else:
- # We're at the beginning of a chunk, so we need to
- # determine the next size to read
- self.chunk_length = self.__read_chunk_length(rfile)
- self.position = 0
- if self.chunk_length == 0:
- # Last chunk. Terminates with a CRLF.
- rfile.readline()
- return b''.join(response)
-
- def read(self, length=None):
- if self.chunked_input:
- return self._chunked_read(length)
- return self._do_read(length)
-
- def readline(self, size=None):
- if self.chunked_input:
- return self._chunked_read(size, True)
- return self._do_read(size, use_readline=True)
-
- def readlines(self, hint=None):
- # pylint:disable=unused-argument
- return list(self)
-
- def __iter__(self):
- return self
-
- def next(self):
- line = self.readline()
- if not line:
- raise StopIteration
- return line
- __next__ = next
-
-
-try:
- import mimetools
- headers_factory = mimetools.Message
-except ImportError:
- # adapt Python 3 HTTP headers to old API
- from http import client # pylint:disable=import-error
-
- class OldMessage(client.HTTPMessage):
- def __init__(self, **kwargs):
- super(client.HTTPMessage, self).__init__(**kwargs) # pylint:disable=bad-super-call
- self.status = ''
-
- def getheader(self, name, default=None):
- return self.get(name, default)
-
- @property
- def headers(self):
- for key, value in self._headers:
- yield '%s: %s\r\n' % (key, value)
-
- @property
- def typeheader(self):
- return self.get('content-type')
-
- def headers_factory(fp, *args): # pylint:disable=unused-argument
- try:
- ret = client.parse_headers(fp, _class=OldMessage)
- except client.LineTooLong:
- ret = OldMessage()
- ret.status = 'Line too long'
- return ret
-
-
-class WSGIHandler(object):
- """
- Handles HTTP requests from a socket, creates the WSGI environment, and
- interacts with the WSGI application.
-
- This is the default value of :attr:`WSGIServer.handler_class`.
- This class may be subclassed carefully, and that class set on a
- :class:`WSGIServer` instance through a keyword argument at
- construction time.
-
- Instances are constructed with the same arguments as passed to the
- server's :meth:`WSGIServer.handle` method followed by the server
- itself. The application and environment are obtained from the server.
-
- """
- # pylint:disable=too-many-instance-attributes
-
- protocol_version = 'HTTP/1.1'
- if PY3:
- # if we do like Py2, then headers_factory unconditionally
- # becomes a bound method, meaning the fp argument becomes WSGIHandler
- def MessageClass(self, *args):
- return headers_factory(*args)
- else:
- MessageClass = headers_factory
-
- # Attributes reset at various times for each request; not public
- # documented. Class attributes to keep the constructor fast
- # (but not make lint tools complain)
-
- status = None # byte string: b'200 OK'
- _orig_status = None # native string: '200 OK'
- response_headers = None # list of tuples (b'name', b'value')
- code = None # Integer parsed from status
- provided_date = None
- provided_content_length = None
- close_connection = False
- time_start = 0 # time.time() when begin handling request
- time_finish = 0 # time.time() when done handling request
- headers_sent = False # Have we already sent headers?
- response_use_chunked = False # Write with transfer-encoding chunked
- environ = None # Dict from self.get_environ
- application = None # application callable from self.server.application
- requestline = None # native str 'GET / HTTP/1.1'
- response_length = 0 # How much data we sent
- result = None # The return value of the WSGI application
- wsgi_input = None # Instance of Input()
- content_length = 0 # From application-provided headers Incoming
- # request headers, instance of MessageClass (gunicorn uses hasattr
- # on this so the default value needs to be compatible with the
- # API)
- headers = headers_factory(BytesIO())
- request_version = None # str: 'HTTP 1.1'
- command = None # str: 'GET'
- path = None # str: '/'
-
- def __init__(self, sock, address, server, rfile=None):
- # Deprecation: The rfile kwarg was introduced in 1.0a1 as part
- # of a refactoring. It was never documented or used. It is
- # considered DEPRECATED and may be removed in the future. Its
- # use is not supported.
-
- self.socket = sock
- self.client_address = address
- self.server = server
- if rfile is None:
- self.rfile = sock.makefile('rb', -1)
- else:
- self.rfile = rfile
-
- def handle(self):
- """
- The main request handling method, called by the server.
-
- This method runs a request handling loop, calling
- :meth:`handle_one_request` until all requests on the
- connection have been handled (that is, it implements
- keep-alive).
- """
- try:
- while self.socket is not None:
- self.time_start = time.time()
- self.time_finish = 0
-
- result = self.handle_one_request()
- if result is None:
- break
- if result is True:
- continue
-
- self.status, response_body = result
- self.socket.sendall(response_body)
- if self.time_finish == 0:
- self.time_finish = time.time()
- self.log_request()
- break
- finally:
- if self.socket is not None:
- _sock = getattr(self.socket, '_sock', None) # Python 3
- try:
- # read out request data to prevent error: [Errno 104] Connection reset by peer
- if _sock:
- try:
- # socket.recv would hang
- _sock.recv(16384)
- finally:
- _sock.close()
- self.socket.close()
- except socket.error:
- pass
- self.__dict__.pop('socket', None)
- self.__dict__.pop('rfile', None)
-
- def _check_http_version(self):
- version_str = self.request_version
- if not version_str.startswith("HTTP/"):
- return False
- version = tuple(int(x) for x in version_str[5:].split(".")) # "HTTP/"
- if version[1] < 0 or version < (0, 9) or version >= (2, 0):
- return False
- return True
-
- def read_request(self, raw_requestline):
- """
- Parse the incoming request.
-
- Parses various headers into ``self.headers`` using
- :attr:`MessageClass`. Other attributes that are set upon a successful
- return of this method include ``self.content_length`` and ``self.close_connection``.
-
- :param str raw_requestline: A native :class:`str` representing
- the request line. A processed version of this will be stored
- into ``self.requestline``.
-
- :raises ValueError: If the request is invalid. This error will
- not be logged as a traceback (because it's a client issue, not a server problem).
- :return: A boolean value indicating whether the request was successfully parsed.
- This method should either return a true value or have raised a ValueError
- with details about the parsing error.
-
- .. versionchanged:: 1.1b6
- Raise the previously documented :exc:`ValueError` in more cases instead of returning a
- false value; this allows subclasses more opportunity to customize behaviour.
- """
- # pylint:disable=too-many-branches
- self.requestline = raw_requestline.rstrip()
- words = self.requestline.split()
- if len(words) == 3:
- self.command, self.path, self.request_version = words
- if not self._check_http_version():
- raise _InvalidClientRequest('Invalid http version: %r' % (raw_requestline,))
- elif len(words) == 2:
- self.command, self.path = words
- if self.command != "GET":
- raise _InvalidClientRequest('Expected GET method: %r' % (raw_requestline,))
- self.request_version = "HTTP/0.9"
- # QQQ I'm pretty sure we can drop support for HTTP/0.9
- else:
- raise _InvalidClientRequest('Invalid HTTP method: %r' % (raw_requestline,))
-
- self.headers = self.MessageClass(self.rfile, 0)
-
- if self.headers.status:
- raise _InvalidClientRequest('Invalid headers status: %r' % (self.headers.status,))
-
- if self.headers.get("transfer-encoding", "").lower() == "chunked":
- try:
- del self.headers["content-length"]
- except KeyError:
- pass
-
- content_length = self.headers.get("content-length")
- if content_length is not None:
- content_length = int(content_length)
- if content_length < 0:
- raise _InvalidClientRequest('Invalid Content-Length: %r' % (content_length,))
-
- if content_length and self.command in ('HEAD', ):
- raise _InvalidClientRequest('Unexpected Content-Length')
-
- self.content_length = content_length
-
- if self.request_version == "HTTP/1.1":
- conntype = self.headers.get("Connection", "").lower()
- self.close_connection = (conntype == 'close')
- else:
- self.close_connection = True
-
- return True
-
- def log_error(self, msg, *args):
- try:
- message = msg % args
- except Exception: # pylint:disable=broad-except
- traceback.print_exc()
- message = '%r %r' % (msg, args)
- try:
- message = '%s: %s' % (self.socket, message)
- except Exception: # pylint:disable=broad-except
- pass
-
- try:
- self.server.error_log.write(message + '\n')
- except Exception: # pylint:disable=broad-except
- traceback.print_exc()
-
- def read_requestline(self):
- """
- Read and return the HTTP request line.
-
- Under both Python 2 and 3, this should return the native
- ``str`` type; under Python 3, this probably means the bytes read
- from the network need to be decoded (using the ISO-8859-1 charset, aka
- latin-1).
- """
- line = self.rfile.readline(MAX_REQUEST_LINE)
- if PY3:
- line = line.decode('latin-1')
- return line
-
- def handle_one_request(self):
- """
- Handles one HTTP request using ``self.socket`` and ``self.rfile``.
-
- Each invocation of this method will do several things, including (but not limited to):
-
- - Read the request line using :meth:`read_requestline`;
- - Read the rest of the request, including headers, with :meth:`read_request`;
- - Construct a new WSGI environment in ``self.environ`` using :meth:`get_environ`;
- - Store the application in ``self.application``, retrieving it from the server;
- - Handle the remainder of the request, including invoking the application,
- with :meth:`handle_one_response`
-
- There are several possible return values to indicate the state
- of the client connection:
-
- - ``None``
- The client connection is already closed or should
- be closed because the WSGI application or client set the
- ``Connection: close`` header. The request handling
- loop should terminate and perform cleanup steps.
- - (status, body)
- An HTTP status and body tuple. The request was in error,
- as detailed by the status and body. The request handling
- loop should terminate, close the connection, and perform
- cleanup steps. Note that the ``body`` is the complete contents
- to send to the client, including all headers and the initial
- status line.
- - ``True``
- The literal ``True`` value. The request was successfully handled
- and the response sent to the client by :meth:`handle_one_response`.
- The connection remains open to process more requests and the connection
- handling loop should call this method again. This is the typical return
- value.
-
- .. seealso:: :meth:`handle`
-
- .. versionchanged:: 1.1b6
- Funnel exceptions having to do with invalid HTTP requests through
- :meth:`_handle_client_error` to allow subclasses to customize. Note that
- this is experimental and may change in the future.
- """
- # pylint:disable=too-many-return-statements
- if self.rfile.closed:
- return
-
- try:
- self.requestline = self.read_requestline()
- # Account for old subclasses that haven't done this
- if PY3 and isinstance(self.requestline, bytes):
- self.requestline = self.requestline.decode('latin-1')
- except socket.error:
- # "Connection reset by peer" or other socket errors aren't interesting here
- return
-
- if not self.requestline:
- return
-
- self.response_length = 0
-
- if len(self.requestline) >= MAX_REQUEST_LINE:
- return ('414', _REQUEST_TOO_LONG_RESPONSE)
-
- try:
- # for compatibility with older versions of pywsgi, we pass self.requestline as an argument there
- # NOTE: read_request is supposed to raise ValueError on invalid input; allow old
- # subclasses that return a False value instead.
- # NOTE: This can mutate the value of self.headers, so self.get_environ() must not be
- # called until AFTER this call is done.
- if not self.read_request(self.requestline):
- return ('400', _BAD_REQUEST_RESPONSE)
- except Exception as ex: # pylint:disable=broad-except
- # Notice we don't use self.handle_error because it reports
- # a 500 error to the client, and this is almost certainly
- # a client error.
- # Provide a hook for subclasses.
- return self._handle_client_error(ex)
-
- self.environ = self.get_environ()
- self.application = self.server.application
-
- self.handle_one_response()
-
- if self.close_connection:
- return
-
- if self.rfile.closed:
- return
-
- return True # read more requests
-
- def finalize_headers(self):
- if self.provided_date is None:
- self.response_headers.append((b'Date', format_date_time(time.time())))
-
- if self.code not in (304, 204):
- # the reply will include message-body; make sure we have either Content-Length or chunked
- if self.provided_content_length is None:
- if hasattr(self.result, '__len__'):
- total_len = sum(len(chunk) for chunk in self.result)
- total_len_str = str(total_len)
- if PY3:
- total_len_str = total_len_str.encode("latin-1")
- self.response_headers.append((b'Content-Length', total_len_str))
- else:
- if self.request_version != 'HTTP/1.0':
- self.response_use_chunked = True
- self.response_headers.append((b'Transfer-Encoding', b'chunked'))
-
- def _sendall(self, data):
- try:
- self.socket.sendall(data)
- except socket.error as ex:
- self.status = 'socket error: %s' % ex
- if self.code > 0:
- self.code = -self.code
- raise
- self.response_length += len(data)
-
- def _write(self, data,
- _PY34_EXACTLY=(sys.version_info[:2] == (3, 4)),
- _bytearray=bytearray):
- if not data:
- # The application/middleware are allowed to yield
- # empty bytestrings.
- return
-
- if self.response_use_chunked:
- ## Write the chunked encoding
- # header
- if _PY34_EXACTLY:
- # This is the only version we support that doesn't
- # allow % to be used with bytes. Passing a bytestring
- # directly in to bytearray() is faster than passing a
- # (unicode) str with encoding, which naturally is faster still
- # than encoding first. Interestingly, byte formatting on Python 3
- # is faster than str formatting.
- header_str = '%x\r\n' % len(data)
- towrite = _bytearray(header_str, 'ascii')
- else:
- header_str = b'%x\r\n' % len(data)
- towrite = _bytearray(header_str)
-
- # data
- towrite += data
- # trailer
- towrite += b'\r\n'
- self._sendall(towrite)
- else:
- self._sendall(data)
-
- def write(self, data):
- # The write() callable we return from start_response.
- # https://www.python.org/dev/peps/pep-3333/#the-write-callable
- # Supposed to do pretty much the same thing as yielding values
- # from the application's return.
- if self.code in (304, 204) and data:
- raise AssertionError('The %s response must have no body' % self.code)
-
- if self.headers_sent:
- self._write(data)
- else:
- if not self.status:
- raise AssertionError("The application did not call start_response()")
- self._write_with_headers(data)
-
- def _write_with_headers(self, data):
- self.headers_sent = True
- self.finalize_headers()
-
- # self.response_headers and self.status are already in latin-1, as encoded by self.start_response
- towrite = bytearray(b'HTTP/1.1 ')
- towrite += self.status
- towrite += b'\r\n'
- for header, value in self.response_headers:
- towrite += header
- towrite += b': '
- towrite += value
- towrite += b"\r\n"
-
- towrite += b'\r\n'
- self._sendall(towrite)
- # No need to copy the data into towrite; we may make an extra syscall
- # but the copy time could be substantial too, and it reduces the chances
- # of sendall being able to send everything in one go
- self._write(data)
-
- def start_response(self, status, headers, exc_info=None):
- """
- .. versionchanged:: 1.2a1
- Avoid HTTP header injection by raising a :exc:`ValueError`
- if *status* or any *header* name or value contains a carriage
- return or newline.
- .. versionchanged:: 1.1b5
- Pro-actively handle checking the encoding of the status line
- and headers during this method. On Python 2, avoid some
- extra encodings.
- """
- # pylint:disable=too-many-branches,too-many-statements
- if exc_info:
- try:
- if self.headers_sent:
- # Re-raise original exception if headers sent
- reraise(*exc_info)
- finally:
- # Avoid dangling circular ref
- exc_info = None
-
- # Pep 3333, "The start_response callable":
- # https://www.python.org/dev/peps/pep-3333/#the-start-response-callable
- # "Servers should check for errors in the headers at the time
- # start_response is called, so that an error can be raised
- # while the application is still running." Here, we check the encoding.
- # This aids debugging: headers especially are generated programmatically
- # and an encoding error in a loop or list comprehension yields an opaque
- # UnicodeError without any clue which header was wrong.
- # Note that this results in copying the header list at this point, not modifying it,
- # although we are allowed to do so if needed. This slightly increases memory usage.
- # We also check for HTTP Response Splitting vulnerabilities
- response_headers = []
- header = None
- value = None
- try:
- for header, value in headers:
- if not isinstance(header, str):
- raise UnicodeError("The header must be a native string", header, value)
- if not isinstance(value, str):
- raise UnicodeError("The value must be a native string", header, value)
- if '\r' in header or '\n' in header:
- raise ValueError('carriage return or newline in header name', header)
- if '\r' in value or '\n' in value:
- raise ValueError('carriage return or newline in header value', value)
- # Either we're on Python 2, in which case bytes is correct, or
- # we're on Python 3 and the user screwed up (because it should be a native
- # string). In either case, make sure that this is latin-1 compatible. Under
- # Python 2, bytes.encode() will take a round-trip through the system encoding,
- # which may be ascii, which is not really what we want. However, the latin-1 encoding
- # can encode everything except control characters and the block from 0x7F to 0x9F, so
- # explicitly round-tripping bytes through the encoding is unlikely to be of much
- # benefit, so we go for speed (the WSGI spec specifically calls out allowing the range
- # from 0x00 to 0xFF, although the HTTP spec forbids the control characters).
- # Note: Some Python 2 implementations, like Jython, may allow non-octet (above 255) values
- # in their str implementation; this is mentioned in the WSGI spec, but we don't
- # run on any platform like that so we can assume that a str value is pure bytes.
- response_headers.append((header if not PY3 else header.encode("latin-1"),
- value if not PY3 else value.encode("latin-1")))
- except UnicodeEncodeError:
- # If we get here, we're guaranteed to have a header and value
- raise UnicodeError("Non-latin1 header", repr(header), repr(value))
-
- # Same as above
- if not isinstance(status, str):
- raise UnicodeError("The status string must be a native string")
- if '\r' in status or '\n' in status:
- raise ValueError("carriage return or newline in status", status)
- # don't assign to anything until the validation is complete, including parsing the
- # code
- code = int(status.split(' ', 1)[0])
-
- self.status = status if not PY3 else status.encode("latin-1")
- self._orig_status = status # Preserve the native string for logging
- self.response_headers = response_headers
- self.code = code
-
- provided_connection = None
- self.provided_date = None
- self.provided_content_length = None
-
- for header, value in headers:
- header = header.lower()
- if header == 'connection':
- provided_connection = value
- elif header == 'date':
- self.provided_date = value
- elif header == 'content-length':
- self.provided_content_length = value
-
- if self.request_version == 'HTTP/1.0' and provided_connection is None:
- response_headers.append((b'Connection', b'close'))
- self.close_connection = True
- elif provided_connection == 'close':
- self.close_connection = True
-
- if self.code in (304, 204):
- if self.provided_content_length is not None and self.provided_content_length != '0':
- msg = 'Invalid Content-Length for %s response: %r (must be absent or zero)' % (self.code, self.provided_content_length)
- if PY3:
- msg = msg.encode('latin-1')
- raise AssertionError(msg)
-
- return self.write
-
- def log_request(self):
- self.server.log.write(self.format_request() + '\n')
-
- def format_request(self):
- now = datetime.now().replace(microsecond=0)
- length = self.response_length or '-'
- if self.time_finish:
- delta = '%.6f' % (self.time_finish - self.time_start)
- else:
- delta = '-'
- client_address = self.client_address[0] if isinstance(self.client_address, tuple) else self.client_address
- return '%s - - [%s] "%s" %s %s %s' % (
- client_address or '-',
- now,
- self.requestline or '',
- # Use the native string version of the status, saved so we don't have to
- # decode. But fallback to the encoded 'status' in case of subclasses
- # (Is that really necessary? At least there's no overhead.)
- (self._orig_status or self.status or '000').split()[0],
- length,
- delta)
-
- def process_result(self):
- for data in self.result:
- if data:
- self.write(data)
- if self.status and not self.headers_sent:
- # In other words, the application returned an empty
- # result iterable (and did not use the write callable)
- # Trigger the flush of the headers.
- self.write(b'')
- if self.response_use_chunked:
- self._sendall(b'0\r\n\r\n')
-
-
- def run_application(self):
- assert self.result is None
- try:
- self.result = self.application(self.environ, self.start_response)
- self.process_result()
- finally:
- close = getattr(self.result, 'close', None)
- try:
- if close is not None:
- close()
- finally:
- # Discard the result. If it's a generator this can
- # free a lot of hidden resources (if we failed to iterate
- # all the way through it---the frames are automatically
- # cleaned up when StopIteration is raised); but other cases
- # could still free up resources sooner than otherwise.
- close = None
- self.result = None
-
- #: These errors are silently ignored by :meth:`handle_one_response` to avoid producing
- #: excess log entries on normal operating conditions. They indicate
- #: a remote client has disconnected and there is little or nothing
- #: this process can be expected to do about it. You may change this
- #: value in a subclass.
- #:
- #: The default value includes :data:`errno.EPIPE` and :data:`errno.ECONNRESET`.
- #: On Windows this also includes :data:`errno.WSAECONNABORTED`.
- #:
- #: This is a provisional API, subject to change. See :pr:`377`, :pr:`999`
- #: and :issue:`136`.
- #:
- #: .. versionadded:: 1.3
- ignored_socket_errors = (errno.EPIPE, errno.ECONNRESET)
- try:
- ignored_socket_errors += (errno.WSAECONNABORTED,)
- except AttributeError:
- pass # Not windows
-
- def handle_one_response(self):
- """
- Invoke the application to produce one response.
-
- This is called by :meth:`handle_one_request` after all the
- state for the request has been established. It is responsible
- for error handling.
- """
- self.time_start = time.time()
- self.status = None
- self.headers_sent = False
-
- self.result = None
- self.response_use_chunked = False
- self.response_length = 0
-
- try:
- try:
- self.run_application()
- finally:
- try:
- self.wsgi_input._discard()
- except (socket.error, IOError):
- # Don't let exceptions during discarding
- # input override any exception that may have been
- # raised by the application, such as our own _InvalidClientInput.
- # In the general case, these aren't even worth logging (see the comment
- # just below)
- pass
- except _InvalidClientInput:
- self._send_error_response_if_possible(400)
- except socket.error as ex:
- if ex.args[0] in self.ignored_socket_errors:
- # See description of self.ignored_socket_errors.
- if not PY3:
- sys.exc_clear()
- self.close_connection = True
- else:
- self.handle_error(*sys.exc_info())
- except: # pylint:disable=bare-except
- self.handle_error(*sys.exc_info())
- finally:
- self.time_finish = time.time()
- self.log_request()
-
- def _send_error_response_if_possible(self, error_code):
- if self.response_length:
- self.close_connection = True
- else:
- status, headers, body = _ERRORS[error_code]
- try:
- self.start_response(status, headers[:])
- self.write(body)
- except socket.error:
- if not PY3:
- sys.exc_clear()
- self.close_connection = True
-
- def _log_error(self, t, v, tb):
- # TODO: Shouldn't we dump this to wsgi.errors? If we did that now, it would
- # wind up getting logged twice
- if not issubclass(t, GreenletExit):
- context = self.environ
- if not isinstance(context, self.server.secure_environ_class):
- context = self.server.secure_environ_class(context)
- self.server.loop.handle_error(context, t, v, tb)
-
- def handle_error(self, t, v, tb):
- # Called for internal, unexpected errors, NOT invalid client input
- self._log_error(t, v, tb)
- del tb
- self._send_error_response_if_possible(500)
-
- def _handle_client_error(self, ex):
- # Called for invalid client input
- # Returns the appropriate error response.
- if not isinstance(ex, ValueError):
- # XXX: Why not self._log_error to send it through the loop's
- # handle_error method?
- traceback.print_exc()
- if isinstance(ex, _InvalidClientRequest):
- # These come with good error messages, and we want to let
- # log_error deal with the formatting, especially to handle encoding
- self.log_error(*ex.args)
- else:
- self.log_error('Invalid request: %s', str(ex) or ex.__class__.__name__)
- return ('400', _BAD_REQUEST_RESPONSE)
-
- def _headers(self):
- key = None
- value = None
- IGNORED_KEYS = (None, 'CONTENT_TYPE', 'CONTENT_LENGTH')
- for header in self.headers.headers:
- if key is not None and header[:1] in " \t":
- value += header
- continue
-
- if key not in IGNORED_KEYS:
- yield 'HTTP_' + key, value.strip()
-
- key, value = header.split(':', 1)
- if '_' in key:
- # strip incoming bad veaders
- key = None
- else:
- key = key.replace('-', '_').upper()
-
- if key not in IGNORED_KEYS:
- yield 'HTTP_' + key, value.strip()
-
- def get_environ(self):
- """
- Construct and return a new WSGI environment dictionary for a specific request.
-
- This should begin with asking the server for the base environment
- using :meth:`WSGIServer.get_environ`, and then proceed to add the
- request specific values.
-
- By the time this method is invoked the request line and request shall have
- been parsed and ``self.headers`` shall be populated.
- """
- env = self.server.get_environ()
- env['REQUEST_METHOD'] = self.command
- env['SCRIPT_NAME'] = ''
-
- if '?' in self.path:
- path, query = self.path.split('?', 1)
- else:
- path, query = self.path, ''
- # Note that self.path contains the original str object; if it contains
- # encoded escapes, it will NOT match PATH_INFO.
- env['PATH_INFO'] = unquote_latin1(path)
- env['QUERY_STRING'] = query
-
- if self.headers.typeheader is not None:
- env['CONTENT_TYPE'] = self.headers.typeheader
-
- length = self.headers.getheader('content-length')
- if length:
- env['CONTENT_LENGTH'] = length
- env['SERVER_PROTOCOL'] = self.request_version
-
- client_address = self.client_address
- if isinstance(client_address, tuple):
- env['REMOTE_ADDR'] = str(client_address[0])
- env['REMOTE_PORT'] = str(client_address[1])
-
- for key, value in self._headers():
- if key in env:
- if 'COOKIE' in key:
- env[key] += '; ' + value
- else:
- env[key] += ',' + value
- else:
- env[key] = value
-
- if env.get('HTTP_EXPECT') == '100-continue':
- sock = self.socket
- else:
- sock = None
-
- chunked = env.get('HTTP_TRANSFER_ENCODING', '').lower() == 'chunked'
- self.wsgi_input = Input(self.rfile, self.content_length, socket=sock, chunked_input=chunked)
- env['wsgi.input'] = self.wsgi_input
- return env
-
-
-class _NoopLog(object):
- # Does nothing; implements just enough file-like methods
- # to pass the WSGI validator
-
- def write(self, *args, **kwargs):
- # pylint:disable=unused-argument
- return
-
- def flush(self):
- pass
-
- def writelines(self, *args, **kwargs):
- pass
-
-
-class LoggingLogAdapter(object):
- """
- An adapter for :class:`logging.Logger` instances
- to let them be used with :class:`WSGIServer`.
-
- .. warning:: Unless the entire process is monkey-patched at a very
- early part of the lifecycle (before logging is configured),
- loggers are likely to not be gevent-cooperative. For example,
- the socket and syslog handlers use the socket module in a way
- that can block, and most handlers acquire threading locks.
-
- .. warning:: It *may* be possible for the logging functions to be
- called in the :class:`gevent.Hub` greenlet. Code running in the
- hub greenlet cannot use any gevent blocking functions without triggering
- a ``LoopExit``.
-
- .. versionadded:: 1.1a3
-
- .. versionchanged:: 1.1b6
- Attributes not present on this object are proxied to the underlying
- logger instance. This permits using custom :class:`~logging.Logger`
- subclasses (or indeed, even duck-typed objects).
-
- .. versionchanged:: 1.1
- Strip trailing newline characters on the message passed to :meth:`write`
- because log handlers will usually add one themselves.
- """
-
- # gevent avoids importing and using logging because importing it and
- # creating loggers creates native locks unless monkey-patched.
-
- __slots__ = ('_logger', '_level')
-
- def __init__(self, logger, level=20):
- """
- Write information to the *logger* at the given *level* (default to INFO).
- """
- self._logger = logger
- self._level = level
-
- def write(self, msg):
- if msg and msg.endswith('\n'):
- msg = msg[:-1]
- self._logger.log(self._level, msg)
-
- def flush(self):
- "No-op; required to be a file-like object"
- pass
-
- def writelines(self, lines):
- for line in lines:
- self.write(line)
-
- def __getattr__(self, name):
- return getattr(self._logger, name)
-
- def __setattr__(self, name, value):
- if name not in LoggingLogAdapter.__slots__:
- setattr(self._logger, name, value)
- else:
- object.__setattr__(self, name, value)
-
- def __delattr__(self, name):
- delattr(self._logger, name)
-
-####
-## Environ classes.
-# These subclass dict. They could subclass collections.UserDict on
-# 3.3+ and proxy to the underlying real dict to avoid a copy if we
-# have to print them (on 2.7 it's slightly more complicated to be an
-# instance of collections.MutableMapping; UserDict.UserDict isn't.)
-# Then we could have either the WSGIHandler.get_environ or the
-# WSGIServer.get_environ return one of these proxies, and
-# WSGIHandler.run_application would know to access the `environ.data`
-# attribute to be able to pass the *real* dict to the application
-# (because PEP3333 requires no subclasses, only actual dict objects;
-# wsgiref.validator and webob.Request both enforce this). This has the
-# advantage of not being fragile if anybody else tries to print/log
-# self.environ (and not requiring a copy). However, if there are any
-# subclasses of Handler or Server, this could break if they don't know
-# to return this type.
-####
-
-class Environ(dict):
- """
- A base class that can be used for WSGI environment objects.
-
- Provisional API.
-
- .. versionadded:: 1.2a1
- """
-
- __slots__ = () # add no ivars or weakref ability
-
- def copy(self):
- return self.__class__(self)
-
- if not hasattr(dict, 'iteritems'):
- # Python 3
- def iteritems(self):
- return self.items()
-
- def __reduce_ex__(self, proto):
- return (dict, (), None, None, iter(self.iteritems()))
-
-class SecureEnviron(Environ):
- """
- An environment that does not print its keys and values
- by default.
-
- Provisional API.
-
- This is intended to keep potentially sensitive information like
- HTTP authorization and cookies from being inadvertently printed
- or logged.
-
- For debugging, each instance can have its *secure_repr* attribute
- set to ``False``, which will cause it to print like a normal dict.
-
- When *secure_repr* is ``True`` (the default), then the value of
- the *whitelist_keys* attribute is consulted; if this value is
- true-ish, it should be a container (something that responds to
- ``in``) of key names (typically a list or set). Keys and values in
- this dictionary that are in *whitelist_keys* will then be printed,
- while all other values will be masked. These values may be
- customized on the class by setting the *default_secure_repr* and
- *default_whitelist_keys*, respectively::
-
- >>> environ = SecureEnviron(key='value')
- >>> environ # doctest: +ELLIPSIS
- <pywsgi.SecureEnviron dict (keys: 1) at ...
-
- If we whitelist the key, it gets printed::
-
- >>> environ.whitelist_keys = {'key'}
- >>> environ
- {'key': 'value'}
-
- A non-whitelisted key (*only*, to avoid doctest issues) is masked::
-
- >>> environ['secure'] = 'secret'; del environ['key']
- >>> environ
- {'secure': '<MASKED>'}
-
- We can turn it off entirely for the instance::
-
- >>> environ.secure_repr = False
- >>> environ
- {'secure': 'secret'}
-
- We can also customize it at the class level (here we use a new
- class to be explicit and to avoid polluting the true default
- values; we would set this class to be the ``environ_class`` of the
- server)::
-
- >>> class MyEnviron(SecureEnviron):
- ... default_whitelist_keys = ('key',)
- ...
- >>> environ = MyEnviron({'key': 'value'})
- >>> environ
- {'key': 'value'}
-
- .. versionadded:: 1.2a1
- """
-
- default_secure_repr = True
- default_whitelist_keys = ()
- default_print_masked_keys = True
-
- # Allow instances to override the class values,
- # but inherit from the class if not present. Keeps instances
- # small since we can't combine __slots__ with class attributes
- # of the same name.
- __slots__ = ('secure_repr', 'whitelist_keys', 'print_masked_keys')
-
- def __getattr__(self, name):
- if name in SecureEnviron.__slots__:
- return getattr(type(self), 'default_' + name)
- raise AttributeError(name)
-
- def __repr__(self):
- if self.secure_repr:
- whitelist = self.whitelist_keys
- print_masked = self.print_masked_keys
- if whitelist:
- safe = {k: self[k] if k in whitelist else "<MASKED>"
- for k in self
- if k in whitelist or print_masked}
- safe_repr = repr(safe)
- if not print_masked and len(safe) != len(self):
- safe_repr = safe_repr[:-1] + ", (hidden keys: %d)}" % (len(self) - len(safe))
- return safe_repr
- return "<pywsgi.SecureEnviron dict (keys: %d) at %s>" % (len(self), id(self))
- return Environ.__repr__(self)
- __str__ = __repr__
-
-
-class WSGISecureEnviron(SecureEnviron):
- """
- Specializes the default list of whitelisted keys to a few
- common WSGI variables.
-
- Example::
-
- >>> environ = WSGISecureEnviron(REMOTE_ADDR='::1', HTTP_AUTHORIZATION='secret')
- >>> environ
- {'REMOTE_ADDR': '::1', (hidden keys: 1)}
- >>> import pprint
- >>> pprint.pprint(environ)
- {'REMOTE_ADDR': '::1', (hidden keys: 1)}
- >>> print(pprint.pformat(environ))
- {'REMOTE_ADDR': '::1', (hidden keys: 1)}
- """
- default_whitelist_keys = ('REMOTE_ADDR', 'REMOTE_PORT', 'HTTP_HOST')
- default_print_masked_keys = False
-
-
-class WSGIServer(StreamServer):
- """
- A WSGI server based on :class:`StreamServer` that supports HTTPS.
-
-
- :keyword log: If given, an object with a ``write`` method to which
- request (access) logs will be written. If not given, defaults
- to :obj:`sys.stderr`. You may pass ``None`` to disable request
- logging. You may use a wrapper, around e.g., :mod:`logging`,
- to support objects that don't implement a ``write`` method.
- (If you pass a :class:`~logging.Logger` instance, or in
- general something that provides a ``log`` method but not a
- ``write`` method, such a wrapper will automatically be created
- and it will be logged to at the :data:`~logging.INFO` level.)
-
- :keyword error_log: If given, a file-like object with ``write``,
- ``writelines`` and ``flush`` methods to which error logs will
- be written. If not given, defaults to :obj:`sys.stderr`. You
- may pass ``None`` to disable error logging (not recommended).
- You may use a wrapper, around e.g., :mod:`logging`, to support
- objects that don't implement the proper methods. This
- parameter will become the value for ``wsgi.errors`` in the
- WSGI environment (if not already set). (As with *log*,
- wrappers for :class:`~logging.Logger` instances and the like
- will be created automatically and logged to at the :data:`~logging.ERROR`
- level.)
-
- .. seealso::
-
- :class:`LoggingLogAdapter`
- See important warnings before attempting to use :mod:`logging`.
-
- .. versionchanged:: 1.1a3
- Added the ``error_log`` parameter, and set ``wsgi.errors`` in the WSGI
- environment to this value.
- .. versionchanged:: 1.1a3
- Add support for passing :class:`logging.Logger` objects to the ``log`` and
- ``error_log`` arguments.
- """
-
- #: A callable taking three arguments: (socket, address, server) and returning
- #: an object with a ``handle()`` method. The callable is called once for
- #: each incoming socket request, as is its handle method. The handle method should not
- #: return until all use of the socket is complete.
- #:
- #: This class uses the :class:`WSGIHandler` object as the default value. You may
- #: subclass this class and set a different default value, or you may pass
- #: a value to use in the ``handler_class`` keyword constructor argument.
- handler_class = WSGIHandler
-
- #: The object to which request logs will be written.
- #: It must never be None. Initialized from the ``log`` constructor
- #: parameter.
- log = None
-
- #: The object to which error logs will be written.
- #: It must never be None. Initialized from the ``error_log`` constructor
- #: parameter.
- error_log = None
-
- #: The class of environ objects passed to the handlers.
- #: Must be a dict subclass. For compliance with :pep:`3333`
- #: and libraries like WebOb, this is simply :class:`dict`
- #: but this can be customized in a subclass or per-instance
- #: (probably to :class:`WSGISecureEnviron`).
- #:
- #: .. versionadded:: 1.2a1
- environ_class = dict
-
- # Undocumented internal detail: the class that WSGIHandler._log_error
- # will cast to before passing to the loop.
- secure_environ_class = WSGISecureEnviron
-
- base_env = {'GATEWAY_INTERFACE': 'CGI/1.1',
- 'SERVER_SOFTWARE': 'gevent/%d.%d Python/%d.%d' % (gevent.version_info[:2] + sys.version_info[:2]),
- 'SCRIPT_NAME': '',
- 'wsgi.version': (1, 0),
- 'wsgi.multithread': False, # XXX: Aren't we really, though?
- 'wsgi.multiprocess': False,
- 'wsgi.run_once': False}
-
- def __init__(self, listener, application=None, backlog=None, spawn='default',
- log='default', error_log='default',
- handler_class=None,
- environ=None, **ssl_args):
- StreamServer.__init__(self, listener, backlog=backlog, spawn=spawn, **ssl_args)
- if application is not None:
- self.application = application
- if handler_class is not None:
- self.handler_class = handler_class
-
- # Note that we can't initialize these as class variables:
- # sys.stderr might get monkey patched at runtime.
- def _make_log(l, level=20):
- if l == 'default':
- return sys.stderr
- if l is None:
- return _NoopLog()
- if not hasattr(l, 'write') and hasattr(l, 'log'):
- return LoggingLogAdapter(l, level)
- return l
- self.log = _make_log(log)
- self.error_log = _make_log(error_log, 40) # logging.ERROR
-
- self.set_environ(environ)
- self.set_max_accept()
-
- def set_environ(self, environ=None):
- if environ is not None:
- self.environ = environ
- environ_update = getattr(self, 'environ', None)
-
- self.environ = self.environ_class(self.base_env)
- if self.ssl_enabled:
- self.environ['wsgi.url_scheme'] = 'https'
- else:
- self.environ['wsgi.url_scheme'] = 'http'
- if environ_update is not None:
- self.environ.update(environ_update)
- if self.environ.get('wsgi.errors') is None:
- self.environ['wsgi.errors'] = self.error_log
-
- def set_max_accept(self):
- if self.environ.get('wsgi.multiprocess'):
- self.max_accept = 1
-
- def get_environ(self):
- return self.environ_class(self.environ)
-
- def init_socket(self):
- StreamServer.init_socket(self)
- self.update_environ()
-
- def update_environ(self):
- """
- Called before the first request is handled to fill in WSGI environment values.
-
- This includes getting the correct server name and port.
- """
- address = self.address
- if isinstance(address, tuple):
- if 'SERVER_NAME' not in self.environ:
- try:
- name = socket.getfqdn(address[0])
- except socket.error:
- name = str(address[0])
- if PY3 and not isinstance(name, str):
- name = name.decode('ascii')
- self.environ['SERVER_NAME'] = name
- self.environ.setdefault('SERVER_PORT', str(address[1]))
- else:
- self.environ.setdefault('SERVER_NAME', '')
- self.environ.setdefault('SERVER_PORT', '')
-
- def handle(self, sock, address):
- """
- Create an instance of :attr:`handler_class` to handle the request.
-
- This method blocks until the handler returns.
- """
- # pylint:disable=method-hidden
- handler = self.handler_class(sock, address, self)
- handler.handle()
-
-def _main():
- # Provisional main handler, for quick tests, not production
- # usage.
- from gevent import monkey; monkey.patch_all()
-
- import argparse
- import importlib
-
- parser = argparse.ArgumentParser()
- parser.add_argument("app", help="dotted name of WSGI app callable [module:callable]")
- parser.add_argument("-b", "--bind",
- help="The socket to bind",
- default=":8080")
-
- args = parser.parse_args()
-
- module_name, app_name = args.app.split(':')
- module = importlib.import_module(module_name)
- app = getattr(module, app_name)
- bind = args.bind
-
- server = WSGIServer(bind, app)
- server.serve_forever()
-
-if __name__ == '__main__':
- _main()
diff --git a/python/gevent/queue.c b/python/gevent/queue.c
deleted file mode 100644
index 742cb1a..0000000
--- a/python/gevent/queue.c
+++ /dev/null
@@ -1,22127 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "depends": [
- "src/gevent/_queue.pxd",
- "src\\gevent\\_queue.pxd"
- ],
- "include_dirs": [
- "C:\\Python36\\Include",
- "deps"
- ],
- "name": "gevent._queue",
- "sources": [
- "src/gevent/queue.py"
- ]
- },
- "module_name": "gevent._queue"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 0
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent___queue
-#define __PYX_HAVE_API__gevent___queue
-/* Early includes */
-#include "greenlet/greenlet.h"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\queue.py",
- "src\\gevent\\_queue.pxd",
- "src\\gevent\\__greenlet_primitives.pxd",
- "src\\gevent\\__waiter.pxd",
- "src\\gevent\\_event.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet;
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-struct __pyx_obj_6gevent_8__waiter_Waiter;
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter;
-struct __pyx_obj_6gevent_6_event__AbstractLinkable;
-struct __pyx_obj_6gevent_6_event_Event;
-struct __pyx_obj_6gevent_6_event_AsyncResult;
-struct __pyx_obj_6gevent_6_queue_ItemWaiter;
-struct __pyx_obj_6gevent_6_queue_Queue;
-struct __pyx_obj_6gevent_6_queue_UnboundQueue;
-struct __pyx_obj_6gevent_6_queue_PriorityQueue;
-struct __pyx_obj_6gevent_6_queue_LifoQueue;
-struct __pyx_obj_6gevent_6_queue_JoinableQueue;
-struct __pyx_obj_6gevent_6_queue_Channel;
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core;
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get;
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait;
-
-/* "gevent/_event.pxd":55
- * @cython.locals(todo=set)
- * cpdef _notify_links(self)
- * cdef _wait_core(self, timeout, catch=*) # <<<<<<<<<<<<<<
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*)
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core {
- int __pyx_n;
- PyObject *catch;
-};
-
-/* "gevent/_event.pxd":57
- * cdef _wait_core(self, timeout, catch=*)
- * cdef _wait_return_value(self, waited, wait_success)
- * cdef _wait(self, timeout=*) # <<<<<<<<<<<<<<
- *
- *
- */
-struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait {
- int __pyx_n;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":70
- * cdef public int _imap_task_index
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint successful(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_event.pxd":73
- * cpdef bint successful(self)
- *
- * cpdef wait(self, timeout=*) # <<<<<<<<<<<<<<
- * cpdef bint done(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait {
- int __pyx_n;
- PyObject *timeout;
-};
-struct __pyx_opt_args_6gevent_6_queue_5Queue_put;
-struct __pyx_opt_args_6gevent_6_queue_5Queue_get;
-struct __pyx_opt_args_6gevent_6_queue_5Queue_peek;
-struct __pyx_opt_args_6gevent_6_queue_7Channel_get;
-struct __pyx_opt_args_6gevent_6_queue_12UnboundQueue_put;
-
-/* "gevent/_queue.pxd":37
- * cpdef bint full(self)
- *
- * cpdef put(self, item, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef put_nowait(self, item)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_put {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":42
- * cdef __get_or_peek(self, method, block, timeout)
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef get_nowait(self)
- * cpdef peek(self, block=*, timeout=*)
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":44
- * cpdef get(self, block=*, timeout=*)
- * cpdef get_nowait(self)
- * cpdef peek(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef peek_nowait(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_5Queue_peek {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/_queue.pxd":71
- * cdef _event_unlock
- *
- * cpdef get(self, block=*, timeout=*) # <<<<<<<<<<<<<<
- * cpdef get_nowait(self)
- *
- */
-struct __pyx_opt_args_6gevent_6_queue_7Channel_get {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "src/gevent/queue.py":425
- * self.putters = None # Will never be used.
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * self._put(item)
- * if self.getters:
- */
-struct __pyx_opt_args_6gevent_6_queue_12UnboundQueue_put {
- int __pyx_n;
- PyObject *block;
- PyObject *timeout;
-};
-
-/* "gevent/__greenlet_primitives.pxd":37
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- * cdef class TrackedRawGreenlet(greenlet): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet {
- PyGreenlet __pyx_base;
-};
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet __pyx_base;
- struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtab;
- PyObject *loop;
-};
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-struct __pyx_obj_6gevent_8__waiter_Waiter {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtab;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
- PyGreenlet *greenlet;
- PyObject *value;
- PyObject *_exception;
-};
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-struct __pyx_obj_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *_values;
-};
-
-
-/* "gevent/_event.pxd":38
- * cdef void _init()
- *
- * cdef class _AbstractLinkable: # <<<<<<<<<<<<<<
- * # We declare the __weakref__ here in the base (even though
- * # that's not really what we want) as a workaround for a Cython
- */
-struct __pyx_obj_6gevent_6_event__AbstractLinkable {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *_notifier;
- PyObject *_links;
- struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *hub;
-};
-
-
-/* "gevent/_event.pxd":60
- *
- *
- * cdef class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef bint _flag
- *
- */
-struct __pyx_obj_6gevent_6_event_Event {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- int _flag;
-};
-
-
-/* "gevent/_event.pxd":63
- * cdef bint _flag
- *
- * cdef class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef readonly _value
- * cdef readonly tuple _exc_info
- */
-struct __pyx_obj_6gevent_6_event_AsyncResult {
- struct __pyx_obj_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *_value;
- PyObject *_exc_info;
- int _imap_task_index;
-};
-
-
-/* "gevent/_queue.pxd":14
- * @cython.final
- * @cython.internal
- * cdef class ItemWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef readonly item
- * cdef readonly queue
- */
-struct __pyx_obj_6gevent_6_queue_ItemWaiter {
- struct __pyx_obj_6gevent_8__waiter_Waiter __pyx_base;
- PyObject *item;
- PyObject *queue;
-};
-
-
-/* "gevent/_queue.pxd":18
- * cdef readonly queue
- *
- * cdef class Queue: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly hub
- */
-struct __pyx_obj_6gevent_6_queue_Queue {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_queue_Queue *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *hub;
- PyObject *queue;
- PyObject *getters;
- PyObject *putters;
- PyObject *_event_unlock;
- Py_ssize_t _maxsize;
-};
-
-
-/* "gevent/_queue.pxd":50
- *
- * @cython.final
- * cdef class UnboundQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_UnboundQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":53
- * pass
- *
- * cdef class PriorityQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_PriorityQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":56
- * pass
- *
- * cdef class LifoQueue(Queue): # <<<<<<<<<<<<<<
- * pass
- *
- */
-struct __pyx_obj_6gevent_6_queue_LifoQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
-};
-
-
-/* "gevent/_queue.pxd":59
- * pass
- *
- * cdef class JoinableQueue(Queue): # <<<<<<<<<<<<<<
- * cdef Event _cond
- * cdef readonly int unfinished_tasks
- */
-struct __pyx_obj_6gevent_6_queue_JoinableQueue {
- struct __pyx_obj_6gevent_6_queue_Queue __pyx_base;
- struct __pyx_obj_6gevent_6_event_Event *_cond;
- int unfinished_tasks;
-};
-
-
-/* "gevent/_queue.pxd":64
- *
- *
- * cdef class Channel: # <<<<<<<<<<<<<<
- * cdef __weakref__
- * cdef readonly getters
- */
-struct __pyx_obj_6gevent_6_queue_Channel {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_6_queue_Channel *__pyx_vtab;
- PyObject *__weakref__;
- PyObject *getters;
- PyObject *putters;
- PyObject *hub;
- PyObject *_event_unlock;
-};
-
-
-
-/* "gevent/__greenlet_primitives.pxd":40
- * pass
- *
- * cdef class SwitchOutGreenletWithLoop(TrackedRawGreenlet): # <<<<<<<<<<<<<<
- * cdef public loop
- *
- */
-
-struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop {
- PyObject *(*__pyx_switch)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
- PyObject *(*switch_out)(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop;
-
-
-/* "gevent/__waiter.pxd":33
- * _greenlet_imported = True
- *
- * cdef class Waiter: # <<<<<<<<<<<<<<
- * cdef readonly SwitchOutGreenletWithLoop hub
- * cdef readonly greenlet greenlet
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_Waiter {
- PyObject *(*get)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
- PyObject *(*clear)(struct __pyx_obj_6gevent_8__waiter_Waiter *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *__pyx_vtabptr_6gevent_8__waiter_Waiter;
-
-
-/* "gevent/__waiter.pxd":47
- * @cython.final
- * @cython.internal
- * cdef class MultipleWaiter(Waiter): # <<<<<<<<<<<<<<
- * cdef list _values
- */
-
-struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter *__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter;
-
-
-/* "gevent/_event.pxd":38
- * cdef void _init()
- *
- * cdef class _AbstractLinkable: # <<<<<<<<<<<<<<
- * # We declare the __weakref__ here in the base (even though
- * # that's not really what we want) as a workaround for a Cython
- */
-
-struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable {
- PyObject *(*rawlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- int (*ready)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*unlink)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_check_and_notify)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *);
- PyObject *(*_notify_links)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, int __pyx_skip_dispatch);
- PyObject *(*_wait_core)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait_core *__pyx_optional_args);
- PyObject *(*_wait_return_value)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, PyObject *, PyObject *);
- PyObject *(*_wait)(struct __pyx_obj_6gevent_6_event__AbstractLinkable *, struct __pyx_opt_args_6gevent_6_event_17_AbstractLinkable__wait *__pyx_optional_args);
-};
-static struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable *__pyx_vtabptr_6gevent_6_event__AbstractLinkable;
-
-
-/* "gevent/_event.pxd":60
- *
- *
- * cdef class Event(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef bint _flag
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_Event {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_event_Event *__pyx_vtabptr_6gevent_6_event_Event;
-
-
-/* "gevent/_event.pxd":63
- * cdef bint _flag
- *
- * cdef class AsyncResult(_AbstractLinkable): # <<<<<<<<<<<<<<
- * cdef readonly _value
- * cdef readonly tuple _exc_info
- */
-
-struct __pyx_vtabstruct_6gevent_6_event_AsyncResult {
- struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable __pyx_base;
- PyObject *(*get)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_get *__pyx_optional_args);
- int (*successful)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- PyObject *(*wait)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_event_11AsyncResult_wait *__pyx_optional_args);
- int (*done)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancel)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
- int (*cancelled)(struct __pyx_obj_6gevent_6_event_AsyncResult *, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_6_event_AsyncResult *__pyx_vtabptr_6gevent_6_event_AsyncResult;
-
-
-/* "src/gevent/queue.py":75
- * locals()['Waiter'] = gevent._waiter.Waiter
- *
- * class ItemWaiter(Waiter): # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * # pylint:disable=assigning-non-slot
- * __slots__ = (
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter {
- struct __pyx_vtabstruct_6gevent_8__waiter_Waiter __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter *__pyx_vtabptr_6gevent_6_queue_ItemWaiter;
-
-
-/* "src/gevent/queue.py":93
- * return self.switch(self)
- *
- * class Queue(object): # <<<<<<<<<<<<<<
- * """
- * Create a queue object with a given maximum size.
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_Queue {
- PyObject *(*_get)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*_put)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*_peek)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- Py_ssize_t (*qsize)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- int (*empty)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- int (*full)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*put)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args);
- PyObject *(*put_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch);
- PyObject *(*__pyx___get_or_peek)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, PyObject *, PyObject *);
- PyObject *(*get)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_get *__pyx_optional_args);
- PyObject *(*get_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*peek)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_peek *__pyx_optional_args);
- PyObject *(*peek_nowait)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch);
- PyObject *(*_schedule_unlock)(struct __pyx_obj_6gevent_6_queue_Queue *);
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Queue *__pyx_vtabptr_6gevent_6_queue_Queue;
-
-
-/* "src/gevent/queue.py":413
- *
- *
- * class UnboundQueue(Queue): # <<<<<<<<<<<<<<
- * # A specialization of Queue that knows it can never
- * # be bound. Changing its maxsize has no effect.
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *__pyx_vtabptr_6gevent_6_queue_UnboundQueue;
-
-
-/* "src/gevent/queue.py":431
- *
- *
- * class PriorityQueue(Queue): # <<<<<<<<<<<<<<
- * '''A subclass of :class:`Queue` that retrieves entries in priority order (lowest first).
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue *__pyx_vtabptr_6gevent_6_queue_PriorityQueue;
-
-
-/* "src/gevent/queue.py":456
- *
- *
- * class LifoQueue(Queue): # <<<<<<<<<<<<<<
- * '''A subclass of :class:`Queue` that retrieves most recently added entries first.'''
- *
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue *__pyx_vtabptr_6gevent_6_queue_LifoQueue;
-
-
-/* "src/gevent/queue.py":474
- *
- *
- * class JoinableQueue(Queue): # <<<<<<<<<<<<<<
- * """
- * A subclass of :class:`Queue` that additionally has
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue {
- struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_base;
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue *__pyx_vtabptr_6gevent_6_queue_JoinableQueue;
-
-
-/* "src/gevent/queue.py":560
- *
- *
- * class Channel(object): # <<<<<<<<<<<<<<
- *
- * __slots__ = (
- */
-
-struct __pyx_vtabstruct_6gevent_6_queue_Channel {
- PyObject *(*get)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_7Channel_get *__pyx_optional_args);
- PyObject *(*get_nowait)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch);
- PyObject *(*_schedule_unlock)(struct __pyx_obj_6gevent_6_queue_Channel *);
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Channel *__pyx_vtabptr_6gevent_6_queue_Channel;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* PyIntBinop.proto */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
-#else
-#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
- PyObject_RichCompare(op1, op2, Py_EQ)
- #endif
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- Py_SIZE(list) = len+1;
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyObjectCallMethod1.proto */
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
-static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
-
-/* append.proto */
-static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* StringJoin.proto */
-#if PY_MAJOR_VERSION < 3
-#define __Pyx_PyString_Join __Pyx_PyBytes_Join
-#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
-#else
-#define __Pyx_PyString_Join PyUnicode_Join
-#define __Pyx_PyBaseString_Join PyUnicode_Join
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION < 3
- #define __Pyx_PyBytes_Join _PyString_Join
- #else
- #define __Pyx_PyBytes_Join _PyBytes_Join
- #endif
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
-#endif
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* None.proto */
-static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
-
-/* PyObjectCallMethod0.proto */
-static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
-
-/* pop.proto */
-static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
-#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
- __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
-#else
-#define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L)
-#define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L)
-#endif
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod0.proto */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_CallUnboundCMethod0(cfunc, self)\
- (likely((cfunc)->func) ?\
- (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\
- (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
- (PY_VERSION_HEX >= 0x030700A0 ?\
- (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
- (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
- (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
- ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\
- __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
- __Pyx__CallUnboundCMethod0(cfunc, self))
-#else
-#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
-#endif
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* CallNextTpDealloc.proto */
-static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);
-
-/* CallNextTpTraverse.proto */
-static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
-
-/* CallNextTpClear.proto */
-static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
-
-/* GetVTable.proto */
-static void* __Pyx_GetVtable(PyObject *dict);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* HasAttr.proto */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* GetNameInClass.proto */
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
-
-/* Globals.proto */
-static PyObject* __Pyx_Globals(void);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* VoidPtrExport.proto */
-static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);
-
-/* FunctionExport.proto */
-static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* VoidPtrImport.proto */
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
-
-/* FunctionImport.proto */
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch); /* proto*/
-static Py_ssize_t __pyx_f_6gevent_6_queue_5Queue_qsize(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_6_queue_5Queue_empty(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static int __pyx_f_6gevent_6_queue_5Queue_full(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_put_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue___get_or_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_method, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_get *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_get_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_peek *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_peek_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__schedule_unlock(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_12UnboundQueue_put(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_item, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_12UnboundQueue_put *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13PriorityQueue__put(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13PriorityQueue__get(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__put(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__get(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__peek(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13JoinableQueue__put(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_7Channel_get(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_7Channel_get *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_7Channel_get_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
-static PyObject *__pyx_f_6gevent_6_queue_7Channel__schedule_unlock(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto*/
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'greenlet' */
-
-/* Module declarations from 'gevent.__greenlet_primitives' */
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = 0;
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_wref = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_wref (*__pyx_vp_6gevent_21__greenlet_primitives_wref)
-static PyObject **__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives_BlockingSwitchOutError (*__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError)
-static int *__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported = 0;
-#define __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported (*__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported)
-
-/* Module declarations from 'gevent.__hub_local' */
-static PyObject **__pyx_vp_6gevent_11__hub_local__threadlocal = 0;
-#define __pyx_v_6gevent_11__hub_local__threadlocal (*__pyx_vp_6gevent_11__hub_local__threadlocal)
-static struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(*__pyx_f_6gevent_11__hub_local_get_hub_noargs)(int __pyx_skip_dispatch); /*proto*/
-
-/* Module declarations from 'gevent.__waiter' */
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_Waiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8__waiter_MultipleWaiter = 0;
-static PyObject **__pyx_vp_6gevent_8__waiter_sys = 0;
-#define __pyx_v_6gevent_8__waiter_sys (*__pyx_vp_6gevent_8__waiter_sys)
-static PyObject **__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError = 0;
-#define __pyx_v_6gevent_8__waiter_ConcurrentObjectUseError (*__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError)
-static int *__pyx_vp_6gevent_8__waiter__greenlet_imported = 0;
-#define __pyx_v_6gevent_8__waiter__greenlet_imported (*__pyx_vp_6gevent_8__waiter__greenlet_imported)
-static PyObject **__pyx_vp_6gevent_8__waiter__NONE = 0;
-#define __pyx_v_6gevent_8__waiter__NONE (*__pyx_vp_6gevent_8__waiter__NONE)
-
-/* Module declarations from 'gevent._event' */
-static PyTypeObject *__pyx_ptype_6gevent_6_event_greenlet = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event__AbstractLinkable = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_Event = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_event_AsyncResult = 0;
-static PyObject **__pyx_vp_6gevent_6_event__None = 0;
-#define __pyx_v_6gevent_6_event__None (*__pyx_vp_6gevent_6_event__None)
-static PyObject **__pyx_vp_6gevent_6_event_reraise = 0;
-#define __pyx_v_6gevent_6_event_reraise (*__pyx_vp_6gevent_6_event_reraise)
-static PyObject **__pyx_vp_6gevent_6_event_dump_traceback = 0;
-#define __pyx_v_6gevent_6_event_dump_traceback (*__pyx_vp_6gevent_6_event_dump_traceback)
-static PyObject **__pyx_vp_6gevent_6_event_load_traceback = 0;
-#define __pyx_v_6gevent_6_event_load_traceback (*__pyx_vp_6gevent_6_event_load_traceback)
-static PyObject **__pyx_vp_6gevent_6_event_InvalidSwitchError = 0;
-#define __pyx_v_6gevent_6_event_InvalidSwitchError (*__pyx_vp_6gevent_6_event_InvalidSwitchError)
-static PyObject **__pyx_vp_6gevent_6_event_Timeout = 0;
-#define __pyx_v_6gevent_6_event_Timeout (*__pyx_vp_6gevent_6_event_Timeout)
-static int *__pyx_vp_6gevent_6_event__greenlet_imported = 0;
-#define __pyx_v_6gevent_6_event__greenlet_imported (*__pyx_vp_6gevent_6_event__greenlet_imported)
-
-/* Module declarations from 'gevent._queue' */
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_ItemWaiter = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_Queue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_UnboundQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_PriorityQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_LifoQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_JoinableQueue = 0;
-static PyTypeObject *__pyx_ptype_6gevent_6_queue_Channel = 0;
-static PyObject *__pyx_v_6gevent_6_queue__heappush = 0;
-static PyObject *__pyx_v_6gevent_6_queue__heappop = 0;
-static PyObject *__pyx_v_6gevent_6_queue__heapify = 0;
-static PyObject *__pyx_f_6gevent_6_queue__safe_remove(PyObject *, PyObject *); /*proto*/
-#define __Pyx_MODULE_NAME "gevent._queue"
-extern int __pyx_module_is_main_gevent___queue;
-int __pyx_module_is_main_gevent___queue = 0;
-
-/* Implementation of 'gevent._queue' */
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_DeprecationWarning;
-static PyObject *__pyx_builtin_hex;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_StopIteration;
-static const char __pyx_k_q[] = "q";
-static const char __pyx_k__2[] = " ";
-static const char __pyx_k__3[] = "";
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_get[] = "_get";
-static const char __pyx_k_hex[] = "hex";
-static const char __pyx_k_hub[] = "hub";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_put[] = "_put";
-static const char __pyx_k_s_s[] = "<%s%s>";
-static const char __pyx_k_set[] = "set";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_Full[] = "Full";
-static const char __pyx_k_cond[] = "_cond";
-static const char __pyx_k_copy[] = "copy";
-static const char __pyx_k_full[] = "full";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_item[] = "item";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_loop[] = "loop";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_next[] = "__next__";
-static const char __pyx_k_peek[] = "_peek";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_wait[] = "wait";
-static const char __pyx_k_warn[] = "warn";
-static const char __pyx_k_Empty[] = "Empty";
-static const char __pyx_k_Event[] = "Event";
-static const char __pyx_k_Queue[] = "Queue";
-static const char __pyx_k_block[] = "block";
-static const char __pyx_k_clear[] = "clear";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_deque[] = "deque";
-static const char __pyx_k_empty[] = "empty";
-static const char __pyx_k_get_2[] = "get";
-static const char __pyx_k_heapq[] = "heapq";
-static const char __pyx_k_items[] = "items";
-static const char __pyx_k_put_2[] = "put";
-static const char __pyx_k_qsize[] = "qsize";
-static const char __pyx_k_queue[] = "queue";
-static const char __pyx_k_s_s_2[] = "<%s %s>";
-static const char __pyx_k_slots[] = "__slots__";
-static const char __pyx_k_throw[] = "throw";
-static const char __pyx_k_Waiter[] = "Waiter";
-static const char __pyx_k_append[] = "append";
-static const char __pyx_k_cancel[] = "cancel";
-static const char __pyx_k_format[] = "_format";
-static const char __pyx_k_getter[] = "getter";
-static const char __pyx_k_gevent[] = "gevent";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_next_2[] = "next";
-static const char __pyx_k_peek_2[] = "peek";
-static const char __pyx_k_putter[] = "putter";
-static const char __pyx_k_remove[] = "remove";
-static const char __pyx_k_repeat[] = "repeat";
-static const char __pyx_k_result[] = "result";
-static const char __pyx_k_switch[] = "switch";
-static const char __pyx_k_unlock[] = "_unlock";
-static const char __pyx_k_waiter[] = "_waiter";
-static const char __pyx_k_Channel[] = "Channel";
-static const char __pyx_k_Timeout[] = "Timeout";
-static const char __pyx_k_get_hub[] = "get_hub";
-static const char __pyx_k_getters[] = "getters";
-static const char __pyx_k_heapify[] = "_heapify";
-static const char __pyx_k_heappop[] = "_heappop";
-static const char __pyx_k_imports[] = "__imports__";
-static const char __pyx_k_maxsize[] = "maxsize";
-static const char __pyx_k_popleft[] = "popleft";
-static const char __pyx_k_putters[] = "putters";
-static const char __pyx_k_queue_2[] = "__queue__";
-static const char __pyx_k_queue_r[] = "queue=%r";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_weakref[] = "__weakref__";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_greenlet[] = "greenlet";
-static const char __pyx_k_heappush[] = "_heappush";
-static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
-static const char __pyx_k_s_at_s_s[] = "<%s at %s%s>";
-static const char __pyx_k_waiter_2[] = "waiter";
-static const char __pyx_k_warnings[] = "warnings";
-static const char __pyx_k_LifoQueue[] = "LifoQueue";
-static const char __pyx_k_Queue_get[] = "Queue.get";
-static const char __pyx_k_Queue_put[] = "Queue.put";
-static const char __pyx_k_getters_s[] = "getters[%s]";
-static const char __pyx_k_heapify_2[] = "heapify";
-static const char __pyx_k_heappop_2[] = "heappop";
-static const char __pyx_k_maxsize_2[] = "_maxsize";
-static const char __pyx_k_maxsize_r[] = "maxsize=%r";
-static const char __pyx_k_putters_s[] = "putters[%s]";
-static const char __pyx_k_task_done[] = "task_done";
-static const char __pyx_k_Queue__get[] = "Queue._get";
-static const char __pyx_k_Queue__put[] = "Queue._put";
-static const char __pyx_k_Queue_copy[] = "Queue.copy";
-static const char __pyx_k_Queue_full[] = "Queue.full";
-static const char __pyx_k_Queue_peek[] = "Queue.peek";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_extensions[] = "__extensions__";
-static const char __pyx_k_get_nowait[] = "get_nowait";
-static const char __pyx_k_getcurrent[] = "getcurrent";
-static const char __pyx_k_heappush_2[] = "heappush";
-static const char __pyx_k_implements[] = "__implements__";
-static const char __pyx_k_put_nowait[] = "put_nowait";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_s_at_s_s_2[] = "<%s at %s %s>";
-static const char __pyx_k_stacklevel[] = "stacklevel";
-static const char __pyx_k_warn_depth[] = "_warn_depth";
-static const char __pyx_k_Channel_get[] = "Channel.get";
-static const char __pyx_k_Channel_put[] = "Channel.put";
-static const char __pyx_k_Queue__peek[] = "Queue._peek";
-static const char __pyx_k_Queue_empty[] = "Queue.empty";
-static const char __pyx_k_Queue_qsize[] = "Queue.qsize";
-static const char __pyx_k_SimpleQueue[] = "SimpleQueue";
-static const char __pyx_k_collections[] = "collections";
-static const char __pyx_k_getters_s_2[] = " getters[%s]";
-static const char __pyx_k_peek_nowait[] = "peek_nowait";
-static const char __pyx_k_putters_s_2[] = " putters[%s]";
-static const char __pyx_k_Channel_full[] = "Channel.full";
-static const char __pyx_k_create_queue[] = "_create_queue";
-static const char __pyx_k_event_unlock[] = "_event_unlock";
-static const char __pyx_k_gevent__util[] = "gevent._util";
-static const char __pyx_k_gevent_event[] = "gevent.event";
-static const char __pyx_k_run_callback[] = "run_callback";
-static const char __pyx_k_version_info[] = "version_info";
-static const char __pyx_k_Channel_empty[] = "Channel.empty";
-static const char __pyx_k_Channel_qsize[] = "Channel.qsize";
-static const char __pyx_k_JoinableQueue[] = "JoinableQueue";
-static const char __pyx_k_PriorityQueue[] = "PriorityQueue";
-static const char __pyx_k_PySimpleQueue[] = "_PySimpleQueue";
-static const char __pyx_k_Queue__format[] = "Queue._format";
-static const char __pyx_k_Queue__unlock[] = "Queue._unlock";
-static const char __pyx_k_StopIteration[] = "StopIteration";
-static const char __pyx_k_gevent__queue[] = "gevent._queue";
-static const char __pyx_k_LifoQueue__get[] = "LifoQueue._get";
-static const char __pyx_k_LifoQueue__put[] = "LifoQueue._put";
-static const char __pyx_k_get_hub_noargs[] = "get_hub_noargs";
-static const char __pyx_k_gevent__waiter[] = "gevent._waiter";
-static const char __pyx_k_gevent_timeout[] = "gevent.timeout";
-static const char __pyx_k_import_c_accel[] = "import_c_accel";
-static const char __pyx_k_put_and_switch[] = "put_and_switch";
-static const char __pyx_k_Channel__format[] = "Channel._format";
-static const char __pyx_k_Channel__unlock[] = "Channel._unlock";
-static const char __pyx_k_LifoQueue__peek[] = "LifoQueue._peek";
-static const char __pyx_k_tasks_s__cond_s[] = " tasks=%s _cond=%s";
-static const char __pyx_k_Queue_get_nowait[] = "Queue.get_nowait";
-static const char __pyx_k_Queue_put_nowait[] = "Queue.put_nowait";
-static const char __pyx_k_UnboundQueue_put[] = "UnboundQueue.put";
-static const char __pyx_k_unfinished_tasks[] = "unfinished_tasks";
-static const char __pyx_k_Queue_peek_nowait[] = "Queue.peek_nowait";
-static const char __pyx_k_gevent__hub_local[] = "gevent._hub_local";
-static const char __pyx_k_gevent_exceptions[] = "gevent.exceptions";
-static const char __pyx_k_Channel_get_nowait[] = "Channel.get_nowait";
-static const char __pyx_k_Channel_put_nowait[] = "Channel.put_nowait";
-static const char __pyx_k_DeprecationWarning[] = "DeprecationWarning";
-static const char __pyx_k_InvalidSwitchError[] = "InvalidSwitchError";
-static const char __pyx_k_JoinableQueue__put[] = "JoinableQueue._put";
-static const char __pyx_k_JoinableQueue_copy[] = "JoinableQueue.copy";
-static const char __pyx_k_JoinableQueue_join[] = "JoinableQueue.join";
-static const char __pyx_k_PriorityQueue__get[] = "PriorityQueue._get";
-static const char __pyx_k_PriorityQueue__put[] = "PriorityQueue._put";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy";
-static const char __pyx_k_Queue__create_queue[] = "Queue._create_queue";
-static const char __pyx_k_src_gevent_queue_py[] = "src\\gevent\\queue.py";
-static const char __pyx_k_JoinableQueue__format[] = "JoinableQueue._format";
-static const char __pyx_k_JoinableQueue_task_done[] = "JoinableQueue.task_done";
-static const char __pyx_k_LifoQueue__create_queue[] = "LifoQueue._create_queue";
-static const char __pyx_k_ItemWaiter_put_and_switch[] = "ItemWaiter.put_and_switch";
-static const char __pyx_k_PriorityQueue__create_queue[] = "PriorityQueue._create_queue";
-static const char __pyx_k_UnboundQueue_has_no_maxsize[] = "UnboundQueue has no maxsize";
-static const char __pyx_k_Channels_have_a_maxsize_of_1[] = "Channels have a maxsize of 1";
-static const char __pyx_k_Invalid_switch_into_Channel_put[] = "Invalid switch into Channel.put: %r";
-static const char __pyx_k_Invalid_switch_into_Queue_get_r[] = "Invalid switch into Queue.get: %r";
-static const char __pyx_k_Invalid_switch_into_Queue_put_r[] = "Invalid switch into Queue.put: %r";
-static const char __pyx_k_Queue_0_now_equivalent_to_Queue[] = "Queue(0) now equivalent to Queue(None); if you want a channel, use Channel";
-static const char __pyx_k_Synchronized_queues_The_mod_gev[] = "\nSynchronized queues.\n\nThe :mod:`gevent.queue` module implements multi-producer, multi-consumer queues\nthat work across greenlets, with the API similar to the classes found in the\nstandard :mod:`Queue` and :class:`multiprocessing <multiprocessing.Queue>` modules.\n\nThe classes in this module implement the iterator protocol. Iterating\nover a queue means repeatedly calling :meth:`get <Queue.get>` until\n:meth:`get <Queue.get>` returns ``StopIteration`` (specifically that\nclass, not an instance or subclass).\n\n >>> queue = gevent.queue.Queue()\n >>> queue.put(1)\n >>> queue.put(2)\n >>> queue.put(StopIteration)\n >>> for item in queue:\n ... print(item)\n 1\n 2\n\n.. versionchanged:: 1.0\n ``Queue(0)`` now means queue of infinite size, not a channel. A :exc:`DeprecationWarning`\n will be issued with this argument.\n";
-static const char __pyx_k_task_done_called_too_many_times[] = "task_done() called too many times";
-static PyObject *__pyx_n_s_Channel;
-static PyObject *__pyx_n_s_Channel__format;
-static PyObject *__pyx_n_s_Channel__unlock;
-static PyObject *__pyx_n_s_Channel_empty;
-static PyObject *__pyx_n_s_Channel_full;
-static PyObject *__pyx_n_s_Channel_get;
-static PyObject *__pyx_n_s_Channel_get_nowait;
-static PyObject *__pyx_n_s_Channel_put;
-static PyObject *__pyx_n_s_Channel_put_nowait;
-static PyObject *__pyx_n_s_Channel_qsize;
-static PyObject *__pyx_kp_s_Channels_have_a_maxsize_of_1;
-static PyObject *__pyx_n_s_DeprecationWarning;
-static PyObject *__pyx_n_s_Empty;
-static PyObject *__pyx_n_s_Event;
-static PyObject *__pyx_n_s_Full;
-static PyObject *__pyx_n_s_InvalidSwitchError;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Channel_put;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Queue_get_r;
-static PyObject *__pyx_kp_s_Invalid_switch_into_Queue_put_r;
-static PyObject *__pyx_n_s_ItemWaiter_put_and_switch;
-static PyObject *__pyx_n_s_JoinableQueue;
-static PyObject *__pyx_n_s_JoinableQueue__format;
-static PyObject *__pyx_n_s_JoinableQueue__put;
-static PyObject *__pyx_n_s_JoinableQueue_copy;
-static PyObject *__pyx_n_s_JoinableQueue_join;
-static PyObject *__pyx_n_s_JoinableQueue_task_done;
-static PyObject *__pyx_n_s_LifoQueue;
-static PyObject *__pyx_n_s_LifoQueue__create_queue;
-static PyObject *__pyx_n_s_LifoQueue__get;
-static PyObject *__pyx_n_s_LifoQueue__peek;
-static PyObject *__pyx_n_s_LifoQueue__put;
-static PyObject *__pyx_n_s_PriorityQueue;
-static PyObject *__pyx_n_s_PriorityQueue__create_queue;
-static PyObject *__pyx_n_s_PriorityQueue__get;
-static PyObject *__pyx_n_s_PriorityQueue__put;
-static PyObject *__pyx_n_s_PySimpleQueue;
-static PyObject *__pyx_n_s_Queue;
-static PyObject *__pyx_kp_s_Queue_0_now_equivalent_to_Queue;
-static PyObject *__pyx_n_s_Queue__create_queue;
-static PyObject *__pyx_n_s_Queue__format;
-static PyObject *__pyx_n_s_Queue__get;
-static PyObject *__pyx_n_s_Queue__peek;
-static PyObject *__pyx_n_s_Queue__put;
-static PyObject *__pyx_n_s_Queue__unlock;
-static PyObject *__pyx_n_s_Queue_copy;
-static PyObject *__pyx_n_s_Queue_empty;
-static PyObject *__pyx_n_s_Queue_full;
-static PyObject *__pyx_n_s_Queue_get;
-static PyObject *__pyx_n_s_Queue_get_nowait;
-static PyObject *__pyx_n_s_Queue_peek;
-static PyObject *__pyx_n_s_Queue_peek_nowait;
-static PyObject *__pyx_n_s_Queue_put;
-static PyObject *__pyx_n_s_Queue_put_nowait;
-static PyObject *__pyx_n_s_Queue_qsize;
-static PyObject *__pyx_n_s_SimpleQueue;
-static PyObject *__pyx_n_s_StopIteration;
-static PyObject *__pyx_n_s_Timeout;
-static PyObject *__pyx_kp_s_UnboundQueue_has_no_maxsize;
-static PyObject *__pyx_n_s_UnboundQueue_put;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_n_s_Waiter;
-static PyObject *__pyx_kp_s__2;
-static PyObject *__pyx_kp_s__3;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_append;
-static PyObject *__pyx_n_s_block;
-static PyObject *__pyx_n_s_cancel;
-static PyObject *__pyx_n_s_clear;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_collections;
-static PyObject *__pyx_n_s_cond;
-static PyObject *__pyx_n_s_copy;
-static PyObject *__pyx_n_s_create_queue;
-static PyObject *__pyx_n_s_deque;
-static PyObject *__pyx_n_s_empty;
-static PyObject *__pyx_n_s_event_unlock;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_extensions;
-static PyObject *__pyx_n_s_format;
-static PyObject *__pyx_n_s_full;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_get_2;
-static PyObject *__pyx_n_s_get_hub;
-static PyObject *__pyx_n_s_get_hub_noargs;
-static PyObject *__pyx_n_s_get_nowait;
-static PyObject *__pyx_n_s_getcurrent;
-static PyObject *__pyx_n_s_getter;
-static PyObject *__pyx_n_s_getters;
-static PyObject *__pyx_kp_s_getters_s;
-static PyObject *__pyx_kp_s_getters_s_2;
-static PyObject *__pyx_n_s_gevent;
-static PyObject *__pyx_n_s_gevent__hub_local;
-static PyObject *__pyx_n_s_gevent__queue;
-static PyObject *__pyx_n_s_gevent__util;
-static PyObject *__pyx_n_s_gevent__waiter;
-static PyObject *__pyx_n_s_gevent_event;
-static PyObject *__pyx_n_s_gevent_exceptions;
-static PyObject *__pyx_n_s_gevent_timeout;
-static PyObject *__pyx_n_s_greenlet;
-static PyObject *__pyx_n_s_heapify;
-static PyObject *__pyx_n_s_heapify_2;
-static PyObject *__pyx_n_s_heappop;
-static PyObject *__pyx_n_s_heappop_2;
-static PyObject *__pyx_n_s_heappush;
-static PyObject *__pyx_n_s_heappush_2;
-static PyObject *__pyx_n_s_heapq;
-static PyObject *__pyx_n_s_hex;
-static PyObject *__pyx_n_s_hub;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_n_s_implements;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_import_c_accel;
-static PyObject *__pyx_n_s_imports;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_item;
-static PyObject *__pyx_n_s_items;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_loop;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_maxsize;
-static PyObject *__pyx_n_s_maxsize_2;
-static PyObject *__pyx_kp_s_maxsize_r;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_next;
-static PyObject *__pyx_n_s_next_2;
-static PyObject *__pyx_n_s_peek;
-static PyObject *__pyx_n_s_peek_2;
-static PyObject *__pyx_n_s_peek_nowait;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_popleft;
-static PyObject *__pyx_n_s_put;
-static PyObject *__pyx_n_s_put_2;
-static PyObject *__pyx_n_s_put_and_switch;
-static PyObject *__pyx_n_s_put_nowait;
-static PyObject *__pyx_n_s_putter;
-static PyObject *__pyx_n_s_putters;
-static PyObject *__pyx_kp_s_putters_s;
-static PyObject *__pyx_kp_s_putters_s_2;
-static PyObject *__pyx_n_s_pyx_capi;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_q;
-static PyObject *__pyx_n_s_qsize;
-static PyObject *__pyx_n_s_queue;
-static PyObject *__pyx_n_s_queue_2;
-static PyObject *__pyx_kp_s_queue_r;
-static PyObject *__pyx_n_s_remove;
-static PyObject *__pyx_n_s_repeat;
-static PyObject *__pyx_n_s_result;
-static PyObject *__pyx_n_s_run_callback;
-static PyObject *__pyx_kp_s_s_at_s_s;
-static PyObject *__pyx_kp_s_s_at_s_s_2;
-static PyObject *__pyx_kp_s_s_s;
-static PyObject *__pyx_kp_s_s_s_2;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_set;
-static PyObject *__pyx_n_s_slots;
-static PyObject *__pyx_kp_s_src_gevent_queue_py;
-static PyObject *__pyx_n_s_stacklevel;
-static PyObject *__pyx_n_s_start_new_or_dummy;
-static PyObject *__pyx_n_s_switch;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_task_done;
-static PyObject *__pyx_kp_s_task_done_called_too_many_times;
-static PyObject *__pyx_kp_s_tasks_s__cond_s;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_throw;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_unfinished_tasks;
-static PyObject *__pyx_n_s_unlock;
-static PyObject *__pyx_n_s_version_info;
-static PyObject *__pyx_n_s_wait;
-static PyObject *__pyx_n_s_waiter;
-static PyObject *__pyx_n_s_waiter_2;
-static PyObject *__pyx_n_s_warn;
-static PyObject *__pyx_n_s_warn_depth;
-static PyObject *__pyx_n_s_warnings;
-static PyObject *__pyx_n_s_weakref;
-static int __pyx_pf_6gevent_6_queue_10ItemWaiter___init__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_queue); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_2put_and_switch(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_4item___get__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_5queue___get__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_5Queue___init__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items, PyObject *__pyx_v__warn_depth); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_7maxsize___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_5Queue_7maxsize_2__set__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_nv); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_2copy(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_4_create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_items); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_6_get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_8_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_10_put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_12__repr__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_14__str__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_16_format(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_18qsize(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static Py_ssize_t __pyx_pf_6gevent_6_queue_5Queue_20__len__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_5Queue_22__bool__(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_5Queue_24__nonzero__(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_26empty(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_28full(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_30put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_32put_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_34get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_36get_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_38peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_40peek_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_42_unlock(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_44__iter__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_46__next__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_3hub___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_5queue___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_12UnboundQueue___init__(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_12UnboundQueue_2put(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue__create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_items); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue_2_put(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue_4_get(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue__create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_items); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_2_put(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_4_get(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_6_peek(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_13JoinableQueue___init__(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items, PyObject *__pyx_v_unfinished_tasks); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_2copy(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_4_format(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_6_put(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_8task_done(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_10join(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_16unfinished_tasks___get__(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_6_queue_7Channel___init__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_maxsize); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_2__repr__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_4__str__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_6_format(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7balance___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_8qsize(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_10empty(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_12full(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_14put(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_16put_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_18get(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_20get_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_22_unlock(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_24__iter__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_26__next__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7getters___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7putters___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_3hub___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_6_queue_ItemWaiter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_Queue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_UnboundQueue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_PriorityQueue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_LifoQueue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_JoinableQueue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_6_queue_Channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_int_2;
-static PyObject *__pyx_int_3;
-static PyObject *__pyx_tuple_;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_tuple__25;
-static PyObject *__pyx_tuple__27;
-static PyObject *__pyx_tuple__29;
-static PyObject *__pyx_tuple__31;
-static PyObject *__pyx_tuple__33;
-static PyObject *__pyx_tuple__35;
-static PyObject *__pyx_tuple__37;
-static PyObject *__pyx_tuple__39;
-static PyObject *__pyx_tuple__41;
-static PyObject *__pyx_tuple__43;
-static PyObject *__pyx_tuple__45;
-static PyObject *__pyx_tuple__47;
-static PyObject *__pyx_tuple__49;
-static PyObject *__pyx_tuple__51;
-static PyObject *__pyx_tuple__53;
-static PyObject *__pyx_tuple__55;
-static PyObject *__pyx_tuple__57;
-static PyObject *__pyx_tuple__59;
-static PyObject *__pyx_tuple__60;
-static PyObject *__pyx_tuple__62;
-static PyObject *__pyx_tuple__64;
-static PyObject *__pyx_tuple__66;
-static PyObject *__pyx_tuple__68;
-static PyObject *__pyx_tuple__70;
-static PyObject *__pyx_tuple__71;
-static PyObject *__pyx_tuple__73;
-static PyObject *__pyx_tuple__75;
-static PyObject *__pyx_tuple__77;
-static PyObject *__pyx_tuple__79;
-static PyObject *__pyx_tuple__81;
-static PyObject *__pyx_tuple__83;
-static PyObject *__pyx_tuple__85;
-static PyObject *__pyx_tuple__87;
-static PyObject *__pyx_codeobj__9;
-static PyObject *__pyx_codeobj__12;
-static PyObject *__pyx_codeobj__14;
-static PyObject *__pyx_codeobj__16;
-static PyObject *__pyx_codeobj__18;
-static PyObject *__pyx_codeobj__20;
-static PyObject *__pyx_codeobj__22;
-static PyObject *__pyx_codeobj__24;
-static PyObject *__pyx_codeobj__26;
-static PyObject *__pyx_codeobj__28;
-static PyObject *__pyx_codeobj__30;
-static PyObject *__pyx_codeobj__32;
-static PyObject *__pyx_codeobj__34;
-static PyObject *__pyx_codeobj__36;
-static PyObject *__pyx_codeobj__38;
-static PyObject *__pyx_codeobj__40;
-static PyObject *__pyx_codeobj__42;
-static PyObject *__pyx_codeobj__44;
-static PyObject *__pyx_codeobj__46;
-static PyObject *__pyx_codeobj__48;
-static PyObject *__pyx_codeobj__50;
-static PyObject *__pyx_codeobj__52;
-static PyObject *__pyx_codeobj__54;
-static PyObject *__pyx_codeobj__56;
-static PyObject *__pyx_codeobj__58;
-static PyObject *__pyx_codeobj__61;
-static PyObject *__pyx_codeobj__63;
-static PyObject *__pyx_codeobj__65;
-static PyObject *__pyx_codeobj__67;
-static PyObject *__pyx_codeobj__69;
-static PyObject *__pyx_codeobj__72;
-static PyObject *__pyx_codeobj__74;
-static PyObject *__pyx_codeobj__76;
-static PyObject *__pyx_codeobj__78;
-static PyObject *__pyx_codeobj__80;
-static PyObject *__pyx_codeobj__82;
-static PyObject *__pyx_codeobj__84;
-static PyObject *__pyx_codeobj__86;
-static PyObject *__pyx_codeobj__88;
-/* Late includes */
-
-/* "src/gevent/queue.py":64
- * # pylint:disable=assignment-from-no-return
- *
- * def _safe_remove(deq, item): # <<<<<<<<<<<<<<
- * # For when the item may have been removed by
- * # Queue._unlock
- */
-
-static PyObject *__pyx_f_6gevent_6_queue__safe_remove(PyObject *__pyx_v_deq, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- __Pyx_RefNannySetupContext("_safe_remove", 0);
-
- /* "src/gevent/queue.py":67
- * # For when the item may have been removed by
- * # Queue._unlock
- * try: # <<<<<<<<<<<<<<
- * deq.remove(item)
- * except ValueError:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "src/gevent/queue.py":68
- * # Queue._unlock
- * try:
- * deq.remove(item) # <<<<<<<<<<<<<<
- * except ValueError:
- * pass
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_deq, __pyx_n_s_remove); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_item};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_item};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_item);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":67
- * # For when the item may have been removed by
- * # Queue._unlock
- * try: # <<<<<<<<<<<<<<
- * deq.remove(item)
- * except ValueError:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":69
- * try:
- * deq.remove(item)
- * except ValueError: # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
- if (__pyx_t_8) {
- __Pyx_ErrRestore(0,0,0);
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "src/gevent/queue.py":67
- * # For when the item may have been removed by
- * # Queue._unlock
- * try: # <<<<<<<<<<<<<<
- * deq.remove(item)
- * except ValueError:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "src/gevent/queue.py":64
- * # pylint:disable=assignment-from-no-return
- *
- * def _safe_remove(deq, item): # <<<<<<<<<<<<<<
- * # For when the item may have been removed by
- * # Queue._unlock
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._queue._safe_remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":82
- * )
- *
- * def __init__(self, item, queue): # <<<<<<<<<<<<<<
- * Waiter.__init__(self) # pylint:disable=undefined-variable
- * self.item = item
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_10ItemWaiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_queue_10ItemWaiter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_item = 0;
- PyObject *__pyx_v_queue = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item,&__pyx_n_s_queue,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_queue)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 82, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 82, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_item = values[0];
- __pyx_v_queue = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 82, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.ItemWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_10ItemWaiter___init__(((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)__pyx_v_self), __pyx_v_item, __pyx_v_queue);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_10ItemWaiter___init__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_queue) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/queue.py":83
- *
- * def __init__(self, item, queue):
- * Waiter.__init__(self) # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * self.item = item
- * self.queue = queue
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":84
- * def __init__(self, item, queue):
- * Waiter.__init__(self) # pylint:disable=undefined-variable
- * self.item = item # <<<<<<<<<<<<<<
- * self.queue = queue
- *
- */
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- __Pyx_GOTREF(__pyx_v_self->item);
- __Pyx_DECREF(__pyx_v_self->item);
- __pyx_v_self->item = __pyx_v_item;
-
- /* "src/gevent/queue.py":85
- * Waiter.__init__(self) # pylint:disable=undefined-variable
- * self.item = item
- * self.queue = queue # <<<<<<<<<<<<<<
- *
- * def put_and_switch(self):
- */
- __Pyx_INCREF(__pyx_v_queue);
- __Pyx_GIVEREF(__pyx_v_queue);
- __Pyx_GOTREF(__pyx_v_self->queue);
- __Pyx_DECREF(__pyx_v_self->queue);
- __pyx_v_self->queue = __pyx_v_queue;
-
- /* "src/gevent/queue.py":82
- * )
- *
- * def __init__(self, item, queue): # <<<<<<<<<<<<<<
- * Waiter.__init__(self) # pylint:disable=undefined-variable
- * self.item = item
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.ItemWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":87
- * self.queue = queue
- *
- * def put_and_switch(self): # <<<<<<<<<<<<<<
- * self.queue._put(self.item)
- * self.queue = None
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_3put_and_switch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_10ItemWaiter_2put_and_switch[] = "ItemWaiter.put_and_switch(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_10ItemWaiter_3put_and_switch = {"put_and_switch", (PyCFunction)__pyx_pw_6gevent_6_queue_10ItemWaiter_3put_and_switch, METH_NOARGS, __pyx_doc_6gevent_6_queue_10ItemWaiter_2put_and_switch};
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_3put_and_switch(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put_and_switch (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_10ItemWaiter_2put_and_switch(((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_2put_and_switch(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("put_and_switch", 0);
-
- /* "src/gevent/queue.py":88
- *
- * def put_and_switch(self):
- * self.queue._put(self.item) # <<<<<<<<<<<<<<
- * self.queue = None
- * self.item = None
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->queue, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->item); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->item};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->item};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_self->item);
- __Pyx_GIVEREF(__pyx_v_self->item);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->item);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":89
- * def put_and_switch(self):
- * self.queue._put(self.item)
- * self.queue = None # <<<<<<<<<<<<<<
- * self.item = None
- * return self.switch(self)
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->queue);
- __Pyx_DECREF(__pyx_v_self->queue);
- __pyx_v_self->queue = Py_None;
-
- /* "src/gevent/queue.py":90
- * self.queue._put(self.item)
- * self.queue = None
- * self.item = None # <<<<<<<<<<<<<<
- * return self.switch(self)
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->item);
- __Pyx_DECREF(__pyx_v_self->item);
- __pyx_v_self->item = Py_None;
-
- /* "src/gevent/queue.py":91
- * self.queue = None
- * self.item = None
- * return self.switch(self) # <<<<<<<<<<<<<<
- *
- * class Queue(object):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":87
- * self.queue = queue
- *
- * def put_and_switch(self): # <<<<<<<<<<<<<<
- * self.queue._put(self.item)
- * self.queue = None
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.ItemWaiter.put_and_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":15
- * @cython.internal
- * cdef class ItemWaiter(Waiter):
- * cdef readonly item # <<<<<<<<<<<<<<
- * cdef readonly queue
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_4item_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_4item_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_10ItemWaiter_4item___get__(((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_4item___get__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->item);
- __pyx_r = __pyx_v_self->item;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":16
- * cdef class ItemWaiter(Waiter):
- * cdef readonly item
- * cdef readonly queue # <<<<<<<<<<<<<<
- *
- * cdef class Queue:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_5queue_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_10ItemWaiter_5queue_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_10ItemWaiter_5queue___get__(((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_10ItemWaiter_5queue___get__(struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->queue);
- __pyx_r = __pyx_v_self->queue;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":124
- * )
- *
- * def __init__(self, maxsize=None, items=(), _warn_depth=2): # <<<<<<<<<<<<<<
- * if maxsize is not None and maxsize <= 0:
- * if maxsize == 0:
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_5Queue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_queue_5Queue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_maxsize = 0;
- PyObject *__pyx_v_items = 0;
- PyObject *__pyx_v__warn_depth = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_maxsize,&__pyx_n_s_items,&__pyx_n_s_warn_depth,0};
- PyObject* values[3] = {0,0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)__pyx_empty_tuple);
- values[2] = ((PyObject *)__pyx_int_2);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_warn_depth);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 124, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_maxsize = values[0];
- __pyx_v_items = values[1];
- __pyx_v__warn_depth = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 124, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Queue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue___init__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_maxsize, __pyx_v_items, __pyx_v__warn_depth);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_5Queue___init__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items, PyObject *__pyx_v__warn_depth) {
- PyObject *__pyx_v_warnings = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- Py_ssize_t __pyx_t_7;
- Py_ssize_t __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
- __Pyx_INCREF(__pyx_v_maxsize);
-
- /* "src/gevent/queue.py":125
- *
- * def __init__(self, maxsize=None, items=(), _warn_depth=2):
- * if maxsize is not None and maxsize <= 0: # <<<<<<<<<<<<<<
- * if maxsize == 0:
- * import warnings
- */
- __pyx_t_2 = (__pyx_v_maxsize != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = PyObject_RichCompare(__pyx_v_maxsize, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":126
- * def __init__(self, maxsize=None, items=(), _warn_depth=2):
- * if maxsize is not None and maxsize <= 0:
- * if maxsize == 0: # <<<<<<<<<<<<<<
- * import warnings
- * warnings.warn(
- */
- __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_maxsize, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":127
- * if maxsize is not None and maxsize <= 0:
- * if maxsize == 0:
- * import warnings # <<<<<<<<<<<<<<
- * warnings.warn(
- * 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- */
- __pyx_t_4 = __Pyx_Import(__pyx_n_s_warnings, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_v_warnings = __pyx_t_4;
- __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":128
- * if maxsize == 0:
- * import warnings
- * warnings.warn( # <<<<<<<<<<<<<<
- * 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- * DeprecationWarning,
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_warnings, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "src/gevent/queue.py":131
- * 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- * DeprecationWarning,
- * stacklevel=_warn_depth) # <<<<<<<<<<<<<<
- * maxsize = None
- *
- */
- __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 131, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_stacklevel, __pyx_v__warn_depth) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
-
- /* "src/gevent/queue.py":128
- * if maxsize == 0:
- * import warnings
- * warnings.warn( # <<<<<<<<<<<<<<
- * 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- * DeprecationWarning,
- */
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple_, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":126
- * def __init__(self, maxsize=None, items=(), _warn_depth=2):
- * if maxsize is not None and maxsize <= 0:
- * if maxsize == 0: # <<<<<<<<<<<<<<
- * import warnings
- * warnings.warn(
- */
- }
-
- /* "src/gevent/queue.py":132
- * DeprecationWarning,
- * stacklevel=_warn_depth)
- * maxsize = None # <<<<<<<<<<<<<<
- *
- * self._maxsize = maxsize if maxsize is not None else -1
- */
- __Pyx_INCREF(Py_None);
- __Pyx_DECREF_SET(__pyx_v_maxsize, Py_None);
-
- /* "src/gevent/queue.py":125
- *
- * def __init__(self, maxsize=None, items=(), _warn_depth=2):
- * if maxsize is not None and maxsize <= 0: # <<<<<<<<<<<<<<
- * if maxsize == 0:
- * import warnings
- */
- }
-
- /* "src/gevent/queue.py":134
- * maxsize = None
- *
- * self._maxsize = maxsize if maxsize is not None else -1 # <<<<<<<<<<<<<<
- * # Explicitly maintain order for getters and putters that block
- * # so that callers can consistently rely on getting things out
- */
- __pyx_t_1 = (__pyx_v_maxsize != Py_None);
- if ((__pyx_t_1 != 0)) {
- __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_maxsize); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 134, __pyx_L1_error)
- __pyx_t_7 = __pyx_t_8;
- } else {
- __pyx_t_7 = -1L;
- }
- __pyx_v_self->_maxsize = __pyx_t_7;
-
- /* "src/gevent/queue.py":147
- * # many waiters that removing an arbitrary element is a
- * # bottleneck, though.
- * self.getters = collections.deque() # <<<<<<<<<<<<<<
- * self.putters = collections.deque()
- * self.hub = get_hub()
- */
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_deque); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->getters);
- __Pyx_DECREF(__pyx_v_self->getters);
- __pyx_v_self->getters = __pyx_t_6;
- __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":148
- * # bottleneck, though.
- * self.getters = collections.deque()
- * self.putters = collections.deque() # <<<<<<<<<<<<<<
- * self.hub = get_hub()
- * self._event_unlock = None
- */
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deque); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->putters);
- __Pyx_DECREF(__pyx_v_self->putters);
- __pyx_v_self->putters = __pyx_t_6;
- __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":149
- * self.getters = collections.deque()
- * self.putters = collections.deque()
- * self.hub = get_hub() # <<<<<<<<<<<<<<
- * self._event_unlock = None
- * self.queue = self._create_queue(items)
- */
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 149, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(__pyx_v_self->hub);
- __pyx_v_self->hub = __pyx_t_6;
- __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":150
- * self.putters = collections.deque()
- * self.hub = get_hub()
- * self._event_unlock = None # <<<<<<<<<<<<<<
- * self.queue = self._create_queue(items)
- *
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_event_unlock);
- __Pyx_DECREF(__pyx_v_self->_event_unlock);
- __pyx_v_self->_event_unlock = Py_None;
-
- /* "src/gevent/queue.py":151
- * self.hub = get_hub()
- * self._event_unlock = None
- * self.queue = self._create_queue(items) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_queue); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_items); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_items};
- __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_items};
- __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_items);
- __Pyx_GIVEREF(__pyx_v_items);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_items);
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_v_self->queue);
- __Pyx_DECREF(__pyx_v_self->queue);
- __pyx_v_self->queue = __pyx_t_6;
- __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":124
- * )
- *
- * def __init__(self, maxsize=None, items=(), _warn_depth=2): # <<<<<<<<<<<<<<
- * if maxsize is not None and maxsize <= 0:
- * if maxsize == 0:
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._queue.Queue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_warnings);
- __Pyx_XDECREF(__pyx_v_maxsize);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":154
- *
- * @property
- * def maxsize(self): # <<<<<<<<<<<<<<
- * return self._maxsize if self._maxsize > 0 else None
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_7maxsize_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_7maxsize_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_7maxsize___get__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_7maxsize___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/queue.py":155
- * @property
- * def maxsize(self):
- * return self._maxsize if self._maxsize > 0 else None # <<<<<<<<<<<<<<
- *
- * @maxsize.setter
- */
- __Pyx_XDECREF(__pyx_r);
- if (((__pyx_v_self->_maxsize > 0) != 0)) {
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->_maxsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __pyx_t_2;
- __pyx_t_2 = 0;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_1 = Py_None;
- }
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":154
- *
- * @property
- * def maxsize(self): # <<<<<<<<<<<<<<
- * return self._maxsize if self._maxsize > 0 else None
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent._queue.Queue.maxsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":158
- *
- * @maxsize.setter
- * def maxsize(self, nv): # <<<<<<<<<<<<<<
- * # QQQ make maxsize into a property with setter that schedules unlock if necessary
- * if nv is None or nv <= 0:
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_5Queue_7maxsize_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_nv); /*proto*/
-static int __pyx_pw_6gevent_6_queue_5Queue_7maxsize_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_nv) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_7maxsize_2__set__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), ((PyObject *)__pyx_v_nv));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_5Queue_7maxsize_2__set__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_nv) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- __Pyx_RefNannySetupContext("__set__", 0);
-
- /* "src/gevent/queue.py":160
- * def maxsize(self, nv):
- * # QQQ make maxsize into a property with setter that schedules unlock if necessary
- * if nv is None or nv <= 0: # <<<<<<<<<<<<<<
- * self._maxsize = -1
- * else:
- */
- __pyx_t_2 = (__pyx_v_nv == Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (!__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = PyObject_RichCompare(__pyx_v_nv, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_1 = __pyx_t_3;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":161
- * # QQQ make maxsize into a property with setter that schedules unlock if necessary
- * if nv is None or nv <= 0:
- * self._maxsize = -1 # <<<<<<<<<<<<<<
- * else:
- * self._maxsize = nv
- */
- __pyx_v_self->_maxsize = -1L;
-
- /* "src/gevent/queue.py":160
- * def maxsize(self, nv):
- * # QQQ make maxsize into a property with setter that schedules unlock if necessary
- * if nv is None or nv <= 0: # <<<<<<<<<<<<<<
- * self._maxsize = -1
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/queue.py":163
- * self._maxsize = -1
- * else:
- * self._maxsize = nv # <<<<<<<<<<<<<<
- *
- * def copy(self):
- */
- /*else*/ {
- __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_nv); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
- __pyx_v_self->_maxsize = __pyx_t_5;
- }
- __pyx_L3:;
-
- /* "src/gevent/queue.py":158
- *
- * @maxsize.setter
- * def maxsize(self, nv): # <<<<<<<<<<<<<<
- * # QQQ make maxsize into a property with setter that schedules unlock if necessary
- * if nv is None or nv <= 0:
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue.maxsize.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":165
- * self._maxsize = nv
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_2copy[] = "Queue.copy(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_3copy = {"copy", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_3copy, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_2copy};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("copy (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_2copy(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_2copy(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- __Pyx_RefNannySetupContext("copy", 0);
-
- /* "src/gevent/queue.py":166
- *
- * def copy(self):
- * return type(self)(self.maxsize, self.queue) # <<<<<<<<<<<<<<
- *
- * def _create_queue(self, items=()):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maxsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __pyx_t_3 = ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))); __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_self->queue};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_self->queue};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_self->queue);
- __Pyx_GIVEREF(__pyx_v_self->queue);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_self->queue);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":165
- * self._maxsize = nv
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._queue.Queue.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":168
- * return type(self)(self.maxsize, self.queue)
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return collections.deque(items)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_5_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_4_create_queue[] = "Queue._create_queue(self, items=())";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_5_create_queue = {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_5_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_5Queue_4_create_queue};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_5_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_items = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_create_queue (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)__pyx_empty_tuple);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_queue") < 0)) __PYX_ERR(0, 168, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_items = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_create_queue", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Queue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_4_create_queue(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_items);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_4_create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_items) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_create_queue", 0);
-
- /* "src/gevent/queue.py":169
- *
- * def _create_queue(self, items=()):
- * return collections.deque(items) # <<<<<<<<<<<<<<
- *
- * def _get(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deque); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_items};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_items};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
- __Pyx_INCREF(__pyx_v_items);
- __Pyx_GIVEREF(__pyx_v_items);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_items);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":168
- * return type(self)(self.maxsize, self.queue)
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return collections.deque(items)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":171
- * return collections.deque(items)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.popleft()
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_7_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_7_get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":172
- *
- * def _get(self):
- * return self.queue.popleft() # <<<<<<<<<<<<<<
- *
- * def _peek(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->queue, __pyx_n_s_popleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":171
- * return collections.deque(items)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.popleft()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_7_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_6_get[] = "Queue._get(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_7_get = {"_get", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_7_get, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_6_get};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_7_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_6_get(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_6_get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue__get(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":174
- * return self.queue.popleft()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[0]
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_9_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_peek", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peek); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_9_peek)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":175
- *
- * def _peek(self):
- * return self.queue[0] # <<<<<<<<<<<<<<
- *
- * def _put(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->queue, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":174
- * return self.queue.popleft()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[0]
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue._peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_9_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_8_peek[] = "Queue._peek(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_9_peek = {"_peek", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_9_peek, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_8_peek};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_9_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_peek (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_8_peek(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_8_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_peek", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue__peek(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue._peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":177
- * return self.queue[0]
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_11_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("_put", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_11_put)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_item);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":178
- *
- * def _put(self, item):
- * self.queue.append(item) # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_self->queue, __pyx_v_item); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 178, __pyx_L1_error)
-
- /* "src/gevent/queue.py":177
- * return self.queue[0]
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.Queue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_11_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_10_put[] = "Queue._put(self, item)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_11_put = {"_put", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_11_put, METH_O, __pyx_doc_6gevent_6_queue_5Queue_10_put};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_11_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_put (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_10_put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_10_put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue__put(__pyx_v_self, __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":180
- * self.queue.append(item)
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_13__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_13__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_12__repr__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_12__repr__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "src/gevent/queue.py":181
- *
- * def __repr__(self):
- * return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format()) # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_at_s_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":180
- * self.queue.append(item)
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.Queue.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":183
- * return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_15__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_15__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_14__str__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_14__str__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/queue.py":184
- *
- * def __str__(self):
- * return '<%s%s>' % (type(self).__name__, self._format()) # <<<<<<<<<<<<<<
- *
- * def _format(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":183
- * return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":186
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = []
- * if self.maxsize is not None:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_17_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_16_format[] = "Queue._format(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_17_format = {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_17_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_16_format};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_17_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_16_format(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_16_format(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- Py_ssize_t __pyx_t_6;
- __Pyx_RefNannySetupContext("_format", 0);
-
- /* "src/gevent/queue.py":187
- *
- * def _format(self):
- * result = [] # <<<<<<<<<<<<<<
- * if self.maxsize is not None:
- * result.append('maxsize=%r' % (self.maxsize, ))
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":188
- * def _format(self):
- * result = []
- * if self.maxsize is not None: # <<<<<<<<<<<<<<
- * result.append('maxsize=%r' % (self.maxsize, ))
- * if getattr(self, 'queue', None):
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maxsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = (__pyx_t_1 != Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":189
- * result = []
- * if self.maxsize is not None:
- * result.append('maxsize=%r' % (self.maxsize, )) # <<<<<<<<<<<<<<
- * if getattr(self, 'queue', None):
- * result.append('queue=%r' % (self.queue, ))
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maxsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_maxsize_r, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":188
- * def _format(self):
- * result = []
- * if self.maxsize is not None: # <<<<<<<<<<<<<<
- * result.append('maxsize=%r' % (self.maxsize, ))
- * if getattr(self, 'queue', None):
- */
- }
-
- /* "src/gevent/queue.py":190
- * if self.maxsize is not None:
- * result.append('maxsize=%r' % (self.maxsize, ))
- * if getattr(self, 'queue', None): # <<<<<<<<<<<<<<
- * result.append('queue=%r' % (self.queue, ))
- * if self.getters:
- */
- __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_queue, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":191
- * result.append('maxsize=%r' % (self.maxsize, ))
- * if getattr(self, 'queue', None):
- * result.append('queue=%r' % (self.queue, )) # <<<<<<<<<<<<<<
- * if self.getters:
- * result.append('getters[%s]' % len(self.getters))
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_self->queue);
- __Pyx_GIVEREF(__pyx_v_self->queue);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->queue);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_queue_r, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 191, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":190
- * if self.maxsize is not None:
- * result.append('maxsize=%r' % (self.maxsize, ))
- * if getattr(self, 'queue', None): # <<<<<<<<<<<<<<
- * result.append('queue=%r' % (self.queue, ))
- * if self.getters:
- */
- }
-
- /* "src/gevent/queue.py":192
- * if getattr(self, 'queue', None):
- * result.append('queue=%r' % (self.queue, ))
- * if self.getters: # <<<<<<<<<<<<<<
- * result.append('getters[%s]' % len(self.getters))
- * if self.putters:
- */
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 192, __pyx_L1_error)
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":193
- * result.append('queue=%r' % (self.queue, ))
- * if self.getters:
- * result.append('getters[%s]' % len(self.getters)) # <<<<<<<<<<<<<<
- * if self.putters:
- * result.append('putters[%s]' % len(self.putters))
- */
- __pyx_t_4 = __pyx_v_self->getters;
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_6 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_getters_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":192
- * if getattr(self, 'queue', None):
- * result.append('queue=%r' % (self.queue, ))
- * if self.getters: # <<<<<<<<<<<<<<
- * result.append('getters[%s]' % len(self.getters))
- * if self.putters:
- */
- }
-
- /* "src/gevent/queue.py":194
- * if self.getters:
- * result.append('getters[%s]' % len(self.getters))
- * if self.putters: # <<<<<<<<<<<<<<
- * result.append('putters[%s]' % len(self.putters))
- * if result:
- */
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":195
- * result.append('getters[%s]' % len(self.getters))
- * if self.putters:
- * result.append('putters[%s]' % len(self.putters)) # <<<<<<<<<<<<<<
- * if result:
- * return ' ' + ' '.join(result)
- */
- __pyx_t_1 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_putters_s, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 195, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":194
- * if self.getters:
- * result.append('getters[%s]' % len(self.getters))
- * if self.putters: # <<<<<<<<<<<<<<
- * result.append('putters[%s]' % len(self.putters))
- * if result:
- */
- }
-
- /* "src/gevent/queue.py":196
- * if self.putters:
- * result.append('putters[%s]' % len(self.putters))
- * if result: # <<<<<<<<<<<<<<
- * return ' ' + ' '.join(result)
- * return ''
- */
- __pyx_t_3 = (PyList_GET_SIZE(__pyx_v_result) != 0);
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":197
- * result.append('putters[%s]' % len(self.putters))
- * if result:
- * return ' ' + ' '.join(result) # <<<<<<<<<<<<<<
- * return ''
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyNumber_Add(__pyx_kp_s__2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":196
- * if self.putters:
- * result.append('putters[%s]' % len(self.putters))
- * if result: # <<<<<<<<<<<<<<
- * return ' ' + ' '.join(result)
- * return ''
- */
- }
-
- /* "src/gevent/queue.py":198
- * if result:
- * return ' ' + ' '.join(result)
- * return '' # <<<<<<<<<<<<<<
- *
- * def qsize(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_kp_s__3);
- __pyx_r = __pyx_kp_s__3;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":186
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = []
- * if self.maxsize is not None:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":200
- * return ''
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * """Return the size of the queue."""
- * return len(self.queue)
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_19qsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static Py_ssize_t __pyx_f_6gevent_6_queue_5Queue_qsize(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- __Pyx_RefNannySetupContext("qsize", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_qsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_19qsize)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":202
- * def qsize(self):
- * """Return the size of the queue."""
- * return len(self.queue) # <<<<<<<<<<<<<<
- *
- * def __len__(self):
- */
- __pyx_t_1 = __pyx_v_self->queue;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":200
- * return ''
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * """Return the size of the queue."""
- * return len(self.queue)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._queue.Queue.qsize", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_19qsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_18qsize[] = "Queue.qsize(self) -> Py_ssize_t\nReturn the size of the queue.";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_19qsize = {"qsize", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_19qsize, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_18qsize};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_19qsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("qsize (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_18qsize(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_18qsize(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("qsize", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_f_6gevent_6_queue_5Queue_qsize(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.qsize", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":204
- * return len(self.queue)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * """
- * Return the size of the queue. This is the same as :meth:`qsize`.
- */
-
-/* Python wrapper */
-static Py_ssize_t __pyx_pw_6gevent_6_queue_5Queue_21__len__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_20__len__[] = "\n Return the size of the queue. This is the same as :meth:`qsize`.\n\n .. versionadded: 1.1b3\n\n Previously, getting len() of a queue would raise a TypeError.\n ";
-#if CYTHON_COMPILING_IN_CPYTHON
-struct wrapperbase __pyx_wrapperbase_6gevent_6_queue_5Queue_20__len__;
-#endif
-static Py_ssize_t __pyx_pw_6gevent_6_queue_5Queue_21__len__(PyObject *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_20__len__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_ssize_t __pyx_pf_6gevent_6_queue_5Queue_20__len__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__", 0);
-
- /* "src/gevent/queue.py":213
- * """
- *
- * return self.qsize() # <<<<<<<<<<<<<<
- *
- * def __bool__(self):
- */
- __pyx_r = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":204
- * return len(self.queue)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * """
- * Return the size of the queue. This is the same as :meth:`qsize`.
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":215
- * return self.qsize()
- *
- * def __bool__(self): # <<<<<<<<<<<<<<
- * """
- * A queue object is always True.
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_5Queue_23__bool__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_6_queue_5Queue_23__bool__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_22__bool__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_5Queue_22__bool__(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__bool__", 0);
-
- /* "src/gevent/queue.py":224
- * to return True for backwards compatibility.
- * """
- * return True # <<<<<<<<<<<<<<
- *
- * def __nonzero__(self):
- */
- __pyx_r = 1;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":215
- * return self.qsize()
- *
- * def __bool__(self): # <<<<<<<<<<<<<<
- * """
- * A queue object is always True.
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":226
- * return True
- *
- * def __nonzero__(self): # <<<<<<<<<<<<<<
- * # Py2.
- * # For Cython; __bool__ becomes a special method that we can't
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_5Queue_25__nonzero__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_6_queue_5Queue_25__nonzero__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_24__nonzero__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_5Queue_24__nonzero__(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__nonzero__", 0);
-
- /* "src/gevent/queue.py":230
- * # For Cython; __bool__ becomes a special method that we can't
- * # get by name.
- * return True # <<<<<<<<<<<<<<
- *
- * def empty(self):
- */
- __pyx_r = 1;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":226
- * return True
- *
- * def __nonzero__(self): # <<<<<<<<<<<<<<
- * # Py2.
- * # For Cython; __bool__ becomes a special method that we can't
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":232
- * return True
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is empty, ``False`` otherwise."""
- * return not self.qsize()
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_27empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_queue_5Queue_empty(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("empty", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_27empty)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":234
- * def empty(self):
- * """Return ``True`` if the queue is empty, ``False`` otherwise."""
- * return not self.qsize() # <<<<<<<<<<<<<<
- *
- * def full(self):
- */
- __pyx_r = (!(((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0));
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":232
- * return True
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is empty, ``False`` otherwise."""
- * return not self.qsize()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._queue.Queue.empty", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_27empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_26empty[] = "Queue.empty(self) -> bool\nReturn ``True`` if the queue is empty, ``False`` otherwise.";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_27empty = {"empty", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_27empty, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_26empty};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_27empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("empty (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_26empty(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_26empty(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("empty", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_queue_5Queue_empty(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.empty", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":236
- * return not self.qsize()
- *
- * def full(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is full, ``False`` otherwise.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_29full(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static int __pyx_f_6gevent_6_queue_5Queue_full(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("full", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_full); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_29full)) {
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_5;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":241
- * ``Queue(None)`` is never full.
- * """
- * return self._maxsize > 0 and self.qsize() >= self._maxsize # <<<<<<<<<<<<<<
- *
- * def put(self, item, block=True, timeout=None):
- */
- __pyx_t_6 = ((__pyx_v_self->_maxsize > 0) != 0);
- if (__pyx_t_6) {
- } else {
- __pyx_t_5 = __pyx_t_6;
- goto __pyx_L3_bool_binop_done;
- }
- __pyx_t_6 = ((((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) >= __pyx_v_self->_maxsize) != 0);
- __pyx_t_5 = __pyx_t_6;
- __pyx_L3_bool_binop_done:;
- __pyx_r = __pyx_t_5;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":236
- * return not self.qsize()
- *
- * def full(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is full, ``False`` otherwise.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_WriteUnraisable("gevent._queue.Queue.full", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_29full(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_28full[] = "Queue.full(self) -> bool\nReturn ``True`` if the queue is full, ``False`` otherwise.\n\n ``Queue(None)`` is never full.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_29full = {"full", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_29full, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_28full};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_29full(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("full (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_28full(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_28full(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("full", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_6_queue_5Queue_full(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.full", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":243
- * return self._maxsize > 0 and self.qsize() >= self._maxsize
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Put an item into the queue.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_31put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args) {
- PyObject *__pyx_v_block = ((PyObject *)Py_True);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_getter = NULL;
- struct __pyx_obj_6gevent_6_queue_ItemWaiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- char const *__pyx_t_11;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- __Pyx_RefNannySetupContext("put", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_block = __pyx_optional_args->block;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- __Pyx_INCREF(__pyx_v_timeout);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_31put)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_item, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_item, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_item);
- __Pyx_INCREF(__pyx_v_block);
- __Pyx_GIVEREF(__pyx_v_block);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_block);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":254
- * is ignored in that case).
- * """
- * if self._maxsize == -1 or self.qsize() < self._maxsize: # <<<<<<<<<<<<<<
- * # there's a free slot, put an item right away
- * self._put(item)
- */
- __pyx_t_8 = ((__pyx_v_self->_maxsize == -1L) != 0);
- if (!__pyx_t_8) {
- } else {
- __pyx_t_7 = __pyx_t_8;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_8 = ((((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) < __pyx_v_self->_maxsize) != 0);
- __pyx_t_7 = __pyx_t_8;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":256
- * if self._maxsize == -1 or self.qsize() < self._maxsize:
- * # there's a free slot, put an item right away
- * self._put(item) # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_put(__pyx_v_self, __pyx_v_item, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":257
- * # there's a free slot, put an item right away
- * self._put(item)
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * elif self.hub is getcurrent():
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 257, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":258
- * self._put(item)
- * if self.getters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * elif self.hub is getcurrent():
- * # We're in the mainloop, so we cannot wait; we can switch to other greenlets though.
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":257
- * # there's a free slot, put an item right away
- * self._put(item)
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * elif self.hub is getcurrent():
- */
- }
-
- /* "src/gevent/queue.py":254
- * is ignored in that case).
- * """
- * if self._maxsize == -1 or self.qsize() < self._maxsize: # <<<<<<<<<<<<<<
- * # there's a free slot, put an item right away
- * self._put(item)
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/queue.py":259
- * if self.getters:
- * self._schedule_unlock()
- * elif self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * # We're in the mainloop, so we cannot wait; we can switch to other greenlets though.
- * # Check if possible to get a free slot in the queue.
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_7 = (__pyx_v_self->hub == __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/queue.py":262
- * # We're in the mainloop, so we cannot wait; we can switch to other greenlets though.
- * # Check if possible to get a free slot in the queue.
- * while self.getters and self.qsize() and self.qsize() >= self._maxsize: # <<<<<<<<<<<<<<
- * getter = self.getters.popleft()
- * getter.switch(getter)
- */
- while (1) {
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
- if (__pyx_t_7) {
- } else {
- __pyx_t_8 = __pyx_t_7;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_7 = (((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0);
- if (__pyx_t_7) {
- } else {
- __pyx_t_8 = __pyx_t_7;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_7 = ((((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) >= __pyx_v_self->_maxsize) != 0);
- __pyx_t_8 = __pyx_t_7;
- __pyx_L9_bool_binop_done:;
- if (!__pyx_t_8) break;
-
- /* "src/gevent/queue.py":263
- * # Check if possible to get a free slot in the queue.
- * while self.getters and self.qsize() and self.qsize() >= self._maxsize:
- * getter = self.getters.popleft() # <<<<<<<<<<<<<<
- * getter.switch(getter)
- * if self.qsize() < self._maxsize:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->getters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF_SET(__pyx_v_getter, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":264
- * while self.getters and self.qsize() and self.qsize() >= self._maxsize:
- * getter = self.getters.popleft()
- * getter.switch(getter) # <<<<<<<<<<<<<<
- * if self.qsize() < self._maxsize:
- * self._put(item)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_getter, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_getter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_getter};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_getter};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_getter);
- __Pyx_GIVEREF(__pyx_v_getter);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_getter);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":265
- * getter = self.getters.popleft()
- * getter.switch(getter)
- * if self.qsize() < self._maxsize: # <<<<<<<<<<<<<<
- * self._put(item)
- * return
- */
- __pyx_t_8 = ((((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) < __pyx_v_self->_maxsize) != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/queue.py":266
- * getter.switch(getter)
- * if self.qsize() < self._maxsize:
- * self._put(item) # <<<<<<<<<<<<<<
- * return
- * raise Full
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_put(__pyx_v_self, __pyx_v_item, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":267
- * if self.qsize() < self._maxsize:
- * self._put(item)
- * return # <<<<<<<<<<<<<<
- * raise Full
- * elif block:
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":265
- * getter = self.getters.popleft()
- * getter.switch(getter)
- * if self.qsize() < self._maxsize: # <<<<<<<<<<<<<<
- * self._put(item)
- * return
- */
- }
-
- /* "src/gevent/queue.py":268
- * self._put(item)
- * return
- * raise Full # <<<<<<<<<<<<<<
- * elif block:
- * waiter = ItemWaiter(item, self)
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Full); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 268, __pyx_L1_error)
-
- /* "src/gevent/queue.py":259
- * if self.getters:
- * self._schedule_unlock()
- * elif self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * # We're in the mainloop, so we cannot wait; we can switch to other greenlets though.
- * # Check if possible to get a free slot in the queue.
- */
- }
-
- /* "src/gevent/queue.py":269
- * return
- * raise Full
- * elif block: # <<<<<<<<<<<<<<
- * waiter = ItemWaiter(item, self)
- * self.putters.append(waiter)
- */
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 269, __pyx_L1_error)
- if (likely(__pyx_t_8)) {
-
- /* "src/gevent/queue.py":270
- * raise Full
- * elif block:
- * waiter = ItemWaiter(item, self) # <<<<<<<<<<<<<<
- * self.putters.append(waiter)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_item);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self));
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_6_queue_ItemWaiter), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":271
- * elif block:
- * waiter = ItemWaiter(item, self)
- * self.putters.append(waiter) # <<<<<<<<<<<<<<
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- */
- __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->putters, ((PyObject *)__pyx_v_waiter)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 271, __pyx_L1_error)
-
- /* "src/gevent/queue.py":272
- * waiter = ItemWaiter(item, self)
- * self.putters.append(waiter)
- * timeout = Timeout._start_new_or_dummy(timeout, Full) # <<<<<<<<<<<<<<
- * try:
- * if self.getters:
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Full); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":273
- * self.putters.append(waiter)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try: # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- /*try:*/ {
-
- /* "src/gevent/queue.py":274
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 274, __pyx_L14_error)
- if (__pyx_t_8) {
-
- /* "src/gevent/queue.py":275
- * try:
- * if self.getters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * result = waiter.get()
- * if result is not waiter:
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":274
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- }
-
- /* "src/gevent/queue.py":276
- * if self.getters:
- * self._schedule_unlock()
- * result = waiter.get() # <<<<<<<<<<<<<<
- * if result is not waiter:
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter *)__pyx_v_waiter->__pyx_base.__pyx_vtab)->__pyx_base.get(((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_v_waiter), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_result = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":277
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- * finally:
- */
- __pyx_t_8 = (__pyx_v_result != ((PyObject *)__pyx_v_waiter));
- __pyx_t_7 = (__pyx_t_8 != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "src/gevent/queue.py":278
- * result = waiter.get()
- * if result is not waiter:
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, )) # <<<<<<<<<<<<<<
- * finally:
- * timeout.cancel()
- */
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_result);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Queue_put_r, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 278, __pyx_L14_error)
-
- /* "src/gevent/queue.py":277
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- * finally:
- */
- }
- }
-
- /* "src/gevent/queue.py":280
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- * finally:
- * timeout.cancel() # <<<<<<<<<<<<<<
- * _safe_remove(self.putters, waiter)
- * else:
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":281
- * finally:
- * timeout.cancel()
- * _safe_remove(self.putters, waiter) # <<<<<<<<<<<<<<
- * else:
- * raise Full
- */
- __pyx_t_2 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_6 = __pyx_f_6gevent_6_queue__safe_remove(__pyx_t_2, ((PyObject *)__pyx_v_waiter)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L15;
- }
- __pyx_L14_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __pyx_t_5 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
- {
-
- /* "src/gevent/queue.py":280
- * raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- * finally:
- * timeout.cancel() # <<<<<<<<<<<<<<
- * _safe_remove(self.putters, waiter)
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L19_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L19_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L19_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":281
- * finally:
- * timeout.cancel()
- * _safe_remove(self.putters, waiter) # <<<<<<<<<<<<<<
- * else:
- * raise Full
- */
- __pyx_t_6 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_6);
- __pyx_t_2 = __pyx_f_6gevent_6_queue__safe_remove(__pyx_t_6, ((PyObject *)__pyx_v_waiter)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L19_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
- goto __pyx_L1_error;
- __pyx_L19_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L15:;
- }
-
- /* "src/gevent/queue.py":269
- * return
- * raise Full
- * elif block: # <<<<<<<<<<<<<<
- * waiter = ItemWaiter(item, self)
- * self.putters.append(waiter)
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/queue.py":283
- * _safe_remove(self.putters, waiter)
- * else:
- * raise Full # <<<<<<<<<<<<<<
- *
- * def put_nowait(self, item):
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Full); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 283, __pyx_L1_error)
- }
- __pyx_L3:;
-
- /* "src/gevent/queue.py":243
- * return self._maxsize > 0 and self.qsize() >= self._maxsize
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Put an item into the queue.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._queue.Queue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_getter);
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_31put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_30put[] = "Queue.put(self, item, block=True, timeout=None)\nPut an item into the queue.\n\n If optional arg *block* is true and *timeout* is ``None`` (the default),\n block if necessary until a free slot is available. If *timeout* is\n a positive number, it blocks at most *timeout* seconds and raises\n the :class:`Full` exception if no free slot was available within that time.\n Otherwise (*block* is false), put an item on the queue if a free slot\n is immediately available, else raise the :class:`Full` exception (*timeout*\n is ignored in that case).\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_31put = {"put", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_31put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_5Queue_30put};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_31put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_item = 0;
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item,&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 243, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_item = values[0];
- __pyx_v_block = values[1];
- __pyx_v_timeout = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("put", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 243, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Queue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_30put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_item, __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_30put(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_put __pyx_t_2;
- __Pyx_RefNannySetupContext("put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_queue_Queue->put(__pyx_v_self, __pyx_v_item, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":285
- * raise Full
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * """Put an item into the queue without blocking.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_33put_nowait(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_put_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_put __pyx_t_6;
- __Pyx_RefNannySetupContext("put_nowait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put_nowait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_33put_nowait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_item);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":291
- * Otherwise raise the :class:`Full` exception.
- * """
- * self.put(item, False) # <<<<<<<<<<<<<<
- *
- * def __get_or_peek(self, method, block, timeout):
- */
- __pyx_t_6.__pyx_n = 1;
- __pyx_t_6.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->put(__pyx_v_self, __pyx_v_item, 0, &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":285
- * raise Full
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * """Put an item into the queue without blocking.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.Queue.put_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_33put_nowait(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_32put_nowait[] = "Queue.put_nowait(self, item)\nPut an item into the queue without blocking.\n\n Only enqueue the item if a free slot is immediately available.\n Otherwise raise the :class:`Full` exception.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_33put_nowait = {"put_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_33put_nowait, METH_O, __pyx_doc_6gevent_6_queue_5Queue_32put_nowait};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_33put_nowait(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_32put_nowait(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_32put_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("put_nowait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue_put_nowait(__pyx_v_self, __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.put_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":293
- * self.put(item, False)
- *
- * def __get_or_peek(self, method, block, timeout): # <<<<<<<<<<<<<<
- * # Internal helper method. The `method` should be either
- * # self._get when called from self.get() or self._peek when
- */
-
-static PyObject *__pyx_f_6gevent_6_queue_5Queue___get_or_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_method, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- int __pyx_t_10;
- char const *__pyx_t_11;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- __Pyx_RefNannySetupContext("__get_or_peek", 0);
- __Pyx_INCREF(__pyx_v_timeout);
-
- /* "src/gevent/queue.py":299
- * # to see if there are items in the queue.
- *
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet
- * # there are no items in the queue; try to fix the situation by unlocking putters
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = (__pyx_v_self->hub == __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":302
- * # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet
- * # there are no items in the queue; try to fix the situation by unlocking putters
- * while self.putters: # <<<<<<<<<<<<<<
- * # Note: get() used popleft(), peek used pop(); popleft
- * # is almost certainly correct.
- */
- while (1) {
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 302, __pyx_L1_error)
- if (!__pyx_t_5) break;
-
- /* "src/gevent/queue.py":305
- * # Note: get() used popleft(), peek used pop(); popleft
- * # is almost certainly correct.
- * self.putters.popleft().put_and_switch() # <<<<<<<<<<<<<<
- * if self.qsize():
- * return method()
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->putters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put_and_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":306
- * # is almost certainly correct.
- * self.putters.popleft().put_and_switch()
- * if self.qsize(): # <<<<<<<<<<<<<<
- * return method()
- * raise Empty()
- */
- __pyx_t_5 = (((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":307
- * self.putters.popleft().put_and_switch()
- * if self.qsize():
- * return method() # <<<<<<<<<<<<<<
- * raise Empty()
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_method);
- __pyx_t_3 = __pyx_v_method; __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":306
- * # is almost certainly correct.
- * self.putters.popleft().put_and_switch()
- * if self.qsize(): # <<<<<<<<<<<<<<
- * return method()
- * raise Empty()
- */
- }
- }
-
- /* "src/gevent/queue.py":308
- * if self.qsize():
- * return method()
- * raise Empty() # <<<<<<<<<<<<<<
- *
- * if not block:
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 308, __pyx_L1_error)
-
- /* "src/gevent/queue.py":299
- * # to see if there are items in the queue.
- *
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet
- * # there are no items in the queue; try to fix the situation by unlocking putters
- */
- }
-
- /* "src/gevent/queue.py":310
- * raise Empty()
- *
- * if not block: # <<<<<<<<<<<<<<
- * # We can't block, we're not the hub, and we have nothing
- * # to return. No choice...
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 310, __pyx_L1_error)
- __pyx_t_4 = ((!__pyx_t_5) != 0);
- if (unlikely(__pyx_t_4)) {
-
- /* "src/gevent/queue.py":313
- * # We can't block, we're not the hub, and we have nothing
- * # to return. No choice...
- * raise Empty() # <<<<<<<<<<<<<<
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 313, __pyx_L1_error)
-
- /* "src/gevent/queue.py":310
- * raise Empty()
- *
- * if not block: # <<<<<<<<<<<<<<
- * # We can't block, we're not the hub, and we have nothing
- * # to return. No choice...
- */
- }
-
- /* "src/gevent/queue.py":315
- * raise Empty()
- *
- * waiter = Waiter() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":316
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty) # <<<<<<<<<<<<<<
- * try:
- * self.getters.append(waiter)
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_timeout, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_timeout, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":317
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try: # <<<<<<<<<<<<<<
- * self.getters.append(waiter)
- * if self.putters:
- */
- /*try:*/ {
-
- /* "src/gevent/queue.py":318
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try:
- * self.getters.append(waiter) # <<<<<<<<<<<<<<
- * if self.putters:
- * self._schedule_unlock()
- */
- __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->getters, ((PyObject *)__pyx_v_waiter)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 318, __pyx_L9_error)
-
- /* "src/gevent/queue.py":319
- * try:
- * self.getters.append(waiter)
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 319, __pyx_L9_error)
- if (__pyx_t_4) {
-
- /* "src/gevent/queue.py":320
- * self.getters.append(waiter)
- * if self.putters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * result = waiter.get()
- * if result is not waiter:
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":319
- * try:
- * self.getters.append(waiter)
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- }
-
- /* "src/gevent/queue.py":321
- * if self.putters:
- * self._schedule_unlock()
- * result = waiter.get() # <<<<<<<<<<<<<<
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, ))
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *)__pyx_v_waiter->__pyx_vtab)->get(__pyx_v_waiter, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":322
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, ))
- * return method()
- */
- __pyx_t_4 = (__pyx_v_result != ((PyObject *)__pyx_v_waiter));
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (unlikely(__pyx_t_5)) {
-
- /* "src/gevent/queue.py":323
- * result = waiter.get()
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, )) # <<<<<<<<<<<<<<
- * return method()
- * finally:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_result);
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Queue_get_r, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 323, __pyx_L9_error)
-
- /* "src/gevent/queue.py":322
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, ))
- * return method()
- */
- }
-
- /* "src/gevent/queue.py":324
- * if result is not waiter:
- * raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, ))
- * return method() # <<<<<<<<<<<<<<
- * finally:
- * timeout.cancel()
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_method);
- __pyx_t_2 = __pyx_v_method; __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L9_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L9_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L8_return;
- }
-
- /* "src/gevent/queue.py":326
- * return method()
- * finally:
- * timeout.cancel() # <<<<<<<<<<<<<<
- * _safe_remove(self.getters, waiter)
- *
- */
- /*finally:*/ {
- __pyx_L9_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __pyx_t_7 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
- {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L14_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L14_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":327
- * finally:
- * timeout.cancel()
- * _safe_remove(self.getters, waiter) # <<<<<<<<<<<<<<
- *
- * def get(self, block=True, timeout=None):
- */
- __pyx_t_1 = __pyx_v_self->getters;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = __pyx_f_6gevent_6_queue__safe_remove(__pyx_t_1, ((PyObject *)__pyx_v_waiter)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L14_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
- goto __pyx_L1_error;
- __pyx_L14_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L8_return: {
- __pyx_t_17 = __pyx_r;
- __pyx_r = 0;
-
- /* "src/gevent/queue.py":326
- * return method()
- * finally:
- * timeout.cancel() # <<<<<<<<<<<<<<
- * _safe_remove(self.getters, waiter)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (__pyx_t_6) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":327
- * finally:
- * timeout.cancel()
- * _safe_remove(self.getters, waiter) # <<<<<<<<<<<<<<
- *
- * def get(self, block=True, timeout=None):
- */
- __pyx_t_2 = __pyx_v_self->getters;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_1 = __pyx_f_6gevent_6_queue__safe_remove(__pyx_t_2, ((PyObject *)__pyx_v_waiter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_17;
- __pyx_t_17 = 0;
- goto __pyx_L0;
- }
- }
-
- /* "src/gevent/queue.py":293
- * self.put(item, False)
- *
- * def __get_or_peek(self, method, block, timeout): # <<<<<<<<<<<<<<
- * # Internal helper method. The `method` should be either
- * # self._get when called from self.get() or self._peek when
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent._queue.Queue.__get_or_peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":329
- * _safe_remove(self.getters, waiter)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_35get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_get *__pyx_optional_args) {
- PyObject *__pyx_v_block = ((PyObject *)Py_True);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("get", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_block = __pyx_optional_args->block;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_35get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_block);
- __Pyx_GIVEREF(__pyx_v_block);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_block);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":339
- * (*timeout* is ignored in that case).
- * """
- * if self.qsize(): # <<<<<<<<<<<<<<
- * if self.putters:
- * self._schedule_unlock()
- */
- __pyx_t_7 = (((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":340
- * """
- * if self.qsize():
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * return self._get()
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 340, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":341
- * if self.qsize():
- * if self.putters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * return self._get()
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":340
- * """
- * if self.qsize():
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * return self._get()
- */
- }
-
- /* "src/gevent/queue.py":342
- * if self.putters:
- * self._schedule_unlock()
- * return self._get() # <<<<<<<<<<<<<<
- *
- * return self.__get_or_peek(self._get, block, timeout)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_get(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":339
- * (*timeout* is ignored in that case).
- * """
- * if self.qsize(): # <<<<<<<<<<<<<<
- * if self.putters:
- * self._schedule_unlock()
- */
- }
-
- /* "src/gevent/queue.py":344
- * return self._get()
- *
- * return self.__get_or_peek(self._get, block, timeout) # <<<<<<<<<<<<<<
- *
- * def get_nowait(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->__pyx___get_or_peek(__pyx_v_self, __pyx_t_1, __pyx_v_block, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":329
- * _safe_remove(self.getters, waiter)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._queue.Queue.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_35get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_34get[] = "Queue.get(self, block=True, timeout=None)\nRemove and return an item from the queue.\n\n If optional args *block* is true and *timeout* is ``None`` (the default),\n block if necessary until an item is available. If *timeout* is a positive number,\n it blocks at most *timeout* seconds and raises the :class:`Empty` exception\n if no item was available within that time. Otherwise (*block* is false), return\n an item if one is immediately available, else raise the :class:`Empty` exception\n (*timeout* is ignored in that case).\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_35get = {"get", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_35get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_5Queue_34get};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_35get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 329, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_block = values[0];
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("get", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 329, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Queue.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_34get(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_34get(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_get __pyx_t_2;
- __Pyx_RefNannySetupContext("get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_queue_Queue->get(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":346
- * return self.__get_or_peek(self._get, block, timeout)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue without blocking.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_37get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_get_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_get __pyx_t_5;
- __Pyx_RefNannySetupContext("get_nowait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_nowait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_37get_nowait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":352
- * raise the :class:`Empty` exception.
- * """
- * return self.get(False) # <<<<<<<<<<<<<<
- *
- * def peek(self, block=True, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_5.__pyx_n = 1;
- __pyx_t_5.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, &__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":346
- * return self.__get_or_peek(self._get, block, timeout)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue without blocking.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue.get_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_37get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_36get_nowait[] = "Queue.get_nowait(self)\nRemove and return an item from the queue without blocking.\n\n Only get an item if one is immediately available. Otherwise\n raise the :class:`Empty` exception.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_37get_nowait = {"get_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_37get_nowait, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_36get_nowait};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_37get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_36get_nowait(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_36get_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_nowait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue_get_nowait(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.get_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":354
- * return self.get(False)
- *
- * def peek(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return an item from the queue without removing it.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_39peek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_peek *__pyx_optional_args) {
- PyObject *__pyx_v_block = ((PyObject *)Py_True);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("peek", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_block = __pyx_optional_args->block;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peek_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_39peek)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_block);
- __Pyx_GIVEREF(__pyx_v_block);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_block);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":364
- * (*timeout* is ignored in that case).
- * """
- * if self.qsize(): # <<<<<<<<<<<<<<
- * # XXX: Why doesn't this schedule an unlock like get() does?
- * return self._peek()
- */
- __pyx_t_7 = (((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":366
- * if self.qsize():
- * # XXX: Why doesn't this schedule an unlock like get() does?
- * return self._peek() # <<<<<<<<<<<<<<
- *
- * return self.__get_or_peek(self._peek, block, timeout)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_peek(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":364
- * (*timeout* is ignored in that case).
- * """
- * if self.qsize(): # <<<<<<<<<<<<<<
- * # XXX: Why doesn't this schedule an unlock like get() does?
- * return self._peek()
- */
- }
-
- /* "src/gevent/queue.py":368
- * return self._peek()
- *
- * return self.__get_or_peek(self._peek, block, timeout) # <<<<<<<<<<<<<<
- *
- * def peek_nowait(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peek); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->__pyx___get_or_peek(__pyx_v_self, __pyx_t_1, __pyx_v_block, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":354
- * return self.get(False)
- *
- * def peek(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return an item from the queue without removing it.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._queue.Queue.peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_39peek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_38peek[] = "Queue.peek(self, block=True, timeout=None)\nReturn an item from the queue without removing it.\n\n If optional args *block* is true and *timeout* is ``None`` (the default),\n block if necessary until an item is available. If *timeout* is a positive number,\n it blocks at most *timeout* seconds and raises the :class:`Empty` exception\n if no item was available within that time. Otherwise (*block* is false), return\n an item if one is immediately available, else raise the :class:`Empty` exception\n (*timeout* is ignored in that case).\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_39peek = {"peek", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_39peek, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_5Queue_38peek};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_39peek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("peek (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peek") < 0)) __PYX_ERR(0, 354, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_block = values[0];
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("peek", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 354, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Queue.peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_38peek(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_38peek(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_peek __pyx_t_2;
- __Pyx_RefNannySetupContext("peek", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_queue_Queue->peek(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":370
- * return self.__get_or_peek(self._peek, block, timeout)
- *
- * def peek_nowait(self): # <<<<<<<<<<<<<<
- * """Return an item from the queue without blocking.
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_41peek_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_5Queue_peek_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_peek __pyx_t_5;
- __Pyx_RefNannySetupContext("peek_nowait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peek_nowait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_41peek_nowait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":376
- * raise the :class:`Empty` exception.
- * """
- * return self.peek(False) # <<<<<<<<<<<<<<
- *
- * def _unlock(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_5.__pyx_n = 1;
- __pyx_t_5.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->peek(__pyx_v_self, 0, &__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":370
- * return self.__get_or_peek(self._peek, block, timeout)
- *
- * def peek_nowait(self): # <<<<<<<<<<<<<<
- * """Return an item from the queue without blocking.
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Queue.peek_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_41peek_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_40peek_nowait[] = "Queue.peek_nowait(self)\nReturn an item from the queue without blocking.\n\n Only return an item if one is immediately available. Otherwise\n raise the :class:`Empty` exception.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_41peek_nowait = {"peek_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_41peek_nowait, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_40peek_nowait};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_41peek_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("peek_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_40peek_nowait(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_40peek_nowait(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("peek_nowait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue_peek_nowait(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.peek_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":378
- * return self.peek(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while True:
- * repeat = False
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_43_unlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_5Queue_42_unlock[] = "Queue._unlock(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_5Queue_43_unlock = {"_unlock", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_43_unlock, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_42_unlock};
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_43_unlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_unlock (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_42_unlock(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_42_unlock(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- int __pyx_v_repeat;
- PyObject *__pyx_v_putter = NULL;
- PyObject *__pyx_v_getter = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- __Pyx_RefNannySetupContext("_unlock", 0);
-
- /* "src/gevent/queue.py":379
- *
- * def _unlock(self):
- * while True: # <<<<<<<<<<<<<<
- * repeat = False
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- */
- while (1) {
-
- /* "src/gevent/queue.py":380
- * def _unlock(self):
- * while True:
- * repeat = False # <<<<<<<<<<<<<<
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- * repeat = True
- */
- __pyx_v_repeat = 0;
-
- /* "src/gevent/queue.py":381
- * while True:
- * repeat = False
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize): # <<<<<<<<<<<<<<
- * repeat = True
- * try:
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_2 = ((__pyx_v_self->_maxsize == -1L) != 0);
- if (!__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_2 = ((((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) < __pyx_v_self->_maxsize) != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L6_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":382
- * repeat = False
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- * repeat = True # <<<<<<<<<<<<<<
- * try:
- * putter = self.putters.popleft()
- */
- __pyx_v_repeat = 1;
-
- /* "src/gevent/queue.py":383
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- * repeat = True
- * try: # <<<<<<<<<<<<<<
- * putter = self.putters.popleft()
- * self._put(putter.item)
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- /*try:*/ {
-
- /* "src/gevent/queue.py":384
- * repeat = True
- * try:
- * putter = self.putters.popleft() # <<<<<<<<<<<<<<
- * self._put(putter.item)
- * except: # pylint:disable=bare-except
- */
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->putters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 384, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- if (__pyx_t_8) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 384, __pyx_L9_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 384, __pyx_L9_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_putter, __pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":385
- * try:
- * putter = self.putters.popleft()
- * self._put(putter.item) # <<<<<<<<<<<<<<
- * except: # pylint:disable=bare-except
- * putter.throw(*sys.exc_info())
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_putter, __pyx_n_s_item); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->_put(__pyx_v_self, __pyx_t_6, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 385, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "src/gevent/queue.py":383
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- * repeat = True
- * try: # <<<<<<<<<<<<<<
- * putter = self.putters.popleft()
- * self._put(putter.item)
- */
- }
-
- /* "src/gevent/queue.py":389
- * putter.throw(*sys.exc_info())
- * else:
- * putter.switch(putter) # <<<<<<<<<<<<<<
- * if self.getters and self.qsize():
- * repeat = True
- */
- /*else:*/ {
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_putter, __pyx_n_s_switch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_8) {
- __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_putter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_putter};
- __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_putter};
- __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_7);
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
- __Pyx_INCREF(__pyx_v_putter);
- __Pyx_GIVEREF(__pyx_v_putter);
- PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_putter);
- __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- goto __pyx_L16_try_end;
- __pyx_L9_error:;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "src/gevent/queue.py":386
- * putter = self.putters.popleft()
- * self._put(putter.item)
- * except: # pylint:disable=bare-except # <<<<<<<<<<<<<<
- * putter.throw(*sys.exc_info())
- * else:
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._queue.Queue._unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_9) < 0) __PYX_ERR(0, 386, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_t_9);
-
- /* "src/gevent/queue.py":387
- * self._put(putter.item)
- * except: # pylint:disable=bare-except
- * putter.throw(*sys.exc_info()) # <<<<<<<<<<<<<<
- * else:
- * putter.switch(putter)
- */
- if (unlikely(!__pyx_v_putter)) { __Pyx_RaiseUnboundLocalError("putter"); __PYX_ERR(0, 387, __pyx_L11_except_error) }
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_putter, __pyx_n_s_throw); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __pyx_t_11 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_12, function);
- }
- }
- if (__pyx_t_11) {
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else {
- __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- }
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 387, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L10_exception_handled;
- }
- __pyx_L11_except_error:;
-
- /* "src/gevent/queue.py":383
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- * repeat = True
- * try: # <<<<<<<<<<<<<<
- * putter = self.putters.popleft()
- * self._put(putter.item)
- */
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L1_error;
- __pyx_L10_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- __pyx_L16_try_end:;
- }
-
- /* "src/gevent/queue.py":381
- * while True:
- * repeat = False
- * if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize): # <<<<<<<<<<<<<<
- * repeat = True
- * try:
- */
- }
-
- /* "src/gevent/queue.py":390
- * else:
- * putter.switch(putter)
- * if self.getters and self.qsize(): # <<<<<<<<<<<<<<
- * repeat = True
- * getter = self.getters.popleft()
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 390, __pyx_L1_error)
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L20_bool_binop_done;
- }
- __pyx_t_2 = (((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->qsize(__pyx_v_self, 0) != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L20_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":391
- * putter.switch(putter)
- * if self.getters and self.qsize():
- * repeat = True # <<<<<<<<<<<<<<
- * getter = self.getters.popleft()
- * getter.switch(getter)
- */
- __pyx_v_repeat = 1;
-
- /* "src/gevent/queue.py":392
- * if self.getters and self.qsize():
- * repeat = True
- * getter = self.getters.popleft() # <<<<<<<<<<<<<<
- * getter.switch(getter)
- * if not repeat:
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->getters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 392, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_7) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 392, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- } else {
- __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 392, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF_SET(__pyx_v_getter, __pyx_t_9);
- __pyx_t_9 = 0;
-
- /* "src/gevent/queue.py":393
- * repeat = True
- * getter = self.getters.popleft()
- * getter.switch(getter) # <<<<<<<<<<<<<<
- * if not repeat:
- * return
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_getter, __pyx_n_s_switch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_getter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_getter};
- __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_getter};
- __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_INCREF(__pyx_v_getter);
- __Pyx_GIVEREF(__pyx_v_getter);
- PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_getter);
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "src/gevent/queue.py":390
- * else:
- * putter.switch(putter)
- * if self.getters and self.qsize(): # <<<<<<<<<<<<<<
- * repeat = True
- * getter = self.getters.popleft()
- */
- }
-
- /* "src/gevent/queue.py":394
- * getter = self.getters.popleft()
- * getter.switch(getter)
- * if not repeat: # <<<<<<<<<<<<<<
- * return
- *
- */
- __pyx_t_1 = ((!(__pyx_v_repeat != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":395
- * getter.switch(getter)
- * if not repeat:
- * return # <<<<<<<<<<<<<<
- *
- * def _schedule_unlock(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":394
- * getter = self.getters.popleft()
- * getter.switch(getter)
- * if not repeat: # <<<<<<<<<<<<<<
- * return
- *
- */
- }
- }
-
- /* "src/gevent/queue.py":378
- * return self.peek(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while True:
- * repeat = False
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_AddTraceback("gevent._queue.Queue._unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_putter);
- __Pyx_XDECREF(__pyx_v_getter);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":397
- * return
- *
- * def _schedule_unlock(self): # <<<<<<<<<<<<<<
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- */
-
-static PyObject *__pyx_f_6gevent_6_queue_5Queue__schedule_unlock(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("_schedule_unlock", 0);
-
- /* "src/gevent/queue.py":398
- *
- * def _schedule_unlock(self):
- * if not self._event_unlock: # <<<<<<<<<<<<<<
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_event_unlock); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 398, __pyx_L1_error)
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/queue.py":399
- * def _schedule_unlock(self):
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock) # <<<<<<<<<<<<<<
- *
- * def __iter__(self):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->hub, __pyx_n_s_loop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_event_unlock);
- __Pyx_DECREF(__pyx_v_self->_event_unlock);
- __pyx_v_self->_event_unlock = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":398
- *
- * def _schedule_unlock(self):
- * if not self._event_unlock: # <<<<<<<<<<<<<<
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- */
- }
-
- /* "src/gevent/queue.py":397
- * return
- *
- * def _schedule_unlock(self): # <<<<<<<<<<<<<<
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._queue.Queue._schedule_unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":401
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_45__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_45__iter__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_44__iter__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_44__iter__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "src/gevent/queue.py":402
- *
- * def __iter__(self):
- * return self # <<<<<<<<<<<<<<
- *
- * def __next__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":401
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":404
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * result = self.get()
- * if result is StopIteration:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_47__next__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_47__next__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_46__next__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_46__next__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "src/gevent/queue.py":405
- *
- * def __next__(self):
- * result = self.get() # <<<<<<<<<<<<<<
- * if result is StopIteration:
- * raise result
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Queue *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":406
- * def __next__(self):
- * result = self.get()
- * if result is StopIteration: # <<<<<<<<<<<<<<
- * raise result
- * return result
- */
- __pyx_t_2 = (__pyx_v_result == __pyx_builtin_StopIteration);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (unlikely(__pyx_t_3)) {
-
- /* "src/gevent/queue.py":407
- * result = self.get()
- * if result is StopIteration:
- * raise result # <<<<<<<<<<<<<<
- * return result
- *
- */
- __Pyx_Raise(__pyx_v_result, 0, 0, 0);
- __PYX_ERR(0, 407, __pyx_L1_error)
-
- /* "src/gevent/queue.py":406
- * def __next__(self):
- * result = self.get()
- * if result is StopIteration: # <<<<<<<<<<<<<<
- * raise result
- * return result
- */
- }
-
- /* "src/gevent/queue.py":408
- * if result is StopIteration:
- * raise result
- * return result # <<<<<<<<<<<<<<
- *
- * next = __next__ # Py2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":404
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * result = self.get()
- * if result is StopIteration:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Queue.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":20
- * cdef class Queue:
- * cdef __weakref__
- * cdef readonly hub # <<<<<<<<<<<<<<
- * cdef readonly queue
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_3hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_3hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_3hub___get__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_3hub___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->hub);
- __pyx_r = __pyx_v_self->hub;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":21
- * cdef __weakref__
- * cdef readonly hub
- * cdef readonly queue # <<<<<<<<<<<<<<
- *
- * cdef getters
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_5queue_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_5Queue_5queue_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_5Queue_5queue___get__(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_5Queue_5queue___get__(struct __pyx_obj_6gevent_6_queue_Queue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->queue);
- __pyx_r = __pyx_v_self->queue;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":419
- * __slots__ = ()
- *
- * def __init__(self, maxsize=None, items=()): # <<<<<<<<<<<<<<
- * if maxsize is not None:
- * raise ValueError("UnboundQueue has no maxsize")
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_12UnboundQueue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_queue_12UnboundQueue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_maxsize = 0;
- PyObject *__pyx_v_items = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_maxsize,&__pyx_n_s_items,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)__pyx_empty_tuple);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 419, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_maxsize = values[0];
- __pyx_v_items = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 419, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.UnboundQueue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_12UnboundQueue___init__(((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)__pyx_v_self), __pyx_v_maxsize, __pyx_v_items);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_12UnboundQueue___init__(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/queue.py":420
- *
- * def __init__(self, maxsize=None, items=()):
- * if maxsize is not None: # <<<<<<<<<<<<<<
- * raise ValueError("UnboundQueue has no maxsize")
- * Queue.__init__(self, maxsize, items)
- */
- __pyx_t_1 = (__pyx_v_maxsize != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/queue.py":421
- * def __init__(self, maxsize=None, items=()):
- * if maxsize is not None:
- * raise ValueError("UnboundQueue has no maxsize") # <<<<<<<<<<<<<<
- * Queue.__init__(self, maxsize, items)
- * self.putters = None # Will never be used.
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 421, __pyx_L1_error)
-
- /* "src/gevent/queue.py":420
- *
- * def __init__(self, maxsize=None, items=()):
- * if maxsize is not None: # <<<<<<<<<<<<<<
- * raise ValueError("UnboundQueue has no maxsize")
- * Queue.__init__(self, maxsize, items)
- */
- }
-
- /* "src/gevent/queue.py":422
- * if maxsize is not None:
- * raise ValueError("UnboundQueue has no maxsize")
- * Queue.__init__(self, maxsize, items) # <<<<<<<<<<<<<<
- * self.putters = None # Will never be used.
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_queue_Queue), __pyx_n_s_init); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_maxsize, __pyx_v_items};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_maxsize, __pyx_v_items};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_maxsize);
- __Pyx_GIVEREF(__pyx_v_maxsize);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_maxsize);
- __Pyx_INCREF(__pyx_v_items);
- __Pyx_GIVEREF(__pyx_v_items);
- PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_items);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":423
- * raise ValueError("UnboundQueue has no maxsize")
- * Queue.__init__(self, maxsize, items)
- * self.putters = None # Will never be used. # <<<<<<<<<<<<<<
- *
- * def put(self, item, block=True, timeout=None):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->__pyx_base.putters);
- __Pyx_DECREF(__pyx_v_self->__pyx_base.putters);
- __pyx_v_self->__pyx_base.putters = Py_None;
-
- /* "src/gevent/queue.py":419
- * __slots__ = ()
- *
- * def __init__(self, maxsize=None, items=()): # <<<<<<<<<<<<<<
- * if maxsize is not None:
- * raise ValueError("UnboundQueue has no maxsize")
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._queue.UnboundQueue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":425
- * self.putters = None # Will never be used.
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * self._put(item)
- * if self.getters:
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_12UnboundQueue_3put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_12UnboundQueue_put(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_item, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_12UnboundQueue_put *__pyx_optional_args) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("put", 0);
- if (__pyx_optional_args) {
- }
-
- /* "src/gevent/queue.py":426
- *
- * def put(self, item, block=True, timeout=None):
- * self._put(item) # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_item, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":427
- * def put(self, item, block=True, timeout=None):
- * self._put(item)
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- *
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base.getters); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 427, __pyx_L1_error)
- if (__pyx_t_2) {
-
- /* "src/gevent/queue.py":428
- * self._put(item)
- * if self.getters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._schedule_unlock(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":427
- * def put(self, item, block=True, timeout=None):
- * self._put(item)
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- *
- */
- }
-
- /* "src/gevent/queue.py":425
- * self.putters = None # Will never be used.
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * self._put(item)
- * if self.getters:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.UnboundQueue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_12UnboundQueue_3put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_12UnboundQueue_2put[] = "UnboundQueue.put(self, item, block=True, timeout=None)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_12UnboundQueue_3put = {"put", (PyCFunction)__pyx_pw_6gevent_6_queue_12UnboundQueue_3put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_12UnboundQueue_2put};
-static PyObject *__pyx_pw_6gevent_6_queue_12UnboundQueue_3put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_item = 0;
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item,&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 425, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_item = values[0];
- __pyx_v_block = values[1];
- __pyx_v_timeout = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("put", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 425, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.UnboundQueue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_12UnboundQueue_2put(((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)__pyx_v_self), __pyx_v_item, __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_12UnboundQueue_2put(struct __pyx_obj_6gevent_6_queue_UnboundQueue *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_5Queue_put __pyx_t_2;
- __Pyx_RefNannySetupContext("put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_queue_UnboundQueue->__pyx_base.put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_item, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.UnboundQueue.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":444
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * q = list(items)
- * _heapify(q)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_1_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13PriorityQueue__create_queue[] = "PriorityQueue._create_queue(self, items=())";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13PriorityQueue_1_create_queue = {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_1_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_13PriorityQueue__create_queue};
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_1_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_items = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_create_queue (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)__pyx_empty_tuple);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_queue") < 0)) __PYX_ERR(0, 444, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_items = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_create_queue", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 444, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_13PriorityQueue__create_queue(((struct __pyx_obj_6gevent_6_queue_PriorityQueue *)__pyx_v_self), __pyx_v_items);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue__create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_items) {
- PyObject *__pyx_v_q = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_create_queue", 0);
-
- /* "src/gevent/queue.py":445
- *
- * def _create_queue(self, items=()):
- * q = list(items) # <<<<<<<<<<<<<<
- * _heapify(q)
- * return q
- */
- __pyx_t_1 = PySequence_List(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_q = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":446
- * def _create_queue(self, items=()):
- * q = list(items)
- * _heapify(q) # <<<<<<<<<<<<<<
- * return q
- *
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_queue__heapify);
- __pyx_t_2 = __pyx_v_6gevent_6_queue__heapify; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_q};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_q};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_q);
- __Pyx_GIVEREF(__pyx_v_q);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_q);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":447
- * q = list(items)
- * _heapify(q)
- * return q # <<<<<<<<<<<<<<
- *
- * def _put(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_q);
- __pyx_r = __pyx_v_q;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":444
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * q = list(items)
- * _heapify(q)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_q);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":449
- * return q
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * _heappush(self.queue, item)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13PriorityQueue__put(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("_put", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_3_put)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_item);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":450
- *
- * def _put(self, item):
- * _heappush(self.queue, item) # <<<<<<<<<<<<<<
- *
- * def _get(self):
- */
- __Pyx_INCREF(__pyx_v_6gevent_6_queue__heappush);
- __pyx_t_2 = __pyx_v_6gevent_6_queue__heappush; __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_self->__pyx_base.queue, __pyx_v_item};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_self->__pyx_base.queue, __pyx_v_item};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_self->__pyx_base.queue);
- __Pyx_GIVEREF(__pyx_v_self->__pyx_base.queue);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_self->__pyx_base.queue);
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_item);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":449
- * return q
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * _heappush(self.queue, item)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13PriorityQueue_2_put[] = "PriorityQueue._put(self, item)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13PriorityQueue_3_put = {"_put", (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_3_put, METH_O, __pyx_doc_6gevent_6_queue_13PriorityQueue_2_put};
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_put (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13PriorityQueue_2_put(((struct __pyx_obj_6gevent_6_queue_PriorityQueue *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue_2_put(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_13PriorityQueue__put(__pyx_v_self, __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":452
- * _heappush(self.queue, item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return _heappop(self.queue)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13PriorityQueue__get(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_5_get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":453
- *
- * def _get(self):
- * return _heappop(self.queue) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_6gevent_6_queue__heappop);
- __pyx_t_2 = __pyx_v_6gevent_6_queue__heappop; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->__pyx_base.queue); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.queue};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self->__pyx_base.queue};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_self->__pyx_base.queue);
- __Pyx_GIVEREF(__pyx_v_self->__pyx_base.queue);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.queue);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":452
- * _heappush(self.queue, item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return _heappop(self.queue)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13PriorityQueue_4_get[] = "PriorityQueue._get(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13PriorityQueue_5_get = {"_get", (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_5_get, METH_NOARGS, __pyx_doc_6gevent_6_queue_13PriorityQueue_4_get};
-static PyObject *__pyx_pw_6gevent_6_queue_13PriorityQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13PriorityQueue_4_get(((struct __pyx_obj_6gevent_6_queue_PriorityQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13PriorityQueue_4_get(struct __pyx_obj_6gevent_6_queue_PriorityQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_13PriorityQueue__get(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.PriorityQueue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":461
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return list(items)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_1_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_9LifoQueue__create_queue[] = "LifoQueue._create_queue(self, items=())";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_9LifoQueue_1_create_queue = {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_1_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_9LifoQueue__create_queue};
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_1_create_queue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_items = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_create_queue (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)__pyx_empty_tuple);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_queue") < 0)) __PYX_ERR(0, 461, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_items = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_create_queue", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 461, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.LifoQueue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_9LifoQueue__create_queue(((struct __pyx_obj_6gevent_6_queue_LifoQueue *)__pyx_v_self), __pyx_v_items);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue__create_queue(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_items) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_create_queue", 0);
-
- /* "src/gevent/queue.py":462
- *
- * def _create_queue(self, items=()):
- * return list(items) # <<<<<<<<<<<<<<
- *
- * def _put(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PySequence_List(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":461
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return list(items)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._create_queue", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":464
- * return list(items)
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__put(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- __Pyx_RefNannySetupContext("_put", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_3_put)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_item);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":465
- *
- * def _put(self, item):
- * self.queue.append(item) # <<<<<<<<<<<<<<
- *
- * def _get(self):
- */
- __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_self->__pyx_base.queue, __pyx_v_item); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 465, __pyx_L1_error)
-
- /* "src/gevent/queue.py":464
- * return list(items)
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_9LifoQueue_2_put[] = "LifoQueue._put(self, item)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_9LifoQueue_3_put = {"_put", (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_3_put, METH_O, __pyx_doc_6gevent_6_queue_9LifoQueue_2_put};
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_3_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_put (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_9LifoQueue_2_put(((struct __pyx_obj_6gevent_6_queue_LifoQueue *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_2_put(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_9LifoQueue__put(__pyx_v_self, __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":467
- * self.queue.append(item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.pop()
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__get(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_5_get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":468
- *
- * def _get(self):
- * return self.queue.pop() # <<<<<<<<<<<<<<
- *
- * def _peek(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_self->__pyx_base.queue); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":467
- * self.queue.append(item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.pop()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_9LifoQueue_4_get[] = "LifoQueue._get(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_9LifoQueue_5_get = {"_get", (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_5_get, METH_NOARGS, __pyx_doc_6gevent_6_queue_9LifoQueue_4_get};
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_5_get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_9LifoQueue_4_get(((struct __pyx_obj_6gevent_6_queue_LifoQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_4_get(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_9LifoQueue__get(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":470
- * return self.queue.pop()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[-1]
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_7_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_9LifoQueue__peek(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_peek", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peek); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_7_peek)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":471
- *
- * def _peek(self):
- * return self.queue[-1] # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->__pyx_base.queue, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":470
- * return self.queue.pop()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[-1]
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_7_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_9LifoQueue_6_peek[] = "LifoQueue._peek(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_9LifoQueue_7_peek = {"_peek", (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_7_peek, METH_NOARGS, __pyx_doc_6gevent_6_queue_9LifoQueue_6_peek};
-static PyObject *__pyx_pw_6gevent_6_queue_9LifoQueue_7_peek(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_peek (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_9LifoQueue_6_peek(((struct __pyx_obj_6gevent_6_queue_LifoQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_9LifoQueue_6_peek(struct __pyx_obj_6gevent_6_queue_LifoQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_peek", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_9LifoQueue__peek(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.LifoQueue._peek", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":485
- * )
- *
- * def __init__(self, maxsize=None, items=(), unfinished_tasks=None): # <<<<<<<<<<<<<<
- * """
- *
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_13JoinableQueue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue___init__[] = "\n\n .. versionchanged:: 1.1a1\n If *unfinished_tasks* is not given, then all the given *items*\n (if any) will be considered unfinished.\n\n ";
-#if CYTHON_COMPILING_IN_CPYTHON
-struct wrapperbase __pyx_wrapperbase_6gevent_6_queue_13JoinableQueue___init__;
-#endif
-static int __pyx_pw_6gevent_6_queue_13JoinableQueue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_maxsize = 0;
- PyObject *__pyx_v_items = 0;
- PyObject *__pyx_v_unfinished_tasks = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_maxsize,&__pyx_n_s_items,&__pyx_n_s_unfinished_tasks,0};
- PyObject* values[3] = {0,0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)__pyx_empty_tuple);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unfinished_tasks);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 485, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_maxsize = values[0];
- __pyx_v_items = values[1];
- __pyx_v_unfinished_tasks = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 485, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue___init__(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self), __pyx_v_maxsize, __pyx_v_items, __pyx_v_unfinished_tasks);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_13JoinableQueue___init__(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_maxsize, PyObject *__pyx_v_items, PyObject *__pyx_v_unfinished_tasks) {
- PyObject *__pyx_v_Event = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- int __pyx_t_6;
- Py_ssize_t __pyx_t_7;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/queue.py":493
- *
- * """
- * Queue.__init__(self, maxsize, items, _warn_depth=3) # <<<<<<<<<<<<<<
- *
- * from gevent.event import Event
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_queue_Queue), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_maxsize);
- __Pyx_GIVEREF(__pyx_v_maxsize);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_maxsize);
- __Pyx_INCREF(__pyx_v_items);
- __Pyx_GIVEREF(__pyx_v_items);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_items);
- __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_warn_depth, __pyx_int_3) < 0) __PYX_ERR(0, 493, __pyx_L1_error)
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 493, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "src/gevent/queue.py":495
- * Queue.__init__(self, maxsize, items, _warn_depth=3)
- *
- * from gevent.event import Event # <<<<<<<<<<<<<<
- * self._cond = Event()
- * self._cond.set()
- */
- __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_n_s_Event);
- __Pyx_GIVEREF(__pyx_n_s_Event);
- PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_Event);
- __pyx_t_3 = __Pyx_Import(__pyx_n_s_gevent_event, __pyx_t_4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Event); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_4);
- __pyx_v_Event = __pyx_t_4;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":496
- *
- * from gevent.event import Event
- * self._cond = Event() # <<<<<<<<<<<<<<
- * self._cond.set()
- *
- */
- __Pyx_INCREF(__pyx_v_Event);
- __pyx_t_4 = __pyx_v_Event; __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6gevent_6_event_Event))))) __PYX_ERR(0, 496, __pyx_L1_error)
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_cond);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->_cond));
- __pyx_v_self->_cond = ((struct __pyx_obj_6gevent_6_event_Event *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":497
- * from gevent.event import Event
- * self._cond = Event()
- * self._cond.set() # <<<<<<<<<<<<<<
- *
- * if unfinished_tasks:
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_cond), __pyx_n_s_set); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 497, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":499
- * self._cond.set()
- *
- * if unfinished_tasks: # <<<<<<<<<<<<<<
- * self.unfinished_tasks = unfinished_tasks
- * elif items:
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_unfinished_tasks); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 499, __pyx_L1_error)
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":500
- *
- * if unfinished_tasks:
- * self.unfinished_tasks = unfinished_tasks # <<<<<<<<<<<<<<
- * elif items:
- * self.unfinished_tasks = len(items)
- */
- __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_unfinished_tasks); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L1_error)
- __pyx_v_self->unfinished_tasks = __pyx_t_6;
-
- /* "src/gevent/queue.py":499
- * self._cond.set()
- *
- * if unfinished_tasks: # <<<<<<<<<<<<<<
- * self.unfinished_tasks = unfinished_tasks
- * elif items:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/queue.py":501
- * if unfinished_tasks:
- * self.unfinished_tasks = unfinished_tasks
- * elif items: # <<<<<<<<<<<<<<
- * self.unfinished_tasks = len(items)
- * else:
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_items); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 501, __pyx_L1_error)
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":502
- * self.unfinished_tasks = unfinished_tasks
- * elif items:
- * self.unfinished_tasks = len(items) # <<<<<<<<<<<<<<
- * else:
- * self.unfinished_tasks = 0
- */
- __pyx_t_7 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 502, __pyx_L1_error)
- __pyx_v_self->unfinished_tasks = __pyx_t_7;
-
- /* "src/gevent/queue.py":501
- * if unfinished_tasks:
- * self.unfinished_tasks = unfinished_tasks
- * elif items: # <<<<<<<<<<<<<<
- * self.unfinished_tasks = len(items)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "src/gevent/queue.py":504
- * self.unfinished_tasks = len(items)
- * else:
- * self.unfinished_tasks = 0 # <<<<<<<<<<<<<<
- *
- * if self.unfinished_tasks:
- */
- /*else*/ {
- __pyx_v_self->unfinished_tasks = 0;
- }
- __pyx_L3:;
-
- /* "src/gevent/queue.py":506
- * self.unfinished_tasks = 0
- *
- * if self.unfinished_tasks: # <<<<<<<<<<<<<<
- * self._cond.clear()
- *
- */
- __pyx_t_5 = (__pyx_v_self->unfinished_tasks != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":507
- *
- * if self.unfinished_tasks:
- * self._cond.clear() # <<<<<<<<<<<<<<
- *
- * def copy(self):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_cond), __pyx_n_s_clear); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 507, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_2) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":506
- * self.unfinished_tasks = 0
- *
- * if self.unfinished_tasks: # <<<<<<<<<<<<<<
- * self._cond.clear()
- *
- */
- }
-
- /* "src/gevent/queue.py":485
- * )
- *
- * def __init__(self, maxsize=None, items=(), unfinished_tasks=None): # <<<<<<<<<<<<<<
- * """
- *
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_Event);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":509
- * self._cond.clear()
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue_2copy[] = "JoinableQueue.copy(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13JoinableQueue_3copy = {"copy", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_3copy, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_2copy};
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("copy (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_2copy(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_2copy(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("copy", 0);
-
- /* "src/gevent/queue.py":510
- *
- * def copy(self):
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks) # <<<<<<<<<<<<<<
- *
- * def _format(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maxsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->unfinished_tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __pyx_t_4 = ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))); __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_self->__pyx_base.queue, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_self->__pyx_base.queue, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_self->__pyx_base.queue);
- __Pyx_GIVEREF(__pyx_v_self->__pyx_base.queue);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_self->__pyx_base.queue);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":509
- * self._cond.clear()
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":512
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = Queue._format(self)
- * if self.unfinished_tasks:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_5_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue_4_format[] = "JoinableQueue._format(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13JoinableQueue_5_format = {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_5_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_4_format};
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_5_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_4_format(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_4_format(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- __Pyx_RefNannySetupContext("_format", 0);
-
- /* "src/gevent/queue.py":513
- *
- * def _format(self):
- * result = Queue._format(self) # <<<<<<<<<<<<<<
- * if self.unfinished_tasks:
- * result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_6_queue_Queue), __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":514
- * def _format(self):
- * result = Queue._format(self)
- * if self.unfinished_tasks: # <<<<<<<<<<<<<<
- * result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond)
- * return result
- */
- __pyx_t_5 = (__pyx_v_self->unfinished_tasks != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":515
- * result = Queue._format(self)
- * if self.unfinished_tasks:
- * result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond) # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->unfinished_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 515, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->_cond));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_cond));
- PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self->_cond));
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_tasks_s__cond_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 515, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":514
- * def _format(self):
- * result = Queue._format(self)
- * if self.unfinished_tasks: # <<<<<<<<<<<<<<
- * result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond)
- * return result
- */
- }
-
- /* "src/gevent/queue.py":516
- * if self.unfinished_tasks:
- * result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond)
- * return result # <<<<<<<<<<<<<<
- *
- * def _put(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":512
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = Queue._format(self)
- * if self.unfinished_tasks:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":518
- * return result
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * Queue._put(self, item)
- * self.unfinished_tasks += 1
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_7_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_13JoinableQueue__put(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_item, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("_put", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_7_put)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_item);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":519
- *
- * def _put(self, item):
- * Queue._put(self, item) # <<<<<<<<<<<<<<
- * self.unfinished_tasks += 1
- * self._cond.clear()
- */
- __pyx_t_1 = __pyx_f_6gevent_6_queue_5Queue__put(((struct __pyx_obj_6gevent_6_queue_Queue *)__pyx_v_self), __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":520
- * def _put(self, item):
- * Queue._put(self, item)
- * self.unfinished_tasks += 1 # <<<<<<<<<<<<<<
- * self._cond.clear()
- *
- */
- __pyx_v_self->unfinished_tasks = (__pyx_v_self->unfinished_tasks + 1);
-
- /* "src/gevent/queue.py":521
- * Queue._put(self, item)
- * self.unfinished_tasks += 1
- * self._cond.clear() # <<<<<<<<<<<<<<
- *
- * def task_done(self):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_cond), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":518
- * return result
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * Queue._put(self, item)
- * self.unfinished_tasks += 1
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_7_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue_6_put[] = "JoinableQueue._put(self, item)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13JoinableQueue_7_put = {"_put", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_7_put, METH_O, __pyx_doc_6gevent_6_queue_13JoinableQueue_6_put};
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_7_put(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_put (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_6_put(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_6_put(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_put", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_13JoinableQueue__put(__pyx_v_self, __pyx_v_item, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue._put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":523
- * self._cond.clear()
- *
- * def task_done(self): # <<<<<<<<<<<<<<
- * '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
- * For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_9task_done(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue_8task_done[] = "JoinableQueue.task_done(self)\nIndicate that a formerly enqueued task is complete. Used by queue consumer threads.\n For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue\n that the processing on the task is complete.\n\n If a :meth:`join` is currently blocking, it will resume when all items have been processed\n (meaning that a :meth:`task_done` call was received for every item that had been\n :meth:`put <Queue.put>` into the queue).\n\n Raises a :exc:`ValueError` if called more times than there were items placed in the queue.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13JoinableQueue_9task_done = {"task_done", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_9task_done, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_8task_done};
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_9task_done(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("task_done (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_8task_done(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_8task_done(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("task_done", 0);
-
- /* "src/gevent/queue.py":534
- * Raises a :exc:`ValueError` if called more times than there were items placed in the queue.
- * '''
- * if self.unfinished_tasks <= 0: # <<<<<<<<<<<<<<
- * raise ValueError('task_done() called too many times')
- * self.unfinished_tasks -= 1
- */
- __pyx_t_1 = ((__pyx_v_self->unfinished_tasks <= 0) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "src/gevent/queue.py":535
- * '''
- * if self.unfinished_tasks <= 0:
- * raise ValueError('task_done() called too many times') # <<<<<<<<<<<<<<
- * self.unfinished_tasks -= 1
- * if self.unfinished_tasks == 0:
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 535, __pyx_L1_error)
-
- /* "src/gevent/queue.py":534
- * Raises a :exc:`ValueError` if called more times than there were items placed in the queue.
- * '''
- * if self.unfinished_tasks <= 0: # <<<<<<<<<<<<<<
- * raise ValueError('task_done() called too many times')
- * self.unfinished_tasks -= 1
- */
- }
-
- /* "src/gevent/queue.py":536
- * if self.unfinished_tasks <= 0:
- * raise ValueError('task_done() called too many times')
- * self.unfinished_tasks -= 1 # <<<<<<<<<<<<<<
- * if self.unfinished_tasks == 0:
- * self._cond.set()
- */
- __pyx_v_self->unfinished_tasks = (__pyx_v_self->unfinished_tasks - 1);
-
- /* "src/gevent/queue.py":537
- * raise ValueError('task_done() called too many times')
- * self.unfinished_tasks -= 1
- * if self.unfinished_tasks == 0: # <<<<<<<<<<<<<<
- * self._cond.set()
- *
- */
- __pyx_t_1 = ((__pyx_v_self->unfinished_tasks == 0) != 0);
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":538
- * self.unfinished_tasks -= 1
- * if self.unfinished_tasks == 0:
- * self._cond.set() # <<<<<<<<<<<<<<
- *
- * def join(self, timeout=None):
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_cond), __pyx_n_s_set); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 538, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":537
- * raise ValueError('task_done() called too many times')
- * self.unfinished_tasks -= 1
- * if self.unfinished_tasks == 0: # <<<<<<<<<<<<<<
- * self._cond.set()
- *
- */
- }
-
- /* "src/gevent/queue.py":523
- * self._cond.clear()
- *
- * def task_done(self): # <<<<<<<<<<<<<<
- * '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
- * For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.task_done", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":540
- * self._cond.set()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * '''
- * Block until all items in the queue have been gotten and processed.
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_11join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_13JoinableQueue_10join[] = "JoinableQueue.join(self, timeout=None)\n\n Block until all items in the queue have been gotten and processed.\n\n The count of unfinished tasks goes up whenever an item is added to the queue.\n The count goes down whenever a consumer thread calls :meth:`task_done` to indicate\n that the item was retrieved and all work on it is complete. When the count of\n unfinished tasks drops to zero, :meth:`join` unblocks.\n\n :param float timeout: If not ``None``, then wait no more than this time in seconds\n for all tasks to finish.\n :return: ``True`` if all tasks have finished; if ``timeout`` was given and expired before\n all tasks finished, ``False``.\n\n .. versionchanged:: 1.1a1\n Add the *timeout* parameter.\n ";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_13JoinableQueue_11join = {"join", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_11join, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_13JoinableQueue_10join};
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_11join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("join (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "join") < 0)) __PYX_ERR(0, 540, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_timeout = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("join", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 540, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_10join(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self), __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_10join(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("join", 0);
-
- /* "src/gevent/queue.py":557
- * Add the *timeout* parameter.
- * '''
- * return self._cond.wait(timeout=timeout) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_cond), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 557, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_timeout, __pyx_v_timeout) < 0) __PYX_ERR(0, 557, __pyx_L1_error)
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 557, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":540
- * self._cond.set()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * '''
- * Block until all items in the queue have been gotten and processed.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":61
- * cdef class JoinableQueue(Queue):
- * cdef Event _cond
- * cdef readonly int unfinished_tasks # <<<<<<<<<<<<<<
- *
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_16unfinished_tasks_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_13JoinableQueue_16unfinished_tasks_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_13JoinableQueue_16unfinished_tasks___get__(((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_13JoinableQueue_16unfinished_tasks___get__(struct __pyx_obj_6gevent_6_queue_JoinableQueue *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->unfinished_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 61, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.JoinableQueue.unfinished_tasks.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":570
- * )
- *
- * def __init__(self, maxsize=1): # <<<<<<<<<<<<<<
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1:
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_6_queue_7Channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_6_queue_7Channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_maxsize = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_maxsize,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)__pyx_int_1);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 570, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_maxsize = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 570, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel___init__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self), __pyx_v_maxsize);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_6_queue_7Channel___init__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_maxsize) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "src/gevent/queue.py":572
- * def __init__(self, maxsize=1):
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1: # <<<<<<<<<<<<<<
- * raise ValueError("Channels have a maxsize of 1")
- * self.getters = collections.deque()
- */
- __pyx_t_1 = PyObject_RichCompare(__pyx_v_maxsize, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 572, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(__pyx_t_2)) {
-
- /* "src/gevent/queue.py":573
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1:
- * raise ValueError("Channels have a maxsize of 1") # <<<<<<<<<<<<<<
- * self.getters = collections.deque()
- * self.putters = collections.deque()
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 573, __pyx_L1_error)
-
- /* "src/gevent/queue.py":572
- * def __init__(self, maxsize=1):
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1: # <<<<<<<<<<<<<<
- * raise ValueError("Channels have a maxsize of 1")
- * self.getters = collections.deque()
- */
- }
-
- /* "src/gevent/queue.py":574
- * if maxsize != 1:
- * raise ValueError("Channels have a maxsize of 1")
- * self.getters = collections.deque() # <<<<<<<<<<<<<<
- * self.putters = collections.deque()
- * self.hub = get_hub()
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_deque); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->getters);
- __Pyx_DECREF(__pyx_v_self->getters);
- __pyx_v_self->getters = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":575
- * raise ValueError("Channels have a maxsize of 1")
- * self.getters = collections.deque()
- * self.putters = collections.deque() # <<<<<<<<<<<<<<
- * self.hub = get_hub()
- * self._event_unlock = None
- */
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deque); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->putters);
- __Pyx_DECREF(__pyx_v_self->putters);
- __pyx_v_self->putters = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":576
- * self.getters = collections.deque()
- * self.putters = collections.deque()
- * self.hub = get_hub() # <<<<<<<<<<<<<<
- * self._event_unlock = None
- *
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 576, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->hub);
- __Pyx_DECREF(__pyx_v_self->hub);
- __pyx_v_self->hub = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":577
- * self.putters = collections.deque()
- * self.hub = get_hub()
- * self._event_unlock = None # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_event_unlock);
- __Pyx_DECREF(__pyx_v_self->_event_unlock);
- __pyx_v_self->_event_unlock = Py_None;
-
- /* "src/gevent/queue.py":570
- * )
- *
- * def __init__(self, maxsize=1): # <<<<<<<<<<<<<<
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1:
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":579
- * self._event_unlock = None
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_3__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_3__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_2__repr__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_2__repr__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "src/gevent/queue.py":580
- *
- * def __repr__(self):
- * return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format()) # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_at_s_s_2, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":579
- * self._event_unlock = None
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.Channel.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":582
- * return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_5__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_5__str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_4__str__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_4__str__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "src/gevent/queue.py":583
- *
- * def __str__(self):
- * return '<%s %s>' % (type(self).__name__, self._format()) # <<<<<<<<<<<<<<
- *
- * def _format(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 583, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 583, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":582
- * return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format())
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Channel.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":585
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = ''
- * if self.getters:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_6_format[] = "Channel._format(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_7_format = {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_7_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_6_format};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_format (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_6_format(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_6_format(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("_format", 0);
-
- /* "src/gevent/queue.py":586
- *
- * def _format(self):
- * result = '' # <<<<<<<<<<<<<<
- * if self.getters:
- * result += ' getters[%s]' % len(self.getters)
- */
- __Pyx_INCREF(__pyx_kp_s__3);
- __pyx_v_result = __pyx_kp_s__3;
-
- /* "src/gevent/queue.py":587
- * def _format(self):
- * result = ''
- * if self.getters: # <<<<<<<<<<<<<<
- * result += ' getters[%s]' % len(self.getters)
- * if self.putters:
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 587, __pyx_L1_error)
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":588
- * result = ''
- * if self.getters:
- * result += ' getters[%s]' % len(self.getters) # <<<<<<<<<<<<<<
- * if self.putters:
- * result += ' putters[%s]' % len(self.putters)
- */
- __pyx_t_2 = __pyx_v_self->getters;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_getters_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":587
- * def _format(self):
- * result = ''
- * if self.getters: # <<<<<<<<<<<<<<
- * result += ' getters[%s]' % len(self.getters)
- * if self.putters:
- */
- }
-
- /* "src/gevent/queue.py":589
- * if self.getters:
- * result += ' getters[%s]' % len(self.getters)
- * if self.putters: # <<<<<<<<<<<<<<
- * result += ' putters[%s]' % len(self.putters)
- * return result
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
- if (__pyx_t_1) {
-
- /* "src/gevent/queue.py":590
- * result += ' getters[%s]' % len(self.getters)
- * if self.putters:
- * result += ' putters[%s]' % len(self.putters) # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_t_2 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 590, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 590, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_putters_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 590, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 590, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":589
- * if self.getters:
- * result += ' getters[%s]' % len(self.getters)
- * if self.putters: # <<<<<<<<<<<<<<
- * result += ' putters[%s]' % len(self.putters)
- * return result
- */
- }
-
- /* "src/gevent/queue.py":591
- * if self.putters:
- * result += ' putters[%s]' % len(self.putters)
- * return result # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":585
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = ''
- * if self.getters:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Channel._format", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":594
- *
- * @property
- * def balance(self): # <<<<<<<<<<<<<<
- * return len(self.putters) - len(self.getters)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7balance_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7balance_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_7balance___get__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7balance___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- Py_ssize_t __pyx_t_3;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "src/gevent/queue.py":595
- * @property
- * def balance(self):
- * return len(self.putters) - len(self.getters) # <<<<<<<<<<<<<<
- *
- * def qsize(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 595, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __pyx_v_self->getters;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 595, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_2 - __pyx_t_3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":594
- *
- * @property
- * def balance(self): # <<<<<<<<<<<<<<
- * return len(self.putters) - len(self.getters)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Channel.balance.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":597
- * return len(self.putters) - len(self.getters)
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * return 0
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_9qsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_8qsize[] = "Channel.qsize(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_9qsize = {"qsize", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_9qsize, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_8qsize};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_9qsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("qsize (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_8qsize(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_8qsize(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("qsize", 0);
-
- /* "src/gevent/queue.py":598
- *
- * def qsize(self):
- * return 0 # <<<<<<<<<<<<<<
- *
- * def empty(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_int_0);
- __pyx_r = __pyx_int_0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":597
- * return len(self.putters) - len(self.getters)
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * return 0
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":600
- * return 0
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_11empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_10empty[] = "Channel.empty(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_11empty = {"empty", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_11empty, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_10empty};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_11empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("empty (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_10empty(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_10empty(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("empty", 0);
-
- /* "src/gevent/queue.py":601
- *
- * def empty(self):
- * return True # <<<<<<<<<<<<<<
- *
- * def full(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(Py_True);
- __pyx_r = Py_True;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":600
- * return 0
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":603
- * return True
- *
- * def full(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_13full(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_12full[] = "Channel.full(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_13full = {"full", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_13full, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_12full};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_13full(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("full (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_12full(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_12full(CYTHON_UNUSED struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("full", 0);
-
- /* "src/gevent/queue.py":604
- *
- * def full(self):
- * return True # <<<<<<<<<<<<<<
- *
- * def put(self, item, block=True, timeout=None):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(Py_True);
- __pyx_r = Py_True;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":603
- * return True
- *
- * def full(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":606
- * return True
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.getters:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_15put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_14put[] = "Channel.put(self, item, block=True, timeout=None)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_15put = {"put", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_15put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_7Channel_14put};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_15put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_item = 0;
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item,&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[3] = {0,0,0};
- values[1] = ((PyObject *)Py_True);
- values[2] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) __PYX_ERR(0, 606, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_item = values[0];
- __pyx_v_block = values[1];
- __pyx_v_timeout = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("put", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 606, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Channel.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_14put(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self), __pyx_v_item, __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_14put(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_v_getter = NULL;
- struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- int __pyx_t_13;
- char const *__pyx_t_14;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- __Pyx_RefNannySetupContext("put", 0);
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_INCREF(__pyx_v_timeout);
-
- /* "src/gevent/queue.py":607
- *
- * def put(self, item, block=True, timeout=None):
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * if self.getters:
- * getter = self.getters.popleft()
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 607, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = (__pyx_v_self->hub == __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":608
- * def put(self, item, block=True, timeout=None):
- * if self.hub is getcurrent():
- * if self.getters: # <<<<<<<<<<<<<<
- * getter = self.getters.popleft()
- * getter.switch(item)
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
- if (__pyx_t_5) {
-
- /* "src/gevent/queue.py":609
- * if self.hub is getcurrent():
- * if self.getters:
- * getter = self.getters.popleft() # <<<<<<<<<<<<<<
- * getter.switch(item)
- * return
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->getters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_getter = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":610
- * if self.getters:
- * getter = self.getters.popleft()
- * getter.switch(item) # <<<<<<<<<<<<<<
- * return
- * raise Full
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_getter, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_item); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_item};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_item};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_item);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":611
- * getter = self.getters.popleft()
- * getter.switch(item)
- * return # <<<<<<<<<<<<<<
- * raise Full
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":608
- * def put(self, item, block=True, timeout=None):
- * if self.hub is getcurrent():
- * if self.getters: # <<<<<<<<<<<<<<
- * getter = self.getters.popleft()
- * getter.switch(item)
- */
- }
-
- /* "src/gevent/queue.py":612
- * getter.switch(item)
- * return
- * raise Full # <<<<<<<<<<<<<<
- *
- * if not block:
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Full); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 612, __pyx_L1_error)
-
- /* "src/gevent/queue.py":607
- *
- * def put(self, item, block=True, timeout=None):
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * if self.getters:
- * getter = self.getters.popleft()
- */
- }
-
- /* "src/gevent/queue.py":614
- * raise Full
- *
- * if not block: # <<<<<<<<<<<<<<
- * timeout = 0
- *
- */
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 614, __pyx_L1_error)
- __pyx_t_4 = ((!__pyx_t_5) != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/queue.py":615
- *
- * if not block:
- * timeout = 0 # <<<<<<<<<<<<<<
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_int_0);
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_int_0);
-
- /* "src/gevent/queue.py":614
- * raise Full
- *
- * if not block: # <<<<<<<<<<<<<<
- * timeout = 0
- *
- */
- }
-
- /* "src/gevent/queue.py":617
- * timeout = 0
- *
- * waiter = Waiter() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * item = (item, waiter)
- * self.putters.append(item)
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 617, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":618
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- * item = (item, waiter) # <<<<<<<<<<<<<<
- * self.putters.append(item)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_item);
- __Pyx_INCREF(((PyObject *)__pyx_v_waiter));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_waiter));
- PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_waiter));
- __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":619
- * waiter = Waiter() # pylint:disable=undefined-variable
- * item = (item, waiter)
- * self.putters.append(item) # <<<<<<<<<<<<<<
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- */
- __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_self->putters, __pyx_v_item); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 619, __pyx_L1_error)
-
- /* "src/gevent/queue.py":620
- * item = (item, waiter)
- * self.putters.append(item)
- * timeout = Timeout._start_new_or_dummy(timeout, Full) # <<<<<<<<<<<<<<
- * try:
- * if self.getters:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Full); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":621
- * self.putters.append(item)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try: # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- /*try:*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- /*try:*/ {
-
- /* "src/gevent/queue.py":622
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 622, __pyx_L9_error)
- if (__pyx_t_4) {
-
- /* "src/gevent/queue.py":623
- * try:
- * if self.getters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * result = waiter.get()
- * if result is not waiter:
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Channel *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":622
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try:
- * if self.getters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * result = waiter.get()
- */
- }
-
- /* "src/gevent/queue.py":624
- * if self.getters:
- * self._schedule_unlock()
- * result = waiter.get() # <<<<<<<<<<<<<<
- * if result is not waiter:
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *)__pyx_v_waiter->__pyx_vtab)->get(__pyx_v_waiter, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":625
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- * except:
- */
- __pyx_t_4 = (__pyx_v_result != ((PyObject *)__pyx_v_waiter));
- __pyx_t_5 = (__pyx_t_4 != 0);
- if (unlikely(__pyx_t_5)) {
-
- /* "src/gevent/queue.py":626
- * result = waiter.get()
- * if result is not waiter:
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, )) # <<<<<<<<<<<<<<
- * except:
- * _safe_remove(self.putters, item)
- */
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_result);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Channel_put, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (!__pyx_t_9) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 626, __pyx_L9_error)
-
- /* "src/gevent/queue.py":625
- * self._schedule_unlock()
- * result = waiter.get()
- * if result is not waiter: # <<<<<<<<<<<<<<
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- * except:
- */
- }
-
- /* "src/gevent/queue.py":621
- * self.putters.append(item)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try: # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- }
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- goto __pyx_L14_try_end;
- __pyx_L9_error:;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":627
- * if result is not waiter:
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- * except: # <<<<<<<<<<<<<<
- * _safe_remove(self.putters, item)
- * raise
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._queue.Channel.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 627, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "src/gevent/queue.py":628
- * raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- * except:
- * _safe_remove(self.putters, item) # <<<<<<<<<<<<<<
- * raise
- * finally:
- */
- __pyx_t_2 = __pyx_v_self->putters;
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_9 = __pyx_f_6gevent_6_queue__safe_remove(__pyx_t_2, __pyx_v_item); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 628, __pyx_L11_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "src/gevent/queue.py":629
- * except:
- * _safe_remove(self.putters, item)
- * raise # <<<<<<<<<<<<<<
- * finally:
- * timeout.cancel()
- */
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_6, __pyx_t_3);
- __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_3 = 0;
- __PYX_ERR(0, 629, __pyx_L11_except_error)
- }
- __pyx_L11_except_error:;
-
- /* "src/gevent/queue.py":621
- * self.putters.append(item)
- * timeout = Timeout._start_new_or_dummy(timeout, Full)
- * try: # <<<<<<<<<<<<<<
- * if self.getters:
- * self._schedule_unlock()
- */
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
- goto __pyx_L7_error;
- __pyx_L14_try_end:;
- }
- }
-
- /* "src/gevent/queue.py":631
- * raise
- * finally:
- * timeout.cancel() # <<<<<<<<<<<<<<
- *
- * def put_nowait(self, item):
- */
- /*finally:*/ {
- /*normal exit:*/{
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8;
- }
- __pyx_L7_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __pyx_t_8 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
- {
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_cancel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L20_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L20_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L20_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ErrRestore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
- __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
- goto __pyx_L1_error;
- __pyx_L20_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- }
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L8:;
- }
-
- /* "src/gevent/queue.py":606
- * return True
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.getters:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent._queue.Channel.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_getter);
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":633
- * timeout.cancel()
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * self.put(item, False)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_17put_nowait(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_16put_nowait[] = "Channel.put_nowait(self, item)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_17put_nowait = {"put_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_17put_nowait, METH_O, __pyx_doc_6gevent_6_queue_7Channel_16put_nowait};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_17put_nowait(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("put_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_16put_nowait(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_16put_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("put_nowait", 0);
-
- /* "src/gevent/queue.py":634
- *
- * def put_nowait(self, item):
- * self.put(item, False) # <<<<<<<<<<<<<<
- *
- * def get(self, block=True, timeout=None):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_put_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_item, Py_False};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_item, Py_False};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_item);
- __Pyx_INCREF(Py_False);
- __Pyx_GIVEREF(Py_False);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, Py_False);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":633
- * timeout.cancel()
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * self.put(item, False)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent._queue.Channel.put_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":636
- * self.put(item, False)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.putters:
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_19get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_7Channel_get(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_7Channel_get *__pyx_optional_args) {
- PyObject *__pyx_v_block = ((PyObject *)Py_True);
- PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
- PyObject *__pyx_v_item = NULL;
- PyObject *__pyx_v_putter = NULL;
- struct __pyx_obj_6gevent_8__waiter_Waiter *__pyx_v_waiter = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- PyObject *(*__pyx_t_9)(PyObject *);
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- int __pyx_t_13;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- int __pyx_t_16;
- char const *__pyx_t_17;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- __Pyx_RefNannySetupContext("get", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_block = __pyx_optional_args->block;
- if (__pyx_optional_args->__pyx_n > 1) {
- __pyx_v_timeout = __pyx_optional_args->timeout;
- }
- }
- }
- __Pyx_INCREF(__pyx_v_timeout);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_19get)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_block, __pyx_v_timeout};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_v_block);
- __Pyx_GIVEREF(__pyx_v_block);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_block);
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_timeout);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":637
- *
- * def get(self, block=True, timeout=None):
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * if self.putters:
- * item, putter = self.putters.popleft()
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_7 = (__pyx_v_self->hub == __pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_8 = (__pyx_t_7 != 0);
- if (__pyx_t_8) {
-
- /* "src/gevent/queue.py":638
- * def get(self, block=True, timeout=None):
- * if self.hub is getcurrent():
- * if self.putters: # <<<<<<<<<<<<<<
- * item, putter = self.putters.popleft()
- * self.hub.loop.run_callback(putter.switch, putter)
- */
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 638, __pyx_L1_error)
- if (__pyx_t_8) {
-
- /* "src/gevent/queue.py":639
- * if self.hub is getcurrent():
- * if self.putters:
- * item, putter = self.putters.popleft() # <<<<<<<<<<<<<<
- * self.hub.loop.run_callback(putter.switch, putter)
- * return item
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->putters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 639, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- #else
- __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
- index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_2);
- index = 1; __pyx_t_3 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_3);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_6), 2) < 0) __PYX_ERR(0, 639, __pyx_L1_error)
- __pyx_t_9 = NULL;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_9 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 639, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- __pyx_v_item = __pyx_t_2;
- __pyx_t_2 = 0;
- __pyx_v_putter = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":640
- * if self.putters:
- * item, putter = self.putters.popleft()
- * self.hub.loop.run_callback(putter.switch, putter) # <<<<<<<<<<<<<<
- * return item
- *
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->hub, __pyx_n_s_loop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_putter, __pyx_n_s_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_putter};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_putter};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_putter);
- __Pyx_GIVEREF(__pyx_v_putter);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_putter);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":641
- * item, putter = self.putters.popleft()
- * self.hub.loop.run_callback(putter.switch, putter)
- * return item # <<<<<<<<<<<<<<
- *
- * if not block:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_item);
- __pyx_r = __pyx_v_item;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":638
- * def get(self, block=True, timeout=None):
- * if self.hub is getcurrent():
- * if self.putters: # <<<<<<<<<<<<<<
- * item, putter = self.putters.popleft()
- * self.hub.loop.run_callback(putter.switch, putter)
- */
- }
-
- /* "src/gevent/queue.py":637
- *
- * def get(self, block=True, timeout=None):
- * if self.hub is getcurrent(): # <<<<<<<<<<<<<<
- * if self.putters:
- * item, putter = self.putters.popleft()
- */
- }
-
- /* "src/gevent/queue.py":643
- * return item
- *
- * if not block: # <<<<<<<<<<<<<<
- * timeout = 0
- *
- */
- __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_block); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 643, __pyx_L1_error)
- __pyx_t_7 = ((!__pyx_t_8) != 0);
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":644
- *
- * if not block:
- * timeout = 0 # <<<<<<<<<<<<<<
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- */
- __Pyx_INCREF(__pyx_int_0);
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_int_0);
-
- /* "src/gevent/queue.py":643
- * return item
- *
- * if not block: # <<<<<<<<<<<<<<
- * timeout = 0
- *
- */
- }
-
- /* "src/gevent/queue.py":646
- * timeout = 0
- *
- * waiter = Waiter() # pylint:disable=undefined-variable # <<<<<<<<<<<<<<
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try:
- */
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6gevent_8__waiter_Waiter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_waiter = ((struct __pyx_obj_6gevent_8__waiter_Waiter *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":647
- *
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty) # <<<<<<<<<<<<<<
- * try:
- * self.getters.append(waiter)
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_5 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_5 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_timeout, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_v_timeout);
- PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_timeout);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":648
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try: # <<<<<<<<<<<<<<
- * self.getters.append(waiter)
- * if self.putters:
- */
- /*try:*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- /*try:*/ {
-
- /* "src/gevent/queue.py":649
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try:
- * self.getters.append(waiter) # <<<<<<<<<<<<<<
- * if self.putters:
- * self._schedule_unlock()
- */
- __pyx_t_13 = __Pyx_PyObject_Append(__pyx_v_self->getters, ((PyObject *)__pyx_v_waiter)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 649, __pyx_L11_error)
-
- /* "src/gevent/queue.py":650
- * try:
- * self.getters.append(waiter)
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * return waiter.get()
- */
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 650, __pyx_L11_error)
- if (__pyx_t_7) {
-
- /* "src/gevent/queue.py":651
- * self.getters.append(waiter)
- * if self.putters:
- * self._schedule_unlock() # <<<<<<<<<<<<<<
- * return waiter.get()
- * except:
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Channel *)__pyx_v_self->__pyx_vtab)->_schedule_unlock(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":650
- * try:
- * self.getters.append(waiter)
- * if self.putters: # <<<<<<<<<<<<<<
- * self._schedule_unlock()
- * return waiter.get()
- */
- }
-
- /* "src/gevent/queue.py":652
- * if self.putters:
- * self._schedule_unlock()
- * return waiter.get() # <<<<<<<<<<<<<<
- * except:
- * self.getters.remove(waiter)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8__waiter_Waiter *)__pyx_v_waiter->__pyx_vtab)->get(__pyx_v_waiter, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L15_try_return;
-
- /* "src/gevent/queue.py":648
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try: # <<<<<<<<<<<<<<
- * self.getters.append(waiter)
- * if self.putters:
- */
- }
- __pyx_L11_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":653
- * self._schedule_unlock()
- * return waiter.get()
- * except: # <<<<<<<<<<<<<<
- * self.getters.remove(waiter)
- * raise
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent._queue.Channel.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 653, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_6);
-
- /* "src/gevent/queue.py":654
- * return waiter.get()
- * except:
- * self.getters.remove(waiter) # <<<<<<<<<<<<<<
- * raise
- * finally:
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->getters, __pyx_n_s_remove); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_14 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_14)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_14);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_14) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_waiter)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_waiter)};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
- __Pyx_INCREF(((PyObject *)__pyx_v_waiter));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_waiter));
- PyTuple_SET_ITEM(__pyx_t_15, 0+1, ((PyObject *)__pyx_v_waiter));
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 654, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":655
- * except:
- * self.getters.remove(waiter)
- * raise # <<<<<<<<<<<<<<
- * finally:
- * timeout.close()
- */
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_6);
- __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0;
- __PYX_ERR(0, 655, __pyx_L13_except_error)
- }
- __pyx_L13_except_error:;
-
- /* "src/gevent/queue.py":648
- * waiter = Waiter() # pylint:disable=undefined-variable
- * timeout = Timeout._start_new_or_dummy(timeout, Empty)
- * try: # <<<<<<<<<<<<<<
- * self.getters.append(waiter)
- * if self.putters:
- */
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
- goto __pyx_L9_error;
- __pyx_L15_try_return:;
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
- goto __pyx_L8_return;
- }
- }
-
- /* "src/gevent/queue.py":657
- * raise
- * finally:
- * timeout.close() # <<<<<<<<<<<<<<
- *
- * def get_nowait(self):
- */
- /*finally:*/ {
- __pyx_L9_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_18);
- __Pyx_XGOTREF(__pyx_t_19);
- __Pyx_XGOTREF(__pyx_t_20);
- __pyx_t_5 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
- {
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L21_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L21_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L21_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
- }
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ErrRestore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
- __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
- __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
- goto __pyx_L1_error;
- __pyx_L21_error:;
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
- }
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
- goto __pyx_L1_error;
- }
- __pyx_L8_return: {
- __pyx_t_20 = __pyx_r;
- __pyx_r = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_timeout, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_1) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_r = __pyx_t_20;
- __pyx_t_20 = 0;
- goto __pyx_L0;
- }
- }
-
- /* "src/gevent/queue.py":636
- * self.put(item, False)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.putters:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_AddTraceback("gevent._queue.Channel.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XDECREF(__pyx_v_putter);
- __Pyx_XDECREF((PyObject *)__pyx_v_waiter);
- __Pyx_XDECREF(__pyx_v_timeout);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_19get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_18get[] = "Channel.get(self, block=True, timeout=None)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_19get = {"get", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_19get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_7Channel_18get};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_19get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_block = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_block,&__pyx_n_s_timeout,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_True);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 636, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_block = values[0];
- __pyx_v_timeout = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("get", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 636, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent._queue.Channel.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_18get(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self), __pyx_v_block, __pyx_v_timeout);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_18get(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, PyObject *__pyx_v_block, PyObject *__pyx_v_timeout) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_7Channel_get __pyx_t_2;
- __Pyx_RefNannySetupContext("get", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 2;
- __pyx_t_2.block = __pyx_v_block;
- __pyx_t_2.timeout = __pyx_v_timeout;
- __pyx_t_1 = __pyx_vtabptr_6gevent_6_queue_Channel->get(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Channel.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":659
- * timeout.close()
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * return self.get(False)
- *
- */
-
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_21get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_f_6gevent_6_queue_7Channel_get_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self, int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- struct __pyx_opt_args_6gevent_6_queue_7Channel_get __pyx_t_5;
- __Pyx_RefNannySetupContext("get_nowait", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_nowait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_21get_nowait)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 659, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "src/gevent/queue.py":660
- *
- * def get_nowait(self):
- * return self.get(False) # <<<<<<<<<<<<<<
- *
- * def _unlock(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_5.__pyx_n = 1;
- __pyx_t_5.block = Py_False;
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Channel *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, &__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":659
- * timeout.close()
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * return self.get(False)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent._queue.Channel.get_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_21get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_20get_nowait[] = "Channel.get_nowait(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_21get_nowait = {"get_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_21get_nowait, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_20get_nowait};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_21get_nowait(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get_nowait (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_20get_nowait(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_20get_nowait(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("get_nowait", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_6_queue_7Channel_get_nowait(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Channel.get_nowait", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":662
- * return self.get(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while self.putters and self.getters:
- * getter = self.getters.popleft()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_23_unlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6gevent_6_queue_7Channel_22_unlock[] = "Channel._unlock(self)";
-static PyMethodDef __pyx_mdef_6gevent_6_queue_7Channel_23_unlock = {"_unlock", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_23_unlock, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_22_unlock};
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_23_unlock(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_unlock (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_22_unlock(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_22_unlock(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_v_getter = NULL;
- PyObject *__pyx_v_item = NULL;
- PyObject *__pyx_v_putter = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *(*__pyx_t_7)(PyObject *);
- __Pyx_RefNannySetupContext("_unlock", 0);
-
- /* "src/gevent/queue.py":663
- *
- * def _unlock(self):
- * while self.putters and self.getters: # <<<<<<<<<<<<<<
- * getter = self.getters.popleft()
- * item, putter = self.putters.popleft()
- */
- while (1) {
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->putters); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 663, __pyx_L1_error)
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->getters); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 663, __pyx_L1_error)
- __pyx_t_1 = __pyx_t_2;
- __pyx_L5_bool_binop_done:;
- if (!__pyx_t_1) break;
-
- /* "src/gevent/queue.py":664
- * def _unlock(self):
- * while self.putters and self.getters:
- * getter = self.getters.popleft() # <<<<<<<<<<<<<<
- * item, putter = self.putters.popleft()
- * getter.switch(item)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->getters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF_SET(__pyx_v_getter, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":665
- * while self.putters and self.getters:
- * getter = self.getters.popleft()
- * item, putter = self.putters.popleft() # <<<<<<<<<<<<<<
- * getter.switch(item)
- * putter.switch(putter)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->putters, __pyx_n_s_popleft); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
- PyObject* sequence = __pyx_t_3;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 665, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_4 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- #else
- __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
- index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_4);
- index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_5);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
- __pyx_t_7 = NULL;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L8_unpacking_done;
- __pyx_L7_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_7 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 665, __pyx_L1_error)
- __pyx_L8_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
- __pyx_t_4 = 0;
- __Pyx_XDECREF_SET(__pyx_v_putter, __pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "src/gevent/queue.py":666
- * getter = self.getters.popleft()
- * item, putter = self.putters.popleft()
- * getter.switch(item) # <<<<<<<<<<<<<<
- * putter.switch(putter)
- *
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_getter, __pyx_n_s_switch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_item};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_item);
- __Pyx_GIVEREF(__pyx_v_item);
- PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_item);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":667
- * item, putter = self.putters.popleft()
- * getter.switch(item)
- * putter.switch(putter) # <<<<<<<<<<<<<<
- *
- * def _schedule_unlock(self):
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_putter, __pyx_n_s_switch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_putter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_putter};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_putter};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_INCREF(__pyx_v_putter);
- __Pyx_GIVEREF(__pyx_v_putter);
- PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_putter);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
-
- /* "src/gevent/queue.py":662
- * return self.get(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while self.putters and self.getters:
- * getter = self.getters.popleft()
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("gevent._queue.Channel._unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_getter);
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XDECREF(__pyx_v_putter);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":669
- * putter.switch(putter)
- *
- * def _schedule_unlock(self): # <<<<<<<<<<<<<<
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- */
-
-static PyObject *__pyx_f_6gevent_6_queue_7Channel__schedule_unlock(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("_schedule_unlock", 0);
-
- /* "src/gevent/queue.py":670
- *
- * def _schedule_unlock(self):
- * if not self._event_unlock: # <<<<<<<<<<<<<<
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_event_unlock); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 670, __pyx_L1_error)
- __pyx_t_2 = ((!__pyx_t_1) != 0);
- if (__pyx_t_2) {
-
- /* "src/gevent/queue.py":671
- * def _schedule_unlock(self):
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock) # <<<<<<<<<<<<<<
- *
- * def __iter__(self):
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->hub, __pyx_n_s_loop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- if (!__pyx_t_6) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_event_unlock);
- __Pyx_DECREF(__pyx_v_self->_event_unlock);
- __pyx_v_self->_event_unlock = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "src/gevent/queue.py":670
- *
- * def _schedule_unlock(self):
- * if not self._event_unlock: # <<<<<<<<<<<<<<
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- */
- }
-
- /* "src/gevent/queue.py":669
- * putter.switch(putter)
- *
- * def _schedule_unlock(self): # <<<<<<<<<<<<<<
- * if not self._event_unlock:
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent._queue.Channel._schedule_unlock", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":673
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_25__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_25__iter__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_24__iter__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_24__iter__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "src/gevent/queue.py":674
- *
- * def __iter__(self):
- * return self # <<<<<<<<<<<<<<
- *
- * def __next__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":673
- * self._event_unlock = self.hub.loop.run_callback(self._unlock)
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "src/gevent/queue.py":676
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * result = self.get()
- * if result is StopIteration:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_27__next__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_27__next__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_26__next__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_26__next__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "src/gevent/queue.py":677
- *
- * def __next__(self):
- * result = self.get() # <<<<<<<<<<<<<<
- * if result is StopIteration:
- * raise result
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_6_queue_Channel *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 677, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":678
- * def __next__(self):
- * result = self.get()
- * if result is StopIteration: # <<<<<<<<<<<<<<
- * raise result
- * return result
- */
- __pyx_t_2 = (__pyx_v_result == __pyx_builtin_StopIteration);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (unlikely(__pyx_t_3)) {
-
- /* "src/gevent/queue.py":679
- * result = self.get()
- * if result is StopIteration:
- * raise result # <<<<<<<<<<<<<<
- * return result
- *
- */
- __Pyx_Raise(__pyx_v_result, 0, 0, 0);
- __PYX_ERR(0, 679, __pyx_L1_error)
-
- /* "src/gevent/queue.py":678
- * def __next__(self):
- * result = self.get()
- * if result is StopIteration: # <<<<<<<<<<<<<<
- * raise result
- * return result
- */
- }
-
- /* "src/gevent/queue.py":680
- * if result is StopIteration:
- * raise result
- * return result # <<<<<<<<<<<<<<
- *
- * next = __next__ # Py2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "src/gevent/queue.py":676
- * return self
- *
- * def __next__(self): # <<<<<<<<<<<<<<
- * result = self.get()
- * if result is StopIteration:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._queue.Channel.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":66
- * cdef class Channel:
- * cdef __weakref__
- * cdef readonly getters # <<<<<<<<<<<<<<
- * cdef readonly putters
- * cdef readonly hub
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7getters_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7getters_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_7getters___get__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7getters___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->getters);
- __pyx_r = __pyx_v_self->getters;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":67
- * cdef __weakref__
- * cdef readonly getters
- * cdef readonly putters # <<<<<<<<<<<<<<
- * cdef readonly hub
- * cdef _event_unlock
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7putters_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_7putters_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_7putters___get__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_7putters___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->putters);
- __pyx_r = __pyx_v_self->putters;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_queue.pxd":68
- * cdef readonly getters
- * cdef readonly putters
- * cdef readonly hub # <<<<<<<<<<<<<<
- * cdef _event_unlock
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_3hub_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_6_queue_7Channel_3hub_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_6_queue_7Channel_3hub___get__(((struct __pyx_obj_6gevent_6_queue_Channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_6_queue_7Channel_3hub___get__(struct __pyx_obj_6gevent_6_queue_Channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->hub);
- __pyx_r = __pyx_v_self->hub;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_21__greenlet_primitives_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__greenlet_primitives.pxd":24
- * @cython.final
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef bint _greenlet_imported
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":23
- *
- * @cython.final
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_21__greenlet_primitives_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_21__greenlet_primitives__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__greenlet_primitives.pxd":31
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__greenlet_primitives.pxd":32
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef inline object _greenlet_switch(greenlet self):
- */
- __pyx_v_6gevent_21__greenlet_primitives__greenlet_imported = 1;
-
- /* "gevent/__greenlet_primitives.pxd":30
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__greenlet_primitives.pxd":28
- * cdef bint _greenlet_imported
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
-static CYTHON_INLINE PyObject *__pyx_f_6gevent_21__greenlet_primitives__greenlet_switch(PyGreenlet *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_greenlet_switch", 0);
-
- /* "gevent/__greenlet_primitives.pxd":35
- *
- * cdef inline object _greenlet_switch(greenlet self):
- * return PyGreenlet_Switch(self, NULL, NULL) # <<<<<<<<<<<<<<
- *
- * cdef class TrackedRawGreenlet(greenlet):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyGreenlet_Switch(__pyx_v_self, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__greenlet_primitives.pxd":34
- * _greenlet_imported = True
- *
- * cdef inline object _greenlet_switch(greenlet self): # <<<<<<<<<<<<<<
- * return PyGreenlet_Switch(self, NULL, NULL)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__greenlet_primitives._greenlet_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_8__waiter_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/__waiter.pxd":25
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 25, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/__waiter.pxd":24
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.__waiter.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_8__waiter_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_8__waiter__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/__waiter.pxd":30
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/__waiter.pxd":31
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef class Waiter:
- */
- __pyx_v_6gevent_8__waiter__greenlet_imported = 1;
-
- /* "gevent/__waiter.pxd":29
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/__waiter.pxd":27
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
-static CYTHON_INLINE PyGreenlet *__pyx_f_6gevent_6_event_getcurrent(void) {
- PyGreenlet *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("getcurrent", 0);
-
- /* "gevent/_event.pxd":28
- *
- * cdef inline greenlet getcurrent():
- * return PyGreenlet_GetCurrent() # <<<<<<<<<<<<<<
- *
- * cdef inline void greenlet_init():
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = ((PyObject *)PyGreenlet_GetCurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = ((PyGreenlet *)__pyx_t_1);
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "gevent/_event.pxd":27
- * void PyGreenlet_Import()
- *
- * cdef inline greenlet getcurrent(): # <<<<<<<<<<<<<<
- * return PyGreenlet_GetCurrent()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent._event.getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
-static CYTHON_INLINE void __pyx_f_6gevent_6_event_greenlet_init(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("greenlet_init", 0);
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- __pyx_t_1 = ((!(__pyx_v_6gevent_6_event__greenlet_imported != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/_event.pxd":33
- * global _greenlet_imported
- * if not _greenlet_imported:
- * PyGreenlet_Import() # <<<<<<<<<<<<<<
- * _greenlet_imported = True
- *
- */
- PyGreenlet_Import();
-
- /* "gevent/_event.pxd":34
- * if not _greenlet_imported:
- * PyGreenlet_Import()
- * _greenlet_imported = True # <<<<<<<<<<<<<<
- *
- * cdef void _init()
- */
- __pyx_v_6gevent_6_event__greenlet_imported = 1;
-
- /* "gevent/_event.pxd":32
- * cdef inline void greenlet_init():
- * global _greenlet_imported
- * if not _greenlet_imported: # <<<<<<<<<<<<<<
- * PyGreenlet_Import()
- * _greenlet_imported = True
- */
- }
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-static struct __pyx_vtabstruct_6gevent_6_queue_ItemWaiter __pyx_vtable_6gevent_6_queue_ItemWaiter;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_ItemWaiter(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_ItemWaiter *p;
- PyObject *o = __pyx_ptype_6gevent_8__waiter_Waiter->tp_new(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_ItemWaiter *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__pyx_vtabptr_6gevent_6_queue_ItemWaiter;
- p->item = Py_None; Py_INCREF(Py_None);
- p->queue = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_queue_ItemWaiter(PyObject *o) {
- struct __pyx_obj_6gevent_6_queue_ItemWaiter *p = (struct __pyx_obj_6gevent_6_queue_ItemWaiter *)o;
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->item);
- Py_CLEAR(p->queue);
- PyObject_GC_Track(o);
- if (likely(__pyx_ptype_6gevent_8__waiter_Waiter)) __pyx_ptype_6gevent_8__waiter_Waiter->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6gevent_6_queue_ItemWaiter);
-}
-
-static int __pyx_tp_traverse_6gevent_6_queue_ItemWaiter(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_queue_ItemWaiter *p = (struct __pyx_obj_6gevent_6_queue_ItemWaiter *)o;
- e = ((likely(__pyx_ptype_6gevent_8__waiter_Waiter)) ? ((__pyx_ptype_6gevent_8__waiter_Waiter->tp_traverse) ? __pyx_ptype_6gevent_8__waiter_Waiter->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_6_queue_ItemWaiter)); if (e) return e;
- if (p->item) {
- e = (*v)(p->item, a); if (e) return e;
- }
- if (p->queue) {
- e = (*v)(p->queue, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_queue_ItemWaiter(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_queue_ItemWaiter *p = (struct __pyx_obj_6gevent_6_queue_ItemWaiter *)o;
- if (likely(__pyx_ptype_6gevent_8__waiter_Waiter)) { if (__pyx_ptype_6gevent_8__waiter_Waiter->tp_clear) __pyx_ptype_6gevent_8__waiter_Waiter->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_6_queue_ItemWaiter);
- tmp = ((PyObject*)p->item);
- p->item = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->queue);
- p->queue = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_10ItemWaiter_item(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_10ItemWaiter_4item_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_10ItemWaiter_queue(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_10ItemWaiter_5queue_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_ItemWaiter[] = {
- {"put_and_switch", (PyCFunction)__pyx_pw_6gevent_6_queue_10ItemWaiter_3put_and_switch, METH_NOARGS, __pyx_doc_6gevent_6_queue_10ItemWaiter_2put_and_switch},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_queue_ItemWaiter[] = {
- {(char *)"item", __pyx_getprop_6gevent_6_queue_10ItemWaiter_item, 0, (char *)0, 0},
- {(char *)"queue", __pyx_getprop_6gevent_6_queue_10ItemWaiter_queue, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_ItemWaiter = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.ItemWaiter", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_ItemWaiter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_ItemWaiter, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "ItemWaiter(item, queue)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_ItemWaiter, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_ItemWaiter, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_6_queue_ItemWaiter, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_queue_ItemWaiter, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_queue_10ItemWaiter_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_ItemWaiter, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Queue __pyx_vtable_6gevent_6_queue_Queue;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_Queue(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_Queue *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_Queue *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_6_queue_Queue;
- p->hub = Py_None; Py_INCREF(Py_None);
- p->queue = Py_None; Py_INCREF(Py_None);
- p->getters = Py_None; Py_INCREF(Py_None);
- p->putters = Py_None; Py_INCREF(Py_None);
- p->_event_unlock = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_queue_Queue(PyObject *o) {
- struct __pyx_obj_6gevent_6_queue_Queue *p = (struct __pyx_obj_6gevent_6_queue_Queue *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- Py_CLEAR(p->hub);
- Py_CLEAR(p->queue);
- Py_CLEAR(p->getters);
- Py_CLEAR(p->putters);
- Py_CLEAR(p->_event_unlock);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_queue_Queue(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_queue_Queue *p = (struct __pyx_obj_6gevent_6_queue_Queue *)o;
- if (p->hub) {
- e = (*v)(p->hub, a); if (e) return e;
- }
- if (p->queue) {
- e = (*v)(p->queue, a); if (e) return e;
- }
- if (p->getters) {
- e = (*v)(p->getters, a); if (e) return e;
- }
- if (p->putters) {
- e = (*v)(p->putters, a); if (e) return e;
- }
- if (p->_event_unlock) {
- e = (*v)(p->_event_unlock, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_queue_Queue(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_queue_Queue *p = (struct __pyx_obj_6gevent_6_queue_Queue *)o;
- tmp = ((PyObject*)p->hub);
- p->hub = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->queue);
- p->queue = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->getters);
- p->getters = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->putters);
- p->putters = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_event_unlock);
- p->_event_unlock = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_5Queue_maxsize(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_5Queue_7maxsize_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_6_queue_5Queue_maxsize(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_6_queue_5Queue_7maxsize_3__set__(o, v);
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError, "__del__");
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_5Queue_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_5Queue_3hub_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_5Queue_queue(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_5Queue_5queue_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_Queue[] = {
- {"copy", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_3copy, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_2copy},
- {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_5_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_5Queue_4_create_queue},
- {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_17_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_16_format},
- {"_unlock", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_43_unlock, METH_NOARGS, __pyx_doc_6gevent_6_queue_5Queue_42_unlock},
- {"__next__", (PyCFunction)__pyx_pw_6gevent_6_queue_5Queue_47__next__, METH_NOARGS|METH_COEXIST, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_queue_Queue[] = {
- {(char *)"maxsize", __pyx_getprop_6gevent_6_queue_5Queue_maxsize, __pyx_setprop_6gevent_6_queue_5Queue_maxsize, (char *)0, 0},
- {(char *)"hub", __pyx_getprop_6gevent_6_queue_5Queue_hub, 0, (char *)0, 0},
- {(char *)"queue", __pyx_getprop_6gevent_6_queue_5Queue_queue, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_Queue = {
- 0, /*nb_add*/
- 0, /*nb_subtract*/
- 0, /*nb_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_divide*/
- #endif
- 0, /*nb_remainder*/
- 0, /*nb_divmod*/
- 0, /*nb_power*/
- 0, /*nb_negative*/
- 0, /*nb_positive*/
- 0, /*nb_absolute*/
- __pyx_pw_6gevent_6_queue_5Queue_25__nonzero__, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_coerce*/
- #endif
- 0, /*nb_int*/
- #if PY_MAJOR_VERSION < 3
- 0, /*nb_long*/
- #else
- 0, /*reserved*/
- #endif
- 0, /*nb_float*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_oct*/
- #endif
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_hex*/
- #endif
- 0, /*nb_inplace_add*/
- 0, /*nb_inplace_subtract*/
- 0, /*nb_inplace_multiply*/
- #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
- 0, /*nb_inplace_divide*/
- #endif
- 0, /*nb_inplace_remainder*/
- 0, /*nb_inplace_power*/
- 0, /*nb_inplace_lshift*/
- 0, /*nb_inplace_rshift*/
- 0, /*nb_inplace_and*/
- 0, /*nb_inplace_xor*/
- 0, /*nb_inplace_or*/
- 0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
- 0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
- 0, /*nb_index*/
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_matrix_multiply*/
- #endif
- #if PY_VERSION_HEX >= 0x03050000
- 0, /*nb_inplace_matrix_multiply*/
- #endif
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_Queue = {
- __pyx_pw_6gevent_6_queue_5Queue_21__len__, /*sq_length*/
- 0, /*sq_concat*/
- 0, /*sq_repeat*/
- 0, /*sq_item*/
- 0, /*sq_slice*/
- 0, /*sq_ass_item*/
- 0, /*sq_ass_slice*/
- 0, /*sq_contains*/
- 0, /*sq_inplace_concat*/
- 0, /*sq_inplace_repeat*/
-};
-
-static PyMappingMethods __pyx_tp_as_mapping_Queue = {
- __pyx_pw_6gevent_6_queue_5Queue_21__len__, /*mp_length*/
- 0, /*mp_subscript*/
- 0, /*mp_ass_subscript*/
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_Queue = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.Queue", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_Queue), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_Queue, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_6_queue_5Queue_13__repr__, /*tp_repr*/
- &__pyx_tp_as_number_Queue, /*tp_as_number*/
- &__pyx_tp_as_sequence_Queue, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_Queue, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_pw_6gevent_6_queue_5Queue_15__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Queue(maxsize=None, items=(), _warn_depth=2)\n\n Create a queue object with a given maximum size.\n\n If *maxsize* is less than or equal to zero or ``None``, the queue\n size is infinite.\n\n Queues have a ``len`` equal to the number of items in them (the :meth:`qsize`),\n but in a boolean context they are always True.\n\n .. versionchanged:: 1.1b3\n Queues now support :func:`len`; it behaves the same as :meth:`qsize`.\n .. versionchanged:: 1.1b3\n Multiple greenlets that block on a call to :meth:`put` for a full queue\n will now be awakened to put their items into the queue in the order in which\n they arrived. Likewise, multiple greenlets that block on a call to :meth:`get` for\n an empty queue will now receive items in the order in which they blocked. An\n implementation quirk under CPython *usually* ensured this was roughly the case\n previously anyway, but that wasn't the case for PyPy.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_Queue, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_Queue, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- __pyx_pw_6gevent_6_queue_5Queue_45__iter__, /*tp_iter*/
- __pyx_pw_6gevent_6_queue_5Queue_47__next__, /*tp_iternext*/
- __pyx_methods_6gevent_6_queue_Queue, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_queue_Queue, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_queue_5Queue_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_Queue, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_UnboundQueue __pyx_vtable_6gevent_6_queue_UnboundQueue;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_UnboundQueue(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_UnboundQueue *p;
- PyObject *o = __pyx_tp_new_6gevent_6_queue_Queue(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_UnboundQueue *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_queue_Queue*)__pyx_vtabptr_6gevent_6_queue_UnboundQueue;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_UnboundQueue[] = {
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_UnboundQueue = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.UnboundQueue", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_UnboundQueue), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_Queue, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_13__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_15__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "UnboundQueue(maxsize=None, items=())", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_Queue, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_Queue, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_45__iter__, /*tp_iter*/
- #else
- 0, /*tp_iter*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_47__next__, /*tp_iternext*/
- #else
- 0, /*tp_iternext*/
- #endif
- __pyx_methods_6gevent_6_queue_UnboundQueue, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_queue_12UnboundQueue_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_UnboundQueue, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_PriorityQueue __pyx_vtable_6gevent_6_queue_PriorityQueue;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_PriorityQueue(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_PriorityQueue *p;
- PyObject *o = __pyx_tp_new_6gevent_6_queue_Queue(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_PriorityQueue *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_queue_Queue*)__pyx_vtabptr_6gevent_6_queue_PriorityQueue;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_PriorityQueue[] = {
- {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_13PriorityQueue_1_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_13PriorityQueue__create_queue},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_PriorityQueue = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.PriorityQueue", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_PriorityQueue), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_Queue, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_13__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_15__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "A subclass of :class:`Queue` that retrieves entries in priority order (lowest first).\n\n Entries are typically tuples of the form: ``(priority number, data)``.\n\n .. versionchanged:: 1.2a1\n Any *items* given to the constructor will now be passed through\n :func:`heapq.heapify` to ensure the invariants of this class hold.\n Previously it was just assumed that they were already a heap.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_Queue, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_Queue, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_45__iter__, /*tp_iter*/
- #else
- 0, /*tp_iter*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_47__next__, /*tp_iternext*/
- #else
- 0, /*tp_iternext*/
- #endif
- __pyx_methods_6gevent_6_queue_PriorityQueue, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_PriorityQueue, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_LifoQueue __pyx_vtable_6gevent_6_queue_LifoQueue;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_LifoQueue(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_LifoQueue *p;
- PyObject *o = __pyx_tp_new_6gevent_6_queue_Queue(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_LifoQueue *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_queue_Queue*)__pyx_vtabptr_6gevent_6_queue_LifoQueue;
- return o;
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_LifoQueue[] = {
- {"_create_queue", (PyCFunction)__pyx_pw_6gevent_6_queue_9LifoQueue_1_create_queue, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_9LifoQueue__create_queue},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_LifoQueue = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.LifoQueue", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_LifoQueue), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_Queue, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_13__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_15__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "A subclass of :class:`Queue` that retrieves most recently added entries first.", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_Queue, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_Queue, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_45__iter__, /*tp_iter*/
- #else
- 0, /*tp_iter*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_47__next__, /*tp_iternext*/
- #else
- 0, /*tp_iternext*/
- #endif
- __pyx_methods_6gevent_6_queue_LifoQueue, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_1__init__, /*tp_init*/
- #else
- 0, /*tp_init*/
- #endif
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_LifoQueue, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_JoinableQueue __pyx_vtable_6gevent_6_queue_JoinableQueue;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_JoinableQueue(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_JoinableQueue *p;
- PyObject *o = __pyx_tp_new_6gevent_6_queue_Queue(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_JoinableQueue *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_6_queue_Queue*)__pyx_vtabptr_6gevent_6_queue_JoinableQueue;
- p->_cond = ((struct __pyx_obj_6gevent_6_event_Event *)Py_None); Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_queue_JoinableQueue(PyObject *o) {
- struct __pyx_obj_6gevent_6_queue_JoinableQueue *p = (struct __pyx_obj_6gevent_6_queue_JoinableQueue *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->_cond);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_6gevent_6_queue_Queue(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_queue_JoinableQueue(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_queue_JoinableQueue *p = (struct __pyx_obj_6gevent_6_queue_JoinableQueue *)o;
- e = __pyx_tp_traverse_6gevent_6_queue_Queue(o, v, a); if (e) return e;
- if (p->_cond) {
- e = (*v)(((PyObject *)p->_cond), a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_queue_JoinableQueue(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_queue_JoinableQueue *p = (struct __pyx_obj_6gevent_6_queue_JoinableQueue *)o;
- __pyx_tp_clear_6gevent_6_queue_Queue(o);
- tmp = ((PyObject*)p->_cond);
- p->_cond = ((struct __pyx_obj_6gevent_6_event_Event *)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_13JoinableQueue_unfinished_tasks(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_13JoinableQueue_16unfinished_tasks_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_JoinableQueue[] = {
- {"copy", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_3copy, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_2copy},
- {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_5_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_4_format},
- {"task_done", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_9task_done, METH_NOARGS, __pyx_doc_6gevent_6_queue_13JoinableQueue_8task_done},
- {"join", (PyCFunction)__pyx_pw_6gevent_6_queue_13JoinableQueue_11join, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_13JoinableQueue_10join},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_queue_JoinableQueue[] = {
- {(char *)"unfinished_tasks", __pyx_getprop_6gevent_6_queue_13JoinableQueue_unfinished_tasks, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_JoinableQueue = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.JoinableQueue", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_JoinableQueue), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_JoinableQueue, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_13__repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_15__str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "JoinableQueue(maxsize=None, items=(), unfinished_tasks=None)\n\n A subclass of :class:`Queue` that additionally has\n :meth:`task_done` and :meth:`join` methods.\n ", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_JoinableQueue, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_JoinableQueue, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_45__iter__, /*tp_iter*/
- #else
- 0, /*tp_iter*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_pw_6gevent_6_queue_5Queue_47__next__, /*tp_iternext*/
- #else
- 0, /*tp_iternext*/
- #endif
- __pyx_methods_6gevent_6_queue_JoinableQueue, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_queue_JoinableQueue, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_queue_13JoinableQueue_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_JoinableQueue, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_6_queue_Channel __pyx_vtable_6gevent_6_queue_Channel;
-
-static PyObject *__pyx_tp_new_6gevent_6_queue_Channel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_6_queue_Channel *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_6_queue_Channel *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_6_queue_Channel;
- p->getters = Py_None; Py_INCREF(Py_None);
- p->putters = Py_None; Py_INCREF(Py_None);
- p->hub = Py_None; Py_INCREF(Py_None);
- p->_event_unlock = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_6_queue_Channel(PyObject *o) {
- struct __pyx_obj_6gevent_6_queue_Channel *p = (struct __pyx_obj_6gevent_6_queue_Channel *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- if (p->__weakref__) PyObject_ClearWeakRefs(o);
- Py_CLEAR(p->getters);
- Py_CLEAR(p->putters);
- Py_CLEAR(p->hub);
- Py_CLEAR(p->_event_unlock);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_6_queue_Channel(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_6_queue_Channel *p = (struct __pyx_obj_6gevent_6_queue_Channel *)o;
- if (p->getters) {
- e = (*v)(p->getters, a); if (e) return e;
- }
- if (p->putters) {
- e = (*v)(p->putters, a); if (e) return e;
- }
- if (p->hub) {
- e = (*v)(p->hub, a); if (e) return e;
- }
- if (p->_event_unlock) {
- e = (*v)(p->_event_unlock, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_6_queue_Channel(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_6_queue_Channel *p = (struct __pyx_obj_6gevent_6_queue_Channel *)o;
- tmp = ((PyObject*)p->getters);
- p->getters = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->putters);
- p->putters = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->hub);
- p->hub = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_event_unlock);
- p->_event_unlock = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_7Channel_balance(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_7Channel_7balance_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_7Channel_getters(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_7Channel_7getters_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_7Channel_putters(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_7Channel_7putters_1__get__(o);
-}
-
-static PyObject *__pyx_getprop_6gevent_6_queue_7Channel_hub(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_6_queue_7Channel_3hub_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_6gevent_6_queue_Channel[] = {
- {"_format", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_7_format, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_6_format},
- {"qsize", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_9qsize, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_8qsize},
- {"empty", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_11empty, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_10empty},
- {"full", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_13full, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_12full},
- {"put", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_15put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_6_queue_7Channel_14put},
- {"put_nowait", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_17put_nowait, METH_O, __pyx_doc_6gevent_6_queue_7Channel_16put_nowait},
- {"_unlock", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_23_unlock, METH_NOARGS, __pyx_doc_6gevent_6_queue_7Channel_22_unlock},
- {"__next__", (PyCFunction)__pyx_pw_6gevent_6_queue_7Channel_27__next__, METH_NOARGS|METH_COEXIST, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_6_queue_Channel[] = {
- {(char *)"balance", __pyx_getprop_6gevent_6_queue_7Channel_balance, 0, (char *)0, 0},
- {(char *)"getters", __pyx_getprop_6gevent_6_queue_7Channel_getters, 0, (char *)0, 0},
- {(char *)"putters", __pyx_getprop_6gevent_6_queue_7Channel_putters, 0, (char *)0, 0},
- {(char *)"hub", __pyx_getprop_6gevent_6_queue_7Channel_hub, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_6_queue_Channel = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent._queue.Channel", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_6_queue_Channel), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_6_queue_Channel, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_6_queue_7Channel_3__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_pw_6gevent_6_queue_7Channel_5__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Channel(maxsize=1)", /*tp_doc*/
- __pyx_tp_traverse_6gevent_6_queue_Channel, /*tp_traverse*/
- __pyx_tp_clear_6gevent_6_queue_Channel, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- __pyx_pw_6gevent_6_queue_7Channel_25__iter__, /*tp_iter*/
- __pyx_pw_6gevent_6_queue_7Channel_27__next__, /*tp_iternext*/
- __pyx_methods_6gevent_6_queue_Channel, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_6_queue_Channel, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_6_queue_7Channel_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_6_queue_Channel, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec__queue(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec__queue},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "_queue",
- __pyx_k_Synchronized_queues_The_mod_gev, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_Channel, __pyx_k_Channel, sizeof(__pyx_k_Channel), 0, 0, 1, 1},
- {&__pyx_n_s_Channel__format, __pyx_k_Channel__format, sizeof(__pyx_k_Channel__format), 0, 0, 1, 1},
- {&__pyx_n_s_Channel__unlock, __pyx_k_Channel__unlock, sizeof(__pyx_k_Channel__unlock), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_empty, __pyx_k_Channel_empty, sizeof(__pyx_k_Channel_empty), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_full, __pyx_k_Channel_full, sizeof(__pyx_k_Channel_full), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_get, __pyx_k_Channel_get, sizeof(__pyx_k_Channel_get), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_get_nowait, __pyx_k_Channel_get_nowait, sizeof(__pyx_k_Channel_get_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_put, __pyx_k_Channel_put, sizeof(__pyx_k_Channel_put), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_put_nowait, __pyx_k_Channel_put_nowait, sizeof(__pyx_k_Channel_put_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_Channel_qsize, __pyx_k_Channel_qsize, sizeof(__pyx_k_Channel_qsize), 0, 0, 1, 1},
- {&__pyx_kp_s_Channels_have_a_maxsize_of_1, __pyx_k_Channels_have_a_maxsize_of_1, sizeof(__pyx_k_Channels_have_a_maxsize_of_1), 0, 0, 1, 0},
- {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1},
- {&__pyx_n_s_Empty, __pyx_k_Empty, sizeof(__pyx_k_Empty), 0, 0, 1, 1},
- {&__pyx_n_s_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
- {&__pyx_n_s_Full, __pyx_k_Full, sizeof(__pyx_k_Full), 0, 0, 1, 1},
- {&__pyx_n_s_InvalidSwitchError, __pyx_k_InvalidSwitchError, sizeof(__pyx_k_InvalidSwitchError), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_switch_into_Channel_put, __pyx_k_Invalid_switch_into_Channel_put, sizeof(__pyx_k_Invalid_switch_into_Channel_put), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_switch_into_Queue_get_r, __pyx_k_Invalid_switch_into_Queue_get_r, sizeof(__pyx_k_Invalid_switch_into_Queue_get_r), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_switch_into_Queue_put_r, __pyx_k_Invalid_switch_into_Queue_put_r, sizeof(__pyx_k_Invalid_switch_into_Queue_put_r), 0, 0, 1, 0},
- {&__pyx_n_s_ItemWaiter_put_and_switch, __pyx_k_ItemWaiter_put_and_switch, sizeof(__pyx_k_ItemWaiter_put_and_switch), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue, __pyx_k_JoinableQueue, sizeof(__pyx_k_JoinableQueue), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue__format, __pyx_k_JoinableQueue__format, sizeof(__pyx_k_JoinableQueue__format), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue__put, __pyx_k_JoinableQueue__put, sizeof(__pyx_k_JoinableQueue__put), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue_copy, __pyx_k_JoinableQueue_copy, sizeof(__pyx_k_JoinableQueue_copy), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue_join, __pyx_k_JoinableQueue_join, sizeof(__pyx_k_JoinableQueue_join), 0, 0, 1, 1},
- {&__pyx_n_s_JoinableQueue_task_done, __pyx_k_JoinableQueue_task_done, sizeof(__pyx_k_JoinableQueue_task_done), 0, 0, 1, 1},
- {&__pyx_n_s_LifoQueue, __pyx_k_LifoQueue, sizeof(__pyx_k_LifoQueue), 0, 0, 1, 1},
- {&__pyx_n_s_LifoQueue__create_queue, __pyx_k_LifoQueue__create_queue, sizeof(__pyx_k_LifoQueue__create_queue), 0, 0, 1, 1},
- {&__pyx_n_s_LifoQueue__get, __pyx_k_LifoQueue__get, sizeof(__pyx_k_LifoQueue__get), 0, 0, 1, 1},
- {&__pyx_n_s_LifoQueue__peek, __pyx_k_LifoQueue__peek, sizeof(__pyx_k_LifoQueue__peek), 0, 0, 1, 1},
- {&__pyx_n_s_LifoQueue__put, __pyx_k_LifoQueue__put, sizeof(__pyx_k_LifoQueue__put), 0, 0, 1, 1},
- {&__pyx_n_s_PriorityQueue, __pyx_k_PriorityQueue, sizeof(__pyx_k_PriorityQueue), 0, 0, 1, 1},
- {&__pyx_n_s_PriorityQueue__create_queue, __pyx_k_PriorityQueue__create_queue, sizeof(__pyx_k_PriorityQueue__create_queue), 0, 0, 1, 1},
- {&__pyx_n_s_PriorityQueue__get, __pyx_k_PriorityQueue__get, sizeof(__pyx_k_PriorityQueue__get), 0, 0, 1, 1},
- {&__pyx_n_s_PriorityQueue__put, __pyx_k_PriorityQueue__put, sizeof(__pyx_k_PriorityQueue__put), 0, 0, 1, 1},
- {&__pyx_n_s_PySimpleQueue, __pyx_k_PySimpleQueue, sizeof(__pyx_k_PySimpleQueue), 0, 0, 1, 1},
- {&__pyx_n_s_Queue, __pyx_k_Queue, sizeof(__pyx_k_Queue), 0, 0, 1, 1},
- {&__pyx_kp_s_Queue_0_now_equivalent_to_Queue, __pyx_k_Queue_0_now_equivalent_to_Queue, sizeof(__pyx_k_Queue_0_now_equivalent_to_Queue), 0, 0, 1, 0},
- {&__pyx_n_s_Queue__create_queue, __pyx_k_Queue__create_queue, sizeof(__pyx_k_Queue__create_queue), 0, 0, 1, 1},
- {&__pyx_n_s_Queue__format, __pyx_k_Queue__format, sizeof(__pyx_k_Queue__format), 0, 0, 1, 1},
- {&__pyx_n_s_Queue__get, __pyx_k_Queue__get, sizeof(__pyx_k_Queue__get), 0, 0, 1, 1},
- {&__pyx_n_s_Queue__peek, __pyx_k_Queue__peek, sizeof(__pyx_k_Queue__peek), 0, 0, 1, 1},
- {&__pyx_n_s_Queue__put, __pyx_k_Queue__put, sizeof(__pyx_k_Queue__put), 0, 0, 1, 1},
- {&__pyx_n_s_Queue__unlock, __pyx_k_Queue__unlock, sizeof(__pyx_k_Queue__unlock), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_copy, __pyx_k_Queue_copy, sizeof(__pyx_k_Queue_copy), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_empty, __pyx_k_Queue_empty, sizeof(__pyx_k_Queue_empty), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_full, __pyx_k_Queue_full, sizeof(__pyx_k_Queue_full), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_get, __pyx_k_Queue_get, sizeof(__pyx_k_Queue_get), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_get_nowait, __pyx_k_Queue_get_nowait, sizeof(__pyx_k_Queue_get_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_peek, __pyx_k_Queue_peek, sizeof(__pyx_k_Queue_peek), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_peek_nowait, __pyx_k_Queue_peek_nowait, sizeof(__pyx_k_Queue_peek_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_put, __pyx_k_Queue_put, sizeof(__pyx_k_Queue_put), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_put_nowait, __pyx_k_Queue_put_nowait, sizeof(__pyx_k_Queue_put_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_Queue_qsize, __pyx_k_Queue_qsize, sizeof(__pyx_k_Queue_qsize), 0, 0, 1, 1},
- {&__pyx_n_s_SimpleQueue, __pyx_k_SimpleQueue, sizeof(__pyx_k_SimpleQueue), 0, 0, 1, 1},
- {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
- {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1},
- {&__pyx_kp_s_UnboundQueue_has_no_maxsize, __pyx_k_UnboundQueue_has_no_maxsize, sizeof(__pyx_k_UnboundQueue_has_no_maxsize), 0, 0, 1, 0},
- {&__pyx_n_s_UnboundQueue_put, __pyx_k_UnboundQueue_put, sizeof(__pyx_k_UnboundQueue_put), 0, 0, 1, 1},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_n_s_Waiter, __pyx_k_Waiter, sizeof(__pyx_k_Waiter), 0, 0, 1, 1},
- {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
- {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
- {&__pyx_n_s_block, __pyx_k_block, sizeof(__pyx_k_block), 0, 0, 1, 1},
- {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
- {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
- {&__pyx_n_s_cond, __pyx_k_cond, sizeof(__pyx_k_cond), 0, 0, 1, 1},
- {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
- {&__pyx_n_s_create_queue, __pyx_k_create_queue, sizeof(__pyx_k_create_queue), 0, 0, 1, 1},
- {&__pyx_n_s_deque, __pyx_k_deque, sizeof(__pyx_k_deque), 0, 0, 1, 1},
- {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
- {&__pyx_n_s_event_unlock, __pyx_k_event_unlock, sizeof(__pyx_k_event_unlock), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_extensions, __pyx_k_extensions, sizeof(__pyx_k_extensions), 0, 0, 1, 1},
- {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
- {&__pyx_n_s_full, __pyx_k_full, sizeof(__pyx_k_full), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_get_2, __pyx_k_get_2, sizeof(__pyx_k_get_2), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub, __pyx_k_get_hub, sizeof(__pyx_k_get_hub), 0, 0, 1, 1},
- {&__pyx_n_s_get_hub_noargs, __pyx_k_get_hub_noargs, sizeof(__pyx_k_get_hub_noargs), 0, 0, 1, 1},
- {&__pyx_n_s_get_nowait, __pyx_k_get_nowait, sizeof(__pyx_k_get_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1},
- {&__pyx_n_s_getter, __pyx_k_getter, sizeof(__pyx_k_getter), 0, 0, 1, 1},
- {&__pyx_n_s_getters, __pyx_k_getters, sizeof(__pyx_k_getters), 0, 0, 1, 1},
- {&__pyx_kp_s_getters_s, __pyx_k_getters_s, sizeof(__pyx_k_getters_s), 0, 0, 1, 0},
- {&__pyx_kp_s_getters_s_2, __pyx_k_getters_s_2, sizeof(__pyx_k_getters_s_2), 0, 0, 1, 0},
- {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__hub_local, __pyx_k_gevent__hub_local, sizeof(__pyx_k_gevent__hub_local), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__queue, __pyx_k_gevent__queue, sizeof(__pyx_k_gevent__queue), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__util, __pyx_k_gevent__util, sizeof(__pyx_k_gevent__util), 0, 0, 1, 1},
- {&__pyx_n_s_gevent__waiter, __pyx_k_gevent__waiter, sizeof(__pyx_k_gevent__waiter), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_event, __pyx_k_gevent_event, sizeof(__pyx_k_gevent_event), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_exceptions, __pyx_k_gevent_exceptions, sizeof(__pyx_k_gevent_exceptions), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_greenlet, __pyx_k_greenlet, sizeof(__pyx_k_greenlet), 0, 0, 1, 1},
- {&__pyx_n_s_heapify, __pyx_k_heapify, sizeof(__pyx_k_heapify), 0, 0, 1, 1},
- {&__pyx_n_s_heapify_2, __pyx_k_heapify_2, sizeof(__pyx_k_heapify_2), 0, 0, 1, 1},
- {&__pyx_n_s_heappop, __pyx_k_heappop, sizeof(__pyx_k_heappop), 0, 0, 1, 1},
- {&__pyx_n_s_heappop_2, __pyx_k_heappop_2, sizeof(__pyx_k_heappop_2), 0, 0, 1, 1},
- {&__pyx_n_s_heappush, __pyx_k_heappush, sizeof(__pyx_k_heappush), 0, 0, 1, 1},
- {&__pyx_n_s_heappush_2, __pyx_k_heappush_2, sizeof(__pyx_k_heappush_2), 0, 0, 1, 1},
- {&__pyx_n_s_heapq, __pyx_k_heapq, sizeof(__pyx_k_heapq), 0, 0, 1, 1},
- {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
- {&__pyx_n_s_hub, __pyx_k_hub, sizeof(__pyx_k_hub), 0, 0, 1, 1},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_n_s_implements, __pyx_k_implements, sizeof(__pyx_k_implements), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_import_c_accel, __pyx_k_import_c_accel, sizeof(__pyx_k_import_c_accel), 0, 0, 1, 1},
- {&__pyx_n_s_imports, __pyx_k_imports, sizeof(__pyx_k_imports), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
- {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_maxsize, __pyx_k_maxsize, sizeof(__pyx_k_maxsize), 0, 0, 1, 1},
- {&__pyx_n_s_maxsize_2, __pyx_k_maxsize_2, sizeof(__pyx_k_maxsize_2), 0, 0, 1, 1},
- {&__pyx_kp_s_maxsize_r, __pyx_k_maxsize_r, sizeof(__pyx_k_maxsize_r), 0, 0, 1, 0},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
- {&__pyx_n_s_next_2, __pyx_k_next_2, sizeof(__pyx_k_next_2), 0, 0, 1, 1},
- {&__pyx_n_s_peek, __pyx_k_peek, sizeof(__pyx_k_peek), 0, 0, 1, 1},
- {&__pyx_n_s_peek_2, __pyx_k_peek_2, sizeof(__pyx_k_peek_2), 0, 0, 1, 1},
- {&__pyx_n_s_peek_nowait, __pyx_k_peek_nowait, sizeof(__pyx_k_peek_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_popleft, __pyx_k_popleft, sizeof(__pyx_k_popleft), 0, 0, 1, 1},
- {&__pyx_n_s_put, __pyx_k_put, sizeof(__pyx_k_put), 0, 0, 1, 1},
- {&__pyx_n_s_put_2, __pyx_k_put_2, sizeof(__pyx_k_put_2), 0, 0, 1, 1},
- {&__pyx_n_s_put_and_switch, __pyx_k_put_and_switch, sizeof(__pyx_k_put_and_switch), 0, 0, 1, 1},
- {&__pyx_n_s_put_nowait, __pyx_k_put_nowait, sizeof(__pyx_k_put_nowait), 0, 0, 1, 1},
- {&__pyx_n_s_putter, __pyx_k_putter, sizeof(__pyx_k_putter), 0, 0, 1, 1},
- {&__pyx_n_s_putters, __pyx_k_putters, sizeof(__pyx_k_putters), 0, 0, 1, 1},
- {&__pyx_kp_s_putters_s, __pyx_k_putters_s, sizeof(__pyx_k_putters_s), 0, 0, 1, 0},
- {&__pyx_kp_s_putters_s_2, __pyx_k_putters_s_2, sizeof(__pyx_k_putters_s_2), 0, 0, 1, 0},
- {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 1},
- {&__pyx_n_s_qsize, __pyx_k_qsize, sizeof(__pyx_k_qsize), 0, 0, 1, 1},
- {&__pyx_n_s_queue, __pyx_k_queue, sizeof(__pyx_k_queue), 0, 0, 1, 1},
- {&__pyx_n_s_queue_2, __pyx_k_queue_2, sizeof(__pyx_k_queue_2), 0, 0, 1, 1},
- {&__pyx_kp_s_queue_r, __pyx_k_queue_r, sizeof(__pyx_k_queue_r), 0, 0, 1, 0},
- {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
- {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
- {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
- {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1},
- {&__pyx_kp_s_s_at_s_s, __pyx_k_s_at_s_s, sizeof(__pyx_k_s_at_s_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_at_s_s_2, __pyx_k_s_at_s_s_2, sizeof(__pyx_k_s_at_s_s_2), 0, 0, 1, 0},
- {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_s_2, __pyx_k_s_s_2, sizeof(__pyx_k_s_s_2), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
- {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_queue_py, __pyx_k_src_gevent_queue_py, sizeof(__pyx_k_src_gevent_queue_py), 0, 0, 1, 0},
- {&__pyx_n_s_stacklevel, __pyx_k_stacklevel, sizeof(__pyx_k_stacklevel), 0, 0, 1, 1},
- {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1},
- {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_task_done, __pyx_k_task_done, sizeof(__pyx_k_task_done), 0, 0, 1, 1},
- {&__pyx_kp_s_task_done_called_too_many_times, __pyx_k_task_done_called_too_many_times, sizeof(__pyx_k_task_done_called_too_many_times), 0, 0, 1, 0},
- {&__pyx_kp_s_tasks_s__cond_s, __pyx_k_tasks_s__cond_s, sizeof(__pyx_k_tasks_s__cond_s), 0, 0, 1, 0},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_unfinished_tasks, __pyx_k_unfinished_tasks, sizeof(__pyx_k_unfinished_tasks), 0, 0, 1, 1},
- {&__pyx_n_s_unlock, __pyx_k_unlock, sizeof(__pyx_k_unlock), 0, 0, 1, 1},
- {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
- {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
- {&__pyx_n_s_waiter, __pyx_k_waiter, sizeof(__pyx_k_waiter), 0, 0, 1, 1},
- {&__pyx_n_s_waiter_2, __pyx_k_waiter_2, sizeof(__pyx_k_waiter_2), 0, 0, 1, 1},
- {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
- {&__pyx_n_s_warn_depth, __pyx_k_warn_depth, sizeof(__pyx_k_warn_depth), 0, 0, 1, 1},
- {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
- {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 69, __pyx_L1_error)
- __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) __PYX_ERR(0, 130, __pyx_L1_error)
- __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 181, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 181, __pyx_L1_error)
- __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 406, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "src/gevent/queue.py":128
- * if maxsize == 0:
- * import warnings
- * warnings.warn( # <<<<<<<<<<<<<<
- * 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- * DeprecationWarning,
- */
- __pyx_tuple_ = PyTuple_Pack(2, __pyx_kp_s_Queue_0_now_equivalent_to_Queue, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple_);
- __Pyx_GIVEREF(__pyx_tuple_);
-
- /* "src/gevent/queue.py":421
- * def __init__(self, maxsize=None, items=()):
- * if maxsize is not None:
- * raise ValueError("UnboundQueue has no maxsize") # <<<<<<<<<<<<<<
- * Queue.__init__(self, maxsize, items)
- * self.putters = None # Will never be used.
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_UnboundQueue_has_no_maxsize); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 421, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "src/gevent/queue.py":535
- * '''
- * if self.unfinished_tasks <= 0:
- * raise ValueError('task_done() called too many times') # <<<<<<<<<<<<<<
- * self.unfinished_tasks -= 1
- * if self.unfinished_tasks == 0:
- */
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_task_done_called_too_many_times); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 535, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
-
- /* "src/gevent/queue.py":573
- * # We take maxsize to simplify certain kinds of code
- * if maxsize != 1:
- * raise ValueError("Channels have a maxsize of 1") # <<<<<<<<<<<<<<
- * self.getters = collections.deque()
- * self.putters = collections.deque()
- */
- __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Channels_have_a_maxsize_of_1); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 573, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
-
- /* "src/gevent/queue.py":78
- * # pylint:disable=assigning-non-slot
- * __slots__ = (
- * 'item', # <<<<<<<<<<<<<<
- * 'queue',
- * )
- */
- __pyx_tuple__7 = PyTuple_Pack(2, __pyx_n_s_item, __pyx_n_s_queue); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 78, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
-
- /* "src/gevent/queue.py":87
- * self.queue = queue
- *
- * def put_and_switch(self): # <<<<<<<<<<<<<<
- * self.queue._put(self.item)
- * self.queue = None
- */
- __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_and_switch, 87, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 87, __pyx_L1_error)
-
- /* "src/gevent/queue.py":115
- *
- * __slots__ = (
- * '_maxsize', # <<<<<<<<<<<<<<
- * 'getters',
- * 'putters',
- */
- __pyx_tuple__10 = PyTuple_Pack(7, __pyx_n_s_maxsize_2, __pyx_n_s_getters, __pyx_n_s_putters, __pyx_n_s_hub, __pyx_n_s_event_unlock, __pyx_n_s_queue, __pyx_n_s_weakref); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
-
- /* "src/gevent/queue.py":165
- * self._maxsize = nv
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue)
- *
- */
- __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
- __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_copy, 165, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 165, __pyx_L1_error)
-
- /* "src/gevent/queue.py":168
- * return type(self)(self.maxsize, self.queue)
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return collections.deque(items)
- *
- */
- __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_items); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 168, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
- __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_create_queue, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 168, __pyx_L1_error)
-
- /* "src/gevent/queue.py":171
- * return collections.deque(items)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.popleft()
- *
- */
- __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
- __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get, 171, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 171, __pyx_L1_error)
-
- /* "src/gevent/queue.py":174
- * return self.queue.popleft()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[0]
- *
- */
- __pyx_tuple__17 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
- __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_peek, 174, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 174, __pyx_L1_error)
-
- /* "src/gevent/queue.py":177
- * return self.queue[0]
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
- __pyx_tuple__19 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
- __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put, 177, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 177, __pyx_L1_error)
-
- /* "src/gevent/queue.py":186
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = []
- * if self.maxsize is not None:
- */
- __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_result); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_format, 186, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 186, __pyx_L1_error)
-
- /* "src/gevent/queue.py":200
- * return ''
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * """Return the size of the queue."""
- * return len(self.queue)
- */
- __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
- __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_qsize, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 200, __pyx_L1_error)
-
- /* "src/gevent/queue.py":232
- * return True
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is empty, ``False`` otherwise."""
- * return not self.qsize()
- */
- __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__25);
- __Pyx_GIVEREF(__pyx_tuple__25);
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_empty, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 232, __pyx_L1_error)
-
- /* "src/gevent/queue.py":236
- * return not self.qsize()
- *
- * def full(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is full, ``False`` otherwise.
- *
- */
- __pyx_tuple__27 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__27);
- __Pyx_GIVEREF(__pyx_tuple__27);
- __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_full, 236, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 236, __pyx_L1_error)
-
- /* "src/gevent/queue.py":243
- * return self._maxsize > 0 and self.qsize() >= self._maxsize
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Put an item into the queue.
- *
- */
- __pyx_tuple__29 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_item, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__29);
- __Pyx_GIVEREF(__pyx_tuple__29);
- __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_2, 243, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 243, __pyx_L1_error)
-
- /* "src/gevent/queue.py":285
- * raise Full
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * """Put an item into the queue without blocking.
- *
- */
- __pyx_tuple__31 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__31);
- __Pyx_GIVEREF(__pyx_tuple__31);
- __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_nowait, 285, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 285, __pyx_L1_error)
-
- /* "src/gevent/queue.py":329
- * _safe_remove(self.getters, waiter)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue.
- *
- */
- __pyx_tuple__33 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__33);
- __Pyx_GIVEREF(__pyx_tuple__33);
- __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get_2, 329, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 329, __pyx_L1_error)
-
- /* "src/gevent/queue.py":346
- * return self.__get_or_peek(self._get, block, timeout)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue without blocking.
- *
- */
- __pyx_tuple__35 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__35);
- __Pyx_GIVEREF(__pyx_tuple__35);
- __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get_nowait, 346, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 346, __pyx_L1_error)
-
- /* "src/gevent/queue.py":354
- * return self.get(False)
- *
- * def peek(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return an item from the queue without removing it.
- *
- */
- __pyx_tuple__37 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__37);
- __Pyx_GIVEREF(__pyx_tuple__37);
- __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_peek_2, 354, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 354, __pyx_L1_error)
-
- /* "src/gevent/queue.py":370
- * return self.__get_or_peek(self._peek, block, timeout)
- *
- * def peek_nowait(self): # <<<<<<<<<<<<<<
- * """Return an item from the queue without blocking.
- *
- */
- __pyx_tuple__39 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__39);
- __Pyx_GIVEREF(__pyx_tuple__39);
- __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_peek_nowait, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 370, __pyx_L1_error)
-
- /* "src/gevent/queue.py":378
- * return self.peek(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while True:
- * repeat = False
- */
- __pyx_tuple__41 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_repeat, __pyx_n_s_putter, __pyx_n_s_getter); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__41);
- __Pyx_GIVEREF(__pyx_tuple__41);
- __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_unlock, 378, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 378, __pyx_L1_error)
-
- /* "src/gevent/queue.py":425
- * self.putters = None # Will never be used.
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * self._put(item)
- * if self.getters:
- */
- __pyx_tuple__43 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_item, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__43);
- __Pyx_GIVEREF(__pyx_tuple__43);
- __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_2, 425, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 425, __pyx_L1_error)
-
- /* "src/gevent/queue.py":444
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * q = list(items)
- * _heapify(q)
- */
- __pyx_tuple__45 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_q); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 444, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__45);
- __Pyx_GIVEREF(__pyx_tuple__45);
- __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_create_queue, 444, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 444, __pyx_L1_error)
-
- /* "src/gevent/queue.py":449
- * return q
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * _heappush(self.queue, item)
- *
- */
- __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__47);
- __Pyx_GIVEREF(__pyx_tuple__47);
- __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put, 449, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 449, __pyx_L1_error)
-
- /* "src/gevent/queue.py":452
- * _heappush(self.queue, item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return _heappop(self.queue)
- *
- */
- __pyx_tuple__49 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__49);
- __Pyx_GIVEREF(__pyx_tuple__49);
- __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get, 452, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 452, __pyx_L1_error)
-
- /* "src/gevent/queue.py":461
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return list(items)
- *
- */
- __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_items); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__51);
- __Pyx_GIVEREF(__pyx_tuple__51);
- __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_create_queue, 461, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 461, __pyx_L1_error)
-
- /* "src/gevent/queue.py":464
- * return list(items)
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
- __pyx_tuple__53 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__53);
- __Pyx_GIVEREF(__pyx_tuple__53);
- __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put, 464, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 464, __pyx_L1_error)
-
- /* "src/gevent/queue.py":467
- * self.queue.append(item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.pop()
- *
- */
- __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__55);
- __Pyx_GIVEREF(__pyx_tuple__55);
- __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get, 467, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 467, __pyx_L1_error)
-
- /* "src/gevent/queue.py":470
- * return self.queue.pop()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[-1]
- *
- */
- __pyx_tuple__57 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__57);
- __Pyx_GIVEREF(__pyx_tuple__57);
- __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_peek, 470, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 470, __pyx_L1_error)
-
- /* "src/gevent/queue.py":481
- *
- * __slots__ = (
- * '_cond', # <<<<<<<<<<<<<<
- * 'unfinished_tasks',
- * )
- */
- __pyx_tuple__59 = PyTuple_Pack(2, __pyx_n_s_cond, __pyx_n_s_unfinished_tasks); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 481, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__59);
- __Pyx_GIVEREF(__pyx_tuple__59);
-
- /* "src/gevent/queue.py":509
- * self._cond.clear()
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- */
- __pyx_tuple__60 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 509, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__60);
- __Pyx_GIVEREF(__pyx_tuple__60);
- __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_copy, 509, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 509, __pyx_L1_error)
-
- /* "src/gevent/queue.py":512
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = Queue._format(self)
- * if self.unfinished_tasks:
- */
- __pyx_tuple__62 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_result); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__62);
- __Pyx_GIVEREF(__pyx_tuple__62);
- __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_format, 512, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 512, __pyx_L1_error)
-
- /* "src/gevent/queue.py":518
- * return result
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * Queue._put(self, item)
- * self.unfinished_tasks += 1
- */
- __pyx_tuple__64 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__64);
- __Pyx_GIVEREF(__pyx_tuple__64);
- __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put, 518, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 518, __pyx_L1_error)
-
- /* "src/gevent/queue.py":523
- * self._cond.clear()
- *
- * def task_done(self): # <<<<<<<<<<<<<<
- * '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
- * For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
- */
- __pyx_tuple__66 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 523, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__66);
- __Pyx_GIVEREF(__pyx_tuple__66);
- __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_task_done, 523, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 523, __pyx_L1_error)
-
- /* "src/gevent/queue.py":540
- * self._cond.set()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * '''
- * Block until all items in the queue have been gotten and processed.
- */
- __pyx_tuple__68 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 540, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__68);
- __Pyx_GIVEREF(__pyx_tuple__68);
- __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_join, 540, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(0, 540, __pyx_L1_error)
-
- /* "src/gevent/queue.py":563
- *
- * __slots__ = (
- * 'getters', # <<<<<<<<<<<<<<
- * 'putters',
- * 'hub',
- */
- __pyx_tuple__70 = PyTuple_Pack(5, __pyx_n_s_getters, __pyx_n_s_putters, __pyx_n_s_hub, __pyx_n_s_event_unlock, __pyx_n_s_weakref); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 563, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__70);
- __Pyx_GIVEREF(__pyx_tuple__70);
-
- /* "src/gevent/queue.py":585
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = ''
- * if self.getters:
- */
- __pyx_tuple__71 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_result); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 585, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__71);
- __Pyx_GIVEREF(__pyx_tuple__71);
- __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_format, 585, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 585, __pyx_L1_error)
-
- /* "src/gevent/queue.py":597
- * return len(self.putters) - len(self.getters)
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * return 0
- *
- */
- __pyx_tuple__73 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 597, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__73);
- __Pyx_GIVEREF(__pyx_tuple__73);
- __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_qsize, 597, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 597, __pyx_L1_error)
-
- /* "src/gevent/queue.py":600
- * return 0
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
- __pyx_tuple__75 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 600, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__75);
- __Pyx_GIVEREF(__pyx_tuple__75);
- __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_empty, 600, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 600, __pyx_L1_error)
-
- /* "src/gevent/queue.py":603
- * return True
- *
- * def full(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
- __pyx_tuple__77 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 603, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__77);
- __Pyx_GIVEREF(__pyx_tuple__77);
- __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_full, 603, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 603, __pyx_L1_error)
-
- /* "src/gevent/queue.py":606
- * return True
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.getters:
- */
- __pyx_tuple__79 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_item, __pyx_n_s_block, __pyx_n_s_timeout, __pyx_n_s_getter, __pyx_n_s_waiter_2, __pyx_n_s_result); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 606, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__79);
- __Pyx_GIVEREF(__pyx_tuple__79);
- __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_2, 606, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 606, __pyx_L1_error)
-
- /* "src/gevent/queue.py":633
- * timeout.cancel()
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * self.put(item, False)
- *
- */
- __pyx_tuple__81 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_item); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 633, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__81);
- __Pyx_GIVEREF(__pyx_tuple__81);
- __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_put_nowait, 633, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 633, __pyx_L1_error)
-
- /* "src/gevent/queue.py":636
- * self.put(item, False)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.putters:
- */
- __pyx_tuple__83 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_block, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__83);
- __Pyx_GIVEREF(__pyx_tuple__83);
- __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get_2, 636, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(0, 636, __pyx_L1_error)
-
- /* "src/gevent/queue.py":659
- * timeout.close()
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * return self.get(False)
- *
- */
- __pyx_tuple__85 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__85);
- __Pyx_GIVEREF(__pyx_tuple__85);
- __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_get_nowait, 659, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(0, 659, __pyx_L1_error)
-
- /* "src/gevent/queue.py":662
- * return self.get(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while self.putters and self.getters:
- * getter = self.getters.popleft()
- */
- __pyx_tuple__87 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_getter, __pyx_n_s_item, __pyx_n_s_putter); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 662, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__87);
- __Pyx_GIVEREF(__pyx_tuple__87);
- __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_queue_py, __pyx_n_s_unlock, 662, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 662, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_6_queue__heappush = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_queue__heappop = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_6_queue__heapify = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- if (__Pyx_ExportVoidPtr(__pyx_n_s_heappush, (void *)&__pyx_v_6gevent_6_queue__heappush, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_heappop, (void *)&__pyx_v_6gevent_6_queue__heappop, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ExportVoidPtr(__pyx_n_s_heapify, (void *)&__pyx_v_6gevent_6_queue__heapify, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- if (__Pyx_ExportFunction("_safe_remove", (void (*)(void))__pyx_f_6gevent_6_queue__safe_remove, "PyObject *(PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_ptype_6gevent_8__waiter_Waiter = __Pyx_ImportType("gevent.__waiter", "Waiter", sizeof(struct __pyx_obj_6gevent_8__waiter_Waiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_Waiter)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_Waiter = (struct __pyx_vtabstruct_6gevent_8__waiter_Waiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_Waiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_Waiter)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_queue_ItemWaiter = &__pyx_vtable_6gevent_6_queue_ItemWaiter;
- __pyx_vtable_6gevent_6_queue_ItemWaiter.__pyx_base = *__pyx_vtabptr_6gevent_8__waiter_Waiter;
- __pyx_type_6gevent_6_queue_ItemWaiter.tp_base = __pyx_ptype_6gevent_8__waiter_Waiter;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_ItemWaiter) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_ItemWaiter.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_ItemWaiter.tp_dictoffset && __pyx_type_6gevent_6_queue_ItemWaiter.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_ItemWaiter.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_ItemWaiter.tp_dict, __pyx_vtabptr_6gevent_6_queue_ItemWaiter) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "ItemWaiter", (PyObject *)&__pyx_type_6gevent_6_queue_ItemWaiter) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
- __pyx_ptype_6gevent_6_queue_ItemWaiter = &__pyx_type_6gevent_6_queue_ItemWaiter;
- __pyx_vtabptr_6gevent_6_queue_Queue = &__pyx_vtable_6gevent_6_queue_Queue;
- __pyx_vtable_6gevent_6_queue_Queue._get = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue__get;
- __pyx_vtable_6gevent_6_queue_Queue._put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue__put;
- __pyx_vtable_6gevent_6_queue_Queue._peek = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue__peek;
- __pyx_vtable_6gevent_6_queue_Queue.qsize = (Py_ssize_t (*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_qsize;
- __pyx_vtable_6gevent_6_queue_Queue.empty = (int (*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_empty;
- __pyx_vtable_6gevent_6_queue_Queue.full = (int (*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_full;
- __pyx_vtable_6gevent_6_queue_Queue.put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args))__pyx_f_6gevent_6_queue_5Queue_put;
- __pyx_vtable_6gevent_6_queue_Queue.put_nowait = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_put_nowait;
- __pyx_vtable_6gevent_6_queue_Queue.__pyx___get_or_peek = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, PyObject *, PyObject *))__pyx_f_6gevent_6_queue_5Queue___get_or_peek;
- __pyx_vtable_6gevent_6_queue_Queue.get = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_get *__pyx_optional_args))__pyx_f_6gevent_6_queue_5Queue_get;
- __pyx_vtable_6gevent_6_queue_Queue.get_nowait = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_get_nowait;
- __pyx_vtable_6gevent_6_queue_Queue.peek = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_peek *__pyx_optional_args))__pyx_f_6gevent_6_queue_5Queue_peek;
- __pyx_vtable_6gevent_6_queue_Queue.peek_nowait = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_5Queue_peek_nowait;
- __pyx_vtable_6gevent_6_queue_Queue._schedule_unlock = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *))__pyx_f_6gevent_6_queue_5Queue__schedule_unlock;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_Queue) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_Queue.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_Queue.tp_dictoffset && __pyx_type_6gevent_6_queue_Queue.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_Queue.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- #if CYTHON_COMPILING_IN_CPYTHON
- {
- PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gevent_6_queue_Queue, "__len__"); if (unlikely(!wrapper)) __PYX_ERR(0, 93, __pyx_L1_error)
- if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
- __pyx_wrapperbase_6gevent_6_queue_5Queue_20__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
- __pyx_wrapperbase_6gevent_6_queue_5Queue_20__len__.doc = __pyx_doc_6gevent_6_queue_5Queue_20__len__;
- ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gevent_6_queue_5Queue_20__len__;
- }
- }
- #endif
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_Queue.tp_dict, __pyx_vtabptr_6gevent_6_queue_Queue) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Queue", (PyObject *)&__pyx_type_6gevent_6_queue_Queue) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_Queue.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_Queue.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_Queue, __weakref__);
- __pyx_ptype_6gevent_6_queue_Queue = &__pyx_type_6gevent_6_queue_Queue;
- __pyx_vtabptr_6gevent_6_queue_UnboundQueue = &__pyx_vtable_6gevent_6_queue_UnboundQueue;
- __pyx_vtable_6gevent_6_queue_UnboundQueue.__pyx_base = *__pyx_vtabptr_6gevent_6_queue_Queue;
- __pyx_vtable_6gevent_6_queue_UnboundQueue.__pyx_base.put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_5Queue_put *__pyx_optional_args))__pyx_f_6gevent_6_queue_12UnboundQueue_put;
- __pyx_type_6gevent_6_queue_UnboundQueue.tp_base = __pyx_ptype_6gevent_6_queue_Queue;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_UnboundQueue) < 0) __PYX_ERR(0, 413, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_UnboundQueue.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_UnboundQueue.tp_dictoffset && __pyx_type_6gevent_6_queue_UnboundQueue.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_UnboundQueue.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_UnboundQueue.tp_dict, __pyx_vtabptr_6gevent_6_queue_UnboundQueue) < 0) __PYX_ERR(0, 413, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "UnboundQueue", (PyObject *)&__pyx_type_6gevent_6_queue_UnboundQueue) < 0) __PYX_ERR(0, 413, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_UnboundQueue.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_UnboundQueue.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_UnboundQueue, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_queue_UnboundQueue = &__pyx_type_6gevent_6_queue_UnboundQueue;
- __pyx_vtabptr_6gevent_6_queue_PriorityQueue = &__pyx_vtable_6gevent_6_queue_PriorityQueue;
- __pyx_vtable_6gevent_6_queue_PriorityQueue.__pyx_base = *__pyx_vtabptr_6gevent_6_queue_Queue;
- __pyx_vtable_6gevent_6_queue_PriorityQueue.__pyx_base._get = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_13PriorityQueue__get;
- __pyx_vtable_6gevent_6_queue_PriorityQueue.__pyx_base._put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_13PriorityQueue__put;
- __pyx_type_6gevent_6_queue_PriorityQueue.tp_base = __pyx_ptype_6gevent_6_queue_Queue;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_PriorityQueue) < 0) __PYX_ERR(0, 431, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_PriorityQueue.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_PriorityQueue.tp_dictoffset && __pyx_type_6gevent_6_queue_PriorityQueue.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_PriorityQueue.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_PriorityQueue.tp_dict, __pyx_vtabptr_6gevent_6_queue_PriorityQueue) < 0) __PYX_ERR(0, 431, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "PriorityQueue", (PyObject *)&__pyx_type_6gevent_6_queue_PriorityQueue) < 0) __PYX_ERR(0, 431, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_PriorityQueue.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_PriorityQueue.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_PriorityQueue, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_queue_PriorityQueue = &__pyx_type_6gevent_6_queue_PriorityQueue;
- __pyx_vtabptr_6gevent_6_queue_LifoQueue = &__pyx_vtable_6gevent_6_queue_LifoQueue;
- __pyx_vtable_6gevent_6_queue_LifoQueue.__pyx_base = *__pyx_vtabptr_6gevent_6_queue_Queue;
- __pyx_vtable_6gevent_6_queue_LifoQueue.__pyx_base._get = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_9LifoQueue__get;
- __pyx_vtable_6gevent_6_queue_LifoQueue.__pyx_base._put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_9LifoQueue__put;
- __pyx_vtable_6gevent_6_queue_LifoQueue.__pyx_base._peek = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_9LifoQueue__peek;
- __pyx_type_6gevent_6_queue_LifoQueue.tp_base = __pyx_ptype_6gevent_6_queue_Queue;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_LifoQueue) < 0) __PYX_ERR(0, 456, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_LifoQueue.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_LifoQueue.tp_dictoffset && __pyx_type_6gevent_6_queue_LifoQueue.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_LifoQueue.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_LifoQueue.tp_dict, __pyx_vtabptr_6gevent_6_queue_LifoQueue) < 0) __PYX_ERR(0, 456, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "LifoQueue", (PyObject *)&__pyx_type_6gevent_6_queue_LifoQueue) < 0) __PYX_ERR(0, 456, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_LifoQueue.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_LifoQueue.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_LifoQueue, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_queue_LifoQueue = &__pyx_type_6gevent_6_queue_LifoQueue;
- __pyx_vtabptr_6gevent_6_queue_JoinableQueue = &__pyx_vtable_6gevent_6_queue_JoinableQueue;
- __pyx_vtable_6gevent_6_queue_JoinableQueue.__pyx_base = *__pyx_vtabptr_6gevent_6_queue_Queue;
- __pyx_vtable_6gevent_6_queue_JoinableQueue.__pyx_base._put = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Queue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_13JoinableQueue__put;
- __pyx_type_6gevent_6_queue_JoinableQueue.tp_base = __pyx_ptype_6gevent_6_queue_Queue;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_JoinableQueue) < 0) __PYX_ERR(0, 474, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_JoinableQueue.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_JoinableQueue.tp_dictoffset && __pyx_type_6gevent_6_queue_JoinableQueue.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_JoinableQueue.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- #if CYTHON_COMPILING_IN_CPYTHON
- {
- PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gevent_6_queue_JoinableQueue, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 474, __pyx_L1_error)
- if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
- __pyx_wrapperbase_6gevent_6_queue_13JoinableQueue___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
- __pyx_wrapperbase_6gevent_6_queue_13JoinableQueue___init__.doc = __pyx_doc_6gevent_6_queue_13JoinableQueue___init__;
- ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gevent_6_queue_13JoinableQueue___init__;
- }
- }
- #endif
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_JoinableQueue.tp_dict, __pyx_vtabptr_6gevent_6_queue_JoinableQueue) < 0) __PYX_ERR(0, 474, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "JoinableQueue", (PyObject *)&__pyx_type_6gevent_6_queue_JoinableQueue) < 0) __PYX_ERR(0, 474, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_JoinableQueue.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_JoinableQueue.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_JoinableQueue, __pyx_base.__weakref__);
- __pyx_ptype_6gevent_6_queue_JoinableQueue = &__pyx_type_6gevent_6_queue_JoinableQueue;
- __pyx_vtabptr_6gevent_6_queue_Channel = &__pyx_vtable_6gevent_6_queue_Channel;
- __pyx_vtable_6gevent_6_queue_Channel.get = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_6_queue_7Channel_get *__pyx_optional_args))__pyx_f_6gevent_6_queue_7Channel_get;
- __pyx_vtable_6gevent_6_queue_Channel.get_nowait = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Channel *, int __pyx_skip_dispatch))__pyx_f_6gevent_6_queue_7Channel_get_nowait;
- __pyx_vtable_6gevent_6_queue_Channel._schedule_unlock = (PyObject *(*)(struct __pyx_obj_6gevent_6_queue_Channel *))__pyx_f_6gevent_6_queue_7Channel__schedule_unlock;
- if (PyType_Ready(&__pyx_type_6gevent_6_queue_Channel) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
- __pyx_type_6gevent_6_queue_Channel.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_6_queue_Channel.tp_dictoffset && __pyx_type_6gevent_6_queue_Channel.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_6_queue_Channel.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_6_queue_Channel.tp_dict, __pyx_vtabptr_6gevent_6_queue_Channel) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "Channel", (PyObject *)&__pyx_type_6gevent_6_queue_Channel) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
- if (__pyx_type_6gevent_6_queue_Channel.tp_weaklistoffset == 0) __pyx_type_6gevent_6_queue_Channel.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_6_queue_Channel, __weakref__);
- __pyx_ptype_6gevent_6_queue_Channel = &__pyx_type_6gevent_6_queue_Channel;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_6gevent_21__greenlet_primitives_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_greenlet)) __PYX_ERR(2, 12, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet = __Pyx_ImportType("gevent.__greenlet_primitives", "TrackedRawGreenlet", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_TrackedRawGreenlet), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_TrackedRawGreenlet)) __PYX_ERR(2, 37, __pyx_L1_error)
- __pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = __Pyx_ImportType("gevent.__greenlet_primitives", "SwitchOutGreenletWithLoop", sizeof(struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop), 1); if (unlikely(!__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop = (struct __pyx_vtabstruct_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop*)__Pyx_GetVtable(__pyx_ptype_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop)) __PYX_ERR(2, 40, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_8__waiter_greenlet)) __PYX_ERR(3, 15, __pyx_L1_error)
- __pyx_ptype_6gevent_8__waiter_MultipleWaiter = __Pyx_ImportType("gevent.__waiter", "MultipleWaiter", sizeof(struct __pyx_obj_6gevent_8__waiter_MultipleWaiter), 1); if (unlikely(!__pyx_ptype_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __pyx_vtabptr_6gevent_8__waiter_MultipleWaiter = (struct __pyx_vtabstruct_6gevent_8__waiter_MultipleWaiter*)__Pyx_GetVtable(__pyx_ptype_6gevent_8__waiter_MultipleWaiter->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_8__waiter_MultipleWaiter)) __PYX_ERR(3, 47, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_greenlet = __Pyx_ImportType("greenlet", "greenlet", sizeof(PyGreenlet), 0); if (unlikely(!__pyx_ptype_6gevent_6_event_greenlet)) __PYX_ERR(4, 18, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event__AbstractLinkable = __Pyx_ImportType("gevent._event", "_AbstractLinkable", sizeof(struct __pyx_obj_6gevent_6_event__AbstractLinkable), 1); if (unlikely(!__pyx_ptype_6gevent_6_event__AbstractLinkable)) __PYX_ERR(4, 38, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event__AbstractLinkable = (struct __pyx_vtabstruct_6gevent_6_event__AbstractLinkable*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event__AbstractLinkable->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event__AbstractLinkable)) __PYX_ERR(4, 38, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_Event = __Pyx_ImportType("gevent._event", "Event", sizeof(struct __pyx_obj_6gevent_6_event_Event), 1); if (unlikely(!__pyx_ptype_6gevent_6_event_Event)) __PYX_ERR(4, 60, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event_Event = (struct __pyx_vtabstruct_6gevent_6_event_Event*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event_Event->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event_Event)) __PYX_ERR(4, 60, __pyx_L1_error)
- __pyx_ptype_6gevent_6_event_AsyncResult = __Pyx_ImportType("gevent._event", "AsyncResult", sizeof(struct __pyx_obj_6gevent_6_event_AsyncResult), 1); if (unlikely(!__pyx_ptype_6gevent_6_event_AsyncResult)) __PYX_ERR(4, 63, __pyx_L1_error)
- __pyx_vtabptr_6gevent_6_event_AsyncResult = (struct __pyx_vtabstruct_6gevent_6_event_AsyncResult*)__Pyx_GetVtable(__pyx_ptype_6gevent_6_event_AsyncResult->tp_dict); if (unlikely(!__pyx_vtabptr_6gevent_6_event_AsyncResult)) __PYX_ERR(4, 63, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__greenlet_primitives"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "wref", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_wref, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "BlockingSwitchOutError", (void **)&__pyx_vp_6gevent_21__greenlet_primitives_BlockingSwitchOutError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_1, "_greenlet_imported", (void **)&__pyx_vp_6gevent_21__greenlet_primitives__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_2, "_threadlocal", (void **)&__pyx_vp_6gevent_11__hub_local__threadlocal, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_ImportModule("gevent.__waiter"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "sys", (void **)&__pyx_vp_6gevent_8__waiter_sys, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "ConcurrentObjectUseError", (void **)&__pyx_vp_6gevent_8__waiter_ConcurrentObjectUseError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_greenlet_imported", (void **)&__pyx_vp_6gevent_8__waiter__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_3, "_NONE", (void **)&__pyx_vp_6gevent_8__waiter__NONE, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = __Pyx_ImportModule("gevent._event"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_None", (void **)&__pyx_vp_6gevent_6_event__None, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "reraise", (void **)&__pyx_vp_6gevent_6_event_reraise, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "dump_traceback", (void **)&__pyx_vp_6gevent_6_event_dump_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "load_traceback", (void **)&__pyx_vp_6gevent_6_event_load_traceback, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "InvalidSwitchError", (void **)&__pyx_vp_6gevent_6_event_InvalidSwitchError, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "Timeout", (void **)&__pyx_vp_6gevent_6_event_Timeout, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportVoidPtr(__pyx_t_4, "_greenlet_imported", (void **)&__pyx_vp_6gevent_6_event__greenlet_imported, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __pyx_t_1 = __Pyx_ImportModule("gevent.__hub_local"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
- if (__Pyx_ImportFunction(__pyx_t_1, "get_hub_noargs", (void (**)(void))&__pyx_f_6gevent_11__hub_local_get_hub_noargs, "struct __pyx_obj_6gevent_21__greenlet_primitives_SwitchOutGreenletWithLoop *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC init_queue(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC init_queue(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit__queue(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit__queue(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec__queue(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__queue(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("_queue", __pyx_methods, __pyx_k_Synchronized_queues_The_mod_gev, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent___queue) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent._queue")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent._queue", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- if (unlikely(__Pyx_modinit_variable_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "src/gevent/queue.py":31
- *
- * from __future__ import absolute_import
- * import sys # <<<<<<<<<<<<<<
- * from heapq import heappush as _heappush
- * from heapq import heappop as _heappop
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":32
- * from __future__ import absolute_import
- * import sys
- * from heapq import heappush as _heappush # <<<<<<<<<<<<<<
- * from heapq import heappop as _heappop
- * from heapq import heapify as _heapify
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_heappush_2);
- __Pyx_GIVEREF(__pyx_n_s_heappush_2);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_heappush_2);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heappush_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_queue__heappush);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_queue__heappush, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":33
- * import sys
- * from heapq import heappush as _heappush
- * from heapq import heappop as _heappop # <<<<<<<<<<<<<<
- * from heapq import heapify as _heapify
- * import collections
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_heappop_2);
- __Pyx_GIVEREF(__pyx_n_s_heappop_2);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_heappop_2);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_heappop_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_queue__heappop);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_queue__heappop, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":34
- * from heapq import heappush as _heappush
- * from heapq import heappop as _heappop
- * from heapq import heapify as _heapify # <<<<<<<<<<<<<<
- * import collections
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_heapify_2);
- __Pyx_GIVEREF(__pyx_n_s_heapify_2);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_heapify_2);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heapify_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_v_6gevent_6_queue__heapify);
- __Pyx_DECREF_SET(__pyx_v_6gevent_6_queue__heapify, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":35
- * from heapq import heappop as _heappop
- * from heapq import heapify as _heapify
- * import collections # <<<<<<<<<<<<<<
- *
- * if sys.version_info[0] == 2:
- */
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":37
- * import collections
- *
- * if sys.version_info[0] == 2: # <<<<<<<<<<<<<<
- * import Queue as __queue__ # python 3: pylint:disable=import-error
- * else:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 37, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_3) {
-
- /* "src/gevent/queue.py":38
- *
- * if sys.version_info[0] == 2:
- * import Queue as __queue__ # python 3: pylint:disable=import-error # <<<<<<<<<<<<<<
- * else:
- * import queue as __queue__ # python 2: pylint:disable=import-error
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_Queue, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_queue_2, __pyx_t_1) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":37
- * import collections
- *
- * if sys.version_info[0] == 2: # <<<<<<<<<<<<<<
- * import Queue as __queue__ # python 3: pylint:disable=import-error
- * else:
- */
- goto __pyx_L2;
- }
-
- /* "src/gevent/queue.py":40
- * import Queue as __queue__ # python 3: pylint:disable=import-error
- * else:
- * import queue as __queue__ # python 2: pylint:disable=import-error # <<<<<<<<<<<<<<
- * Full = __queue__.Full
- * Empty = __queue__.Empty
- */
- /*else*/ {
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_queue, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_queue_2, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L2:;
-
- /* "src/gevent/queue.py":41
- * else:
- * import queue as __queue__ # python 2: pylint:disable=import-error
- * Full = __queue__.Full # <<<<<<<<<<<<<<
- * Empty = __queue__.Empty
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_queue_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Full); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Full, __pyx_t_2) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":42
- * import queue as __queue__ # python 2: pylint:disable=import-error
- * Full = __queue__.Full
- * Empty = __queue__.Empty # <<<<<<<<<<<<<<
- *
- * from gevent.timeout import Timeout
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_queue_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Empty, __pyx_t_1) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":44
- * Empty = __queue__.Empty
- *
- * from gevent.timeout import Timeout # <<<<<<<<<<<<<<
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from greenlet import getcurrent
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Timeout);
- __Pyx_GIVEREF(__pyx_n_s_Timeout);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Timeout);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timeout, __pyx_t_1) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":45
- *
- * from gevent.timeout import Timeout
- * from gevent._hub_local import get_hub_noargs as get_hub # <<<<<<<<<<<<<<
- * from greenlet import getcurrent
- * from gevent.exceptions import InvalidSwitchError
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_get_hub_noargs);
- __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_hub_noargs);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":46
- * from gevent.timeout import Timeout
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from greenlet import getcurrent # <<<<<<<<<<<<<<
- * from gevent.exceptions import InvalidSwitchError
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_getcurrent);
- __Pyx_GIVEREF(__pyx_n_s_getcurrent);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_getcurrent);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_getcurrent, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":47
- * from gevent._hub_local import get_hub_noargs as get_hub
- * from greenlet import getcurrent
- * from gevent.exceptions import InvalidSwitchError # <<<<<<<<<<<<<<
- *
- * __all__ = []
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_InvalidSwitchError);
- __Pyx_GIVEREF(__pyx_n_s_InvalidSwitchError);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_InvalidSwitchError);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidSwitchError, __pyx_t_2) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":49
- * from gevent.exceptions import InvalidSwitchError
- *
- * __all__ = [] # <<<<<<<<<<<<<<
- * __implements__ = ['Queue', 'PriorityQueue', 'LifoQueue']
- * __extensions__ = ['JoinableQueue', 'Channel']
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":50
- *
- * __all__ = []
- * __implements__ = ['Queue', 'PriorityQueue', 'LifoQueue'] # <<<<<<<<<<<<<<
- * __extensions__ = ['JoinableQueue', 'Channel']
- * __imports__ = ['Empty', 'Full']
- */
- __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Queue);
- __Pyx_GIVEREF(__pyx_n_s_Queue);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Queue);
- __Pyx_INCREF(__pyx_n_s_PriorityQueue);
- __Pyx_GIVEREF(__pyx_n_s_PriorityQueue);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_PriorityQueue);
- __Pyx_INCREF(__pyx_n_s_LifoQueue);
- __Pyx_GIVEREF(__pyx_n_s_LifoQueue);
- PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_LifoQueue);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_implements, __pyx_t_1) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":51
- * __all__ = []
- * __implements__ = ['Queue', 'PriorityQueue', 'LifoQueue']
- * __extensions__ = ['JoinableQueue', 'Channel'] # <<<<<<<<<<<<<<
- * __imports__ = ['Empty', 'Full']
- * if hasattr(__queue__, 'SimpleQueue'):
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_JoinableQueue);
- __Pyx_GIVEREF(__pyx_n_s_JoinableQueue);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_JoinableQueue);
- __Pyx_INCREF(__pyx_n_s_Channel);
- __Pyx_GIVEREF(__pyx_n_s_Channel);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Channel);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_extensions, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":52
- * __implements__ = ['Queue', 'PriorityQueue', 'LifoQueue']
- * __extensions__ = ['JoinableQueue', 'Channel']
- * __imports__ = ['Empty', 'Full'] # <<<<<<<<<<<<<<
- * if hasattr(__queue__, 'SimpleQueue'):
- * __all__.append('SimpleQueue') # New in 3.7
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_Empty);
- __Pyx_GIVEREF(__pyx_n_s_Empty);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Empty);
- __Pyx_INCREF(__pyx_n_s_Full);
- __Pyx_GIVEREF(__pyx_n_s_Full);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Full);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_imports, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":53
- * __extensions__ = ['JoinableQueue', 'Channel']
- * __imports__ = ['Empty', 'Full']
- * if hasattr(__queue__, 'SimpleQueue'): # <<<<<<<<<<<<<<
- * __all__.append('SimpleQueue') # New in 3.7
- * # SimpleQueue is implemented in C and directly allocates locks
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_queue_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_s_SimpleQueue); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 53, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = (__pyx_t_3 != 0);
- if (__pyx_t_4) {
-
- /* "src/gevent/queue.py":54
- * __imports__ = ['Empty', 'Full']
- * if hasattr(__queue__, 'SimpleQueue'):
- * __all__.append('SimpleQueue') # New in 3.7 # <<<<<<<<<<<<<<
- * # SimpleQueue is implemented in C and directly allocates locks
- * # unaffected by monkey patching. We need the Python version.
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_n_s_SimpleQueue); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 54, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":57
- * # SimpleQueue is implemented in C and directly allocates locks
- * # unaffected by monkey patching. We need the Python version.
- * SimpleQueue = __queue__._PySimpleQueue # pylint:disable=no-member # <<<<<<<<<<<<<<
- * __all__ += (__implements__ + __extensions__ + __imports__)
- *
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_queue_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PySimpleQueue); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_SimpleQueue, __pyx_t_2) < 0) __PYX_ERR(0, 57, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "src/gevent/queue.py":53
- * __extensions__ = ['JoinableQueue', 'Channel']
- * __imports__ = ['Empty', 'Full']
- * if hasattr(__queue__, 'SimpleQueue'): # <<<<<<<<<<<<<<
- * __all__.append('SimpleQueue') # New in 3.7
- * # SimpleQueue is implemented in C and directly allocates locks
- */
- }
-
- /* "src/gevent/queue.py":58
- * # unaffected by monkey patching. We need the Python version.
- * SimpleQueue = __queue__._PySimpleQueue # pylint:disable=no-member
- * __all__ += (__implements__ + __extensions__ + __imports__) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_implements); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_extensions); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_imports); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_6) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":72
- * pass
- *
- * import gevent._waiter # <<<<<<<<<<<<<<
- * locals()['Waiter'] = gevent._waiter.Waiter
- *
- */
- __pyx_t_6 = __Pyx_Import(__pyx_n_s_gevent__waiter, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 72, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_6) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":73
- *
- * import gevent._waiter
- * locals()['Waiter'] = gevent._waiter.Waiter # <<<<<<<<<<<<<<
- *
- * class ItemWaiter(Waiter): # pylint:disable=undefined-variable
- */
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_gevent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_waiter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Waiter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_Waiter, __pyx_t_6) < 0)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":78
- * # pylint:disable=assigning-non-slot
- * __slots__ = (
- * 'item', # <<<<<<<<<<<<<<
- * 'queue',
- * )
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_ItemWaiter->tp_dict, __pyx_n_s_slots, __pyx_tuple__7) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_ItemWaiter);
-
- /* "src/gevent/queue.py":87
- * self.queue = queue
- *
- * def put_and_switch(self): # <<<<<<<<<<<<<<
- * self.queue._put(self.item)
- * self.queue = None
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_10ItemWaiter_3put_and_switch, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ItemWaiter_put_and_switch, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_ItemWaiter->tp_dict, __pyx_n_s_put_and_switch, __pyx_t_6) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_ItemWaiter);
-
- /* "src/gevent/queue.py":115
- *
- * __slots__ = (
- * '_maxsize', # <<<<<<<<<<<<<<
- * 'getters',
- * 'putters',
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_slots, __pyx_tuple__10) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":165
- * self._maxsize = nv
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_3copy, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_copy, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_copy, __pyx_t_6) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":168
- * return type(self)(self.maxsize, self.queue)
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return collections.deque(items)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_5_create_queue, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__create_queue, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 168, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_create_queue, __pyx_t_6) < 0) __PYX_ERR(0, 168, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":171
- * return collections.deque(items)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.popleft()
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_7_get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__get, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_get, __pyx_t_6) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":174
- * return self.queue.popleft()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[0]
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_9_peek, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__peek, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_peek, __pyx_t_6) < 0) __PYX_ERR(0, 174, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":177
- * return self.queue[0]
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_11_put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_put, __pyx_t_6) < 0) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":186
- * return '<%s%s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = []
- * if self.maxsize is not None:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_17_format, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__format, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_format, __pyx_t_6) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":200
- * return ''
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * """Return the size of the queue."""
- * return len(self.queue)
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_19qsize, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_qsize, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_qsize, __pyx_t_6) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":232
- * return True
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is empty, ``False`` otherwise."""
- * return not self.qsize()
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_27empty, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_empty, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_empty, __pyx_t_6) < 0) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":236
- * return not self.qsize()
- *
- * def full(self): # <<<<<<<<<<<<<<
- * """Return ``True`` if the queue is full, ``False`` otherwise.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_29full, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_full, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_full, __pyx_t_6) < 0) __PYX_ERR(0, 236, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":243
- * return self._maxsize > 0 and self.qsize() >= self._maxsize
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Put an item into the queue.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_31put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_put_2, __pyx_t_6) < 0) __PYX_ERR(0, 243, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":285
- * raise Full
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * """Put an item into the queue without blocking.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_33put_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_put_nowait, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_put_nowait, __pyx_t_6) < 0) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":329
- * _safe_remove(self.getters, waiter)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_35get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_get, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_get_2, __pyx_t_6) < 0) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":346
- * return self.__get_or_peek(self._get, block, timeout)
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * """Remove and return an item from the queue without blocking.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_37get_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_get_nowait, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_get_nowait, __pyx_t_6) < 0) __PYX_ERR(0, 346, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":354
- * return self.get(False)
- *
- * def peek(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * """Return an item from the queue without removing it.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_39peek, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_peek, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_peek_2, __pyx_t_6) < 0) __PYX_ERR(0, 354, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":370
- * return self.__get_or_peek(self._peek, block, timeout)
- *
- * def peek_nowait(self): # <<<<<<<<<<<<<<
- * """Return an item from the queue without blocking.
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_41peek_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue_peek_nowait, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_peek_nowait, __pyx_t_6) < 0) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":378
- * return self.peek(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while True:
- * repeat = False
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_5Queue_43_unlock, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Queue__unlock, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_unlock, __pyx_t_6) < 0) __PYX_ERR(0, 378, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":410
- * return result
- *
- * next = __next__ # Py2 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_6 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_6_queue_Queue, __pyx_n_s_next); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 410, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Queue->tp_dict, __pyx_n_s_next_2, __pyx_t_6) < 0) __PYX_ERR(0, 410, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Queue);
-
- /* "src/gevent/queue.py":417
- * # be bound. Changing its maxsize has no effect.
- *
- * __slots__ = () # <<<<<<<<<<<<<<
- *
- * def __init__(self, maxsize=None, items=()):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_UnboundQueue->tp_dict, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 417, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_UnboundQueue);
-
- /* "src/gevent/queue.py":425
- * self.putters = None # Will never be used.
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * self._put(item)
- * if self.getters:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_12UnboundQueue_3put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_UnboundQueue_put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_UnboundQueue->tp_dict, __pyx_n_s_put_2, __pyx_t_6) < 0) __PYX_ERR(0, 425, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_UnboundQueue);
-
- /* "src/gevent/queue.py":442
- * '''
- *
- * __slots__ = () # <<<<<<<<<<<<<<
- *
- * def _create_queue(self, items=()):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_PriorityQueue->tp_dict, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_PriorityQueue);
-
- /* "src/gevent/queue.py":444
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * q = list(items)
- * _heapify(q)
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13PriorityQueue_1_create_queue, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PriorityQueue__create_queue, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 444, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_PriorityQueue->tp_dict, __pyx_n_s_create_queue, __pyx_t_6) < 0) __PYX_ERR(0, 444, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_PriorityQueue);
-
- /* "src/gevent/queue.py":449
- * return q
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * _heappush(self.queue, item)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13PriorityQueue_3_put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PriorityQueue__put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_PriorityQueue->tp_dict, __pyx_n_s_put, __pyx_t_6) < 0) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_PriorityQueue);
-
- /* "src/gevent/queue.py":452
- * _heappush(self.queue, item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return _heappop(self.queue)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13PriorityQueue_5_get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PriorityQueue__get, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_PriorityQueue->tp_dict, __pyx_n_s_get, __pyx_t_6) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_PriorityQueue);
-
- /* "src/gevent/queue.py":459
- * '''A subclass of :class:`Queue` that retrieves most recently added entries first.'''
- *
- * __slots__ = () # <<<<<<<<<<<<<<
- *
- * def _create_queue(self, items=()):
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 459, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_LifoQueue);
-
- /* "src/gevent/queue.py":461
- * __slots__ = ()
- *
- * def _create_queue(self, items=()): # <<<<<<<<<<<<<<
- * return list(items)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_9LifoQueue_1_create_queue, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LifoQueue__create_queue, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict, __pyx_n_s_create_queue, __pyx_t_6) < 0) __PYX_ERR(0, 461, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_LifoQueue);
-
- /* "src/gevent/queue.py":464
- * return list(items)
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * self.queue.append(item)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_9LifoQueue_3_put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LifoQueue__put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict, __pyx_n_s_put, __pyx_t_6) < 0) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_LifoQueue);
-
- /* "src/gevent/queue.py":467
- * self.queue.append(item)
- *
- * def _get(self): # <<<<<<<<<<<<<<
- * return self.queue.pop()
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_9LifoQueue_5_get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LifoQueue__get, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict, __pyx_n_s_get, __pyx_t_6) < 0) __PYX_ERR(0, 467, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_LifoQueue);
-
- /* "src/gevent/queue.py":470
- * return self.queue.pop()
- *
- * def _peek(self): # <<<<<<<<<<<<<<
- * return self.queue[-1]
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_9LifoQueue_7_peek, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LifoQueue__peek, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_LifoQueue->tp_dict, __pyx_n_s_peek, __pyx_t_6) < 0) __PYX_ERR(0, 470, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_LifoQueue);
-
- /* "src/gevent/queue.py":481
- *
- * __slots__ = (
- * '_cond', # <<<<<<<<<<<<<<
- * 'unfinished_tasks',
- * )
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_slots, __pyx_tuple__59) < 0) __PYX_ERR(0, 480, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":509
- * self._cond.clear()
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13JoinableQueue_3copy, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_JoinableQueue_copy, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 509, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_copy, __pyx_t_6) < 0) __PYX_ERR(0, 509, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":512
- * return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = Queue._format(self)
- * if self.unfinished_tasks:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13JoinableQueue_5_format, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_JoinableQueue__format, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_format, __pyx_t_6) < 0) __PYX_ERR(0, 512, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":518
- * return result
- *
- * def _put(self, item): # <<<<<<<<<<<<<<
- * Queue._put(self, item)
- * self.unfinished_tasks += 1
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13JoinableQueue_7_put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_JoinableQueue__put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_put, __pyx_t_6) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":523
- * self._cond.clear()
- *
- * def task_done(self): # <<<<<<<<<<<<<<
- * '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
- * For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13JoinableQueue_9task_done, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_JoinableQueue_task_done, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 523, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_task_done, __pyx_t_6) < 0) __PYX_ERR(0, 523, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":540
- * self._cond.set()
- *
- * def join(self, timeout=None): # <<<<<<<<<<<<<<
- * '''
- * Block until all items in the queue have been gotten and processed.
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_13JoinableQueue_11join, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_JoinableQueue_join, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 540, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_JoinableQueue->tp_dict, __pyx_n_s_join, __pyx_t_6) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_JoinableQueue);
-
- /* "src/gevent/queue.py":563
- *
- * __slots__ = (
- * 'getters', # <<<<<<<<<<<<<<
- * 'putters',
- * 'hub',
- */
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_slots, __pyx_tuple__70) < 0) __PYX_ERR(0, 562, __pyx_L1_error)
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":585
- * return '<%s %s>' % (type(self).__name__, self._format())
- *
- * def _format(self): # <<<<<<<<<<<<<<
- * result = ''
- * if self.getters:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_7_format, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel__format, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 585, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_format, __pyx_t_6) < 0) __PYX_ERR(0, 585, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":597
- * return len(self.putters) - len(self.getters)
- *
- * def qsize(self): # <<<<<<<<<<<<<<
- * return 0
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_9qsize, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_qsize, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_qsize, __pyx_t_6) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":600
- * return 0
- *
- * def empty(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_11empty, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_empty, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__76)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 600, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_empty, __pyx_t_6) < 0) __PYX_ERR(0, 600, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":603
- * return True
- *
- * def full(self): # <<<<<<<<<<<<<<
- * return True
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_13full, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_full, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_full, __pyx_t_6) < 0) __PYX_ERR(0, 603, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":606
- * return True
- *
- * def put(self, item, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.getters:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_15put, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_put, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 606, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_put_2, __pyx_t_6) < 0) __PYX_ERR(0, 606, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":633
- * timeout.cancel()
- *
- * def put_nowait(self, item): # <<<<<<<<<<<<<<
- * self.put(item, False)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_17put_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_put_nowait, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 633, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_put_nowait, __pyx_t_6) < 0) __PYX_ERR(0, 633, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":636
- * self.put(item, False)
- *
- * def get(self, block=True, timeout=None): # <<<<<<<<<<<<<<
- * if self.hub is getcurrent():
- * if self.putters:
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_19get, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_get, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__84)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_get_2, __pyx_t_6) < 0) __PYX_ERR(0, 636, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":659
- * timeout.close()
- *
- * def get_nowait(self): # <<<<<<<<<<<<<<
- * return self.get(False)
- *
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_21get_nowait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel_get_nowait, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__86)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_get_nowait, __pyx_t_6) < 0) __PYX_ERR(0, 659, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":662
- * return self.get(False)
- *
- * def _unlock(self): # <<<<<<<<<<<<<<
- * while self.putters and self.getters:
- * getter = self.getters.popleft()
- */
- __pyx_t_6 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_6_queue_7Channel_23_unlock, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Channel__unlock, NULL, __pyx_n_s_gevent__queue, __pyx_d, ((PyObject *)__pyx_codeobj__88)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 662, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_unlock, __pyx_t_6) < 0) __PYX_ERR(0, 662, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":682
- * return result
- *
- * next = __next__ # Py2 # <<<<<<<<<<<<<<
- *
- * from gevent._util import import_c_accel
- */
- __pyx_t_6 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_6_queue_Channel, __pyx_n_s_next); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 682, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_6_queue_Channel->tp_dict, __pyx_n_s_next_2, __pyx_t_6) < 0) __PYX_ERR(0, 682, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- PyType_Modified(__pyx_ptype_6gevent_6_queue_Channel);
-
- /* "src/gevent/queue.py":684
- * next = __next__ # Py2
- *
- * from gevent._util import import_c_accel # <<<<<<<<<<<<<<
- * import_c_accel(globals(), 'gevent._queue')
- */
- __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 684, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_INCREF(__pyx_n_s_import_c_accel);
- __Pyx_GIVEREF(__pyx_n_s_import_c_accel);
- PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_import_c_accel);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_6, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 684, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_6) < 0) __PYX_ERR(0, 684, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "src/gevent/queue.py":685
- *
- * from gevent._util import import_c_accel
- * import_c_accel(globals(), 'gevent._queue') # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = __Pyx_Globals(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 685, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 685, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
- __Pyx_INCREF(__pyx_n_s_gevent__queue);
- __Pyx_GIVEREF(__pyx_n_s_gevent__queue);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_gevent__queue);
- __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 685, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "src/gevent/queue.py":1
- * # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<<
- * # copyright (c) 2018 gevent
- * # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
- */
- __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_6) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "gevent/_event.pxd":30
- * return PyGreenlet_GetCurrent()
- *
- * cdef inline void greenlet_init(): # <<<<<<<<<<<<<<
- * global _greenlet_imported
- * if not _greenlet_imported:
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent._queue", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent._queue");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* SaveResetException */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* PyIntBinop */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
- if (op1 == op2) {
- Py_RETURN_TRUE;
- }
- #if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(op1))) {
- const long b = intval;
- long a = PyInt_AS_LONG(op1);
- if (a == b) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
- }
- #endif
- #if CYTHON_USE_PYLONG_INTERNALS
- if (likely(PyLong_CheckExact(op1))) {
- const long b = intval;
- long a;
- const digit* digits = ((PyLongObject*)op1)->ob_digit;
- const Py_ssize_t size = Py_SIZE(op1);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- a = likely(size) ? digits[0] : 0;
- if (size == -1) a = -a;
- } else {
- switch (size) {
- case -2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- case -3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- case -4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
- }
- CYTHON_FALLTHROUGH;
- #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
- default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
- #else
- default: Py_RETURN_FALSE;
- #endif
- }
- }
- if (a == b) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
- }
- #endif
- if (PyFloat_CheckExact(op1)) {
- const long b = intval;
- double a = PyFloat_AS_DOUBLE(op1);
- if ((double)a == (double)b) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
- }
- return PyObject_RichCompare(op1, op2, Py_EQ);
-}
-#endif
-
-/* Import */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* GetModuleGlobalName */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* PyObjectCallNoArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* PyObjectCallMethod1 */
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = NULL;
-#if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
-#endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- goto done;
-done:
- return result;
-}
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method, *result;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- result = __Pyx__PyObject_CallMethod1(method, arg);
- Py_DECREF(method);
- return result;
-}
-
-/* append */
- static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
- if (likely(PyList_CheckExact(L))) {
- if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
- } else {
- PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
- if (unlikely(!retval))
- return -1;
- Py_DECREF(retval);
- }
- return 0;
-}
-
-/* GetAttr */
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
- static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* StringJoin */
- #if !CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
- return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
-}
-#endif
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* None */
- static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
- PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
-}
-
-/* PyObjectCallMethod0 */
- static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
- PyObject *method, *result = NULL;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) goto bad;
-#if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *function = PyMethod_GET_FUNCTION(method);
- result = __Pyx_PyObject_CallOneArg(function, self);
- Py_DECREF(method);
- return result;
- }
- }
-#endif
- result = __Pyx_PyObject_CallNoArg(method);
- Py_DECREF(method);
-bad:
- return result;
-}
-
-/* UnpackUnboundCMethod */
- static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod0 */
- static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_ASSUME_SAFE_MACROS
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
-#else
- args = PyTuple_Pack(1, self);
- if (unlikely(!args)) goto bad;
-#endif
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- Py_DECREF(args);
-bad:
- return result;
-}
-
-/* pop */
- static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
- if (Py_TYPE(L) == &PySet_Type) {
- return PySet_Pop(L);
- }
- return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
-}
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
- if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
- Py_SIZE(L) -= 1;
- return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
- }
- return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
-}
-#endif
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* RaiseTooManyValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* CallNextTpDealloc */
- static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_dealloc != current_tp_dealloc)
- type = type->tp_base;
- while (type && type->tp_dealloc == current_tp_dealloc)
- type = type->tp_base;
- if (type)
- type->tp_dealloc(obj);
-}
-
-/* CallNextTpTraverse */
- static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_traverse != current_tp_traverse)
- type = type->tp_base;
- while (type && type->tp_traverse == current_tp_traverse)
- type = type->tp_base;
- if (type && type->tp_traverse)
- return type->tp_traverse(obj, v, a);
- return 0;
-}
-
-/* CallNextTpClear */
- static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
- PyTypeObject* type = Py_TYPE(obj);
- while (type && type->tp_clear != current_tp_clear)
- type = type->tp_base;
- while (type && type->tp_clear == current_tp_clear)
- type = type->tp_base;
- if (type && type->tp_clear)
- type->tp_clear(obj);
-}
-
-/* GetVTable */
- static void* __Pyx_GetVtable(PyObject *dict) {
- void* ptr;
- PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
- if (!ob)
- goto bad;
-#if PY_VERSION_HEX >= 0x02070000
- ptr = PyCapsule_GetPointer(ob, 0);
-#else
- ptr = PyCObject_AsVoidPtr(ob);
-#endif
- if (!ptr && !PyErr_Occurred())
- PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
- Py_DECREF(ob);
- return ptr;
-bad:
- Py_XDECREF(ob);
- return NULL;
-}
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* HasAttr */
- static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
- PyObject *r;
- if (unlikely(!__Pyx_PyBaseString_Check(n))) {
- PyErr_SetString(PyExc_TypeError,
- "hasattr(): attribute name must be string");
- return -1;
- }
- r = __Pyx_GetAttr(o, n);
- if (unlikely(!r)) {
- PyErr_Clear();
- return 0;
- } else {
- Py_DECREF(r);
- return 1;
- }
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* GetNameInClass */
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
-}
-static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
-}
-
-/* Globals */
- static PyObject* __Pyx_Globals(void) {
- Py_ssize_t i;
- PyObject *names;
- PyObject *globals = __pyx_d;
- Py_INCREF(globals);
- names = PyObject_Dir(__pyx_m);
- if (!names)
- goto bad;
- for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject* name = PySequence_ITEM(names, i);
- if (!name)
- goto bad;
-#else
- PyObject* name = PyList_GET_ITEM(names, i);
-#endif
- if (!PyDict_Contains(globals, name)) {
- PyObject* value = __Pyx_GetAttr(__pyx_m, name);
- if (!value) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- goto bad;
- }
- if (PyDict_SetItem(globals, name, value) < 0) {
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- Py_DECREF(value);
- goto bad;
- }
- }
-#if CYTHON_COMPILING_IN_PYPY
- Py_DECREF(name);
-#endif
- }
- Py_DECREF(names);
- return globals;
-bad:
- Py_XDECREF(names);
- Py_XDECREF(globals);
- return NULL;
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* VoidPtrExport */
- static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
- PyObject *d;
- PyObject *cobj = 0;
- d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
- Py_XINCREF(d);
- if (!d) {
- d = PyDict_New();
- if (!d)
- goto bad;
- if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItem(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* FunctionExport */
- static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
- if (!d) {
- PyErr_Clear();
- d = PyDict_New();
- if (!d)
- goto bad;
- Py_INCREF(d);
- if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
- goto bad;
- }
- tmp.fp = f;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(tmp.p, sig, 0);
-#else
- cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
-#endif
- if (!cobj)
- goto bad;
- if (PyDict_SetItemString(d, name, cobj) < 0)
- goto bad;
- Py_DECREF(cobj);
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(cobj);
- Py_XDECREF(d);
- return -1;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* VoidPtrImport */
- #ifndef __PYX_HAVE_RT_ImportVoidPtr
-#define __PYX_HAVE_RT_ImportVoidPtr
-static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, name);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C variable %.200s",
- PyModule_GetName(module), name);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- *p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), name, sig, desc);
- goto bad;
- }
- *p = PyCObject_AsVoidPtr(cobj);}
-#endif
- if (!(*p))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* FunctionImport */
- #ifndef __PYX_HAVE_RT_ImportFunction
-#define __PYX_HAVE_RT_ImportFunction
-static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
- PyObject *d = 0;
- PyObject *cobj = 0;
- union {
- void (*fp)(void);
- void *p;
- } tmp;
- d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
- if (!d)
- goto bad;
- cobj = PyDict_GetItemString(d, funcname);
- if (!cobj) {
- PyErr_Format(PyExc_ImportError,
- "%.200s does not export expected C function %.200s",
- PyModule_GetName(module), funcname);
- goto bad;
- }
-#if PY_VERSION_HEX >= 0x02070000
- if (!PyCapsule_IsValid(cobj, sig)) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
- goto bad;
- }
- tmp.p = PyCapsule_GetPointer(cobj, sig);
-#else
- {const char *desc, *s1, *s2;
- desc = (const char *)PyCObject_GetDesc(cobj);
- if (!desc)
- goto bad;
- s1 = desc; s2 = sig;
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- if (*s1 != *s2) {
- PyErr_Format(PyExc_TypeError,
- "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
- PyModule_GetName(module), funcname, sig, desc);
- goto bad;
- }
- tmp.p = PyCObject_AsVoidPtr(cobj);}
-#endif
- *f = tmp.fp;
- if (!(*f))
- goto bad;
- Py_DECREF(d);
- return 0;
-bad:
- Py_XDECREF(d);
- return -1;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/queue.py b/python/gevent/queue.py
deleted file mode 100644
index 57b937b..0000000
--- a/python/gevent/queue.py
+++ /dev/null
@@ -1,685 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-# copyright (c) 2018 gevent
-# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
-"""
-Synchronized queues.
-
-The :mod:`gevent.queue` module implements multi-producer, multi-consumer queues
-that work across greenlets, with the API similar to the classes found in the
-standard :mod:`Queue` and :class:`multiprocessing <multiprocessing.Queue>` modules.
-
-The classes in this module implement the iterator protocol. Iterating
-over a queue means repeatedly calling :meth:`get <Queue.get>` until
-:meth:`get <Queue.get>` returns ``StopIteration`` (specifically that
-class, not an instance or subclass).
-
- >>> queue = gevent.queue.Queue()
- >>> queue.put(1)
- >>> queue.put(2)
- >>> queue.put(StopIteration)
- >>> for item in queue:
- ... print(item)
- 1
- 2
-
-.. versionchanged:: 1.0
- ``Queue(0)`` now means queue of infinite size, not a channel. A :exc:`DeprecationWarning`
- will be issued with this argument.
-"""
-
-from __future__ import absolute_import
-import sys
-from heapq import heappush as _heappush
-from heapq import heappop as _heappop
-from heapq import heapify as _heapify
-import collections
-
-if sys.version_info[0] == 2:
- import Queue as __queue__ # python 3: pylint:disable=import-error
-else:
- import queue as __queue__ # python 2: pylint:disable=import-error
-Full = __queue__.Full
-Empty = __queue__.Empty
-
-from gevent.timeout import Timeout
-from gevent._hub_local import get_hub_noargs as get_hub
-from greenlet import getcurrent
-from gevent.exceptions import InvalidSwitchError
-
-__all__ = []
-__implements__ = ['Queue', 'PriorityQueue', 'LifoQueue']
-__extensions__ = ['JoinableQueue', 'Channel']
-__imports__ = ['Empty', 'Full']
-if hasattr(__queue__, 'SimpleQueue'):
- __all__.append('SimpleQueue') # New in 3.7
- # SimpleQueue is implemented in C and directly allocates locks
- # unaffected by monkey patching. We need the Python version.
- SimpleQueue = __queue__._PySimpleQueue # pylint:disable=no-member
-__all__ += (__implements__ + __extensions__ + __imports__)
-
-
-# pylint 2.0.dev2 things collections.dequeue.popleft() doesn't return
-# pylint:disable=assignment-from-no-return
-
-def _safe_remove(deq, item):
- # For when the item may have been removed by
- # Queue._unlock
- try:
- deq.remove(item)
- except ValueError:
- pass
-
-import gevent._waiter
-locals()['Waiter'] = gevent._waiter.Waiter
-
-class ItemWaiter(Waiter): # pylint:disable=undefined-variable
- # pylint:disable=assigning-non-slot
- __slots__ = (
- 'item',
- 'queue',
- )
-
- def __init__(self, item, queue):
- Waiter.__init__(self) # pylint:disable=undefined-variable
- self.item = item
- self.queue = queue
-
- def put_and_switch(self):
- self.queue._put(self.item)
- self.queue = None
- self.item = None
- return self.switch(self)
-
-class Queue(object):
- """
- Create a queue object with a given maximum size.
-
- If *maxsize* is less than or equal to zero or ``None``, the queue
- size is infinite.
-
- Queues have a ``len`` equal to the number of items in them (the :meth:`qsize`),
- but in a boolean context they are always True.
-
- .. versionchanged:: 1.1b3
- Queues now support :func:`len`; it behaves the same as :meth:`qsize`.
- .. versionchanged:: 1.1b3
- Multiple greenlets that block on a call to :meth:`put` for a full queue
- will now be awakened to put their items into the queue in the order in which
- they arrived. Likewise, multiple greenlets that block on a call to :meth:`get` for
- an empty queue will now receive items in the order in which they blocked. An
- implementation quirk under CPython *usually* ensured this was roughly the case
- previously anyway, but that wasn't the case for PyPy.
- """
-
- __slots__ = (
- '_maxsize',
- 'getters',
- 'putters',
- 'hub',
- '_event_unlock',
- 'queue',
- '__weakref__',
- )
-
- def __init__(self, maxsize=None, items=(), _warn_depth=2):
- if maxsize is not None and maxsize <= 0:
- if maxsize == 0:
- import warnings
- warnings.warn(
- 'Queue(0) now equivalent to Queue(None); if you want a channel, use Channel',
- DeprecationWarning,
- stacklevel=_warn_depth)
- maxsize = None
-
- self._maxsize = maxsize if maxsize is not None else -1
- # Explicitly maintain order for getters and putters that block
- # so that callers can consistently rely on getting things out
- # in the apparent order they went in. This was once required by
- # imap_unordered. Previously these were set() objects, and the
- # items put in the set have default hash() and eq() methods;
- # under CPython, since new objects tend to have increasing
- # hash values, this tended to roughly maintain order anyway,
- # but that's not true under PyPy. An alternative to a deque
- # (to avoid the linear scan of remove()) might be an
- # OrderedDict, but it's 2.7 only; we don't expect to have so
- # many waiters that removing an arbitrary element is a
- # bottleneck, though.
- self.getters = collections.deque()
- self.putters = collections.deque()
- self.hub = get_hub()
- self._event_unlock = None
- self.queue = self._create_queue(items)
-
- @property
- def maxsize(self):
- return self._maxsize if self._maxsize > 0 else None
-
- @maxsize.setter
- def maxsize(self, nv):
- # QQQ make maxsize into a property with setter that schedules unlock if necessary
- if nv is None or nv <= 0:
- self._maxsize = -1
- else:
- self._maxsize = nv
-
- def copy(self):
- return type(self)(self.maxsize, self.queue)
-
- def _create_queue(self, items=()):
- return collections.deque(items)
-
- def _get(self):
- return self.queue.popleft()
-
- def _peek(self):
- return self.queue[0]
-
- def _put(self, item):
- self.queue.append(item)
-
- def __repr__(self):
- return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format())
-
- def __str__(self):
- return '<%s%s>' % (type(self).__name__, self._format())
-
- def _format(self):
- result = []
- if self.maxsize is not None:
- result.append('maxsize=%r' % (self.maxsize, ))
- if getattr(self, 'queue', None):
- result.append('queue=%r' % (self.queue, ))
- if self.getters:
- result.append('getters[%s]' % len(self.getters))
- if self.putters:
- result.append('putters[%s]' % len(self.putters))
- if result:
- return ' ' + ' '.join(result)
- return ''
-
- def qsize(self):
- """Return the size of the queue."""
- return len(self.queue)
-
- def __len__(self):
- """
- Return the size of the queue. This is the same as :meth:`qsize`.
-
- .. versionadded: 1.1b3
-
- Previously, getting len() of a queue would raise a TypeError.
- """
-
- return self.qsize()
-
- def __bool__(self):
- """
- A queue object is always True.
-
- .. versionadded: 1.1b3
-
- Now that queues support len(), they need to implement ``__bool__``
- to return True for backwards compatibility.
- """
- return True
-
- def __nonzero__(self):
- # Py2.
- # For Cython; __bool__ becomes a special method that we can't
- # get by name.
- return True
-
- def empty(self):
- """Return ``True`` if the queue is empty, ``False`` otherwise."""
- return not self.qsize()
-
- def full(self):
- """Return ``True`` if the queue is full, ``False`` otherwise.
-
- ``Queue(None)`` is never full.
- """
- return self._maxsize > 0 and self.qsize() >= self._maxsize
-
- def put(self, item, block=True, timeout=None):
- """Put an item into the queue.
-
- If optional arg *block* is true and *timeout* is ``None`` (the default),
- block if necessary until a free slot is available. If *timeout* is
- a positive number, it blocks at most *timeout* seconds and raises
- the :class:`Full` exception if no free slot was available within that time.
- Otherwise (*block* is false), put an item on the queue if a free slot
- is immediately available, else raise the :class:`Full` exception (*timeout*
- is ignored in that case).
- """
- if self._maxsize == -1 or self.qsize() < self._maxsize:
- # there's a free slot, put an item right away
- self._put(item)
- if self.getters:
- self._schedule_unlock()
- elif self.hub is getcurrent():
- # We're in the mainloop, so we cannot wait; we can switch to other greenlets though.
- # Check if possible to get a free slot in the queue.
- while self.getters and self.qsize() and self.qsize() >= self._maxsize:
- getter = self.getters.popleft()
- getter.switch(getter)
- if self.qsize() < self._maxsize:
- self._put(item)
- return
- raise Full
- elif block:
- waiter = ItemWaiter(item, self)
- self.putters.append(waiter)
- timeout = Timeout._start_new_or_dummy(timeout, Full)
- try:
- if self.getters:
- self._schedule_unlock()
- result = waiter.get()
- if result is not waiter:
- raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, ))
- finally:
- timeout.cancel()
- _safe_remove(self.putters, waiter)
- else:
- raise Full
-
- def put_nowait(self, item):
- """Put an item into the queue without blocking.
-
- Only enqueue the item if a free slot is immediately available.
- Otherwise raise the :class:`Full` exception.
- """
- self.put(item, False)
-
- def __get_or_peek(self, method, block, timeout):
- # Internal helper method. The `method` should be either
- # self._get when called from self.get() or self._peek when
- # called from self.peek(). Call this after the initial check
- # to see if there are items in the queue.
-
- if self.hub is getcurrent():
- # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet
- # there are no items in the queue; try to fix the situation by unlocking putters
- while self.putters:
- # Note: get() used popleft(), peek used pop(); popleft
- # is almost certainly correct.
- self.putters.popleft().put_and_switch()
- if self.qsize():
- return method()
- raise Empty()
-
- if not block:
- # We can't block, we're not the hub, and we have nothing
- # to return. No choice...
- raise Empty()
-
- waiter = Waiter() # pylint:disable=undefined-variable
- timeout = Timeout._start_new_or_dummy(timeout, Empty)
- try:
- self.getters.append(waiter)
- if self.putters:
- self._schedule_unlock()
- result = waiter.get()
- if result is not waiter:
- raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, ))
- return method()
- finally:
- timeout.cancel()
- _safe_remove(self.getters, waiter)
-
- def get(self, block=True, timeout=None):
- """Remove and return an item from the queue.
-
- If optional args *block* is true and *timeout* is ``None`` (the default),
- block if necessary until an item is available. If *timeout* is a positive number,
- it blocks at most *timeout* seconds and raises the :class:`Empty` exception
- if no item was available within that time. Otherwise (*block* is false), return
- an item if one is immediately available, else raise the :class:`Empty` exception
- (*timeout* is ignored in that case).
- """
- if self.qsize():
- if self.putters:
- self._schedule_unlock()
- return self._get()
-
- return self.__get_or_peek(self._get, block, timeout)
-
- def get_nowait(self):
- """Remove and return an item from the queue without blocking.
-
- Only get an item if one is immediately available. Otherwise
- raise the :class:`Empty` exception.
- """
- return self.get(False)
-
- def peek(self, block=True, timeout=None):
- """Return an item from the queue without removing it.
-
- If optional args *block* is true and *timeout* is ``None`` (the default),
- block if necessary until an item is available. If *timeout* is a positive number,
- it blocks at most *timeout* seconds and raises the :class:`Empty` exception
- if no item was available within that time. Otherwise (*block* is false), return
- an item if one is immediately available, else raise the :class:`Empty` exception
- (*timeout* is ignored in that case).
- """
- if self.qsize():
- # XXX: Why doesn't this schedule an unlock like get() does?
- return self._peek()
-
- return self.__get_or_peek(self._peek, block, timeout)
-
- def peek_nowait(self):
- """Return an item from the queue without blocking.
-
- Only return an item if one is immediately available. Otherwise
- raise the :class:`Empty` exception.
- """
- return self.peek(False)
-
- def _unlock(self):
- while True:
- repeat = False
- if self.putters and (self._maxsize == -1 or self.qsize() < self._maxsize):
- repeat = True
- try:
- putter = self.putters.popleft()
- self._put(putter.item)
- except: # pylint:disable=bare-except
- putter.throw(*sys.exc_info())
- else:
- putter.switch(putter)
- if self.getters and self.qsize():
- repeat = True
- getter = self.getters.popleft()
- getter.switch(getter)
- if not repeat:
- return
-
- def _schedule_unlock(self):
- if not self._event_unlock:
- self._event_unlock = self.hub.loop.run_callback(self._unlock)
-
- def __iter__(self):
- return self
-
- def __next__(self):
- result = self.get()
- if result is StopIteration:
- raise result
- return result
-
- next = __next__ # Py2
-
-
-class UnboundQueue(Queue):
- # A specialization of Queue that knows it can never
- # be bound. Changing its maxsize has no effect.
-
- __slots__ = ()
-
- def __init__(self, maxsize=None, items=()):
- if maxsize is not None:
- raise ValueError("UnboundQueue has no maxsize")
- Queue.__init__(self, maxsize, items)
- self.putters = None # Will never be used.
-
- def put(self, item, block=True, timeout=None):
- self._put(item)
- if self.getters:
- self._schedule_unlock()
-
-
-class PriorityQueue(Queue):
- '''A subclass of :class:`Queue` that retrieves entries in priority order (lowest first).
-
- Entries are typically tuples of the form: ``(priority number, data)``.
-
- .. versionchanged:: 1.2a1
- Any *items* given to the constructor will now be passed through
- :func:`heapq.heapify` to ensure the invariants of this class hold.
- Previously it was just assumed that they were already a heap.
- '''
-
- __slots__ = ()
-
- def _create_queue(self, items=()):
- q = list(items)
- _heapify(q)
- return q
-
- def _put(self, item):
- _heappush(self.queue, item)
-
- def _get(self):
- return _heappop(self.queue)
-
-
-class LifoQueue(Queue):
- '''A subclass of :class:`Queue` that retrieves most recently added entries first.'''
-
- __slots__ = ()
-
- def _create_queue(self, items=()):
- return list(items)
-
- def _put(self, item):
- self.queue.append(item)
-
- def _get(self):
- return self.queue.pop()
-
- def _peek(self):
- return self.queue[-1]
-
-
-class JoinableQueue(Queue):
- """
- A subclass of :class:`Queue` that additionally has
- :meth:`task_done` and :meth:`join` methods.
- """
-
- __slots__ = (
- '_cond',
- 'unfinished_tasks',
- )
-
- def __init__(self, maxsize=None, items=(), unfinished_tasks=None):
- """
-
- .. versionchanged:: 1.1a1
- If *unfinished_tasks* is not given, then all the given *items*
- (if any) will be considered unfinished.
-
- """
- Queue.__init__(self, maxsize, items, _warn_depth=3)
-
- from gevent.event import Event
- self._cond = Event()
- self._cond.set()
-
- if unfinished_tasks:
- self.unfinished_tasks = unfinished_tasks
- elif items:
- self.unfinished_tasks = len(items)
- else:
- self.unfinished_tasks = 0
-
- if self.unfinished_tasks:
- self._cond.clear()
-
- def copy(self):
- return type(self)(self.maxsize, self.queue, self.unfinished_tasks)
-
- def _format(self):
- result = Queue._format(self)
- if self.unfinished_tasks:
- result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond)
- return result
-
- def _put(self, item):
- Queue._put(self, item)
- self.unfinished_tasks += 1
- self._cond.clear()
-
- def task_done(self):
- '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
- For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
- that the processing on the task is complete.
-
- If a :meth:`join` is currently blocking, it will resume when all items have been processed
- (meaning that a :meth:`task_done` call was received for every item that had been
- :meth:`put <Queue.put>` into the queue).
-
- Raises a :exc:`ValueError` if called more times than there were items placed in the queue.
- '''
- if self.unfinished_tasks <= 0:
- raise ValueError('task_done() called too many times')
- self.unfinished_tasks -= 1
- if self.unfinished_tasks == 0:
- self._cond.set()
-
- def join(self, timeout=None):
- '''
- Block until all items in the queue have been gotten and processed.
-
- The count of unfinished tasks goes up whenever an item is added to the queue.
- The count goes down whenever a consumer thread calls :meth:`task_done` to indicate
- that the item was retrieved and all work on it is complete. When the count of
- unfinished tasks drops to zero, :meth:`join` unblocks.
-
- :param float timeout: If not ``None``, then wait no more than this time in seconds
- for all tasks to finish.
- :return: ``True`` if all tasks have finished; if ``timeout`` was given and expired before
- all tasks finished, ``False``.
-
- .. versionchanged:: 1.1a1
- Add the *timeout* parameter.
- '''
- return self._cond.wait(timeout=timeout)
-
-
-class Channel(object):
-
- __slots__ = (
- 'getters',
- 'putters',
- 'hub',
- '_event_unlock',
- '__weakref__',
- )
-
- def __init__(self, maxsize=1):
- # We take maxsize to simplify certain kinds of code
- if maxsize != 1:
- raise ValueError("Channels have a maxsize of 1")
- self.getters = collections.deque()
- self.putters = collections.deque()
- self.hub = get_hub()
- self._event_unlock = None
-
- def __repr__(self):
- return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format())
-
- def __str__(self):
- return '<%s %s>' % (type(self).__name__, self._format())
-
- def _format(self):
- result = ''
- if self.getters:
- result += ' getters[%s]' % len(self.getters)
- if self.putters:
- result += ' putters[%s]' % len(self.putters)
- return result
-
- @property
- def balance(self):
- return len(self.putters) - len(self.getters)
-
- def qsize(self):
- return 0
-
- def empty(self):
- return True
-
- def full(self):
- return True
-
- def put(self, item, block=True, timeout=None):
- if self.hub is getcurrent():
- if self.getters:
- getter = self.getters.popleft()
- getter.switch(item)
- return
- raise Full
-
- if not block:
- timeout = 0
-
- waiter = Waiter() # pylint:disable=undefined-variable
- item = (item, waiter)
- self.putters.append(item)
- timeout = Timeout._start_new_or_dummy(timeout, Full)
- try:
- if self.getters:
- self._schedule_unlock()
- result = waiter.get()
- if result is not waiter:
- raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, ))
- except:
- _safe_remove(self.putters, item)
- raise
- finally:
- timeout.cancel()
-
- def put_nowait(self, item):
- self.put(item, False)
-
- def get(self, block=True, timeout=None):
- if self.hub is getcurrent():
- if self.putters:
- item, putter = self.putters.popleft()
- self.hub.loop.run_callback(putter.switch, putter)
- return item
-
- if not block:
- timeout = 0
-
- waiter = Waiter() # pylint:disable=undefined-variable
- timeout = Timeout._start_new_or_dummy(timeout, Empty)
- try:
- self.getters.append(waiter)
- if self.putters:
- self._schedule_unlock()
- return waiter.get()
- except:
- self.getters.remove(waiter)
- raise
- finally:
- timeout.close()
-
- def get_nowait(self):
- return self.get(False)
-
- def _unlock(self):
- while self.putters and self.getters:
- getter = self.getters.popleft()
- item, putter = self.putters.popleft()
- getter.switch(item)
- putter.switch(putter)
-
- def _schedule_unlock(self):
- if not self._event_unlock:
- self._event_unlock = self.hub.loop.run_callback(self._unlock)
-
- def __iter__(self):
- return self
-
- def __next__(self):
- result = self.get()
- if result is StopIteration:
- raise result
- return result
-
- next = __next__ # Py2
-
-from gevent._util import import_c_accel
-import_c_accel(globals(), 'gevent._queue')
diff --git a/python/gevent/resolver/__init__.py b/python/gevent/resolver/__init__.py
deleted file mode 100644
index 3da38e3..0000000
--- a/python/gevent/resolver/__init__.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (c) 2018 gevent contributors. See LICENSE for details.
-
-from _socket import gaierror
-from _socket import error
-from _socket import getservbyname
-from _socket import getaddrinfo
-
-from gevent._compat import string_types
-from gevent._compat import integer_types
-
-from gevent.socket import SOCK_STREAM
-from gevent.socket import SOCK_DGRAM
-from gevent.socket import SOL_TCP
-from gevent.socket import AI_CANONNAME
-from gevent.socket import EAI_SERVICE
-from gevent.socket import AF_INET
-from gevent.socket import AI_PASSIVE
-
-
-def _lookup_port(port, socktype):
- # pylint:disable=too-many-branches
- socktypes = []
- if isinstance(port, string_types):
- try:
- port = int(port)
- except ValueError:
- try:
- if socktype == 0:
- origport = port
- try:
- port = getservbyname(port, 'tcp')
- socktypes.append(SOCK_STREAM)
- except error:
- port = getservbyname(port, 'udp')
- socktypes.append(SOCK_DGRAM)
- else:
- try:
- if port == getservbyname(origport, 'udp'):
- socktypes.append(SOCK_DGRAM)
- except error:
- pass
- elif socktype == SOCK_STREAM:
- port = getservbyname(port, 'tcp')
- elif socktype == SOCK_DGRAM:
- port = getservbyname(port, 'udp')
- else:
- raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype')
- except error as ex:
- if 'not found' in str(ex):
- raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype')
- else:
- raise gaierror(str(ex))
- except UnicodeEncodeError:
- raise error('Int or String expected', port)
- elif port is None:
- port = 0
- elif isinstance(port, integer_types):
- pass
- else:
- raise error('Int or String expected', port, type(port))
- port = int(port % 65536)
- if not socktypes and socktype:
- socktypes.append(socktype)
- return port, socktypes
-
-hostname_types = tuple(set(string_types + (bytearray, bytes)))
-
-def _resolve_special(hostname, family):
- if not isinstance(hostname, hostname_types):
- raise TypeError("argument 1 must be str, bytes or bytearray, not %s" % (type(hostname),))
-
- if hostname == '':
- result = getaddrinfo(None, 0, family, SOCK_DGRAM, 0, AI_PASSIVE)
- if len(result) != 1:
- raise error('wildcard resolved to multiple address')
- return result[0][4][0]
- return hostname
-
-
-class AbstractResolver(object):
-
- def gethostbyname(self, hostname, family=AF_INET):
- hostname = _resolve_special(hostname, family)
- return self.gethostbyname_ex(hostname, family)[-1][0]
-
- def gethostbyname_ex(self, hostname, family=AF_INET):
- aliases = self._getaliases(hostname, family)
- addresses = []
- tuples = self.getaddrinfo(hostname, 0, family,
- SOCK_STREAM,
- SOL_TCP, AI_CANONNAME)
- canonical = tuples[0][3]
- for item in tuples:
- addresses.append(item[4][0])
- # XXX we just ignore aliases
- return (canonical, aliases, addresses)
-
- def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0):
- raise NotImplementedError()
-
- def _getaliases(self, hostname, family):
- # pylint:disable=unused-argument
- return []
diff --git a/python/gevent/resolver/ares.py b/python/gevent/resolver/ares.py
deleted file mode 100644
index ea6e919..0000000
--- a/python/gevent/resolver/ares.py
+++ /dev/null
@@ -1,357 +0,0 @@
-# Copyright (c) 2011-2015 Denis Bilenko. See LICENSE for details.
-"""
-c-ares based hostname resolver.
-"""
-from __future__ import absolute_import, print_function, division
-import os
-import sys
-
-from _socket import getaddrinfo
-from _socket import gaierror
-from _socket import error
-
-from gevent._compat import string_types
-from gevent._compat import text_type
-
-from gevent._compat import reraise
-from gevent._compat import PY3
-
-from gevent.hub import Waiter
-from gevent.hub import get_hub
-
-from gevent.socket import AF_UNSPEC
-from gevent.socket import AF_INET
-from gevent.socket import AF_INET6
-from gevent.socket import SOCK_STREAM
-from gevent.socket import SOCK_DGRAM
-from gevent.socket import SOCK_RAW
-from gevent.socket import AI_NUMERICHOST
-
-from gevent._config import config
-from gevent._config import AresSettingMixin
-
-from .cares import channel, InvalidIP # pylint:disable=import-error,no-name-in-module
-from . import _lookup_port as lookup_port
-from . import _resolve_special
-from . import AbstractResolver
-
-__all__ = ['Resolver']
-
-
-class Resolver(AbstractResolver):
- """
- Implementation of the resolver API using the `c-ares`_ library.
-
- This implementation uses the c-ares library to handle name
- resolution. c-ares is natively asynchronous at the socket level
- and so integrates well into gevent's event loop.
-
- In comparison to :class:`gevent.resolver_thread.Resolver` (which
- delegates to the native system resolver), the implementation is
- much more complex. In addition, there have been reports of it not
- properly honoring certain system configurations (for example, the
- order in which IPv4 and IPv6 results are returned may not match
- the threaded resolver). However, because it does not use threads,
- it may scale better for applications that make many lookups.
-
- There are some known differences from the system resolver:
-
- - ``gethostbyname_ex`` and ``gethostbyaddr`` may return different
- for the ``aliaslist`` tuple member. (Sometimes the same,
- sometimes in a different order, sometimes a different alias
- altogether.)
- - ``gethostbyname_ex`` may return the ``ipaddrlist`` in a different order.
- - ``getaddrinfo`` does not return ``SOCK_RAW`` results.
- - ``getaddrinfo`` may return results in a different order.
- - Handling of ``.local`` (mDNS) names may be different, even if they are listed in
- the hosts file.
- - c-ares will not resolve ``broadcasthost``, even if listed in the hosts file.
- - This implementation may raise ``gaierror(4)`` where the system implementation would raise
- ``herror(1)``.
- - The results for ``localhost`` may be different. In particular, some system
- resolvers will return more results from ``getaddrinfo`` than c-ares does,
- such as SOCK_DGRAM results, and c-ares may report more ips on a multi-homed
- host.
-
- .. caution:: This module is considered extremely experimental on PyPy, and
- due to its implementation in cython, it may be slower. It may also lead to
- interpreter crashes.
-
- .. _c-ares: http://c-ares.haxx.se
- """
-
- ares_class = channel
-
- def __init__(self, hub=None, use_environ=True, **kwargs):
- if hub is None:
- hub = get_hub()
- self.hub = hub
- if use_environ:
- for setting in config.settings.values():
- if isinstance(setting, AresSettingMixin):
- value = setting.get()
- if value is not None:
- kwargs.setdefault(setting.kwarg_name, value)
- self.ares = self.ares_class(hub.loop, **kwargs)
- self.pid = os.getpid()
- self.params = kwargs
- self.fork_watcher = hub.loop.fork(ref=False)
- self.fork_watcher.start(self._on_fork)
-
- def __repr__(self):
- return '<gevent.resolver_ares.Resolver at 0x%x ares=%r>' % (id(self), self.ares)
-
- def _on_fork(self):
- # NOTE: See comment in gevent.hub.reinit.
- pid = os.getpid()
- if pid != self.pid:
- self.hub.loop.run_callback(self.ares.destroy)
- self.ares = self.ares_class(self.hub.loop, **self.params)
- self.pid = pid
-
- def close(self):
- if self.ares is not None:
- self.hub.loop.run_callback(self.ares.destroy)
- self.ares = None
- self.fork_watcher.stop()
-
- def gethostbyname(self, hostname, family=AF_INET):
- hostname = _resolve_special(hostname, family)
- return self.gethostbyname_ex(hostname, family)[-1][0]
-
- def gethostbyname_ex(self, hostname, family=AF_INET):
- if PY3:
- if isinstance(hostname, str):
- hostname = hostname.encode('idna')
- elif not isinstance(hostname, (bytes, bytearray)):
- raise TypeError('Expected es(idna), not %s' % type(hostname).__name__)
- else:
- if isinstance(hostname, text_type):
- hostname = hostname.encode('ascii')
- elif not isinstance(hostname, str):
- raise TypeError('Expected string, not %s' % type(hostname).__name__)
-
- while True:
- ares = self.ares
- try:
- waiter = Waiter(self.hub)
- ares.gethostbyname(waiter, hostname, family)
- result = waiter.get()
- if not result[-1]:
- raise gaierror(-5, 'No address associated with hostname')
- return result
- except gaierror:
- if ares is self.ares:
- if hostname == b'255.255.255.255':
- # The stdlib handles this case in 2.7 and 3.x, but ares does not.
- # It is tested by test_socket.py in 3.4.
- # HACK: So hardcode the expected return.
- return ('255.255.255.255', [], ['255.255.255.255'])
- raise
- # "self.ares is not ares" means channel was destroyed (because we were forked)
-
- def _lookup_port(self, port, socktype):
- return lookup_port(port, socktype)
-
- def _getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0):
- # pylint:disable=too-many-locals,too-many-branches
- if isinstance(host, text_type):
- host = host.encode('idna')
- elif not isinstance(host, str) or (flags & AI_NUMERICHOST):
- # this handles cases which do not require network access
- # 1) host is None
- # 2) host is of an invalid type
- # 3) AI_NUMERICHOST flag is set
- return getaddrinfo(host, port, family, socktype, proto, flags)
- # we also call _socket.getaddrinfo below if family is not one of AF_*
-
- port, socktypes = self._lookup_port(port, socktype)
-
- socktype_proto = [(SOCK_STREAM, 6), (SOCK_DGRAM, 17), (SOCK_RAW, 0)]
- if socktypes:
- socktype_proto = [(x, y) for (x, y) in socktype_proto if x in socktypes]
- if proto:
- socktype_proto = [(x, y) for (x, y) in socktype_proto if proto == y]
-
- ares = self.ares
-
- if family == AF_UNSPEC:
- ares_values = Values(self.hub, 2)
- ares.gethostbyname(ares_values, host, AF_INET)
- ares.gethostbyname(ares_values, host, AF_INET6)
- elif family == AF_INET:
- ares_values = Values(self.hub, 1)
- ares.gethostbyname(ares_values, host, AF_INET)
- elif family == AF_INET6:
- ares_values = Values(self.hub, 1)
- ares.gethostbyname(ares_values, host, AF_INET6)
- else:
- raise gaierror(5, 'ai_family not supported: %r' % (family, ))
-
- values = ares_values.get()
- if len(values) == 2 and values[0] == values[1]:
- values.pop()
-
- result = []
- result4 = []
- result6 = []
-
- for addrs in values:
- if addrs.family == AF_INET:
- for addr in addrs[-1]:
- sockaddr = (addr, port)
- for socktype4, proto4 in socktype_proto:
- result4.append((AF_INET, socktype4, proto4, '', sockaddr))
- elif addrs.family == AF_INET6:
- for addr in addrs[-1]:
- if addr == '::1':
- dest = result
- else:
- dest = result6
- sockaddr = (addr, port, 0, 0)
- for socktype6, proto6 in socktype_proto:
- dest.append((AF_INET6, socktype6, proto6, '', sockaddr))
-
- # As of 2016, some platforms return IPV6 first and some do IPV4 first,
- # and some might even allow configuration of which is which. For backwards
- # compatibility with earlier releases (but not necessarily resolver_thread!)
- # we return 4 first. See https://github.com/gevent/gevent/issues/815 for more.
- result += result4 + result6
-
- if not result:
- raise gaierror(-5, 'No address associated with hostname')
-
- return result
-
- def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0):
- while True:
- ares = self.ares
- try:
- return self._getaddrinfo(host, port, family, socktype, proto, flags)
- except gaierror:
- if ares is self.ares:
- raise
-
- def _gethostbyaddr(self, ip_address):
- if PY3:
- if isinstance(ip_address, str):
- ip_address = ip_address.encode('idna')
- elif not isinstance(ip_address, (bytes, bytearray)):
- raise TypeError('Expected es(idna), not %s' % type(ip_address).__name__)
- else:
- if isinstance(ip_address, text_type):
- ip_address = ip_address.encode('ascii')
- elif not isinstance(ip_address, str):
- raise TypeError('Expected string, not %s' % type(ip_address).__name__)
-
- waiter = Waiter(self.hub)
- try:
- self.ares.gethostbyaddr(waiter, ip_address)
- return waiter.get()
- except InvalidIP:
- result = self._getaddrinfo(ip_address, None, family=AF_UNSPEC, socktype=SOCK_DGRAM)
- if not result:
- raise
- _ip_address = result[0][-1][0]
- if isinstance(_ip_address, text_type):
- _ip_address = _ip_address.encode('ascii')
- if _ip_address == ip_address:
- raise
- waiter.clear()
- self.ares.gethostbyaddr(waiter, _ip_address)
- return waiter.get()
-
- def gethostbyaddr(self, ip_address):
- ip_address = _resolve_special(ip_address, AF_UNSPEC)
- while True:
- ares = self.ares
- try:
- return self._gethostbyaddr(ip_address)
- except gaierror:
- if ares is self.ares:
- raise
-
- def _getnameinfo(self, sockaddr, flags):
- if not isinstance(flags, int):
- raise TypeError('an integer is required')
- if not isinstance(sockaddr, tuple):
- raise TypeError('getnameinfo() argument 1 must be a tuple')
-
- address = sockaddr[0]
- if not PY3 and isinstance(address, text_type):
- address = address.encode('ascii')
-
- if not isinstance(address, string_types):
- raise TypeError('sockaddr[0] must be a string, not %s' % type(address).__name__)
-
- port = sockaddr[1]
- if not isinstance(port, int):
- raise TypeError('port must be an integer, not %s' % type(port))
-
- waiter = Waiter(self.hub)
- result = self._getaddrinfo(address, str(sockaddr[1]), family=AF_UNSPEC, socktype=SOCK_DGRAM)
- if not result:
- reraise(*sys.exc_info())
- elif len(result) != 1:
- raise error('sockaddr resolved to multiple addresses')
- family, _socktype, _proto, _name, address = result[0]
-
- if family == AF_INET:
- if len(sockaddr) != 2:
- raise error("IPv4 sockaddr must be 2 tuple")
- elif family == AF_INET6:
- address = address[:2] + sockaddr[2:]
-
- self.ares.getnameinfo(waiter, address, flags)
- node, service = waiter.get()
-
- if service is None:
- if PY3:
- # ares docs: "If the query did not complete
- # successfully, or one of the values was not
- # requested, node or service will be NULL ". Python 2
- # allows that for the service, but Python 3 raises
- # an error. This is tested by test_socket in py 3.4
- err = gaierror('nodename nor servname provided, or not known')
- err.errno = 8
- raise err
- service = '0'
- return node, service
-
- def getnameinfo(self, sockaddr, flags):
- while True:
- ares = self.ares
- try:
- return self._getnameinfo(sockaddr, flags)
- except gaierror:
- if ares is self.ares:
- raise
-
-
-class Values(object):
- # helper to collect multiple values; ignore errors unless nothing has succeeded
- # QQQ could probably be moved somewhere - hub.py?
-
- __slots__ = ['count', 'values', 'error', 'waiter']
-
- def __init__(self, hub, count):
- self.count = count
- self.values = []
- self.error = None
- self.waiter = Waiter(hub)
-
- def __call__(self, source):
- self.count -= 1
- if source.exception is None:
- self.values.append(source.value)
- else:
- self.error = source.exception
- if self.count <= 0:
- self.waiter.switch(None)
-
- def get(self):
- self.waiter.get()
- if self.values:
- return self.values
- assert error is not None
- raise self.error # pylint:disable=raising-bad-type
diff --git a/python/gevent/resolver/blocking.py b/python/gevent/resolver/blocking.py
deleted file mode 100644
index 84cbd9c..0000000
--- a/python/gevent/resolver/blocking.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (c) 2018 gevent contributors. See LICENSE for details.
-
-import _socket
-
-class Resolver(object):
- """
- A resolver that directly uses the system's resolver functions.
-
- .. caution::
-
- This resolver is *not* cooperative.
-
- This resolver has the lowest overhead of any resolver and
- typically approaches the speed of the unmodified :mod:`socket`
- functions. However, it is not cooperative, so if name resolution
- blocks, the entire thread and all its greenlets will be blocked.
-
- This can be useful during debugging, or it may be a good choice if
- your operating system provides a good caching resolver (such as
- macOS's Directory Services) that is usually very fast and
- functionally non-blocking.
-
- .. versionchanged:: 1.3a2
- This was previously undocumented and existed in :mod:`gevent.socket`.
-
- """
-
- def __init__(self, hub=None):
- pass
-
- def close(self):
- pass
-
- for method in (
- 'gethostbyname',
- 'gethostbyname_ex',
- 'getaddrinfo',
- 'gethostbyaddr',
- 'getnameinfo'
- ):
- locals()[method] = staticmethod(getattr(_socket, method))
diff --git a/python/gevent/resolver/cares.c b/python/gevent/resolver/cares.c
deleted file mode 100644
index e9cf5e0..0000000
--- a/python/gevent/resolver/cares.c
+++ /dev/null
@@ -1,15233 +0,0 @@
-/* Generated by Cython 0.28.5 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "define_macros": [
- [
- "FD_SETSIZE",
- "1024"
- ],
- [
- "_WIN32",
- "1"
- ],
- [
- "CARES_STATICLIB",
- ""
- ],
- [
- "CARES_EMBED",
- "1"
- ]
- ],
- "depends": [
- "C:\\projects\\gevent\\deps\\c-ares\\ares.h",
- "src/gevent/resolver/dnshelper.c",
- "src/gevent/resolver\\cares_ntop.h",
- "src/gevent/resolver\\cares_pton.h",
- "src\\gevent\\resolver\\cares_ntop.h",
- "src\\gevent\\resolver\\cares_pton.h",
- "src\\gevent\\resolver\\dnshelper.c"
- ],
- "include_dirs": [
- "src/gevent/resolver",
- "C:\\projects\\gevent\\deps\\c-ares"
- ],
- "libraries": [
- "ws2_32",
- "advapi32"
- ],
- "name": "gevent.resolver.cares",
- "sources": [
- "src/gevent/resolver/cares.pyx",
- "deps/c-ares\\ares__close_sockets.c",
- "deps/c-ares\\ares__get_hostent.c",
- "deps/c-ares\\ares__read_line.c",
- "deps/c-ares\\ares__timeval.c",
- "deps/c-ares\\ares_android.c",
- "deps/c-ares\\ares_cancel.c",
- "deps/c-ares\\ares_create_query.c",
- "deps/c-ares\\ares_data.c",
- "deps/c-ares\\ares_destroy.c",
- "deps/c-ares\\ares_expand_name.c",
- "deps/c-ares\\ares_expand_string.c",
- "deps/c-ares\\ares_fds.c",
- "deps/c-ares\\ares_free_hostent.c",
- "deps/c-ares\\ares_free_string.c",
- "deps/c-ares\\ares_getenv.c",
- "deps/c-ares\\ares_gethostbyaddr.c",
- "deps/c-ares\\ares_gethostbyname.c",
- "deps/c-ares\\ares_getnameinfo.c",
- "deps/c-ares\\ares_getopt.c",
- "deps/c-ares\\ares_getsock.c",
- "deps/c-ares\\ares_init.c",
- "deps/c-ares\\ares_library_init.c",
- "deps/c-ares\\ares_llist.c",
- "deps/c-ares\\ares_mkquery.c",
- "deps/c-ares\\ares_nowarn.c",
- "deps/c-ares\\ares_options.c",
- "deps/c-ares\\ares_parse_a_reply.c",
- "deps/c-ares\\ares_parse_aaaa_reply.c",
- "deps/c-ares\\ares_parse_mx_reply.c",
- "deps/c-ares\\ares_parse_naptr_reply.c",
- "deps/c-ares\\ares_parse_ns_reply.c",
- "deps/c-ares\\ares_parse_ptr_reply.c",
- "deps/c-ares\\ares_parse_soa_reply.c",
- "deps/c-ares\\ares_parse_srv_reply.c",
- "deps/c-ares\\ares_parse_txt_reply.c",
- "deps/c-ares\\ares_platform.c",
- "deps/c-ares\\ares_process.c",
- "deps/c-ares\\ares_query.c",
- "deps/c-ares\\ares_search.c",
- "deps/c-ares\\ares_send.c",
- "deps/c-ares\\ares_strcasecmp.c",
- "deps/c-ares\\ares_strdup.c",
- "deps/c-ares\\ares_strerror.c",
- "deps/c-ares\\ares_timeout.c",
- "deps/c-ares\\ares_version.c",
- "deps/c-ares\\ares_writev.c",
- "deps/c-ares\\bitncmp.c",
- "deps/c-ares\\inet_net_pton.c",
- "deps/c-ares\\inet_ntop.c",
- "deps/c-ares\\windows_port.c"
- ]
- },
- "module_name": "gevent.resolver.cares"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_28_5"
-#define CYTHON_FUTURE_DIVISION 0
-#include <stddef.h>
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0; // PyThread_create_key reports success always
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif // TSS (Thread Specific Storage) API
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
- #define PyObject_Unicode PyObject_Str
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-
-#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__gevent__resolver__cares
-#define __PYX_HAVE_API__gevent__resolver__cares
-/* Early includes */
-#include "ares.h"
-#include "cares_pton.h"
-#include <string.h>
-#include <stdio.h>
-#include "dnshelper.c"
-#ifdef _OPENMP
-#include <omp.h>
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include <cstdlib>
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "src\\gevent\\resolver\\cares.pyx",
- "type.pxd",
-};
-
-/*--- Type declarations ---*/
-struct __pyx_obj_6gevent_8resolver_5cares_result;
-struct __pyx_obj_6gevent_8resolver_5cares_channel;
-struct __pyx_opt_args_6gevent_8resolver_5cares__convert_cares_flags;
-struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers;
-
-/* "gevent/resolver/cares.pyx":146
- *
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- */
-struct __pyx_opt_args_6gevent_8resolver_5cares__convert_cares_flags {
- int __pyx_n;
- int __pyx_default;
-};
-
-/* "gevent/resolver/cares.pyx":323
- * self.channel = NULL
- *
- * cpdef set_servers(self, servers=None): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers {
- int __pyx_n;
- PyObject *servers;
-};
-
-/* "gevent/resolver/cares.pyx":173
- *
- *
- * cdef class result: # <<<<<<<<<<<<<<
- * cdef public object value
- * cdef public object exception
- */
-struct __pyx_obj_6gevent_8resolver_5cares_result {
- PyObject_HEAD
- PyObject *value;
- PyObject *exception;
-};
-
-
-/* "gevent/resolver/cares.pyx":254
- *
- *
- * cdef class channel: # <<<<<<<<<<<<<<
- *
- * cdef public object loop
- */
-struct __pyx_obj_6gevent_8resolver_5cares_channel {
- PyObject_HEAD
- struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel *__pyx_vtab;
- PyObject *loop;
- struct ares_channeldata *channel;
- PyObject *_watchers;
- PyObject *_timer;
-};
-
-
-
-struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel {
- PyObject *(*set_servers)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers *__pyx_optional_args);
- PyObject *(*_sock_state_callback)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, int, int, int);
- PyObject *(*_getnameinfo)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, PyObject *, PyObject *, int, int __pyx_skip_dispatch);
-};
-static struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel *__pyx_vtabptr_6gevent_8resolver_5cares_channel;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* GetModuleGlobalName.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* WriteUnraisableException.proto */
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename,
- int full_traceback, int nogil);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* RaiseNoneIterError.proto */
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* pyobject_as_double.proto */
-static double __Pyx__PyObject_AsDouble(PyObject* obj);
-#if CYTHON_COMPILING_IN_PYPY
-#define __Pyx_PyObject_AsDouble(obj)\
-(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
- likely(PyInt_CheckExact(obj)) ?\
- PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
-#else
-#define __Pyx_PyObject_AsDouble(obj)\
-((likely(PyFloat_CheckExact(obj))) ?\
- PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
-#endif
-
-/* py_dict_clear.proto */
-#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0)
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* dict_getitem_default.proto */
-static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod1.proto */
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
-#else
-#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
-#endif
-
-/* CallUnboundCMethod2.proto */
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
-#else
-#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
-#endif
-
-/* py_dict_pop.proto */
-static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* CalculateMetaclass.proto */
-static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
-
-/* Py3ClassCreate.proto */
-static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
- PyObject *mkw, PyObject *modname, PyObject *doc);
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
- PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunction.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
- __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* SetNameInClass.proto */
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
-#elif CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
-#else
-#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
-#endif
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* PyIdentifierFromString.proto */
-#if !defined(__Pyx_PyIdentifier_FromString)
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
-#else
- #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
-#endif
-#endif
-
-/* ModuleImport.proto */
-static PyObject *__Pyx_ImportModule(const char *name);
-
-/* TypeImport.proto */
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel_set_servers(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers *__pyx_optional_args); /* proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel__sock_state_callback(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write); /* proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel__getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch); /* proto*/
-
-/* Module declarations from 'gevent.resolver.libcares' */
-
-/* Module declarations from 'libc.string' */
-
-/* Module declarations from 'libc.stdio' */
-
-/* Module declarations from '__builtin__' */
-
-/* Module declarations from 'cpython.type' */
-static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
-
-/* Module declarations from 'cpython' */
-
-/* Module declarations from 'cpython.object' */
-
-/* Module declarations from 'cpython.ref' */
-
-/* Module declarations from 'cpython.mem' */
-
-/* Module declarations from 'gevent.resolver.cares' */
-static PyTypeObject *__pyx_ptype_6gevent_8resolver_5cares_result = 0;
-static PyTypeObject *__pyx_ptype_6gevent_8resolver_5cares_channel = 0;
-static PyObject *__pyx_v_6gevent_8resolver_5cares_string_types = 0;
-static PyObject *__pyx_v_6gevent_8resolver_5cares_text_type = 0;
-static PyObject *__pyx_f_6gevent_8resolver_5cares__prepare_cares_flag_map(void); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares__convert_cares_flags(int, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares__convert_cares_flags *__pyx_optional_args); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_strerror(PyObject *, int __pyx_skip_dispatch); /*proto*/
-static void __pyx_f_6gevent_8resolver_5cares_gevent_sock_state_callback(void *, int, int, int); /*proto*/
-static void __pyx_f_6gevent_8resolver_5cares_gevent_ares_host_callback(void *, int, int, struct hostent *); /*proto*/
-static void __pyx_f_6gevent_8resolver_5cares_gevent_ares_nameinfo_callback(void *, int, int, char *, char *); /*proto*/
-#define __Pyx_MODULE_NAME "gevent.resolver.cares"
-extern int __pyx_module_is_main_gevent__resolver__cares;
-int __pyx_module_is_main_gevent__resolver__cares = 0;
-
-/* Implementation of 'gevent.resolver.cares' */
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_MemoryError;
-static PyObject *__pyx_builtin_TypeError;
-static const char __pyx_k__2[] = ",";
-static const char __pyx_k_fd[] = "fd";
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_io[] = "io";
-static const char __pyx_k_all[] = "__all__";
-static const char __pyx_k_cls[] = "cls";
-static const char __pyx_k_doc[] = "__doc__";
-static const char __pyx_k_get[] = "get";
-static const char __pyx_k_new[] = "__new__";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_s_r[] = "%s(%r)";
-static const char __pyx_k_s_s[] = "%s: %s";
-static const char __pyx_k_sys[] = "sys";
-static const char __pyx_k_addr[] = "addr";
-static const char __pyx_k_loop[] = "loop";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_name[] = "__name__";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_stop[] = "stop";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_again[] = "again";
-static const char __pyx_k_ascii[] = "ascii";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_flags[] = "flags";
-static const char __pyx_k_ndots[] = "ndots";
-static const char __pyx_k_split[] = "split";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_timer[] = "timer";
-static const char __pyx_k_tries[] = "tries";
-static const char __pyx_k_value[] = "value";
-static const char __pyx_k_encode[] = "encode";
-static const char __pyx_k_events[] = "events";
-static const char __pyx_k_family[] = "family";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_module[] = "__module__";
-static const char __pyx_k_name_2[] = "name";
-static const char __pyx_k_socket[] = "_socket";
-static const char __pyx_k_TIMEOUT[] = "TIMEOUT";
-static const char __pyx_k_channel[] = "channel";
-static const char __pyx_k_default[] = "default";
-static const char __pyx_k_destroy[] = "destroy";
-static const char __pyx_k_prepare[] = "__prepare__";
-static const char __pyx_k_servers[] = "servers";
-static const char __pyx_k_timeout[] = "timeout";
-static const char __pyx_k_unicode[] = "unicode";
-static const char __pyx_k_watcher[] = "watcher";
-static const char __pyx_k_ARES_EOF[] = "ARES_EOF";
-static const char __pyx_k_NI_DGRAM[] = "NI_DGRAM";
-static const char __pyx_k_builtins[] = "__builtins__";
-static const char __pyx_k_callback[] = "callback";
-static const char __pyx_k_exc_info[] = "exc_info";
-static const char __pyx_k_gaierror[] = "gaierror";
-static const char __pyx_k_iterable[] = "iterable";
-static const char __pyx_k_on_timer[] = "_on_timer";
-static const char __pyx_k_qualname[] = "__qualname__";
-static const char __pyx_k_sockaddr[] = "sockaddr";
-static const char __pyx_k_tcp_port[] = "tcp_port";
-static const char __pyx_k_udp_port[] = "udp_port";
-static const char __pyx_k_InvalidIP[] = "InvalidIP";
-static const char __pyx_k_NI_NOFQDN[] = "NI_NOFQDN";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_exception[] = "exception";
-static const char __pyx_k_metaclass[] = "__metaclass__";
-static const char __pyx_k_ARES_EFILE[] = "ARES_EFILE";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_basestring[] = "basestring";
-static const char __pyx_k_getnewargs[] = "__getnewargs__";
-static const char __pyx_k_process_fd[] = "_process_fd";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_ARES_ENOMEM[] = "ARES_ENOMEM";
-static const char __pyx_k_MemoryError[] = "MemoryError";
-static const char __pyx_k_NI_NAMEREQD[] = "NI_NAMEREQD";
-static const char __pyx_k_ares_errors[] = "_ares_errors";
-static const char __pyx_k_getnameinfo[] = "_getnameinfo";
-static const char __pyx_k_pass_events[] = "pass_events";
-static const char __pyx_k_set_servers[] = "set_servers";
-static const char __pyx_k_ARES_EBADSTR[] = "ARES_EBADSTR";
-static const char __pyx_k_ARES_ENODATA[] = "ARES_ENODATA";
-static const char __pyx_k_ARES_ENONAME[] = "ARES_ENONAME";
-static const char __pyx_k_ARES_ENOTIMP[] = "ARES_ENOTIMP";
-static const char __pyx_k_ARES_SUCCESS[] = "ARES_SUCCESS";
-static const char __pyx_k_handle_error[] = "handle_error";
-static const char __pyx_k_version_info[] = "version_info";
-static const char __pyx_k_ARES_EBADNAME[] = "ARES_EBADNAME";
-static const char __pyx_k_ARES_EBADRESP[] = "ARES_EBADRESP";
-static const char __pyx_k_ARES_EFORMERR[] = "ARES_EFORMERR";
-static const char __pyx_k_ARES_EREFUSED[] = "ARES_EREFUSED";
-static const char __pyx_k_ARES_ETIMEOUT[] = "ARES_ETIMEOUT";
-static const char __pyx_k_s_exception_r[] = "%s(exception=%r)";
-static const char __pyx_k_ARES_EBADFLAGS[] = "ARES_EBADFLAGS";
-static const char __pyx_k_ARES_EBADHINTS[] = "ARES_EBADHINTS";
-static const char __pyx_k_ARES_EBADQUERY[] = "ARES_EBADQUERY";
-static const char __pyx_k_ARES_ENOTFOUND[] = "ARES_ENOTFOUND";
-static const char __pyx_k_ARES_ESERVFAIL[] = "ARES_ESERVFAIL";
-static const char __pyx_k_NI_NUMERICHOST[] = "NI_NUMERICHOST";
-static const char __pyx_k_NI_NUMERICSERV[] = "NI_NUMERICSERV";
-static const char __pyx_k_cares_flag_map[] = "_cares_flag_map";
-static const char __pyx_k_ARES_EBADFAMILY[] = "ARES_EBADFAMILY";
-static const char __pyx_k_ARES_ECANCELLED[] = "ARES_ECANCELLED";
-static const char __pyx_k_ARES_FLAG_IGNTC[] = "ARES_FLAG_IGNTC";
-static const char __pyx_k_ARES_FLAG_USEVC[] = "ARES_FLAG_USEVC";
-static const char __pyx_k_ares_host_result[] = "ares_host_result";
-static const char __pyx_k_ARES_ECONNREFUSED[] = "ARES_ECONNREFUSED";
-static const char __pyx_k_ARES_EDESTRUCTION[] = "ARES_EDESTRUCTION";
-static const char __pyx_k_ARES_FLAG_PRIMARY[] = "ARES_FLAG_PRIMARY";
-static const char __pyx_k_ARES_ELOADIPHLPAPI[] = "ARES_ELOADIPHLPAPI";
-static const char __pyx_k_ARES_FLAG_NOSEARCH[] = "ARES_FLAG_NOSEARCH";
-static const char __pyx_k_ARES_FLAG_STAYOPEN[] = "ARES_FLAG_STAYOPEN";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_ARES_FLAG_NOALIASES[] = "ARES_FLAG_NOALIASES";
-static const char __pyx_k_ARES_FLAG_NORECURSE[] = "ARES_FLAG_NORECURSE";
-static const char __pyx_k_ARES_ENOTINITIALIZED[] = "ARES_ENOTINITIALIZED";
-static const char __pyx_k_ARES_FLAG_NOCHECKRESP[] = "ARES_FLAG_NOCHECKRESP";
-static const char __pyx_k_gevent_resolver_cares[] = "gevent.resolver.cares";
-static const char __pyx_k_s_value_r_exception_r[] = "%s(value=%r, exception=%r)";
-static const char __pyx_k_ares_host_result___new[] = "ares_host_result.__new__";
-static const char __pyx_k_expected_a_tuple_got_r[] = "expected a tuple, got %r";
-static const char __pyx_k_Invalid_value_for_port_r[] = "Invalid value for port: %r";
-static const char __pyx_k_ARES_EADDRGETNETWORKPARAMS[] = "ARES_EADDRGETNETWORKPARAMS";
-static const char __pyx_k_Bad_value_for_ai_flags_0x_x[] = "Bad value for ai_flags: 0x%x";
-static const char __pyx_k_ares_host_result___getnewargs[] = "ares_host_result.__getnewargs__";
-static const char __pyx_k_src_gevent_resolver_cares_pyx[] = "src\\gevent\\resolver\\cares.pyx";
-static const char __pyx_k_s_at_0x_x__timer_r__watchers_s[] = "<%s at 0x%x _timer=%r _watchers[%s]>";
-static const char __pyx_k_this_ares_channel_has_been_destr[] = "this ares channel has been destroyed";
-static PyObject *__pyx_n_s_ARES_EADDRGETNETWORKPARAMS;
-static PyObject *__pyx_n_s_ARES_EBADFAMILY;
-static PyObject *__pyx_n_s_ARES_EBADFLAGS;
-static PyObject *__pyx_n_s_ARES_EBADHINTS;
-static PyObject *__pyx_n_s_ARES_EBADNAME;
-static PyObject *__pyx_n_s_ARES_EBADQUERY;
-static PyObject *__pyx_n_s_ARES_EBADRESP;
-static PyObject *__pyx_n_s_ARES_EBADSTR;
-static PyObject *__pyx_n_s_ARES_ECANCELLED;
-static PyObject *__pyx_n_s_ARES_ECONNREFUSED;
-static PyObject *__pyx_n_s_ARES_EDESTRUCTION;
-static PyObject *__pyx_n_s_ARES_EFILE;
-static PyObject *__pyx_n_s_ARES_EFORMERR;
-static PyObject *__pyx_n_s_ARES_ELOADIPHLPAPI;
-static PyObject *__pyx_n_s_ARES_ENODATA;
-static PyObject *__pyx_n_s_ARES_ENOMEM;
-static PyObject *__pyx_n_s_ARES_ENONAME;
-static PyObject *__pyx_n_s_ARES_ENOTFOUND;
-static PyObject *__pyx_n_s_ARES_ENOTIMP;
-static PyObject *__pyx_n_s_ARES_ENOTINITIALIZED;
-static PyObject *__pyx_n_s_ARES_EOF;
-static PyObject *__pyx_n_s_ARES_EREFUSED;
-static PyObject *__pyx_n_s_ARES_ESERVFAIL;
-static PyObject *__pyx_n_s_ARES_ETIMEOUT;
-static PyObject *__pyx_n_s_ARES_FLAG_IGNTC;
-static PyObject *__pyx_n_s_ARES_FLAG_NOALIASES;
-static PyObject *__pyx_n_s_ARES_FLAG_NOCHECKRESP;
-static PyObject *__pyx_n_s_ARES_FLAG_NORECURSE;
-static PyObject *__pyx_n_s_ARES_FLAG_NOSEARCH;
-static PyObject *__pyx_n_s_ARES_FLAG_PRIMARY;
-static PyObject *__pyx_n_s_ARES_FLAG_STAYOPEN;
-static PyObject *__pyx_n_s_ARES_FLAG_USEVC;
-static PyObject *__pyx_n_s_ARES_SUCCESS;
-static PyObject *__pyx_kp_s_Bad_value_for_ai_flags_0x_x;
-static PyObject *__pyx_n_s_InvalidIP;
-static PyObject *__pyx_kp_s_Invalid_value_for_port_r;
-static PyObject *__pyx_n_s_MemoryError;
-static PyObject *__pyx_n_s_NI_DGRAM;
-static PyObject *__pyx_n_s_NI_NAMEREQD;
-static PyObject *__pyx_n_s_NI_NOFQDN;
-static PyObject *__pyx_n_s_NI_NUMERICHOST;
-static PyObject *__pyx_n_s_NI_NUMERICSERV;
-static PyObject *__pyx_n_s_TIMEOUT;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_kp_s__2;
-static PyObject *__pyx_n_s_addr;
-static PyObject *__pyx_n_s_again;
-static PyObject *__pyx_n_s_all;
-static PyObject *__pyx_n_s_ares_errors;
-static PyObject *__pyx_n_s_ares_host_result;
-static PyObject *__pyx_n_s_ares_host_result___getnewargs;
-static PyObject *__pyx_n_s_ares_host_result___new;
-static PyObject *__pyx_n_s_ascii;
-static PyObject *__pyx_n_s_basestring;
-static PyObject *__pyx_n_s_builtins;
-static PyObject *__pyx_n_s_callback;
-static PyObject *__pyx_n_s_cares_flag_map;
-static PyObject *__pyx_n_s_channel;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_cls;
-static PyObject *__pyx_n_s_default;
-static PyObject *__pyx_n_s_destroy;
-static PyObject *__pyx_n_s_doc;
-static PyObject *__pyx_n_s_encode;
-static PyObject *__pyx_n_s_events;
-static PyObject *__pyx_n_s_exc_info;
-static PyObject *__pyx_n_s_exception;
-static PyObject *__pyx_kp_s_expected_a_tuple_got_r;
-static PyObject *__pyx_n_s_family;
-static PyObject *__pyx_n_s_fd;
-static PyObject *__pyx_n_s_flags;
-static PyObject *__pyx_n_s_gaierror;
-static PyObject *__pyx_n_s_get;
-static PyObject *__pyx_n_s_getnameinfo;
-static PyObject *__pyx_n_s_getnewargs;
-static PyObject *__pyx_n_s_gevent_resolver_cares;
-static PyObject *__pyx_n_s_handle_error;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_io;
-static PyObject *__pyx_n_s_iterable;
-static PyObject *__pyx_n_s_loop;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_metaclass;
-static PyObject *__pyx_n_s_module;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_name_2;
-static PyObject *__pyx_n_s_ndots;
-static PyObject *__pyx_n_s_new;
-static PyObject *__pyx_n_s_on_timer;
-static PyObject *__pyx_n_s_pass_events;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_prepare;
-static PyObject *__pyx_n_s_process_fd;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_qualname;
-static PyObject *__pyx_kp_s_s_at_0x_x__timer_r__watchers_s;
-static PyObject *__pyx_kp_s_s_exception_r;
-static PyObject *__pyx_kp_s_s_r;
-static PyObject *__pyx_kp_s_s_s;
-static PyObject *__pyx_kp_s_s_value_r_exception_r;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_servers;
-static PyObject *__pyx_n_s_set_servers;
-static PyObject *__pyx_n_s_sockaddr;
-static PyObject *__pyx_n_s_socket;
-static PyObject *__pyx_n_s_split;
-static PyObject *__pyx_kp_s_src_gevent_resolver_cares_pyx;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_stop;
-static PyObject *__pyx_n_s_sys;
-static PyObject *__pyx_n_s_tcp_port;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_kp_s_this_ares_channel_has_been_destr;
-static PyObject *__pyx_n_s_timeout;
-static PyObject *__pyx_n_s_timer;
-static PyObject *__pyx_n_s_tries;
-static PyObject *__pyx_n_s_udp_port;
-static PyObject *__pyx_n_s_unicode;
-static PyObject *__pyx_n_s_value;
-static PyObject *__pyx_n_s_version_info;
-static PyObject *__pyx_n_s_watcher;
-static PyObject *__pyx_pf_6gevent_8resolver_5cares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_6result___init__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_2__repr__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_4successful(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_6get(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_5value___get__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_6result_5value_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_6result_5value_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_9exception___get__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_6result_9exception_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_6result_9exception_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel___init__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_2__repr__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_4destroy(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static void __pyx_pf_6gevent_8resolver_5cares_7channel_6__dealloc__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_8set_servers(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_servers); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_10_on_timer(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_12_process_fd(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_14gethostbyname(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_16gethostbyaddr(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_18_getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_20getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_4loop___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_6_timer___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self); /* proto */
-static PyObject *__pyx_tp_new_6gevent_8resolver_5cares_result(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_6gevent_8resolver_5cares_channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
-static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_int_2;
-static PyObject *__pyx_int_3;
-static PyObject *__pyx_int_4;
-static PyObject *__pyx_int_8;
-static PyObject *__pyx_int_16;
-static PyObject *__pyx_int_neg_1;
-static PyObject *__pyx_int_neg_8;
-static int __pyx_k_;
-static int __pyx_k__5;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_codeobj__8;
-static PyObject *__pyx_codeobj__10;
-/* Late includes */
-
-/* "gevent/resolver/cares.pyx":135
- *
- *
- * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<<
- * global _cares_flag_map
- * import _socket
- */
-
-static PyObject *__pyx_f_6gevent_8resolver_5cares__prepare_cares_flag_map(void) {
- PyObject *__pyx_v__socket = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("_prepare_cares_flag_map", 0);
-
- /* "gevent/resolver/cares.pyx":137
- * cdef _prepare_cares_flag_map():
- * global _cares_flag_map
- * import _socket # <<<<<<<<<<<<<<
- * _cares_flag_map = [
- * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v__socket = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":139
- * import _socket
- * _cares_flag_map = [
- * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), # <<<<<<<<<<<<<<
- * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
- * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
- */
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICHOST, __pyx_int_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NUMERICHOST); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":140
- * _cares_flag_map = [
- * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
- * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), # <<<<<<<<<<<<<<
- * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
- * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
- */
- __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICSERV, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NUMERICSERV); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":141
- * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
- * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
- * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), # <<<<<<<<<<<<<<
- * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
- * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)]
- */
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NOFQDN, __pyx_int_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NOFQDN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":142
- * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
- * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
- * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), # <<<<<<<<<<<<<<
- * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)]
- *
- */
- __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NAMEREQD, __pyx_int_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NAMEREQD); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":143
- * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
- * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
- * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_DGRAM, __pyx_int_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_DGRAM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":138
- * global _cares_flag_map
- * import _socket
- * _cares_flag_map = [ # <<<<<<<<<<<<<<
- * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
- * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
- */
- __pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, __pyx_t_2) < 0) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":135
- *
- *
- * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<<
- * global _cares_flag_map
- * import _socket
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.resolver.cares._prepare_cares_flag_map", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v__socket);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":146
- *
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- */
-
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares__convert_cares_flags(int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares__convert_cares_flags *__pyx_optional_args) {
- int __pyx_v_default = __pyx_k_;
- PyObject *__pyx_v_socket_flag = NULL;
- PyObject *__pyx_v_cares_flag = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *(*__pyx_t_6)(PyObject *);
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *(*__pyx_t_10)(PyObject *);
- int __pyx_t_11;
- __Pyx_RefNannySetupContext("_convert_cares_flags", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_default = __pyx_optional_args->__pyx_default;
- }
- }
-
- /* "gevent/resolver/cares.pyx":147
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
- * if _cares_flag_map is None: # <<<<<<<<<<<<<<
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map:
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = (__pyx_t_1 == Py_None);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "gevent/resolver/cares.pyx":148
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map() # <<<<<<<<<<<<<<
- * for socket_flag, cares_flag in _cares_flag_map:
- * if socket_flag & flags:
- */
- __pyx_t_1 = __pyx_f_6gevent_8resolver_5cares__prepare_cares_flag_map(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":147
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
- * if _cares_flag_map is None: # <<<<<<<<<<<<<<
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map:
- */
- }
-
- /* "gevent/resolver/cares.pyx":149
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<<
- * if socket_flag & flags:
- * default |= cares_flag
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
- __pyx_t_6 = NULL;
- } else {
- __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 149, __pyx_L1_error)
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (likely(!__pyx_t_6)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_6(__pyx_t_4);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 149, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 149, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- __pyx_t_7 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_8 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- #else
- __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
- index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_7);
- index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_t_10 = NULL;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L7_unpacking_done;
- __pyx_L6_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_10 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 149, __pyx_L1_error)
- __pyx_L7_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_socket_flag, __pyx_t_7);
- __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_cares_flag, __pyx_t_8);
- __pyx_t_8 = 0;
-
- /* "gevent/resolver/cares.pyx":150
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map:
- * if socket_flag & flags: # <<<<<<<<<<<<<<
- * default |= cares_flag
- * flags &= ~socket_flag
- */
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = PyNumber_And(__pyx_v_socket_flag, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (__pyx_t_3) {
-
- /* "gevent/resolver/cares.pyx":151
- * for socket_flag, cares_flag in _cares_flag_map:
- * if socket_flag & flags:
- * default |= cares_flag # <<<<<<<<<<<<<<
- * flags &= ~socket_flag
- * if not flags:
- */
- __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_1 = PyNumber_InPlaceOr(__pyx_t_8, __pyx_v_cares_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_default = __pyx_t_11;
-
- /* "gevent/resolver/cares.pyx":152
- * if socket_flag & flags:
- * default |= cares_flag
- * flags &= ~socket_flag # <<<<<<<<<<<<<<
- * if not flags:
- * return default
- */
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = PyNumber_Invert(__pyx_v_socket_flag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = PyNumber_InPlaceAnd(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_v_flags = __pyx_t_11;
-
- /* "gevent/resolver/cares.pyx":150
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map:
- * if socket_flag & flags: # <<<<<<<<<<<<<<
- * default |= cares_flag
- * flags &= ~socket_flag
- */
- }
-
- /* "gevent/resolver/cares.pyx":153
- * default |= cares_flag
- * flags &= ~socket_flag
- * if not flags: # <<<<<<<<<<<<<<
- * return default
- * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
- */
- __pyx_t_3 = ((!(__pyx_v_flags != 0)) != 0);
- if (__pyx_t_3) {
-
- /* "gevent/resolver/cares.pyx":154
- * flags &= ~socket_flag
- * if not flags:
- * return default # <<<<<<<<<<<<<<
- * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_r = __pyx_t_7;
- __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":153
- * default |= cares_flag
- * flags &= ~socket_flag
- * if not flags: # <<<<<<<<<<<<<<
- * return default
- * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
- */
- }
-
- /* "gevent/resolver/cares.pyx":149
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<<
- * if socket_flag & flags:
- * default |= cares_flag
- */
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "gevent/resolver/cares.pyx":155
- * if not flags:
- * return default
- * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__pyx_t_8) {
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
- }
- __Pyx_INCREF(__pyx_int_neg_1);
- __Pyx_GIVEREF(__pyx_int_neg_1);
- PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_int_neg_1);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 155, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":146
- *
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent.resolver.cares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_socket_flag);
- __Pyx_XDECREF(__pyx_v_cares_flag);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_flags;
- int __pyx_v_default;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_convert_cares_flags (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags,&__pyx_n_s_default,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_convert_cares_flags") < 0)) __PYX_ERR(0, 146, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_flags = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L3_error)
- if (values[1]) {
- __pyx_v_default = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_default == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L3_error)
- } else {
- __pyx_v_default = __pyx_k_;
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_convert_cares_flags", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 146, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares__convert_cares_flags(__pyx_self, __pyx_v_flags, __pyx_v_default);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_8resolver_5cares__convert_cares_flags __pyx_t_2;
- __Pyx_RefNannySetupContext("_convert_cares_flags", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.__pyx_default = __pyx_v_default;
- __pyx_t_1 = __pyx_f_6gevent_8resolver_5cares__convert_cares_flags(__pyx_v_flags, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.resolver.cares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":158
- *
- *
- * cpdef strerror(code): # <<<<<<<<<<<<<<
- * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code))
- *
- */
-
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_strerror(PyObject *__pyx_v_code, CYTHON_UNUSED int __pyx_skip_dispatch) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- __Pyx_RefNannySetupContext("strerror", 0);
-
- /* "gevent/resolver/cares.pyx":159
- *
- * cpdef strerror(code):
- * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_errors); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_INCREF(__pyx_v_code);
- __Pyx_GIVEREF(__pyx_v_code);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_code);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 159, __pyx_L1_error)
- if (!__pyx_t_6) {
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __Pyx_INCREF(__pyx_t_2);
- __pyx_t_1 = __pyx_t_2;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- goto __pyx_L3_bool_binop_done;
- }
- __Pyx_INCREF(__pyx_v_code);
- __pyx_t_1 = __pyx_v_code;
- __pyx_L3_bool_binop_done:;
- __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_code); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 159, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyBytes_FromString(ares_strerror(__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":158
- *
- *
- * cpdef strerror(code): # <<<<<<<<<<<<<<
- * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.resolver.cares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("strerror (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_2strerror(__pyx_self, ((PyObject *)__pyx_v_code));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("strerror", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_v_code, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.resolver.cares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":166
- *
- *
- * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<<
- * if not data:
- * return
- */
-
-static void __pyx_f_6gevent_8resolver_5cares_gevent_sock_state_callback(void *__pyx_v_data, int __pyx_v_s, int __pyx_v_read, int __pyx_v_write) {
- struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_ch = 0;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("gevent_sock_state_callback", 0);
-
- /* "gevent/resolver/cares.pyx":167
- *
- * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
- * if not data: # <<<<<<<<<<<<<<
- * return
- * cdef channel ch = <channel>data
- */
- __pyx_t_1 = ((!(__pyx_v_data != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":168
- * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
- * if not data:
- * return # <<<<<<<<<<<<<<
- * cdef channel ch = <channel>data
- * ch._sock_state_callback(s, read, write)
- */
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":167
- *
- * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
- * if not data: # <<<<<<<<<<<<<<
- * return
- * cdef channel ch = <channel>data
- */
- }
-
- /* "gevent/resolver/cares.pyx":169
- * if not data:
- * return
- * cdef channel ch = <channel>data # <<<<<<<<<<<<<<
- * ch._sock_state_callback(s, read, write)
- *
- */
- __pyx_t_2 = ((PyObject *)__pyx_v_data);
- __Pyx_INCREF(__pyx_t_2);
- __pyx_v_ch = ((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":170
- * return
- * cdef channel ch = <channel>data
- * ch._sock_state_callback(s, read, write) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel *)__pyx_v_ch->__pyx_vtab)->_sock_state_callback(__pyx_v_ch, __pyx_v_s, __pyx_v_read, __pyx_v_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":166
- *
- *
- * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<<
- * if not data:
- * return
- */
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_WriteUnraisable("gevent.resolver.cares.gevent_sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_ch);
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/resolver/cares.pyx":177
- * cdef public object exception
- *
- * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<<
- * self.value = value
- * self.exception = exception
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_value = 0;
- PyObject *__pyx_v_exception = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_exception,0};
- PyObject* values[2] = {0,0};
- values[0] = ((PyObject *)Py_None);
- values[1] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value);
- if (value) { values[0] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exception);
- if (value) { values[1] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 177, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_value = values[0];
- __pyx_v_exception = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 177, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.result.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result___init__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self), __pyx_v_value, __pyx_v_exception);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_6result___init__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "gevent/resolver/cares.pyx":178
- *
- * def __init__(self, object value=None, object exception=None):
- * self.value = value # <<<<<<<<<<<<<<
- * self.exception = exception
- *
- */
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = __pyx_v_value;
-
- /* "gevent/resolver/cares.pyx":179
- * def __init__(self, object value=None, object exception=None):
- * self.value = value
- * self.exception = exception # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __Pyx_INCREF(__pyx_v_exception);
- __Pyx_GIVEREF(__pyx_v_exception);
- __Pyx_GOTREF(__pyx_v_self->exception);
- __Pyx_DECREF(__pyx_v_self->exception);
- __pyx_v_self->exception = __pyx_v_exception;
-
- /* "gevent/resolver/cares.pyx":177
- * cdef public object exception
- *
- * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<<
- * self.value = value
- * self.exception = exception
- */
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":181
- * self.exception = exception
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * if self.exception is None:
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_3__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_3__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_2__repr__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_2__repr__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "gevent/resolver/cares.pyx":182
- *
- * def __repr__(self):
- * if self.exception is None: # <<<<<<<<<<<<<<
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- * elif self.value is None:
- */
- __pyx_t_1 = (__pyx_v_self->exception == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "gevent/resolver/cares.pyx":183
- * def __repr__(self):
- * if self.exception is None:
- * return '%s(%r)' % (self.__class__.__name__, self.value) # <<<<<<<<<<<<<<
- * elif self.value is None:
- * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_self->value);
- __Pyx_GIVEREF(__pyx_v_self->value);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":182
- *
- * def __repr__(self):
- * if self.exception is None: # <<<<<<<<<<<<<<
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- * elif self.value is None:
- */
- }
-
- /* "gevent/resolver/cares.pyx":184
- * if self.exception is None:
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- * elif self.value is None: # <<<<<<<<<<<<<<
- * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
- * else:
- */
- __pyx_t_2 = (__pyx_v_self->value == Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":185
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- * elif self.value is None:
- * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) # <<<<<<<<<<<<<<
- * else:
- * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_self->exception);
- __Pyx_GIVEREF(__pyx_v_self->exception);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->exception);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_exception_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":184
- * if self.exception is None:
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- * elif self.value is None: # <<<<<<<<<<<<<<
- * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
- * else:
- */
- }
-
- /* "gevent/resolver/cares.pyx":187
- * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
- * else:
- * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) # <<<<<<<<<<<<<<
- * # add repr_recursive precaution
- *
- */
- /*else*/ {
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_self->value);
- __Pyx_GIVEREF(__pyx_v_self->value);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value);
- __Pyx_INCREF(__pyx_v_self->exception);
- __Pyx_GIVEREF(__pyx_v_self->exception);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->exception);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_value_r_exception_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
- }
-
- /* "gevent/resolver/cares.pyx":181
- * self.exception = exception
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * if self.exception is None:
- * return '%s(%r)' % (self.__class__.__name__, self.value)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("gevent.resolver.cares.result.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":190
- * # add repr_recursive precaution
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * return self.exception is None
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("successful (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_4successful(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_4successful(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("successful", 0);
-
- /* "gevent/resolver/cares.pyx":191
- *
- * def successful(self):
- * return self.exception is None # <<<<<<<<<<<<<<
- *
- * def get(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = (__pyx_v_self->exception == Py_None);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":190
- * # add repr_recursive precaution
- *
- * def successful(self): # <<<<<<<<<<<<<<
- * return self.exception is None
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.resolver.cares.result.successful", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":193
- * return self.exception is None
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if self.exception is not None:
- * raise self.exception
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("get (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_6get(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_6get(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- __Pyx_RefNannySetupContext("get", 0);
-
- /* "gevent/resolver/cares.pyx":194
- *
- * def get(self):
- * if self.exception is not None: # <<<<<<<<<<<<<<
- * raise self.exception
- * return self.value
- */
- __pyx_t_1 = (__pyx_v_self->exception != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "gevent/resolver/cares.pyx":195
- * def get(self):
- * if self.exception is not None:
- * raise self.exception # <<<<<<<<<<<<<<
- * return self.value
- *
- */
- __Pyx_Raise(__pyx_v_self->exception, 0, 0, 0);
- __PYX_ERR(0, 195, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":194
- *
- * def get(self):
- * if self.exception is not None: # <<<<<<<<<<<<<<
- * raise self.exception
- * return self.value
- */
- }
-
- /* "gevent/resolver/cares.pyx":196
- * if self.exception is not None:
- * raise self.exception
- * return self.value # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":193
- * return self.exception is None
- *
- * def get(self): # <<<<<<<<<<<<<<
- * if self.exception is not None:
- * raise self.exception
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.result.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":174
- *
- * cdef class result:
- * cdef public object value # <<<<<<<<<<<<<<
- * cdef public object exception
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_5value_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_5value___get__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_5value___get__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->value);
- __pyx_r = __pyx_v_self->value;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_5value_2__set__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_6result_5value_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_6result_5value_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_6result_5value_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_5value_4__del__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_6result_5value_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->value);
- __Pyx_DECREF(__pyx_v_self->value);
- __pyx_v_self->value = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":175
- * cdef class result:
- * cdef public object value
- * cdef public object exception # <<<<<<<<<<<<<<
- *
- * def __init__(self, object value=None, object exception=None):
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_6result_9exception_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_9exception___get__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_6result_9exception___get__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->exception);
- __pyx_r = __pyx_v_self->exception;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_9exception_2__set__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_6result_9exception_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->exception);
- __Pyx_DECREF(__pyx_v_self->exception);
- __pyx_v_self->exception = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_6result_9exception_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_6result_9exception_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_6result_9exception_4__del__(((struct __pyx_obj_6gevent_8resolver_5cares_result *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_6result_9exception_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_result *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->exception);
- __Pyx_DECREF(__pyx_v_self->exception);
- __pyx_v_self->exception = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":201
- * class ares_host_result(tuple):
- *
- * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_8resolver_5cares_16ares_host_result_1__new__ = {"__new__", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_cls = 0;
- PyObject *__pyx_v_family = 0;
- PyObject *__pyx_v_iterable = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_family,&__pyx_n_s_iterable,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_family)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 1); __PYX_ERR(0, 201, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iterable)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 2); __PYX_ERR(0, 201, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 201, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_cls = values[0];
- __pyx_v_family = values[1];
- __pyx_v_iterable = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_16ares_host_result___new__(__pyx_self, __pyx_v_cls, __pyx_v_family, __pyx_v_iterable);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__new__", 0);
-
- /* "gevent/resolver/cares.pyx":202
- *
- * def __new__(cls, family, iterable):
- * cdef object self = tuple.__new__(cls, iterable) # <<<<<<<<<<<<<<
- * self.family = family
- * return self
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_cls);
- __Pyx_GIVEREF(__pyx_v_cls);
- PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_cls);
- __Pyx_INCREF(__pyx_v_iterable);
- __Pyx_GIVEREF(__pyx_v_iterable);
- PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_iterable);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_self = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":203
- * def __new__(cls, family, iterable):
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family # <<<<<<<<<<<<<<
- * return self
- *
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_family, __pyx_v_family) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":204
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family
- * return self # <<<<<<<<<<<<<<
- *
- * def __getnewargs__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self);
- __pyx_r = __pyx_v_self;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":201
- * class ares_host_result(tuple):
- *
- * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.resolver.cares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_self);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":206
- * return self
- *
- * def __getnewargs__(self): # <<<<<<<<<<<<<<
- * return (self.family, tuple(self))
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_6gevent_8resolver_5cares_16ares_host_result_3__getnewargs__ = {"__getnewargs__", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_3__getnewargs__, METH_O, 0};
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getnewargs__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_16ares_host_result_2__getnewargs__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_RefNannySetupContext("__getnewargs__", 0);
-
- /* "gevent/resolver/cares.pyx":207
- *
- * def __getnewargs__(self):
- * return (self.family, tuple(self)) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_family); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":206
- * return self
- *
- * def __getnewargs__(self): # <<<<<<<<<<<<<<
- * return (self.family, tuple(self))
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("gevent.resolver.cares.ares_host_result.__getnewargs__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":210
- *
- *
- * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<<
- * cdef channel channel
- * cdef object callback
- */
-
-static void __pyx_f_6gevent_8resolver_5cares_gevent_ares_host_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, struct hostent *__pyx_v_host) {
- struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_channel = 0;
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_host_result = 0;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- int __pyx_t_12;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- __Pyx_RefNannySetupContext("gevent_ares_host_callback", 0);
-
- /* "gevent/resolver/cares.pyx":213
- * cdef channel channel
- * cdef object callback
- * channel, callback = <tuple>arg # <<<<<<<<<<<<<<
- * Py_DECREF(<tuple>arg)
- * cdef object host_result
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_arg);
- __Pyx_INCREF(__pyx_t_1);
- if (likely(__pyx_t_1 != Py_None)) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 213, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- #else
- __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 213, __pyx_L1_error)
- }
- if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_8resolver_5cares_channel))))) __PYX_ERR(0, 213, __pyx_L1_error)
- __pyx_v_channel = ((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_v_callback = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":214
- * cdef object callback
- * channel, callback = <tuple>arg
- * Py_DECREF(<tuple>arg) # <<<<<<<<<<<<<<
- * cdef object host_result
- * try:
- */
- Py_DECREF(((PyObject *)__pyx_v_arg));
-
- /* "gevent/resolver/cares.pyx":216
- * Py_DECREF(<tuple>arg)
- * cdef object host_result
- * try: # <<<<<<<<<<<<<<
- * if status or not host:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":217
- * cdef object host_result
- * try:
- * if status or not host: # <<<<<<<<<<<<<<
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- */
- __pyx_t_8 = (__pyx_v_status != 0);
- if (!__pyx_t_8) {
- } else {
- __pyx_t_7 = __pyx_t_8;
- goto __pyx_L10_bool_binop_done;
- }
- __pyx_t_8 = ((!(__pyx_v_host != 0)) != 0);
- __pyx_t_7 = __pyx_t_8;
- __pyx_L10_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "gevent/resolver/cares.pyx":218
- * try:
- * if status or not host:
- * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<<
- * else:
- * try:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_11 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = NULL;
- __pyx_t_12 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_12 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else
- #endif
- {
- __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_13);
- if (__pyx_t_10) {
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_9);
- PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_11);
- PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11);
- __pyx_t_9 = 0;
- __pyx_t_11 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8resolver_5cares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_INCREF(__pyx_v_callback);
- __pyx_t_2 = __pyx_v_callback; __pyx_t_13 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_13)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_13);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_13) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":217
- * cdef object host_result
- * try:
- * if status or not host: # <<<<<<<<<<<<<<
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- */
- goto __pyx_L9;
- }
-
- /* "gevent/resolver/cares.pyx":220
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- * try: # <<<<<<<<<<<<<<
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- * except:
- */
- /*else*/ {
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":221
- * else:
- * try:
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) # <<<<<<<<<<<<<<
- * except:
- * callback(result(None, sys.exc_info()[1]))
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_host_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_host->h_addrtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_3 = parse_h_name(__pyx_v_host); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_13 = parse_h_aliases(__pyx_v_host); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_13);
- __pyx_t_9 = parse_h_addr_list(__pyx_v_host); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_13);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_9);
- PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
- __pyx_t_3 = 0;
- __pyx_t_13 = 0;
- __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- __pyx_t_12 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_12 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- {
- __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_13);
- if (__pyx_t_9) {
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_11);
- PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_10);
- PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
- __pyx_t_11 = 0;
- __pyx_t_10 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L12_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_host_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":220
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- * try: # <<<<<<<<<<<<<<
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- * except:
- */
- }
-
- /* "gevent/resolver/cares.pyx":225
- * callback(result(None, sys.exc_info()[1]))
- * else:
- * callback(result(host_result)) # <<<<<<<<<<<<<<
- * except:
- * channel.loop.handle_error(callback, *sys.exc_info())
- */
- /*else:*/ {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_8resolver_5cares_result), __pyx_v_host_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_callback);
- __pyx_t_13 = __pyx_v_callback; __pyx_t_10 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_13, function);
- }
- }
- if (!__pyx_t_10) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_13)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
- PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_2};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- goto __pyx_L17_try_end;
- __pyx_L12_error:;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":222
- * try:
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- * except: # <<<<<<<<<<<<<<
- * callback(result(None, sys.exc_info()[1]))
- * else:
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.resolver.cares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_13, &__pyx_t_11) < 0) __PYX_ERR(0, 222, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_GOTREF(__pyx_t_11);
-
- /* "gevent/resolver/cares.pyx":223
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- * except:
- * callback(result(None, sys.exc_info()[1])) # <<<<<<<<<<<<<<
- * else:
- * callback(result(host_result))
- */
- __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (__pyx_t_9) {
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- }
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_10, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_10, 0, Py_None);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8resolver_5cares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_INCREF(__pyx_v_callback);
- __pyx_t_10 = __pyx_v_callback; __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_10, function);
- }
- }
- if (!__pyx_t_9) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_10)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
- PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_9); __pyx_t_9 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L14_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L13_exception_handled;
- }
- __pyx_L14_except_error:;
-
- /* "gevent/resolver/cares.pyx":220
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- * try: # <<<<<<<<<<<<<<
- * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- * except:
- */
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- goto __pyx_L3_error;
- __pyx_L13_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
- __pyx_L17_try_end:;
- }
- }
- __pyx_L9:;
-
- /* "gevent/resolver/cares.pyx":216
- * Py_DECREF(<tuple>arg)
- * cdef object host_result
- * try: # <<<<<<<<<<<<<<
- * if status or not host:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
-
- /* "gevent/resolver/cares.pyx":226
- * else:
- * callback(result(host_result))
- * except: # <<<<<<<<<<<<<<
- * channel.loop.handle_error(callback, *sys.exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.resolver.cares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_13, &__pyx_t_1) < 0) __PYX_ERR(0, 226, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_GOTREF(__pyx_t_1);
-
- /* "gevent/resolver/cares.pyx":227
- * callback(result(host_result))
- * except:
- * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_callback);
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_17 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- }
- __Pyx_GOTREF(__pyx_t_17);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- __pyx_t_17 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_17);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L4_exception_handled;
- }
- __pyx_L5_except_error:;
-
- /* "gevent/resolver/cares.pyx":216
- * Py_DECREF(<tuple>arg)
- * cdef object host_result
- * try: # <<<<<<<<<<<<<<
- * if status or not host:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- __pyx_L8_try_end:;
- }
-
- /* "gevent/resolver/cares.pyx":210
- *
- *
- * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<<
- * cdef channel channel
- * cdef object callback
- */
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_17);
- __Pyx_WriteUnraisable("gevent.resolver.cares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_channel);
- __Pyx_XDECREF(__pyx_v_callback);
- __Pyx_XDECREF(__pyx_v_host_result);
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/resolver/cares.pyx":230
- *
- *
- * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<<
- * cdef channel channel
- * cdef object callback
- */
-
-static void __pyx_f_6gevent_8resolver_5cares_gevent_ares_nameinfo_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, char *__pyx_v_c_node, char *__pyx_v_c_service) {
- struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_channel = 0;
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_node = 0;
- PyObject *__pyx_v_service = 0;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- int __pyx_t_11;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- __Pyx_RefNannySetupContext("gevent_ares_nameinfo_callback", 0);
-
- /* "gevent/resolver/cares.pyx":233
- * cdef channel channel
- * cdef object callback
- * channel, callback = <tuple>arg # <<<<<<<<<<<<<<
- * Py_DECREF(<tuple>arg)
- * cdef object node
- */
- __pyx_t_1 = ((PyObject *)__pyx_v_arg);
- __Pyx_INCREF(__pyx_t_1);
- if (likely(__pyx_t_1 != Py_None)) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 233, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- #else
- __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 233, __pyx_L1_error)
- }
- if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_8resolver_5cares_channel))))) __PYX_ERR(0, 233, __pyx_L1_error)
- __pyx_v_channel = ((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_v_callback = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":234
- * cdef object callback
- * channel, callback = <tuple>arg
- * Py_DECREF(<tuple>arg) # <<<<<<<<<<<<<<
- * cdef object node
- * cdef object service
- */
- Py_DECREF(((PyObject *)__pyx_v_arg));
-
- /* "gevent/resolver/cares.pyx":237
- * cdef object node
- * cdef object service
- * try: # <<<<<<<<<<<<<<
- * if status:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":238
- * cdef object service
- * try:
- * if status: # <<<<<<<<<<<<<<
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- */
- __pyx_t_7 = (__pyx_v_status != 0);
- if (__pyx_t_7) {
-
- /* "gevent/resolver/cares.pyx":239
- * try:
- * if status:
- * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<<
- * else:
- * if c_node:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- {
- __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_12);
- if (__pyx_t_9) {
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_10);
- PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10);
- __pyx_t_8 = 0;
- __pyx_t_10 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8resolver_5cares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_INCREF(__pyx_v_callback);
- __pyx_t_2 = __pyx_v_callback; __pyx_t_12 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_12)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_12);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_12) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":238
- * cdef object service
- * try:
- * if status: # <<<<<<<<<<<<<<
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- */
- goto __pyx_L9;
- }
-
- /* "gevent/resolver/cares.pyx":241
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- * if c_node: # <<<<<<<<<<<<<<
- * node = PyUnicode_FromString(c_node)
- * else:
- */
- /*else*/ {
- __pyx_t_7 = (__pyx_v_c_node != 0);
- if (__pyx_t_7) {
-
- /* "gevent/resolver/cares.pyx":242
- * else:
- * if c_node:
- * node = PyUnicode_FromString(c_node) # <<<<<<<<<<<<<<
- * else:
- * node = None
- */
- __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_node); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_node = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":241
- * callback(result(None, gaierror(status, strerror(status))))
- * else:
- * if c_node: # <<<<<<<<<<<<<<
- * node = PyUnicode_FromString(c_node)
- * else:
- */
- goto __pyx_L10;
- }
-
- /* "gevent/resolver/cares.pyx":244
- * node = PyUnicode_FromString(c_node)
- * else:
- * node = None # <<<<<<<<<<<<<<
- * if c_service:
- * service = PyUnicode_FromString(c_service)
- */
- /*else*/ {
- __Pyx_INCREF(Py_None);
- __pyx_v_node = Py_None;
- }
- __pyx_L10:;
-
- /* "gevent/resolver/cares.pyx":245
- * else:
- * node = None
- * if c_service: # <<<<<<<<<<<<<<
- * service = PyUnicode_FromString(c_service)
- * else:
- */
- __pyx_t_7 = (__pyx_v_c_service != 0);
- if (__pyx_t_7) {
-
- /* "gevent/resolver/cares.pyx":246
- * node = None
- * if c_service:
- * service = PyUnicode_FromString(c_service) # <<<<<<<<<<<<<<
- * else:
- * service = None
- */
- __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_service = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":245
- * else:
- * node = None
- * if c_service: # <<<<<<<<<<<<<<
- * service = PyUnicode_FromString(c_service)
- * else:
- */
- goto __pyx_L11;
- }
-
- /* "gevent/resolver/cares.pyx":248
- * service = PyUnicode_FromString(c_service)
- * else:
- * service = None # <<<<<<<<<<<<<<
- * callback(result((node, service)))
- * except:
- */
- /*else*/ {
- __Pyx_INCREF(Py_None);
- __pyx_v_service = Py_None;
- }
- __pyx_L11:;
-
- /* "gevent/resolver/cares.pyx":249
- * else:
- * service = None
- * callback(result((node, service))) # <<<<<<<<<<<<<<
- * except:
- * channel.loop.handle_error(callback, *sys.exc_info())
- */
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_node);
- __Pyx_GIVEREF(__pyx_v_node);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_node);
- __Pyx_INCREF(__pyx_v_service);
- __Pyx_GIVEREF(__pyx_v_service);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_service);
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6gevent_8resolver_5cares_result), __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_INCREF(__pyx_v_callback);
- __pyx_t_2 = __pyx_v_callback; __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- {
- __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_GIVEREF(__pyx_t_10);
- PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_10);
- __pyx_t_10 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __pyx_L9:;
-
- /* "gevent/resolver/cares.pyx":237
- * cdef object node
- * cdef object service
- * try: # <<<<<<<<<<<<<<
- * if status:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":250
- * service = None
- * callback(result((node, service)))
- * except: # <<<<<<<<<<<<<<
- * channel.loop.handle_error(callback, *sys.exc_info())
- *
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.resolver.cares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_12) < 0) __PYX_ERR(0, 250, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_t_12);
-
- /* "gevent/resolver/cares.pyx":251
- * callback(result((node, service)))
- * except:
- * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback);
- __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_13, function);
- }
- }
- if (__pyx_t_9) {
- __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- }
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 251, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- goto __pyx_L4_exception_handled;
- }
- __pyx_L5_except_error:;
-
- /* "gevent/resolver/cares.pyx":237
- * cdef object node
- * cdef object service
- * try: # <<<<<<<<<<<<<<
- * if status:
- * callback(result(None, gaierror(status, strerror(status))))
- */
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- __pyx_L8_try_end:;
- }
-
- /* "gevent/resolver/cares.pyx":230
- *
- *
- * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<<
- * cdef channel channel
- * cdef object callback
- */
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_WriteUnraisable("gevent.resolver.cares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_channel);
- __Pyx_XDECREF(__pyx_v_callback);
- __Pyx_XDECREF(__pyx_v_node);
- __Pyx_XDECREF(__pyx_v_service);
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/resolver/cares.pyx":261
- * cdef public object _timer
- *
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
- * udp_port=None, tcp_port=None, servers=None):
- * cdef ares_channeldata* channel = NULL
- */
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_loop = 0;
- PyObject *__pyx_v_flags = 0;
- PyObject *__pyx_v_timeout = 0;
- PyObject *__pyx_v_tries = 0;
- PyObject *__pyx_v_ndots = 0;
- PyObject *__pyx_v_udp_port = 0;
- PyObject *__pyx_v_tcp_port = 0;
- PyObject *__pyx_v_servers = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_flags,&__pyx_n_s_timeout,&__pyx_n_s_tries,&__pyx_n_s_ndots,&__pyx_n_s_udp_port,&__pyx_n_s_tcp_port,&__pyx_n_s_servers,0};
- PyObject* values[8] = {0,0,0,0,0,0,0,0};
- values[1] = ((PyObject *)Py_None);
- values[2] = ((PyObject *)Py_None);
- values[3] = ((PyObject *)Py_None);
- values[4] = ((PyObject *)Py_None);
-
- /* "gevent/resolver/cares.pyx":262
- *
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
- * udp_port=None, tcp_port=None, servers=None): # <<<<<<<<<<<<<<
- * cdef ares_channeldata* channel = NULL
- * cdef cares.ares_options options
- */
- values[5] = ((PyObject *)Py_None);
- values[6] = ((PyObject *)Py_None);
- values[7] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
- CYTHON_FALLTHROUGH;
- case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
- CYTHON_FALLTHROUGH;
- case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
- CYTHON_FALLTHROUGH;
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags);
- if (value) { values[1] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
- if (value) { values[2] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tries);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ndots);
- if (value) { values[4] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 5:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_udp_port);
- if (value) { values[5] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 6:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tcp_port);
- if (value) { values[6] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 7:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_servers);
- if (value) { values[7] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 261, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
- CYTHON_FALLTHROUGH;
- case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
- CYTHON_FALLTHROUGH;
- case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
- CYTHON_FALLTHROUGH;
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_loop = values[0];
- __pyx_v_flags = values[1];
- __pyx_v_timeout = values[2];
- __pyx_v_tries = values[3];
- __pyx_v_ndots = values[4];
- __pyx_v_udp_port = values[5];
- __pyx_v_tcp_port = values[6];
- __pyx_v_servers = values[7];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel___init__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_loop, __pyx_v_flags, __pyx_v_timeout, __pyx_v_tries, __pyx_v_ndots, __pyx_v_udp_port, __pyx_v_tcp_port, __pyx_v_servers);
-
- /* "gevent/resolver/cares.pyx":261
- * cdef public object _timer
- *
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
- * udp_port=None, tcp_port=None, servers=None):
- * cdef ares_channeldata* channel = NULL
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel___init__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers) {
- struct ares_channeldata *__pyx_v_channel;
- struct ares_options __pyx_v_options;
- int __pyx_v_optmask;
- int __pyx_v_result;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- double __pyx_t_5;
- unsigned short __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers __pyx_t_15;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "gevent/resolver/cares.pyx":263
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
- * udp_port=None, tcp_port=None, servers=None):
- * cdef ares_channeldata* channel = NULL # <<<<<<<<<<<<<<
- * cdef cares.ares_options options
- * memset(&options, 0, sizeof(cares.ares_options))
- */
- __pyx_v_channel = NULL;
-
- /* "gevent/resolver/cares.pyx":265
- * cdef ares_channeldata* channel = NULL
- * cdef cares.ares_options options
- * memset(&options, 0, sizeof(cares.ares_options)) # <<<<<<<<<<<<<<
- * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
- * options.sock_state_cb = <void*>gevent_sock_state_callback
- */
- memset((&__pyx_v_options), 0, (sizeof(struct ares_options)));
-
- /* "gevent/resolver/cares.pyx":266
- * cdef cares.ares_options options
- * memset(&options, 0, sizeof(cares.ares_options))
- * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB # <<<<<<<<<<<<<<
- * options.sock_state_cb = <void*>gevent_sock_state_callback
- * options.sock_state_cb_data = <void*>self
- */
- __pyx_v_optmask = ARES_OPT_SOCK_STATE_CB;
-
- /* "gevent/resolver/cares.pyx":267
- * memset(&options, 0, sizeof(cares.ares_options))
- * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
- * options.sock_state_cb = <void*>gevent_sock_state_callback # <<<<<<<<<<<<<<
- * options.sock_state_cb_data = <void*>self
- * if flags is not None:
- */
- __pyx_v_options.sock_state_cb = ((void *)__pyx_f_6gevent_8resolver_5cares_gevent_sock_state_callback);
-
- /* "gevent/resolver/cares.pyx":268
- * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
- * options.sock_state_cb = <void*>gevent_sock_state_callback
- * options.sock_state_cb_data = <void*>self # <<<<<<<<<<<<<<
- * if flags is not None:
- * options.flags = int(flags)
- */
- __pyx_v_options.sock_state_cb_data = ((void *)__pyx_v_self);
-
- /* "gevent/resolver/cares.pyx":269
- * options.sock_state_cb = <void*>gevent_sock_state_callback
- * options.sock_state_cb_data = <void*>self
- * if flags is not None: # <<<<<<<<<<<<<<
- * options.flags = int(flags)
- * optmask |= cares.ARES_OPT_FLAGS
- */
- __pyx_t_1 = (__pyx_v_flags != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "gevent/resolver/cares.pyx":270
- * options.sock_state_cb_data = <void*>self
- * if flags is not None:
- * options.flags = int(flags) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_FLAGS
- * if timeout is not None:
- */
- __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_options.flags = __pyx_t_4;
-
- /* "gevent/resolver/cares.pyx":271
- * if flags is not None:
- * options.flags = int(flags)
- * optmask |= cares.ARES_OPT_FLAGS # <<<<<<<<<<<<<<
- * if timeout is not None:
- * options.timeout = int(float(timeout) * 1000)
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_FLAGS);
-
- /* "gevent/resolver/cares.pyx":269
- * options.sock_state_cb = <void*>gevent_sock_state_callback
- * options.sock_state_cb_data = <void*>self
- * if flags is not None: # <<<<<<<<<<<<<<
- * options.flags = int(flags)
- * optmask |= cares.ARES_OPT_FLAGS
- */
- }
-
- /* "gevent/resolver/cares.pyx":272
- * options.flags = int(flags)
- * optmask |= cares.ARES_OPT_FLAGS
- * if timeout is not None: # <<<<<<<<<<<<<<
- * options.timeout = int(float(timeout) * 1000)
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- */
- __pyx_t_2 = (__pyx_v_timeout != Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":273
- * optmask |= cares.ARES_OPT_FLAGS
- * if timeout is not None:
- * options.timeout = int(float(timeout) * 1000) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- * if tries is not None:
- */
- __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_timeout); if (unlikely(__pyx_t_5 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error)
- __pyx_v_options.timeout = ((int)(__pyx_t_5 * 1000.0));
-
- /* "gevent/resolver/cares.pyx":274
- * if timeout is not None:
- * options.timeout = int(float(timeout) * 1000)
- * optmask |= cares.ARES_OPT_TIMEOUTMS # <<<<<<<<<<<<<<
- * if tries is not None:
- * options.tries = int(tries)
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TIMEOUTMS);
-
- /* "gevent/resolver/cares.pyx":272
- * options.flags = int(flags)
- * optmask |= cares.ARES_OPT_FLAGS
- * if timeout is not None: # <<<<<<<<<<<<<<
- * options.timeout = int(float(timeout) * 1000)
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- */
- }
-
- /* "gevent/resolver/cares.pyx":275
- * options.timeout = int(float(timeout) * 1000)
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- * if tries is not None: # <<<<<<<<<<<<<<
- * options.tries = int(tries)
- * optmask |= cares.ARES_OPT_TRIES
- */
- __pyx_t_1 = (__pyx_v_tries != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "gevent/resolver/cares.pyx":276
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- * if tries is not None:
- * options.tries = int(tries) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_TRIES
- * if ndots is not None:
- */
- __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tries); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_options.tries = __pyx_t_4;
-
- /* "gevent/resolver/cares.pyx":277
- * if tries is not None:
- * options.tries = int(tries)
- * optmask |= cares.ARES_OPT_TRIES # <<<<<<<<<<<<<<
- * if ndots is not None:
- * options.ndots = int(ndots)
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TRIES);
-
- /* "gevent/resolver/cares.pyx":275
- * options.timeout = int(float(timeout) * 1000)
- * optmask |= cares.ARES_OPT_TIMEOUTMS
- * if tries is not None: # <<<<<<<<<<<<<<
- * options.tries = int(tries)
- * optmask |= cares.ARES_OPT_TRIES
- */
- }
-
- /* "gevent/resolver/cares.pyx":278
- * options.tries = int(tries)
- * optmask |= cares.ARES_OPT_TRIES
- * if ndots is not None: # <<<<<<<<<<<<<<
- * options.ndots = int(ndots)
- * optmask |= cares.ARES_OPT_NDOTS
- */
- __pyx_t_2 = (__pyx_v_ndots != Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":279
- * optmask |= cares.ARES_OPT_TRIES
- * if ndots is not None:
- * options.ndots = int(ndots) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_NDOTS
- * if udp_port is not None:
- */
- __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_ndots); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_options.ndots = __pyx_t_4;
-
- /* "gevent/resolver/cares.pyx":280
- * if ndots is not None:
- * options.ndots = int(ndots)
- * optmask |= cares.ARES_OPT_NDOTS # <<<<<<<<<<<<<<
- * if udp_port is not None:
- * options.udp_port = int(udp_port)
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_NDOTS);
-
- /* "gevent/resolver/cares.pyx":278
- * options.tries = int(tries)
- * optmask |= cares.ARES_OPT_TRIES
- * if ndots is not None: # <<<<<<<<<<<<<<
- * options.ndots = int(ndots)
- * optmask |= cares.ARES_OPT_NDOTS
- */
- }
-
- /* "gevent/resolver/cares.pyx":281
- * options.ndots = int(ndots)
- * optmask |= cares.ARES_OPT_NDOTS
- * if udp_port is not None: # <<<<<<<<<<<<<<
- * options.udp_port = int(udp_port)
- * optmask |= cares.ARES_OPT_UDP_PORT
- */
- __pyx_t_1 = (__pyx_v_udp_port != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "gevent/resolver/cares.pyx":282
- * optmask |= cares.ARES_OPT_NDOTS
- * if udp_port is not None:
- * options.udp_port = int(udp_port) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_UDP_PORT
- * if tcp_port is not None:
- */
- __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_udp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 282, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_options.udp_port = __pyx_t_6;
-
- /* "gevent/resolver/cares.pyx":283
- * if udp_port is not None:
- * options.udp_port = int(udp_port)
- * optmask |= cares.ARES_OPT_UDP_PORT # <<<<<<<<<<<<<<
- * if tcp_port is not None:
- * options.tcp_port = int(tcp_port)
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_UDP_PORT);
-
- /* "gevent/resolver/cares.pyx":281
- * options.ndots = int(ndots)
- * optmask |= cares.ARES_OPT_NDOTS
- * if udp_port is not None: # <<<<<<<<<<<<<<
- * options.udp_port = int(udp_port)
- * optmask |= cares.ARES_OPT_UDP_PORT
- */
- }
-
- /* "gevent/resolver/cares.pyx":284
- * options.udp_port = int(udp_port)
- * optmask |= cares.ARES_OPT_UDP_PORT
- * if tcp_port is not None: # <<<<<<<<<<<<<<
- * options.tcp_port = int(tcp_port)
- * optmask |= cares.ARES_OPT_TCP_PORT
- */
- __pyx_t_2 = (__pyx_v_tcp_port != Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":285
- * optmask |= cares.ARES_OPT_UDP_PORT
- * if tcp_port is not None:
- * options.tcp_port = int(tcp_port) # <<<<<<<<<<<<<<
- * optmask |= cares.ARES_OPT_TCP_PORT
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- */
- __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tcp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_options.tcp_port = __pyx_t_6;
-
- /* "gevent/resolver/cares.pyx":286
- * if tcp_port is not None:
- * options.tcp_port = int(tcp_port)
- * optmask |= cares.ARES_OPT_TCP_PORT # <<<<<<<<<<<<<<
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- * if result:
- */
- __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TCP_PORT);
-
- /* "gevent/resolver/cares.pyx":284
- * options.udp_port = int(udp_port)
- * optmask |= cares.ARES_OPT_UDP_PORT
- * if tcp_port is not None: # <<<<<<<<<<<<<<
- * options.tcp_port = int(tcp_port)
- * optmask |= cares.ARES_OPT_TCP_PORT
- */
- }
-
- /* "gevent/resolver/cares.pyx":287
- * options.tcp_port = int(tcp_port)
- * optmask |= cares.ARES_OPT_TCP_PORT
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? # <<<<<<<<<<<<<<
- * if result:
- * raise gaierror(result, strerror(result))
- */
- __pyx_v_result = ares_library_init(ARES_LIB_INIT_ALL);
-
- /* "gevent/resolver/cares.pyx":288
- * optmask |= cares.ARES_OPT_TCP_PORT
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- * if result: # <<<<<<<<<<<<<<
- * raise gaierror(result, strerror(result))
- * result = cares.ares_init_options(&channel, &options, optmask)
- */
- __pyx_t_1 = (__pyx_v_result != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "gevent/resolver/cares.pyx":289
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- * if result:
- * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<<
- * result = cares.ares_init_options(&channel, &options, optmask)
- * if result:
- */
- __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_10 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_9)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_9);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- } else
- #endif
- {
- __pyx_t_11 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- if (__pyx_t_9) {
- __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_10);
- PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_10);
- __pyx_t_8 = 0;
- __pyx_t_10 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 289, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":288
- * optmask |= cares.ARES_OPT_TCP_PORT
- * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- * if result: # <<<<<<<<<<<<<<
- * raise gaierror(result, strerror(result))
- * result = cares.ares_init_options(&channel, &options, optmask)
- */
- }
-
- /* "gevent/resolver/cares.pyx":290
- * if result:
- * raise gaierror(result, strerror(result))
- * result = cares.ares_init_options(&channel, &options, optmask) # <<<<<<<<<<<<<<
- * if result:
- * raise gaierror(result, strerror(result))
- */
- __pyx_v_result = ares_init_options((&__pyx_v_channel), (&__pyx_v_options), __pyx_v_optmask);
-
- /* "gevent/resolver/cares.pyx":291
- * raise gaierror(result, strerror(result))
- * result = cares.ares_init_options(&channel, &options, optmask)
- * if result: # <<<<<<<<<<<<<<
- * raise gaierror(result, strerror(result))
- * self._timer = loop.timer(TIMEOUT, TIMEOUT)
- */
- __pyx_t_1 = (__pyx_v_result != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "gevent/resolver/cares.pyx":292
- * result = cares.ares_init_options(&channel, &options, optmask)
- * if result:
- * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<<
- * self._timer = loop.timer(TIMEOUT, TIMEOUT)
- * self._watchers = {}
- */
- __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_8 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__pyx_t_10) {
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_11);
- PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_4, __pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_4, __pyx_t_8);
- __pyx_t_11 = 0;
- __pyx_t_8 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 292, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":291
- * raise gaierror(result, strerror(result))
- * result = cares.ares_init_options(&channel, &options, optmask)
- * if result: # <<<<<<<<<<<<<<
- * raise gaierror(result, strerror(result))
- * self._timer = loop.timer(TIMEOUT, TIMEOUT)
- */
- }
-
- /* "gevent/resolver/cares.pyx":293
- * if result:
- * raise gaierror(result, strerror(result))
- * self._timer = loop.timer(TIMEOUT, TIMEOUT) # <<<<<<<<<<<<<<
- * self._watchers = {}
- * self.channel = channel
- */
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_timer); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_11 = NULL;
- __pyx_t_4 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_4 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- if (__pyx_t_11) {
- __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_9);
- PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, __pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, __pyx_t_8);
- __pyx_t_9 = 0;
- __pyx_t_8 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":294
- * raise gaierror(result, strerror(result))
- * self._timer = loop.timer(TIMEOUT, TIMEOUT)
- * self._watchers = {} # <<<<<<<<<<<<<<
- * self.channel = channel
- * try:
- */
- __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_watchers);
- __Pyx_DECREF(__pyx_v_self->_watchers);
- __pyx_v_self->_watchers = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":295
- * self._timer = loop.timer(TIMEOUT, TIMEOUT)
- * self._watchers = {}
- * self.channel = channel # <<<<<<<<<<<<<<
- * try:
- * if servers is not None:
- */
- __pyx_v_self->channel = __pyx_v_channel;
-
- /* "gevent/resolver/cares.pyx":296
- * self._watchers = {}
- * self.channel = channel
- * try: # <<<<<<<<<<<<<<
- * if servers is not None:
- * self.set_servers(servers)
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
- __Pyx_XGOTREF(__pyx_t_12);
- __Pyx_XGOTREF(__pyx_t_13);
- __Pyx_XGOTREF(__pyx_t_14);
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":297
- * self.channel = channel
- * try:
- * if servers is not None: # <<<<<<<<<<<<<<
- * self.set_servers(servers)
- * self.loop = loop
- */
- __pyx_t_1 = (__pyx_v_servers != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "gevent/resolver/cares.pyx":298
- * try:
- * if servers is not None:
- * self.set_servers(servers) # <<<<<<<<<<<<<<
- * self.loop = loop
- * except:
- */
- __pyx_t_15.__pyx_n = 1;
- __pyx_t_15.servers = __pyx_v_servers;
- __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel *)__pyx_v_self->__pyx_vtab)->set_servers(__pyx_v_self, 0, &__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L11_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":297
- * self.channel = channel
- * try:
- * if servers is not None: # <<<<<<<<<<<<<<
- * self.set_servers(servers)
- * self.loop = loop
- */
- }
-
- /* "gevent/resolver/cares.pyx":299
- * if servers is not None:
- * self.set_servers(servers)
- * self.loop = loop # <<<<<<<<<<<<<<
- * except:
- * self.destroy()
- */
- __Pyx_INCREF(__pyx_v_loop);
- __Pyx_GIVEREF(__pyx_v_loop);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = __pyx_v_loop;
-
- /* "gevent/resolver/cares.pyx":296
- * self._watchers = {}
- * self.channel = channel
- * try: # <<<<<<<<<<<<<<
- * if servers is not None:
- * self.set_servers(servers)
- */
- }
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
- __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
- goto __pyx_L16_try_end;
- __pyx_L11_error:;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":300
- * self.set_servers(servers)
- * self.loop = loop
- * except: # <<<<<<<<<<<<<<
- * self.destroy()
- * raise
- */
- /*except:*/ {
- __Pyx_AddTraceback("gevent.resolver.cares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_7, &__pyx_t_10) < 0) __PYX_ERR(0, 300, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_10);
-
- /* "gevent/resolver/cares.pyx":301
- * self.loop = loop
- * except:
- * self.destroy() # <<<<<<<<<<<<<<
- * raise
- *
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 301, __pyx_L13_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_11 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_11)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_11);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_11) {
- __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 301, __pyx_L13_except_error)
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- } else {
- __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 301, __pyx_L13_except_error)
- }
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "gevent/resolver/cares.pyx":302
- * except:
- * self.destroy()
- * raise # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_7, __pyx_t_10);
- __pyx_t_3 = 0; __pyx_t_7 = 0; __pyx_t_10 = 0;
- __PYX_ERR(0, 302, __pyx_L13_except_error)
- }
- __pyx_L13_except_error:;
-
- /* "gevent/resolver/cares.pyx":296
- * self._watchers = {}
- * self.channel = channel
- * try: # <<<<<<<<<<<<<<
- * if servers is not None:
- * self.set_servers(servers)
- */
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_XGIVEREF(__pyx_t_13);
- __Pyx_XGIVEREF(__pyx_t_14);
- __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
- goto __pyx_L1_error;
- __pyx_L16_try_end:;
- }
-
- /* "gevent/resolver/cares.pyx":261
- * cdef public object _timer
- *
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
- * udp_port=None, tcp_port=None, servers=None):
- * cdef ares_channeldata* channel = NULL
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":304
- * raise
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_3__repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_3__repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_2__repr__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_2__repr__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_v_args = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- Py_ssize_t __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "gevent/resolver/cares.pyx":305
- *
- * def __repr__(self):
- * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) # <<<<<<<<<<<<<<
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __pyx_v_self->_watchers;
- __Pyx_INCREF(__pyx_t_3);
- if (unlikely(__pyx_t_3 == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(0, 305, __pyx_L1_error)
- }
- __pyx_t_4 = PyDict_Size(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_self->_timer);
- __Pyx_GIVEREF(__pyx_v_self->_timer);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->_timer);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_v_args = ((PyObject*)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "gevent/resolver/cares.pyx":306
- * def __repr__(self):
- * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args # <<<<<<<<<<<<<<
- *
- * def destroy(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":304
- * raise
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_args);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":308
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
- *
- * def destroy(self): # <<<<<<<<<<<<<<
- * if self.channel:
- * # XXX ares_library_cleanup?
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_4destroy(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_4destroy(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- __Pyx_RefNannySetupContext("destroy", 0);
-
- /* "gevent/resolver/cares.pyx":309
- *
- * def destroy(self):
- * if self.channel: # <<<<<<<<<<<<<<
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- */
- __pyx_t_1 = (__pyx_v_self->channel != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":311
- * if self.channel:
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<<
- * self.channel = NULL
- * self._watchers.clear()
- */
- ares_destroy(__pyx_v_self->channel);
-
- /* "gevent/resolver/cares.pyx":312
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- * self.channel = NULL # <<<<<<<<<<<<<<
- * self._watchers.clear()
- * self._timer.stop()
- */
- __pyx_v_self->channel = NULL;
-
- /* "gevent/resolver/cares.pyx":313
- * cares.ares_destroy(self.channel)
- * self.channel = NULL
- * self._watchers.clear() # <<<<<<<<<<<<<<
- * self._timer.stop()
- * self.loop = None
- */
- if (unlikely(__pyx_v_self->_watchers == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
- __PYX_ERR(0, 313, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_PyDict_Clear(__pyx_v_self->_watchers); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 313, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":314
- * self.channel = NULL
- * self._watchers.clear()
- * self._timer.stop() # <<<<<<<<<<<<<<
- * self.loop = None
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":315
- * self._watchers.clear()
- * self._timer.stop()
- * self.loop = None # <<<<<<<<<<<<<<
- *
- * def __dealloc__(self):
- */
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = Py_None;
-
- /* "gevent/resolver/cares.pyx":309
- *
- * def destroy(self):
- * if self.channel: # <<<<<<<<<<<<<<
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- */
- }
-
- /* "gevent/resolver/cares.pyx":308
- * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
- *
- * def destroy(self): # <<<<<<<<<<<<<<
- * if self.channel:
- * # XXX ares_library_cleanup?
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":317
- * self.loop = None
- *
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * if self.channel:
- * # XXX ares_library_cleanup?
- */
-
-/* Python wrapper */
-static void __pyx_pw_6gevent_8resolver_5cares_7channel_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_6gevent_8resolver_5cares_7channel_7__dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_6gevent_8resolver_5cares_7channel_6__dealloc__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_pf_6gevent_8resolver_5cares_7channel_6__dealloc__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- /* "gevent/resolver/cares.pyx":318
- *
- * def __dealloc__(self):
- * if self.channel: # <<<<<<<<<<<<<<
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- */
- __pyx_t_1 = (__pyx_v_self->channel != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":320
- * if self.channel:
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<<
- * self.channel = NULL
- *
- */
- ares_destroy(__pyx_v_self->channel);
-
- /* "gevent/resolver/cares.pyx":321
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- * self.channel = NULL # <<<<<<<<<<<<<<
- *
- * cpdef set_servers(self, servers=None):
- */
- __pyx_v_self->channel = NULL;
-
- /* "gevent/resolver/cares.pyx":318
- *
- * def __dealloc__(self):
- * if self.channel: # <<<<<<<<<<<<<<
- * # XXX ares_library_cleanup?
- * cares.ares_destroy(self.channel)
- */
- }
-
- /* "gevent/resolver/cares.pyx":317
- * self.loop = None
- *
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * if self.channel:
- * # XXX ares_library_cleanup?
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "gevent/resolver/cares.pyx":323
- * self.channel = NULL
- *
- * cpdef set_servers(self, servers=None): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel_set_servers(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers *__pyx_optional_args) {
- PyObject *__pyx_v_servers = ((PyObject *)Py_None);
- int __pyx_v_length;
- CYTHON_UNUSED int __pyx_v_result;
- int __pyx_v_index;
- char *__pyx_v_string;
- struct ares_addr_node *__pyx_v_c_servers;
- PyObject *__pyx_v_server = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- Py_ssize_t __pyx_t_9;
- PyObject *(*__pyx_t_10)(PyObject *);
- char *__pyx_t_11;
- PyObject *__pyx_t_12 = NULL;
- int __pyx_t_13;
- char const *__pyx_t_14;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- __Pyx_RefNannySetupContext("set_servers", 0);
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_servers = __pyx_optional_args->servers;
- }
- }
- __Pyx_INCREF(__pyx_v_servers);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_servers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_9set_servers)) {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_4) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_servers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_servers};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_servers};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
- __Pyx_INCREF(__pyx_v_servers);
- __Pyx_GIVEREF(__pyx_v_servers);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_servers);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "gevent/resolver/cares.pyx":324
- *
- * cpdef set_servers(self, servers=None):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * if not servers:
- */
- __pyx_t_6 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "gevent/resolver/cares.pyx":325
- * cpdef set_servers(self, servers=None):
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
- * if not servers:
- * servers = []
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_t_3);
- __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_kp_s_this_ares_channel_has_been_destr);
- __pyx_t_3 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 325, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":324
- *
- * cpdef set_servers(self, servers=None):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * if not servers:
- */
- }
-
- /* "gevent/resolver/cares.pyx":326
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * if not servers: # <<<<<<<<<<<<<<
- * servers = []
- * if isinstance(servers, string_types):
- */
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_servers); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 326, __pyx_L1_error)
- __pyx_t_8 = ((!__pyx_t_6) != 0);
- if (__pyx_t_8) {
-
- /* "gevent/resolver/cares.pyx":327
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * if not servers:
- * servers = [] # <<<<<<<<<<<<<<
- * if isinstance(servers, string_types):
- * servers = servers.split(',')
- */
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":326
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * if not servers: # <<<<<<<<<<<<<<
- * servers = []
- * if isinstance(servers, string_types):
- */
- }
-
- /* "gevent/resolver/cares.pyx":328
- * if not servers:
- * servers = []
- * if isinstance(servers, string_types): # <<<<<<<<<<<<<<
- * servers = servers.split(',')
- * cdef int length = len(servers)
- */
- __pyx_t_1 = __pyx_v_6gevent_8resolver_5cares_string_types;
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_8 = PyObject_IsInstance(__pyx_v_servers, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 328, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = (__pyx_t_8 != 0);
- if (__pyx_t_6) {
-
- /* "gevent/resolver/cares.pyx":329
- * servers = []
- * if isinstance(servers, string_types):
- * servers = servers.split(',') # <<<<<<<<<<<<<<
- * cdef int length = len(servers)
- * cdef int result, index
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_servers, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":328
- * if not servers:
- * servers = []
- * if isinstance(servers, string_types): # <<<<<<<<<<<<<<
- * servers = servers.split(',')
- * cdef int length = len(servers)
- */
- }
-
- /* "gevent/resolver/cares.pyx":330
- * if isinstance(servers, string_types):
- * servers = servers.split(',')
- * cdef int length = len(servers) # <<<<<<<<<<<<<<
- * cdef int result, index
- * cdef char* string
- */
- __pyx_t_9 = PyObject_Length(__pyx_v_servers); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 330, __pyx_L1_error)
- __pyx_v_length = __pyx_t_9;
-
- /* "gevent/resolver/cares.pyx":334
- * cdef char* string
- * cdef cares.ares_addr_node* c_servers
- * if length <= 0: # <<<<<<<<<<<<<<
- * result = cares.ares_set_servers(self.channel, NULL)
- * else:
- */
- __pyx_t_6 = ((__pyx_v_length <= 0) != 0);
- if (__pyx_t_6) {
-
- /* "gevent/resolver/cares.pyx":335
- * cdef cares.ares_addr_node* c_servers
- * if length <= 0:
- * result = cares.ares_set_servers(self.channel, NULL) # <<<<<<<<<<<<<<
- * else:
- * c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length)
- */
- __pyx_v_result = ares_set_servers(__pyx_v_self->channel, NULL);
-
- /* "gevent/resolver/cares.pyx":334
- * cdef char* string
- * cdef cares.ares_addr_node* c_servers
- * if length <= 0: # <<<<<<<<<<<<<<
- * result = cares.ares_set_servers(self.channel, NULL)
- * else:
- */
- goto __pyx_L6;
- }
-
- /* "gevent/resolver/cares.pyx":337
- * result = cares.ares_set_servers(self.channel, NULL)
- * else:
- * c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length) # <<<<<<<<<<<<<<
- * if not c_servers:
- * raise MemoryError
- */
- /*else*/ {
- __pyx_v_c_servers = ((struct ares_addr_node *)PyMem_Malloc(((sizeof(struct ares_addr_node)) * __pyx_v_length)));
-
- /* "gevent/resolver/cares.pyx":338
- * else:
- * c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length)
- * if not c_servers: # <<<<<<<<<<<<<<
- * raise MemoryError
- * try:
- */
- __pyx_t_6 = ((!(__pyx_v_c_servers != 0)) != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "gevent/resolver/cares.pyx":339
- * c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length)
- * if not c_servers:
- * raise MemoryError # <<<<<<<<<<<<<<
- * try:
- * index = 0
- */
- PyErr_NoMemory(); __PYX_ERR(0, 339, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":338
- * else:
- * c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length)
- * if not c_servers: # <<<<<<<<<<<<<<
- * raise MemoryError
- * try:
- */
- }
-
- /* "gevent/resolver/cares.pyx":340
- * if not c_servers:
- * raise MemoryError
- * try: # <<<<<<<<<<<<<<
- * index = 0
- * for server in servers:
- */
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":341
- * raise MemoryError
- * try:
- * index = 0 # <<<<<<<<<<<<<<
- * for server in servers:
- * if isinstance(server, unicode):
- */
- __pyx_v_index = 0;
-
- /* "gevent/resolver/cares.pyx":342
- * try:
- * index = 0
- * for server in servers: # <<<<<<<<<<<<<<
- * if isinstance(server, unicode):
- * server = server.encode('ascii')
- */
- if (likely(PyList_CheckExact(__pyx_v_servers)) || PyTuple_CheckExact(__pyx_v_servers)) {
- __pyx_t_2 = __pyx_v_servers; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = 0;
- __pyx_t_10 = NULL;
- } else {
- __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_servers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 342, __pyx_L9_error)
- }
- for (;;) {
- if (likely(!__pyx_t_10)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 342, __pyx_L9_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- } else {
- if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 342, __pyx_L9_error)
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- #endif
- }
- } else {
- __pyx_t_1 = __pyx_t_10(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(0, 342, __pyx_L9_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- __Pyx_XDECREF_SET(__pyx_v_server, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":343
- * index = 0
- * for server in servers:
- * if isinstance(server, unicode): # <<<<<<<<<<<<<<
- * server = server.encode('ascii')
- * string = <char*?>server
- */
- __pyx_t_6 = PyUnicode_Check(__pyx_v_server);
- __pyx_t_8 = (__pyx_t_6 != 0);
- if (__pyx_t_8) {
-
- /* "gevent/resolver/cares.pyx":344
- * for server in servers:
- * if isinstance(server, unicode):
- * server = server.encode('ascii') # <<<<<<<<<<<<<<
- * string = <char*?>server
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_server, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 344, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_server, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "gevent/resolver/cares.pyx":343
- * index = 0
- * for server in servers:
- * if isinstance(server, unicode): # <<<<<<<<<<<<<<
- * server = server.encode('ascii')
- * string = <char*?>server
- */
- }
-
- /* "gevent/resolver/cares.pyx":345
- * if isinstance(server, unicode):
- * server = server.encode('ascii')
- * string = <char*?>server # <<<<<<<<<<<<<<
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET
- */
- __pyx_t_11 = __Pyx_PyObject_AsWritableString(__pyx_v_server); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L9_error)
- __pyx_v_string = ((char *)__pyx_t_11);
-
- /* "gevent/resolver/cares.pyx":346
- * server = server.encode('ascii')
- * string = <char*?>server
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
- * c_servers[index].family = AF_INET
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
- */
- __pyx_t_8 = ((ares_inet_pton(AF_INET, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0);
- if (__pyx_t_8) {
-
- /* "gevent/resolver/cares.pyx":347
- * string = <char*?>server
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET # <<<<<<<<<<<<<<
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET6
- */
- (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET;
-
- /* "gevent/resolver/cares.pyx":346
- * server = server.encode('ascii')
- * string = <char*?>server
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
- * c_servers[index].family = AF_INET
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
- */
- goto __pyx_L14;
- }
-
- /* "gevent/resolver/cares.pyx":348
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
- * c_servers[index].family = AF_INET6
- * else:
- */
- __pyx_t_8 = ((ares_inet_pton(AF_INET6, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0);
- if (likely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":349
- * c_servers[index].family = AF_INET
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET6 # <<<<<<<<<<<<<<
- * else:
- * raise InvalidIP(repr(string))
- */
- (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET6;
-
- /* "gevent/resolver/cares.pyx":348
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- * c_servers[index].family = AF_INET
- * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
- * c_servers[index].family = AF_INET6
- * else:
- */
- goto __pyx_L14;
- }
-
- /* "gevent/resolver/cares.pyx":351
- * c_servers[index].family = AF_INET6
- * else:
- * raise InvalidIP(repr(string)) # <<<<<<<<<<<<<<
- * c_servers[index].next = &c_servers[index] + 1
- * index += 1
- */
- /*else*/ {
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_string); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyObject_Repr(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- if (!__pyx_t_3) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else
- #endif
- {
- __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 351, __pyx_L9_error)
- }
- __pyx_L14:;
-
- /* "gevent/resolver/cares.pyx":352
- * else:
- * raise InvalidIP(repr(string))
- * c_servers[index].next = &c_servers[index] + 1 # <<<<<<<<<<<<<<
- * index += 1
- * if index >= length:
- */
- (__pyx_v_c_servers[__pyx_v_index]).next = ((&(__pyx_v_c_servers[__pyx_v_index])) + 1);
-
- /* "gevent/resolver/cares.pyx":353
- * raise InvalidIP(repr(string))
- * c_servers[index].next = &c_servers[index] + 1
- * index += 1 # <<<<<<<<<<<<<<
- * if index >= length:
- * break
- */
- __pyx_v_index = (__pyx_v_index + 1);
-
- /* "gevent/resolver/cares.pyx":354
- * c_servers[index].next = &c_servers[index] + 1
- * index += 1
- * if index >= length: # <<<<<<<<<<<<<<
- * break
- * c_servers[length - 1].next = NULL
- */
- __pyx_t_8 = ((__pyx_v_index >= __pyx_v_length) != 0);
- if (__pyx_t_8) {
-
- /* "gevent/resolver/cares.pyx":355
- * index += 1
- * if index >= length:
- * break # <<<<<<<<<<<<<<
- * c_servers[length - 1].next = NULL
- * index = cares.ares_set_servers(self.channel, c_servers)
- */
- goto __pyx_L12_break;
-
- /* "gevent/resolver/cares.pyx":354
- * c_servers[index].next = &c_servers[index] + 1
- * index += 1
- * if index >= length: # <<<<<<<<<<<<<<
- * break
- * c_servers[length - 1].next = NULL
- */
- }
-
- /* "gevent/resolver/cares.pyx":342
- * try:
- * index = 0
- * for server in servers: # <<<<<<<<<<<<<<
- * if isinstance(server, unicode):
- * server = server.encode('ascii')
- */
- }
- __pyx_L12_break:;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":356
- * if index >= length:
- * break
- * c_servers[length - 1].next = NULL # <<<<<<<<<<<<<<
- * index = cares.ares_set_servers(self.channel, c_servers)
- * if index:
- */
- (__pyx_v_c_servers[(__pyx_v_length - 1)]).next = NULL;
-
- /* "gevent/resolver/cares.pyx":357
- * break
- * c_servers[length - 1].next = NULL
- * index = cares.ares_set_servers(self.channel, c_servers) # <<<<<<<<<<<<<<
- * if index:
- * raise ValueError(strerror(index))
- */
- __pyx_v_index = ares_set_servers(__pyx_v_self->channel, __pyx_v_c_servers);
-
- /* "gevent/resolver/cares.pyx":358
- * c_servers[length - 1].next = NULL
- * index = cares.ares_set_servers(self.channel, c_servers)
- * if index: # <<<<<<<<<<<<<<
- * raise ValueError(strerror(index))
- * finally:
- */
- __pyx_t_8 = (__pyx_v_index != 0);
- if (unlikely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":359
- * index = cares.ares_set_servers(self.channel, c_servers)
- * if index:
- * raise ValueError(strerror(index)) # <<<<<<<<<<<<<<
- * finally:
- * PyMem_Free(c_servers)
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __pyx_f_6gevent_8resolver_5cares_strerror(__pyx_t_2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 359, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L9_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 359, __pyx_L9_error)
-
- /* "gevent/resolver/cares.pyx":358
- * c_servers[length - 1].next = NULL
- * index = cares.ares_set_servers(self.channel, c_servers)
- * if index: # <<<<<<<<<<<<<<
- * raise ValueError(strerror(index))
- * finally:
- */
- }
- }
-
- /* "gevent/resolver/cares.pyx":361
- * raise ValueError(strerror(index))
- * finally:
- * PyMem_Free(c_servers) # <<<<<<<<<<<<<<
- *
- * # this crashes c-ares
- */
- /*finally:*/ {
- /*normal exit:*/{
- PyMem_Free(__pyx_v_c_servers);
- goto __pyx_L10;
- }
- __pyx_L9_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
- __Pyx_XGOTREF(__pyx_t_15);
- __Pyx_XGOTREF(__pyx_t_16);
- __Pyx_XGOTREF(__pyx_t_17);
- __Pyx_XGOTREF(__pyx_t_18);
- __Pyx_XGOTREF(__pyx_t_19);
- __Pyx_XGOTREF(__pyx_t_20);
- __pyx_t_7 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
- {
- PyMem_Free(__pyx_v_c_servers);
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_18);
- __Pyx_XGIVEREF(__pyx_t_19);
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
- }
- __Pyx_XGIVEREF(__pyx_t_15);
- __Pyx_XGIVEREF(__pyx_t_16);
- __Pyx_XGIVEREF(__pyx_t_17);
- __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
- __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
- __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
- goto __pyx_L1_error;
- }
- __pyx_L10:;
- }
- }
- __pyx_L6:;
-
- /* "gevent/resolver/cares.pyx":323
- * self.channel = NULL
- *
- * cpdef set_servers(self, servers=None): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_server);
- __Pyx_XDECREF(__pyx_v_servers);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_servers = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("set_servers (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_servers,0};
- PyObject* values[1] = {0};
- values[0] = ((PyObject *)Py_None);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_servers);
- if (value) { values[0] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_servers") < 0)) __PYX_ERR(0, 323, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_servers = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("set_servers", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 323, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_8set_servers(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_servers);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_8set_servers(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_servers) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers __pyx_t_2;
- __Pyx_RefNannySetupContext("set_servers", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2.__pyx_n = 1;
- __pyx_t_2.servers = __pyx_v_servers;
- __pyx_t_1 = __pyx_vtabptr_6gevent_8resolver_5cares_channel->set_servers(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":367
- * # cares.ares_cancel(self.channel)
- *
- * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<<
- * if not self.channel:
- * return
- */
-
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel__sock_state_callback(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write) {
- PyObject *__pyx_v_watcher = 0;
- int __pyx_v_events;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- __Pyx_RefNannySetupContext("_sock_state_callback", 0);
-
- /* "gevent/resolver/cares.pyx":368
- *
- * cdef _sock_state_callback(self, int socket, int read, int write):
- * if not self.channel: # <<<<<<<<<<<<<<
- * return
- * cdef object watcher = self._watchers.get(socket)
- */
- __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":369
- * cdef _sock_state_callback(self, int socket, int read, int write):
- * if not self.channel:
- * return # <<<<<<<<<<<<<<
- * cdef object watcher = self._watchers.get(socket)
- * cdef int events = 0
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":368
- *
- * cdef _sock_state_callback(self, int socket, int read, int write):
- * if not self.channel: # <<<<<<<<<<<<<<
- * return
- * cdef object watcher = self._watchers.get(socket)
- */
- }
-
- /* "gevent/resolver/cares.pyx":370
- * if not self.channel:
- * return
- * cdef object watcher = self._watchers.get(socket) # <<<<<<<<<<<<<<
- * cdef int events = 0
- * if read:
- */
- if (unlikely(__pyx_v_self->_watchers == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
- __PYX_ERR(0, 370, __pyx_L1_error)
- }
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->_watchers, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_watcher = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":371
- * return
- * cdef object watcher = self._watchers.get(socket)
- * cdef int events = 0 # <<<<<<<<<<<<<<
- * if read:
- * events |= EV_READ
- */
- __pyx_v_events = 0;
-
- /* "gevent/resolver/cares.pyx":372
- * cdef object watcher = self._watchers.get(socket)
- * cdef int events = 0
- * if read: # <<<<<<<<<<<<<<
- * events |= EV_READ
- * if write:
- */
- __pyx_t_1 = (__pyx_v_read != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":373
- * cdef int events = 0
- * if read:
- * events |= EV_READ # <<<<<<<<<<<<<<
- * if write:
- * events |= EV_WRITE
- */
- __pyx_v_events = (__pyx_v_events | 1);
-
- /* "gevent/resolver/cares.pyx":372
- * cdef object watcher = self._watchers.get(socket)
- * cdef int events = 0
- * if read: # <<<<<<<<<<<<<<
- * events |= EV_READ
- * if write:
- */
- }
-
- /* "gevent/resolver/cares.pyx":374
- * if read:
- * events |= EV_READ
- * if write: # <<<<<<<<<<<<<<
- * events |= EV_WRITE
- * if watcher is None:
- */
- __pyx_t_1 = (__pyx_v_write != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":375
- * events |= EV_READ
- * if write:
- * events |= EV_WRITE # <<<<<<<<<<<<<<
- * if watcher is None:
- * if not events:
- */
- __pyx_v_events = (__pyx_v_events | 2);
-
- /* "gevent/resolver/cares.pyx":374
- * if read:
- * events |= EV_READ
- * if write: # <<<<<<<<<<<<<<
- * events |= EV_WRITE
- * if watcher is None:
- */
- }
-
- /* "gevent/resolver/cares.pyx":376
- * if write:
- * events |= EV_WRITE
- * if watcher is None: # <<<<<<<<<<<<<<
- * if not events:
- * return
- */
- __pyx_t_1 = (__pyx_v_watcher == Py_None);
- __pyx_t_4 = (__pyx_t_1 != 0);
- if (__pyx_t_4) {
-
- /* "gevent/resolver/cares.pyx":377
- * events |= EV_WRITE
- * if watcher is None:
- * if not events: # <<<<<<<<<<<<<<
- * return
- * watcher = self.loop.io(socket, events)
- */
- __pyx_t_4 = ((!(__pyx_v_events != 0)) != 0);
- if (__pyx_t_4) {
-
- /* "gevent/resolver/cares.pyx":378
- * if watcher is None:
- * if not events:
- * return # <<<<<<<<<<<<<<
- * watcher = self.loop.io(socket, events)
- * self._watchers[socket] = watcher
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":377
- * events |= EV_WRITE
- * if watcher is None:
- * if not events: # <<<<<<<<<<<<<<
- * return
- * watcher = self.loop.io(socket, events)
- */
- }
-
- /* "gevent/resolver/cares.pyx":379
- * if not events:
- * return
- * watcher = self.loop.io(socket, events) # <<<<<<<<<<<<<<
- * self._watchers[socket] = watcher
- * elif events:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__pyx_t_7) {
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_watcher, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":380
- * return
- * watcher = self.loop.io(socket, events)
- * self._watchers[socket] = watcher # <<<<<<<<<<<<<<
- * elif events:
- * if watcher.events == events:
- */
- if (unlikely(__pyx_v_self->_watchers == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(0, 380, __pyx_L1_error)
- }
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (unlikely(PyDict_SetItem(__pyx_v_self->_watchers, __pyx_t_3, __pyx_v_watcher) < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "gevent/resolver/cares.pyx":376
- * if write:
- * events |= EV_WRITE
- * if watcher is None: # <<<<<<<<<<<<<<
- * if not events:
- * return
- */
- goto __pyx_L6;
- }
-
- /* "gevent/resolver/cares.pyx":381
- * watcher = self.loop.io(socket, events)
- * self._watchers[socket] = watcher
- * elif events: # <<<<<<<<<<<<<<
- * if watcher.events == events:
- * return
- */
- __pyx_t_4 = (__pyx_v_events != 0);
- if (__pyx_t_4) {
-
- /* "gevent/resolver/cares.pyx":382
- * self._watchers[socket] = watcher
- * elif events:
- * if watcher.events == events: # <<<<<<<<<<<<<<
- * return
- * watcher.stop()
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 382, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 382, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (__pyx_t_4) {
-
- /* "gevent/resolver/cares.pyx":383
- * elif events:
- * if watcher.events == events:
- * return # <<<<<<<<<<<<<<
- * watcher.stop()
- * watcher.events = events
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":382
- * self._watchers[socket] = watcher
- * elif events:
- * if watcher.events == events: # <<<<<<<<<<<<<<
- * return
- * watcher.stop()
- */
- }
-
- /* "gevent/resolver/cares.pyx":384
- * if watcher.events == events:
- * return
- * watcher.stop() # <<<<<<<<<<<<<<
- * watcher.events = events
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 384, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 384, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "gevent/resolver/cares.pyx":385
- * return
- * watcher.stop()
- * watcher.events = events # <<<<<<<<<<<<<<
- * else:
- * watcher.stop()
- */
- __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_watcher, __pyx_n_s_events, __pyx_t_9) < 0) __PYX_ERR(0, 385, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "gevent/resolver/cares.pyx":381
- * watcher = self.loop.io(socket, events)
- * self._watchers[socket] = watcher
- * elif events: # <<<<<<<<<<<<<<
- * if watcher.events == events:
- * return
- */
- goto __pyx_L6;
- }
-
- /* "gevent/resolver/cares.pyx":387
- * watcher.events = events
- * else:
- * watcher.stop() # <<<<<<<<<<<<<<
- * watcher.close()
- * self._watchers.pop(socket, None)
- */
- /*else*/ {
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "gevent/resolver/cares.pyx":388
- * else:
- * watcher.stop()
- * watcher.close() # <<<<<<<<<<<<<<
- * self._watchers.pop(socket, None)
- * if not self._watchers:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 388, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 388, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "gevent/resolver/cares.pyx":389
- * watcher.stop()
- * watcher.close()
- * self._watchers.pop(socket, None) # <<<<<<<<<<<<<<
- * if not self._watchers:
- * self._timer.stop()
- */
- if (unlikely(__pyx_v_self->_watchers == Py_None)) {
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
- __PYX_ERR(0, 389, __pyx_L1_error)
- }
- __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 389, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_self->_watchers, __pyx_t_9, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":390
- * watcher.close()
- * self._watchers.pop(socket, None)
- * if not self._watchers: # <<<<<<<<<<<<<<
- * self._timer.stop()
- * return
- */
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_watchers); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 390, __pyx_L1_error)
- __pyx_t_1 = ((!__pyx_t_4) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":391
- * self._watchers.pop(socket, None)
- * if not self._watchers:
- * self._timer.stop() # <<<<<<<<<<<<<<
- * return
- * watcher.start(self._process_fd, watcher, pass_events=True)
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 391, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (__pyx_t_3) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error)
- }
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":390
- * watcher.close()
- * self._watchers.pop(socket, None)
- * if not self._watchers: # <<<<<<<<<<<<<<
- * self._timer.stop()
- * return
- */
- }
-
- /* "gevent/resolver/cares.pyx":392
- * if not self._watchers:
- * self._timer.stop()
- * return # <<<<<<<<<<<<<<
- * watcher.start(self._process_fd, watcher, pass_events=True)
- * self._timer.again(self._on_timer)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- }
- __pyx_L6:;
-
- /* "gevent/resolver/cares.pyx":393
- * self._timer.stop()
- * return
- * watcher.start(self._process_fd, watcher, pass_events=True) # <<<<<<<<<<<<<<
- * self._timer.again(self._on_timer)
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_process_fd); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_9);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
- __Pyx_INCREF(__pyx_v_watcher);
- __Pyx_GIVEREF(__pyx_v_watcher);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_watcher);
- __pyx_t_9 = 0;
- __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_pass_events, Py_True) < 0) __PYX_ERR(0, 393, __pyx_L1_error)
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "gevent/resolver/cares.pyx":394
- * return
- * watcher.start(self._process_fd, watcher, pass_events=True)
- * self._timer.again(self._on_timer) # <<<<<<<<<<<<<<
- *
- * def _on_timer(self):
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_again); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_9, function);
- }
- }
- if (!__pyx_t_2) {
- __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_3};
- __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
- PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_3};
- __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
- /* "gevent/resolver/cares.pyx":367
- * # cares.ares_cancel(self.channel)
- *
- * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<<
- * if not self.channel:
- * return
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("gevent.resolver.cares.channel._sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_watcher);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":396
- * self._timer.again(self._on_timer)
- *
- * def _on_timer(self): # <<<<<<<<<<<<<<
- * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_on_timer (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_10_on_timer(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_10_on_timer(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_on_timer", 0);
-
- /* "gevent/resolver/cares.pyx":397
- *
- * def _on_timer(self):
- * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) # <<<<<<<<<<<<<<
- *
- * def _process_fd(self, int events, object watcher):
- */
- ares_process_fd(__pyx_v_self->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD);
-
- /* "gevent/resolver/cares.pyx":396
- * self._timer.again(self._on_timer)
- *
- * def _on_timer(self): # <<<<<<<<<<<<<<
- * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":399
- * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
- *
- * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<<
- * if not self.channel:
- * return
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- int __pyx_v_events;
- PyObject *__pyx_v_watcher = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_process_fd (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_events,&__pyx_n_s_watcher,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_events)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, 1); __PYX_ERR(0, 399, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_process_fd") < 0)) __PYX_ERR(0, 399, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_events = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L3_error)
- __pyx_v_watcher = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_12_process_fd(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_events, __pyx_v_watcher);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_12_process_fd(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher) {
- int __pyx_v_read_fd;
- int __pyx_v_write_fd;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- __Pyx_RefNannySetupContext("_process_fd", 0);
-
- /* "gevent/resolver/cares.pyx":400
- *
- * def _process_fd(self, int events, object watcher):
- * if not self.channel: # <<<<<<<<<<<<<<
- * return
- * cdef int read_fd = watcher.fd
- */
- __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":401
- * def _process_fd(self, int events, object watcher):
- * if not self.channel:
- * return # <<<<<<<<<<<<<<
- * cdef int read_fd = watcher.fd
- * cdef int write_fd = read_fd
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":400
- *
- * def _process_fd(self, int events, object watcher):
- * if not self.channel: # <<<<<<<<<<<<<<
- * return
- * cdef int read_fd = watcher.fd
- */
- }
-
- /* "gevent/resolver/cares.pyx":402
- * if not self.channel:
- * return
- * cdef int read_fd = watcher.fd # <<<<<<<<<<<<<<
- * cdef int write_fd = read_fd
- * if not (events & EV_READ):
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_read_fd = __pyx_t_3;
-
- /* "gevent/resolver/cares.pyx":403
- * return
- * cdef int read_fd = watcher.fd
- * cdef int write_fd = read_fd # <<<<<<<<<<<<<<
- * if not (events & EV_READ):
- * read_fd = cares.ARES_SOCKET_BAD
- */
- __pyx_v_write_fd = __pyx_v_read_fd;
-
- /* "gevent/resolver/cares.pyx":404
- * cdef int read_fd = watcher.fd
- * cdef int write_fd = read_fd
- * if not (events & EV_READ): # <<<<<<<<<<<<<<
- * read_fd = cares.ARES_SOCKET_BAD
- * if not (events & EV_WRITE):
- */
- __pyx_t_1 = ((!((__pyx_v_events & 1) != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":405
- * cdef int write_fd = read_fd
- * if not (events & EV_READ):
- * read_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<<
- * if not (events & EV_WRITE):
- * write_fd = cares.ARES_SOCKET_BAD
- */
- __pyx_v_read_fd = ARES_SOCKET_BAD;
-
- /* "gevent/resolver/cares.pyx":404
- * cdef int read_fd = watcher.fd
- * cdef int write_fd = read_fd
- * if not (events & EV_READ): # <<<<<<<<<<<<<<
- * read_fd = cares.ARES_SOCKET_BAD
- * if not (events & EV_WRITE):
- */
- }
-
- /* "gevent/resolver/cares.pyx":406
- * if not (events & EV_READ):
- * read_fd = cares.ARES_SOCKET_BAD
- * if not (events & EV_WRITE): # <<<<<<<<<<<<<<
- * write_fd = cares.ARES_SOCKET_BAD
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- */
- __pyx_t_1 = ((!((__pyx_v_events & 2) != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":407
- * read_fd = cares.ARES_SOCKET_BAD
- * if not (events & EV_WRITE):
- * write_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<<
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- *
- */
- __pyx_v_write_fd = ARES_SOCKET_BAD;
-
- /* "gevent/resolver/cares.pyx":406
- * if not (events & EV_READ):
- * read_fd = cares.ARES_SOCKET_BAD
- * if not (events & EV_WRITE): # <<<<<<<<<<<<<<
- * write_fd = cares.ARES_SOCKET_BAD
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- */
- }
-
- /* "gevent/resolver/cares.pyx":408
- * if not (events & EV_WRITE):
- * write_fd = cares.ARES_SOCKET_BAD
- * cares.ares_process_fd(self.channel, read_fd, write_fd) # <<<<<<<<<<<<<<
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET):
- */
- ares_process_fd(__pyx_v_self->channel, __pyx_v_read_fd, __pyx_v_write_fd);
-
- /* "gevent/resolver/cares.pyx":399
- * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
- *
- * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<<
- * if not self.channel:
- * return
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("gevent.resolver.cares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":410
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- char *__pyx_v_name;
- int __pyx_v_family;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("gethostbyname (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_name_2,&__pyx_n_s_family,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name_2)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, 1); __PYX_ERR(0, 410, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_family);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyname") < 0)) __PYX_ERR(0, 410, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_callback = values[0];
- __pyx_v_name = __Pyx_PyObject_AsWritableString(values[1]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) __PYX_ERR(0, 410, __pyx_L3_error)
- if (values[2]) {
- __pyx_v_family = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_family == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 410, __pyx_L3_error)
- } else {
- __pyx_v_family = __pyx_k__5;
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 410, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_14gethostbyname(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_callback, __pyx_v_name, __pyx_v_family);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_14gethostbyname(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family) {
- PyObject *__pyx_v_arg = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("gethostbyname", 0);
-
- /* "gevent/resolver/cares.pyx":411
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * # note that for file lookups still AF_INET can be returned for AF_INET6 request
- */
- __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "gevent/resolver/cares.pyx":412
- * def gethostbyname(self, object callback, char* name, int family=AF_INET):
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
- * # note that for file lookups still AF_INET can be returned for AF_INET6 request
- * cdef object arg = (self, callback)
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
- __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
- __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 412, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":411
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * # note that for file lookups still AF_INET can be returned for AF_INET6 request
- */
- }
-
- /* "gevent/resolver/cares.pyx":414
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * # note that for file lookups still AF_INET can be returned for AF_INET6 request
- * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
- * Py_INCREF(arg)
- * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
- */
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback);
- __pyx_v_arg = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":415
- * # note that for file lookups still AF_INET can be returned for AF_INET6 request
- * cdef object arg = (self, callback)
- * Py_INCREF(arg) # <<<<<<<<<<<<<<
- * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- */
- Py_INCREF(__pyx_v_arg);
-
- /* "gevent/resolver/cares.pyx":416
- * cdef object arg = (self, callback)
- * Py_INCREF(arg)
- * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<<
- *
- * def gethostbyaddr(self, object callback, char* addr):
- */
- ares_gethostbyname(__pyx_v_self->channel, __pyx_v_name, __pyx_v_family, ((void *)__pyx_f_6gevent_8resolver_5cares_gevent_ares_host_callback), ((void *)__pyx_v_arg));
-
- /* "gevent/resolver/cares.pyx":410
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_arg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":418
- * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- char *__pyx_v_addr;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("gethostbyaddr (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_addr,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, 1); __PYX_ERR(0, 418, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyaddr") < 0)) __PYX_ERR(0, 418, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_callback = values[0];
- __pyx_v_addr = __Pyx_PyObject_AsWritableString(values[1]); if (unlikely((!__pyx_v_addr) && PyErr_Occurred())) __PYX_ERR(0, 418, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 418, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_16gethostbyaddr(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_callback, __pyx_v_addr);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_16gethostbyaddr(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr) {
- char __pyx_v_addr_packed[16];
- int __pyx_v_family;
- int __pyx_v_length;
- PyObject *__pyx_v_arg = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- __Pyx_RefNannySetupContext("gethostbyaddr", 0);
-
- /* "gevent/resolver/cares.pyx":419
- *
- * def gethostbyaddr(self, object callback, char* addr):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * # will guess the family
- */
- __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "gevent/resolver/cares.pyx":420
- * def gethostbyaddr(self, object callback, char* addr):
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
- * # will guess the family
- * cdef char addr_packed[16]
- */
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
- __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
- __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 420, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":419
- *
- * def gethostbyaddr(self, object callback, char* addr):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * # will guess the family
- */
- }
-
- /* "gevent/resolver/cares.pyx":425
- * cdef int family
- * cdef int length
- * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
- * family = AF_INET
- * length = 4
- */
- __pyx_t_1 = ((ares_inet_pton(AF_INET, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0);
- if (__pyx_t_1) {
-
- /* "gevent/resolver/cares.pyx":426
- * cdef int length
- * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0:
- * family = AF_INET # <<<<<<<<<<<<<<
- * length = 4
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
- */
- __pyx_v_family = AF_INET;
-
- /* "gevent/resolver/cares.pyx":427
- * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0:
- * family = AF_INET
- * length = 4 # <<<<<<<<<<<<<<
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
- * family = AF_INET6
- */
- __pyx_v_length = 4;
-
- /* "gevent/resolver/cares.pyx":425
- * cdef int family
- * cdef int length
- * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
- * family = AF_INET
- * length = 4
- */
- goto __pyx_L4;
- }
-
- /* "gevent/resolver/cares.pyx":428
- * family = AF_INET
- * length = 4
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
- * family = AF_INET6
- * length = 16
- */
- __pyx_t_1 = ((ares_inet_pton(AF_INET6, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0);
- if (likely(__pyx_t_1)) {
-
- /* "gevent/resolver/cares.pyx":429
- * length = 4
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
- * family = AF_INET6 # <<<<<<<<<<<<<<
- * length = 16
- * else:
- */
- __pyx_v_family = AF_INET6;
-
- /* "gevent/resolver/cares.pyx":430
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
- * family = AF_INET6
- * length = 16 # <<<<<<<<<<<<<<
- * else:
- * raise InvalidIP(repr(addr))
- */
- __pyx_v_length = 16;
-
- /* "gevent/resolver/cares.pyx":428
- * family = AF_INET
- * length = 4
- * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
- * family = AF_INET6
- * length = 16
- */
- goto __pyx_L4;
- }
-
- /* "gevent/resolver/cares.pyx":432
- * length = 16
- * else:
- * raise InvalidIP(repr(addr)) # <<<<<<<<<<<<<<
- * cdef object arg = (self, callback)
- * Py_INCREF(arg)
- */
- /*else*/ {
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_addr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 432, __pyx_L1_error)
- }
- __pyx_L4:;
-
- /* "gevent/resolver/cares.pyx":433
- * else:
- * raise InvalidIP(repr(addr))
- * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
- * Py_INCREF(arg)
- * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
- */
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback);
- __pyx_v_arg = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":434
- * raise InvalidIP(repr(addr))
- * cdef object arg = (self, callback)
- * Py_INCREF(arg) # <<<<<<<<<<<<<<
- * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- */
- Py_INCREF(__pyx_v_arg);
-
- /* "gevent/resolver/cares.pyx":435
- * cdef object arg = (self, callback)
- * Py_INCREF(arg)
- * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<<
- *
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
- */
- ares_gethostbyaddr(__pyx_v_self->channel, __pyx_v_addr_packed, __pyx_v_length, __pyx_v_family, ((void *)__pyx_f_6gevent_8resolver_5cares_gevent_ares_host_callback), ((void *)__pyx_v_arg));
-
- /* "gevent/resolver/cares.pyx":418
- * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_arg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":437
- * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6gevent_8resolver_5cares_7channel__getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch) {
- char *__pyx_v_hostp;
- int __pyx_v_port;
- int __pyx_v_flowinfo;
- int __pyx_v_scope_id;
- struct sockaddr_in6 __pyx_v_sa6;
- int __pyx_v_length;
- PyObject *__pyx_v_arg = 0;
- struct sockaddr *__pyx_v_x;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- int __pyx_t_9;
- __Pyx_RefNannySetupContext("_getnameinfo", 0);
- /* Check if called by wrapper */
- if (unlikely(__pyx_skip_dispatch)) ;
- /* Check if overridden in Python */
- else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getnameinfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_19_getnameinfo)) {
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_1);
- __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_callback);
- __Pyx_INCREF(__pyx_v_sockaddr);
- __Pyx_GIVEREF(__pyx_v_sockaddr);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_sockaddr);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
-
- /* "gevent/resolver/cares.pyx":438
- *
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * cdef char* hostp = NULL
- */
- __pyx_t_8 = ((!(__pyx_v_self->channel != 0)) != 0);
- if (unlikely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":439
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
- * cdef char* hostp = NULL
- * cdef int port = 0
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_7 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (__pyx_t_7) {
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4);
- __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
- PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
- __pyx_t_4 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 439, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":438
- *
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
- * if not self.channel: # <<<<<<<<<<<<<<
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * cdef char* hostp = NULL
- */
- }
-
- /* "gevent/resolver/cares.pyx":440
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * cdef char* hostp = NULL # <<<<<<<<<<<<<<
- * cdef int port = 0
- * cdef int flowinfo = 0
- */
- __pyx_v_hostp = NULL;
-
- /* "gevent/resolver/cares.pyx":441
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- * cdef char* hostp = NULL
- * cdef int port = 0 # <<<<<<<<<<<<<<
- * cdef int flowinfo = 0
- * cdef int scope_id = 0
- */
- __pyx_v_port = 0;
-
- /* "gevent/resolver/cares.pyx":442
- * cdef char* hostp = NULL
- * cdef int port = 0
- * cdef int flowinfo = 0 # <<<<<<<<<<<<<<
- * cdef int scope_id = 0
- * cdef sockaddr_in6 sa6
- */
- __pyx_v_flowinfo = 0;
-
- /* "gevent/resolver/cares.pyx":443
- * cdef int port = 0
- * cdef int flowinfo = 0
- * cdef int scope_id = 0 # <<<<<<<<<<<<<<
- * cdef sockaddr_in6 sa6
- * if not PyTuple_Check(sockaddr):
- */
- __pyx_v_scope_id = 0;
-
- /* "gevent/resolver/cares.pyx":445
- * cdef int scope_id = 0
- * cdef sockaddr_in6 sa6
- * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<<
- * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- */
- __pyx_t_8 = ((!(PyTuple_Check(__pyx_v_sockaddr) != 0)) != 0);
- if (unlikely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":446
- * cdef sockaddr_in6 sa6
- * if not PyTuple_Check(sockaddr):
- * raise TypeError('expected a tuple, got %r' % (sockaddr, )) # <<<<<<<<<<<<<<
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- * if port < 0 or port > 65535:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_sockaddr);
- __Pyx_GIVEREF(__pyx_v_sockaddr);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sockaddr);
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_expected_a_tuple_got_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 446, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":445
- * cdef int scope_id = 0
- * cdef sockaddr_in6 sa6
- * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<<
- * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- */
- }
-
- /* "gevent/resolver/cares.pyx":447
- * if not PyTuple_Check(sockaddr):
- * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) # <<<<<<<<<<<<<<
- * if port < 0 or port > 65535:
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- */
- __pyx_t_6 = PyArg_ParseTuple(__pyx_v_sockaddr, ((char *)"si|ii"), (&__pyx_v_hostp), (&__pyx_v_port), (&__pyx_v_flowinfo), (&__pyx_v_scope_id)); if (unlikely(__pyx_t_6 == ((int)0))) __PYX_ERR(0, 447, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":448
- * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- * if port < 0 or port > 65535: # <<<<<<<<<<<<<<
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- */
- __pyx_t_9 = ((__pyx_v_port < 0) != 0);
- if (!__pyx_t_9) {
- } else {
- __pyx_t_8 = __pyx_t_9;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_9 = ((__pyx_v_port > 0xFFFF) != 0);
- __pyx_t_8 = __pyx_t_9;
- __pyx_L6_bool_binop_done:;
- if (unlikely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":449
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- * if port < 0 or port > 65535:
- * raise gaierror(-8, 'Invalid value for port: %r' % port) # <<<<<<<<<<<<<<
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- * if length <= 0:
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_port_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_int_neg_8);
- __Pyx_GIVEREF(__pyx_int_neg_8);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_int_neg_8);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 449, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":448
- * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- * if port < 0 or port > 65535: # <<<<<<<<<<<<<<
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- */
- }
-
- /* "gevent/resolver/cares.pyx":450
- * if port < 0 or port > 65535:
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) # <<<<<<<<<<<<<<
- * if length <= 0:
- * raise InvalidIP(repr(hostp))
- */
- __pyx_v_length = gevent_make_sockaddr(__pyx_v_hostp, __pyx_v_port, __pyx_v_flowinfo, __pyx_v_scope_id, (&__pyx_v_sa6));
-
- /* "gevent/resolver/cares.pyx":451
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- * if length <= 0: # <<<<<<<<<<<<<<
- * raise InvalidIP(repr(hostp))
- * cdef object arg = (self, callback)
- */
- __pyx_t_8 = ((__pyx_v_length <= 0) != 0);
- if (unlikely(__pyx_t_8)) {
-
- /* "gevent/resolver/cares.pyx":452
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- * if length <= 0:
- * raise InvalidIP(repr(hostp)) # <<<<<<<<<<<<<<
- * cdef object arg = (self, callback)
- * Py_INCREF(arg)
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_hostp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- if (!__pyx_t_7) {
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 452, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":451
- * raise gaierror(-8, 'Invalid value for port: %r' % port)
- * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- * if length <= 0: # <<<<<<<<<<<<<<
- * raise InvalidIP(repr(hostp))
- * cdef object arg = (self, callback)
- */
- }
-
- /* "gevent/resolver/cares.pyx":453
- * if length <= 0:
- * raise InvalidIP(repr(hostp))
- * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
- * Py_INCREF(arg)
- * cdef sockaddr_t* x = <sockaddr_t*>&sa6
- */
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
- __Pyx_INCREF(__pyx_v_callback);
- __Pyx_GIVEREF(__pyx_v_callback);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_callback);
- __pyx_v_arg = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":454
- * raise InvalidIP(repr(hostp))
- * cdef object arg = (self, callback)
- * Py_INCREF(arg) # <<<<<<<<<<<<<<
- * cdef sockaddr_t* x = <sockaddr_t*>&sa6
- * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
- */
- Py_INCREF(__pyx_v_arg);
-
- /* "gevent/resolver/cares.pyx":455
- * cdef object arg = (self, callback)
- * Py_INCREF(arg)
- * cdef sockaddr_t* x = <sockaddr_t*>&sa6 # <<<<<<<<<<<<<<
- * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
- *
- */
- __pyx_v_x = ((struct sockaddr *)(&__pyx_v_sa6));
-
- /* "gevent/resolver/cares.pyx":456
- * Py_INCREF(arg)
- * cdef sockaddr_t* x = <sockaddr_t*>&sa6
- * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) # <<<<<<<<<<<<<<
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags):
- */
- ares_getnameinfo(__pyx_v_self->channel, __pyx_v_x, __pyx_v_length, __pyx_v_flags, ((void *)__pyx_f_6gevent_8resolver_5cares_gevent_ares_nameinfo_callback), ((void *)__pyx_v_arg));
-
- /* "gevent/resolver/cares.pyx":437
- * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
- *
- * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("gevent.resolver.cares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_arg);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_sockaddr = 0;
- int __pyx_v_flags;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("_getnameinfo (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 437, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 437, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getnameinfo") < 0)) __PYX_ERR(0, 437, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_callback = values[0];
- __pyx_v_sockaddr = ((PyObject*)values[1]);
- __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 437, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 437, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 437, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_18_getnameinfo(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_18_getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("_getnameinfo", 0);
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_f_6gevent_8resolver_5cares_7channel__getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.resolver.cares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":458
- * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
- * try:
- * flags = _convert_cares_flags(flags)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_callback = 0;
- PyObject *__pyx_v_sockaddr = 0;
- int __pyx_v_flags;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("getnameinfo (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 458, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 458, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getnameinfo") < 0)) __PYX_ERR(0, 458, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_callback = values[0];
- __pyx_v_sockaddr = ((PyObject*)values[1]);
- __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 458, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 458, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("gevent.resolver.cares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 458, __pyx_L1_error)
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_20getnameinfo(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags);
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_20getnameinfo(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- __Pyx_RefNannySetupContext("getnameinfo", 0);
-
- /* "gevent/resolver/cares.pyx":459
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags):
- * try: # <<<<<<<<<<<<<<
- * flags = _convert_cares_flags(flags)
- * except gaierror:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_1);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- /*try:*/ {
-
- /* "gevent/resolver/cares.pyx":460
- * def getnameinfo(self, object callback, tuple sockaddr, int flags):
- * try:
- * flags = _convert_cares_flags(flags) # <<<<<<<<<<<<<<
- * except gaierror:
- * # The stdlib just ignores bad flags
- */
- __pyx_t_4 = __pyx_f_6gevent_8resolver_5cares__convert_cares_flags(__pyx_v_flags, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 460, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 460, __pyx_L3_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_flags = __pyx_t_5;
-
- /* "gevent/resolver/cares.pyx":459
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags):
- * try: # <<<<<<<<<<<<<<
- * flags = _convert_cares_flags(flags)
- * except gaierror:
- */
- }
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L8_try_end;
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "gevent/resolver/cares.pyx":461
- * try:
- * flags = _convert_cares_flags(flags)
- * except gaierror: # <<<<<<<<<<<<<<
- * # The stdlib just ignores bad flags
- * flags = 0
- */
- __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7);
- __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 461, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_8);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_ErrRestore(__pyx_t_4, __pyx_t_6, __pyx_t_7);
- __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0;
- if (__pyx_t_5) {
- __Pyx_AddTraceback("gevent.resolver.cares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 461, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "gevent/resolver/cares.pyx":463
- * except gaierror:
- * # The stdlib just ignores bad flags
- * flags = 0 # <<<<<<<<<<<<<<
- * return self._getnameinfo(callback, sockaddr, flags)
- */
- __pyx_v_flags = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L4_exception_handled;
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "gevent/resolver/cares.pyx":459
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags):
- * try: # <<<<<<<<<<<<<<
- * flags = _convert_cares_flags(flags)
- * except gaierror:
- */
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- goto __pyx_L1_error;
- __pyx_L4_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_1);
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
- __pyx_L8_try_end:;
- }
-
- /* "gevent/resolver/cares.pyx":464
- * # The stdlib just ignores bad flags
- * flags = 0
- * return self._getnameinfo(callback, sockaddr, flags) # <<<<<<<<<<<<<<
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = ((struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel *)__pyx_v_self->__pyx_vtab)->_getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 464, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "gevent/resolver/cares.pyx":458
- * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
- *
- * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
- * try:
- * flags = _convert_cares_flags(flags)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("gevent.resolver.cares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":256
- * cdef class channel:
- *
- * cdef public object loop # <<<<<<<<<<<<<<
- * cdef ares_channeldata* channel
- * cdef public dict _watchers
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_4loop_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_4loop___get__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_4loop___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->loop);
- __pyx_r = __pyx_v_self->loop;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_2__set__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_4__del__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_4loop_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->loop);
- __Pyx_DECREF(__pyx_v_self->loop);
- __pyx_v_self->loop = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":258
- * cdef public object loop
- * cdef ares_channeldata* channel
- * cdef public dict _watchers # <<<<<<<<<<<<<<
- * cdef public object _timer
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers___get__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_watchers);
- __pyx_r = __pyx_v_self->_watchers;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_2__set__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- __Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 258, __pyx_L1_error)
- __pyx_t_1 = __pyx_v_value;
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v_self->_watchers);
- __Pyx_DECREF(__pyx_v_self->_watchers);
- __pyx_v_self->_watchers = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("gevent.resolver.cares.channel._watchers.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_4__del__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_9_watchers_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_watchers);
- __Pyx_DECREF(__pyx_v_self->_watchers);
- __pyx_v_self->_watchers = ((PyObject*)Py_None);
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "gevent/resolver/cares.pyx":259
- * cdef ares_channeldata* channel
- * cdef public dict _watchers
- * cdef public object _timer # <<<<<<<<<<<<<<
- *
- * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer___get__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_6gevent_8resolver_5cares_7channel_6_timer___get__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_timer);
- __pyx_r = __pyx_v_self->_timer;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_2__set__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_2__set__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__set__", 0);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = __pyx_v_value;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* Python wrapper */
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_5__del__(PyObject *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_4__del__(((struct __pyx_obj_6gevent_8resolver_5cares_channel *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_6gevent_8resolver_5cares_7channel_6_timer_4__del__(struct __pyx_obj_6gevent_8resolver_5cares_channel *__pyx_v_self) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->_timer);
- __Pyx_DECREF(__pyx_v_self->_timer);
- __pyx_v_self->_timer = Py_None;
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_tp_new_6gevent_8resolver_5cares_result(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_8resolver_5cares_result *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8resolver_5cares_result *)o);
- p->value = Py_None; Py_INCREF(Py_None);
- p->exception = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8resolver_5cares_result(PyObject *o) {
- struct __pyx_obj_6gevent_8resolver_5cares_result *p = (struct __pyx_obj_6gevent_8resolver_5cares_result *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->value);
- Py_CLEAR(p->exception);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8resolver_5cares_result(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8resolver_5cares_result *p = (struct __pyx_obj_6gevent_8resolver_5cares_result *)o;
- if (p->value) {
- e = (*v)(p->value, a); if (e) return e;
- }
- if (p->exception) {
- e = (*v)(p->exception, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8resolver_5cares_result(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8resolver_5cares_result *p = (struct __pyx_obj_6gevent_8resolver_5cares_result *)o;
- tmp = ((PyObject*)p->value);
- p->value = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->exception);
- p->exception = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_8resolver_5cares_6result_value(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8resolver_5cares_6result_5value_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_8resolver_5cares_6result_value(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_8resolver_5cares_6result_5value_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_8resolver_5cares_6result_5value_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_8resolver_5cares_6result_exception(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8resolver_5cares_6result_9exception_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_8resolver_5cares_6result_exception(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_8resolver_5cares_6result_9exception_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_8resolver_5cares_6result_9exception_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_8resolver_5cares_result[] = {
- {"successful", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_6result_5successful, METH_NOARGS, 0},
- {"get", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_6result_7get, METH_NOARGS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8resolver_5cares_result[] = {
- {(char *)"value", __pyx_getprop_6gevent_8resolver_5cares_6result_value, __pyx_setprop_6gevent_8resolver_5cares_6result_value, (char *)0, 0},
- {(char *)"exception", __pyx_getprop_6gevent_8resolver_5cares_6result_exception, __pyx_setprop_6gevent_8resolver_5cares_6result_exception, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8resolver_5cares_result = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.resolver.cares.result", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8resolver_5cares_result), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8resolver_5cares_result, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_8resolver_5cares_6result_3__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_8resolver_5cares_result, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8resolver_5cares_result, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8resolver_5cares_result, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8resolver_5cares_result, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8resolver_5cares_6result_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8resolver_5cares_result, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-static struct __pyx_vtabstruct_6gevent_8resolver_5cares_channel __pyx_vtable_6gevent_8resolver_5cares_channel;
-
-static PyObject *__pyx_tp_new_6gevent_8resolver_5cares_channel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_obj_6gevent_8resolver_5cares_channel *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_obj_6gevent_8resolver_5cares_channel *)o);
- p->__pyx_vtab = __pyx_vtabptr_6gevent_8resolver_5cares_channel;
- p->loop = Py_None; Py_INCREF(Py_None);
- p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_timer = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_6gevent_8resolver_5cares_channel(PyObject *o) {
- struct __pyx_obj_6gevent_8resolver_5cares_channel *p = (struct __pyx_obj_6gevent_8resolver_5cares_channel *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- ++Py_REFCNT(o);
- __pyx_pw_6gevent_8resolver_5cares_7channel_7__dealloc__(o);
- --Py_REFCNT(o);
- PyErr_Restore(etype, eval, etb);
- }
- Py_CLEAR(p->loop);
- Py_CLEAR(p->_watchers);
- Py_CLEAR(p->_timer);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_6gevent_8resolver_5cares_channel(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_obj_6gevent_8resolver_5cares_channel *p = (struct __pyx_obj_6gevent_8resolver_5cares_channel *)o;
- if (p->loop) {
- e = (*v)(p->loop, a); if (e) return e;
- }
- if (p->_watchers) {
- e = (*v)(p->_watchers, a); if (e) return e;
- }
- if (p->_timer) {
- e = (*v)(p->_timer, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_6gevent_8resolver_5cares_channel(PyObject *o) {
- PyObject* tmp;
- struct __pyx_obj_6gevent_8resolver_5cares_channel *p = (struct __pyx_obj_6gevent_8resolver_5cares_channel *)o;
- tmp = ((PyObject*)p->loop);
- p->loop = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_watchers);
- p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_timer);
- p->_timer = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyObject *__pyx_getprop_6gevent_8resolver_5cares_7channel_loop(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_8resolver_5cares_7channel_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_4loop_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_8resolver_5cares_7channel__watchers(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_8resolver_5cares_7channel__watchers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_9_watchers_5__del__(o);
- }
-}
-
-static PyObject *__pyx_getprop_6gevent_8resolver_5cares_7channel__timer(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_1__get__(o);
-}
-
-static int __pyx_setprop_6gevent_8resolver_5cares_7channel__timer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
- if (v) {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_3__set__(o, v);
- }
- else {
- return __pyx_pw_6gevent_8resolver_5cares_7channel_6_timer_5__del__(o);
- }
-}
-
-static PyMethodDef __pyx_methods_6gevent_8resolver_5cares_channel[] = {
- {"destroy", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_5destroy, METH_NOARGS, 0},
- {"set_servers", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_9set_servers, METH_VARARGS|METH_KEYWORDS, 0},
- {"_on_timer", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_11_on_timer, METH_NOARGS, 0},
- {"_process_fd", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_13_process_fd, METH_VARARGS|METH_KEYWORDS, 0},
- {"gethostbyname", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_15gethostbyname, METH_VARARGS|METH_KEYWORDS, 0},
- {"gethostbyaddr", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_17gethostbyaddr, METH_VARARGS|METH_KEYWORDS, 0},
- {"_getnameinfo", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_19_getnameinfo, METH_VARARGS|METH_KEYWORDS, 0},
- {"getnameinfo", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_7channel_21getnameinfo, METH_VARARGS|METH_KEYWORDS, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_6gevent_8resolver_5cares_channel[] = {
- {(char *)"loop", __pyx_getprop_6gevent_8resolver_5cares_7channel_loop, __pyx_setprop_6gevent_8resolver_5cares_7channel_loop, (char *)0, 0},
- {(char *)"_watchers", __pyx_getprop_6gevent_8resolver_5cares_7channel__watchers, __pyx_setprop_6gevent_8resolver_5cares_7channel__watchers, (char *)0, 0},
- {(char *)"_timer", __pyx_getprop_6gevent_8resolver_5cares_7channel__timer, __pyx_setprop_6gevent_8resolver_5cares_7channel__timer, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type_6gevent_8resolver_5cares_channel = {
- PyVarObject_HEAD_INIT(0, 0)
- "gevent.resolver.cares.channel", /*tp_name*/
- sizeof(struct __pyx_obj_6gevent_8resolver_5cares_channel), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_6gevent_8resolver_5cares_channel, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_pw_6gevent_8resolver_5cares_7channel_3__repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_6gevent_8resolver_5cares_channel, /*tp_traverse*/
- __pyx_tp_clear_6gevent_8resolver_5cares_channel, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_6gevent_8resolver_5cares_channel, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_6gevent_8resolver_5cares_channel, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_pw_6gevent_8resolver_5cares_7channel_1__init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_6gevent_8resolver_5cares_channel, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {"_convert_cares_flags", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_1_convert_cares_flags, METH_VARARGS|METH_KEYWORDS, 0},
- {"strerror", (PyCFunction)__pyx_pw_6gevent_8resolver_5cares_3strerror, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec_cares(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec_cares},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "cares",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_k_ARES_EADDRGETNETWORKPARAMS, sizeof(__pyx_k_ARES_EADDRGETNETWORKPARAMS), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADFAMILY, __pyx_k_ARES_EBADFAMILY, sizeof(__pyx_k_ARES_EBADFAMILY), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADFLAGS, __pyx_k_ARES_EBADFLAGS, sizeof(__pyx_k_ARES_EBADFLAGS), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADHINTS, __pyx_k_ARES_EBADHINTS, sizeof(__pyx_k_ARES_EBADHINTS), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADNAME, __pyx_k_ARES_EBADNAME, sizeof(__pyx_k_ARES_EBADNAME), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADQUERY, __pyx_k_ARES_EBADQUERY, sizeof(__pyx_k_ARES_EBADQUERY), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADRESP, __pyx_k_ARES_EBADRESP, sizeof(__pyx_k_ARES_EBADRESP), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EBADSTR, __pyx_k_ARES_EBADSTR, sizeof(__pyx_k_ARES_EBADSTR), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ECANCELLED, __pyx_k_ARES_ECANCELLED, sizeof(__pyx_k_ARES_ECANCELLED), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ECONNREFUSED, __pyx_k_ARES_ECONNREFUSED, sizeof(__pyx_k_ARES_ECONNREFUSED), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EDESTRUCTION, __pyx_k_ARES_EDESTRUCTION, sizeof(__pyx_k_ARES_EDESTRUCTION), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EFILE, __pyx_k_ARES_EFILE, sizeof(__pyx_k_ARES_EFILE), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EFORMERR, __pyx_k_ARES_EFORMERR, sizeof(__pyx_k_ARES_EFORMERR), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_k_ARES_ELOADIPHLPAPI, sizeof(__pyx_k_ARES_ELOADIPHLPAPI), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENODATA, __pyx_k_ARES_ENODATA, sizeof(__pyx_k_ARES_ENODATA), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENOMEM, __pyx_k_ARES_ENOMEM, sizeof(__pyx_k_ARES_ENOMEM), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENONAME, __pyx_k_ARES_ENONAME, sizeof(__pyx_k_ARES_ENONAME), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENOTFOUND, __pyx_k_ARES_ENOTFOUND, sizeof(__pyx_k_ARES_ENOTFOUND), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENOTIMP, __pyx_k_ARES_ENOTIMP, sizeof(__pyx_k_ARES_ENOTIMP), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ENOTINITIALIZED, __pyx_k_ARES_ENOTINITIALIZED, sizeof(__pyx_k_ARES_ENOTINITIALIZED), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EOF, __pyx_k_ARES_EOF, sizeof(__pyx_k_ARES_EOF), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_EREFUSED, __pyx_k_ARES_EREFUSED, sizeof(__pyx_k_ARES_EREFUSED), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ESERVFAIL, __pyx_k_ARES_ESERVFAIL, sizeof(__pyx_k_ARES_ESERVFAIL), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_ETIMEOUT, __pyx_k_ARES_ETIMEOUT, sizeof(__pyx_k_ARES_ETIMEOUT), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_IGNTC, __pyx_k_ARES_FLAG_IGNTC, sizeof(__pyx_k_ARES_FLAG_IGNTC), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_NOALIASES, __pyx_k_ARES_FLAG_NOALIASES, sizeof(__pyx_k_ARES_FLAG_NOALIASES), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_k_ARES_FLAG_NOCHECKRESP, sizeof(__pyx_k_ARES_FLAG_NOCHECKRESP), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_NORECURSE, __pyx_k_ARES_FLAG_NORECURSE, sizeof(__pyx_k_ARES_FLAG_NORECURSE), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_k_ARES_FLAG_NOSEARCH, sizeof(__pyx_k_ARES_FLAG_NOSEARCH), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_PRIMARY, __pyx_k_ARES_FLAG_PRIMARY, sizeof(__pyx_k_ARES_FLAG_PRIMARY), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_k_ARES_FLAG_STAYOPEN, sizeof(__pyx_k_ARES_FLAG_STAYOPEN), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_FLAG_USEVC, __pyx_k_ARES_FLAG_USEVC, sizeof(__pyx_k_ARES_FLAG_USEVC), 0, 0, 1, 1},
- {&__pyx_n_s_ARES_SUCCESS, __pyx_k_ARES_SUCCESS, sizeof(__pyx_k_ARES_SUCCESS), 0, 0, 1, 1},
- {&__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_k_Bad_value_for_ai_flags_0x_x, sizeof(__pyx_k_Bad_value_for_ai_flags_0x_x), 0, 0, 1, 0},
- {&__pyx_n_s_InvalidIP, __pyx_k_InvalidIP, sizeof(__pyx_k_InvalidIP), 0, 0, 1, 1},
- {&__pyx_kp_s_Invalid_value_for_port_r, __pyx_k_Invalid_value_for_port_r, sizeof(__pyx_k_Invalid_value_for_port_r), 0, 0, 1, 0},
- {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
- {&__pyx_n_s_NI_DGRAM, __pyx_k_NI_DGRAM, sizeof(__pyx_k_NI_DGRAM), 0, 0, 1, 1},
- {&__pyx_n_s_NI_NAMEREQD, __pyx_k_NI_NAMEREQD, sizeof(__pyx_k_NI_NAMEREQD), 0, 0, 1, 1},
- {&__pyx_n_s_NI_NOFQDN, __pyx_k_NI_NOFQDN, sizeof(__pyx_k_NI_NOFQDN), 0, 0, 1, 1},
- {&__pyx_n_s_NI_NUMERICHOST, __pyx_k_NI_NUMERICHOST, sizeof(__pyx_k_NI_NUMERICHOST), 0, 0, 1, 1},
- {&__pyx_n_s_NI_NUMERICSERV, __pyx_k_NI_NUMERICSERV, sizeof(__pyx_k_NI_NUMERICSERV), 0, 0, 1, 1},
- {&__pyx_n_s_TIMEOUT, __pyx_k_TIMEOUT, sizeof(__pyx_k_TIMEOUT), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
- {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
- {&__pyx_n_s_again, __pyx_k_again, sizeof(__pyx_k_again), 0, 0, 1, 1},
- {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
- {&__pyx_n_s_ares_errors, __pyx_k_ares_errors, sizeof(__pyx_k_ares_errors), 0, 0, 1, 1},
- {&__pyx_n_s_ares_host_result, __pyx_k_ares_host_result, sizeof(__pyx_k_ares_host_result), 0, 0, 1, 1},
- {&__pyx_n_s_ares_host_result___getnewargs, __pyx_k_ares_host_result___getnewargs, sizeof(__pyx_k_ares_host_result___getnewargs), 0, 0, 1, 1},
- {&__pyx_n_s_ares_host_result___new, __pyx_k_ares_host_result___new, sizeof(__pyx_k_ares_host_result___new), 0, 0, 1, 1},
- {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1},
- {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1},
- {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
- {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
- {&__pyx_n_s_cares_flag_map, __pyx_k_cares_flag_map, sizeof(__pyx_k_cares_flag_map), 0, 0, 1, 1},
- {&__pyx_n_s_channel, __pyx_k_channel, sizeof(__pyx_k_channel), 0, 0, 1, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
- {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
- {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
- {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
- {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
- {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1},
- {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
- {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
- {&__pyx_kp_s_expected_a_tuple_got_r, __pyx_k_expected_a_tuple_got_r, sizeof(__pyx_k_expected_a_tuple_got_r), 0, 0, 1, 0},
- {&__pyx_n_s_family, __pyx_k_family, sizeof(__pyx_k_family), 0, 0, 1, 1},
- {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
- {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
- {&__pyx_n_s_gaierror, __pyx_k_gaierror, sizeof(__pyx_k_gaierror), 0, 0, 1, 1},
- {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
- {&__pyx_n_s_getnameinfo, __pyx_k_getnameinfo, sizeof(__pyx_k_getnameinfo), 0, 0, 1, 1},
- {&__pyx_n_s_getnewargs, __pyx_k_getnewargs, sizeof(__pyx_k_getnewargs), 0, 0, 1, 1},
- {&__pyx_n_s_gevent_resolver_cares, __pyx_k_gevent_resolver_cares, sizeof(__pyx_k_gevent_resolver_cares), 0, 0, 1, 1},
- {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1},
- {&__pyx_n_s_iterable, __pyx_k_iterable, sizeof(__pyx_k_iterable), 0, 0, 1, 1},
- {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
- {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
- {&__pyx_n_s_ndots, __pyx_k_ndots, sizeof(__pyx_k_ndots), 0, 0, 1, 1},
- {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
- {&__pyx_n_s_on_timer, __pyx_k_on_timer, sizeof(__pyx_k_on_timer), 0, 0, 1, 1},
- {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
- {&__pyx_n_s_process_fd, __pyx_k_process_fd, sizeof(__pyx_k_process_fd), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
- {&__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_k_s_at_0x_x__timer_r__watchers_s, sizeof(__pyx_k_s_at_0x_x__timer_r__watchers_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_exception_r, __pyx_k_s_exception_r, sizeof(__pyx_k_s_exception_r), 0, 0, 1, 0},
- {&__pyx_kp_s_s_r, __pyx_k_s_r, sizeof(__pyx_k_s_r), 0, 0, 1, 0},
- {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
- {&__pyx_kp_s_s_value_r_exception_r, __pyx_k_s_value_r_exception_r, sizeof(__pyx_k_s_value_r_exception_r), 0, 0, 1, 0},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_servers, __pyx_k_servers, sizeof(__pyx_k_servers), 0, 0, 1, 1},
- {&__pyx_n_s_set_servers, __pyx_k_set_servers, sizeof(__pyx_k_set_servers), 0, 0, 1, 1},
- {&__pyx_n_s_sockaddr, __pyx_k_sockaddr, sizeof(__pyx_k_sockaddr), 0, 0, 1, 1},
- {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
- {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
- {&__pyx_kp_s_src_gevent_resolver_cares_pyx, __pyx_k_src_gevent_resolver_cares_pyx, sizeof(__pyx_k_src_gevent_resolver_cares_pyx), 0, 0, 1, 0},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
- {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
- {&__pyx_n_s_tcp_port, __pyx_k_tcp_port, sizeof(__pyx_k_tcp_port), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_kp_s_this_ares_channel_has_been_destr, __pyx_k_this_ares_channel_has_been_destr, sizeof(__pyx_k_this_ares_channel_has_been_destr), 0, 0, 1, 0},
- {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
- {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1},
- {&__pyx_n_s_tries, __pyx_k_tries, sizeof(__pyx_k_tries), 0, 0, 1, 1},
- {&__pyx_n_s_udp_port, __pyx_k_udp_port, sizeof(__pyx_k_udp_port), 0, 0, 1, 1},
- {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1},
- {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
- {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
- {&__pyx_n_s_watcher, __pyx_k_watcher, sizeof(__pyx_k_watcher), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 162, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 305, __pyx_L1_error)
- __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 339, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 446, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "gevent/resolver/cares.pyx":329
- * servers = []
- * if isinstance(servers, string_types):
- * servers = servers.split(',') # <<<<<<<<<<<<<<
- * cdef int length = len(servers)
- * cdef int result, index
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s__2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 329, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
-
- /* "gevent/resolver/cares.pyx":344
- * for server in servers:
- * if isinstance(server, unicode):
- * server = server.encode('ascii') # <<<<<<<<<<<<<<
- * string = <char*?>server
- * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 344, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "gevent/resolver/cares.pyx":162
- *
- *
- * class InvalidIP(ValueError): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_tuple__6 = PyTuple_Pack(1, __pyx_builtin_ValueError); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
-
- /* "gevent/resolver/cares.pyx":201
- * class ares_host_result(tuple):
- *
- * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family
- */
- __pyx_tuple__7 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_family, __pyx_n_s_iterable, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 201, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
- __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_resolver_cares_pyx, __pyx_n_s_new, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 201, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":206
- * return self
- *
- * def __getnewargs__(self): # <<<<<<<<<<<<<<
- * return (self.family, tuple(self))
- *
- */
- __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 206, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
- __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent_resolver_cares_pyx, __pyx_n_s_getnewargs, 206, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 206, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
- __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static int __Pyx_modinit_global_init_code(void); /*proto*/
-static int __Pyx_modinit_variable_export_code(void); /*proto*/
-static int __Pyx_modinit_function_export_code(void); /*proto*/
-static int __Pyx_modinit_type_init_code(void); /*proto*/
-static int __Pyx_modinit_type_import_code(void); /*proto*/
-static int __Pyx_modinit_variable_import_code(void); /*proto*/
-static int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __pyx_v_6gevent_8resolver_5cares_string_types = Py_None; Py_INCREF(Py_None);
- __pyx_v_6gevent_8resolver_5cares_text_type = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_6gevent_8resolver_5cares_result) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
- __pyx_type_6gevent_8resolver_5cares_result.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8resolver_5cares_result.tp_dictoffset && __pyx_type_6gevent_8resolver_5cares_result.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8resolver_5cares_result.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (PyObject_SetAttrString(__pyx_m, "result", (PyObject *)&__pyx_type_6gevent_8resolver_5cares_result) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
- __pyx_ptype_6gevent_8resolver_5cares_result = &__pyx_type_6gevent_8resolver_5cares_result;
- __pyx_vtabptr_6gevent_8resolver_5cares_channel = &__pyx_vtable_6gevent_8resolver_5cares_channel;
- __pyx_vtable_6gevent_8resolver_5cares_channel.set_servers = (PyObject *(*)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_8resolver_5cares_7channel_set_servers *__pyx_optional_args))__pyx_f_6gevent_8resolver_5cares_7channel_set_servers;
- __pyx_vtable_6gevent_8resolver_5cares_channel._sock_state_callback = (PyObject *(*)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, int, int, int))__pyx_f_6gevent_8resolver_5cares_7channel__sock_state_callback;
- __pyx_vtable_6gevent_8resolver_5cares_channel._getnameinfo = (PyObject *(*)(struct __pyx_obj_6gevent_8resolver_5cares_channel *, PyObject *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_6gevent_8resolver_5cares_7channel__getnameinfo;
- if (PyType_Ready(&__pyx_type_6gevent_8resolver_5cares_channel) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
- __pyx_type_6gevent_8resolver_5cares_channel.tp_print = 0;
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gevent_8resolver_5cares_channel.tp_dictoffset && __pyx_type_6gevent_8resolver_5cares_channel.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type_6gevent_8resolver_5cares_channel.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type_6gevent_8resolver_5cares_channel.tp_dict, __pyx_vtabptr_6gevent_8resolver_5cares_channel) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
- if (PyObject_SetAttrString(__pyx_m, "channel", (PyObject *)&__pyx_type_6gevent_8resolver_5cares_channel) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
- __pyx_ptype_6gevent_8resolver_5cares_channel = &__pyx_type_6gevent_8resolver_5cares_channel;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
- #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
- sizeof(PyTypeObject),
- #else
- sizeof(PyHeapTypeObject),
- #endif
- 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(1, 9, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#endif
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC initcares(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC initcares(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit_cares(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit_cares(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- result = PyDict_SetItemString(moddict, to_name, value);
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static int __pyx_pymod_exec_cares(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- PyObject *__pyx_t_13 = NULL;
- PyObject *__pyx_t_14 = NULL;
- PyObject *__pyx_t_15 = NULL;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- PyObject *__pyx_t_18 = NULL;
- PyObject *__pyx_t_19 = NULL;
- PyObject *__pyx_t_20 = NULL;
- PyObject *__pyx_t_21 = NULL;
- PyObject *__pyx_t_22 = NULL;
- PyObject *__pyx_t_23 = NULL;
- PyObject *__pyx_t_24 = NULL;
- PyObject *__pyx_t_25 = NULL;
- PyObject *__pyx_t_26 = NULL;
- PyObject *__pyx_t_27 = NULL;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cares(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("cares", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- #if CYTHON_COMPILING_IN_PYPY
- Py_INCREF(__pyx_b);
- #endif
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_gevent__resolver__cares) {
- if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "gevent.resolver.cares")) {
- if (unlikely(PyDict_SetItemString(modules, "gevent.resolver.cares", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- (void)__Pyx_modinit_variable_export_code();
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
- if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "gevent/resolver/cares.pyx":8
- * # cython: auto_pickle=False
- * cimport libcares as cares
- * import sys # <<<<<<<<<<<<<<
- *
- * from cpython.ref cimport Py_INCREF
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":15
- * from cpython.mem cimport PyMem_Free
- *
- * from _socket import gaierror # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_gaierror);
- __Pyx_GIVEREF(__pyx_n_s_gaierror);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gaierror);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_socket, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_gaierror, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":18
- *
- *
- * __all__ = ['channel'] # <<<<<<<<<<<<<<
- *
- * cdef object string_types
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_channel);
- __Pyx_GIVEREF(__pyx_n_s_channel);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_channel);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":23
- * cdef object text_type
- *
- * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<<
- * string_types = str,
- * text_type = str
- */
- __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 23, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_3) {
-
- /* "gevent/resolver/cares.pyx":24
- *
- * if sys.version_info[0] >= 3:
- * string_types = str, # <<<<<<<<<<<<<<
- * text_type = str
- * else:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)(&PyString_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyString_Type)));
- __Pyx_XGOTREF(__pyx_v_6gevent_8resolver_5cares_string_types);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8resolver_5cares_string_types, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":25
- * if sys.version_info[0] >= 3:
- * string_types = str,
- * text_type = str # <<<<<<<<<<<<<<
- * else:
- * string_types = __builtins__.basestring,
- */
- __Pyx_INCREF(((PyObject *)(&PyString_Type)));
- __Pyx_XGOTREF(__pyx_v_6gevent_8resolver_5cares_text_type);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8resolver_5cares_text_type, ((PyObject *)(&PyString_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
-
- /* "gevent/resolver/cares.pyx":23
- * cdef object text_type
- *
- * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<<
- * string_types = str,
- * text_type = str
- */
- goto __pyx_L2;
- }
-
- /* "gevent/resolver/cares.pyx":27
- * text_type = str
- * else:
- * string_types = __builtins__.basestring, # <<<<<<<<<<<<<<
- * text_type = __builtins__.unicode
- *
- */
- /*else*/ {
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basestring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __pyx_t_2 = 0;
- __Pyx_XGOTREF(__pyx_v_6gevent_8resolver_5cares_string_types);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8resolver_5cares_string_types, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "gevent/resolver/cares.pyx":28
- * else:
- * string_types = __builtins__.basestring,
- * text_type = __builtins__.unicode # <<<<<<<<<<<<<<
- *
- * TIMEOUT = 1
- */
- __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XGOTREF(__pyx_v_6gevent_8resolver_5cares_text_type);
- __Pyx_DECREF_SET(__pyx_v_6gevent_8resolver_5cares_text_type, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_2 = 0;
- }
- __pyx_L2:;
-
- /* "gevent/resolver/cares.pyx":30
- * text_type = __builtins__.unicode
- *
- * TIMEOUT = 1 # <<<<<<<<<<<<<<
- *
- * DEF EV_READ = 1
- */
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_int_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":67
- *
- *
- * ARES_SUCCESS = cares.ARES_SUCCESS # <<<<<<<<<<<<<<
- * ARES_ENODATA = cares.ARES_ENODATA
- * ARES_EFORMERR = cares.ARES_EFORMERR
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_SUCCESS, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":68
- *
- * ARES_SUCCESS = cares.ARES_SUCCESS
- * ARES_ENODATA = cares.ARES_ENODATA # <<<<<<<<<<<<<<
- * ARES_EFORMERR = cares.ARES_EFORMERR
- * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENODATA, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":69
- * ARES_SUCCESS = cares.ARES_SUCCESS
- * ARES_ENODATA = cares.ARES_ENODATA
- * ARES_EFORMERR = cares.ARES_EFORMERR # <<<<<<<<<<<<<<
- * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
- * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFORMERR, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":70
- * ARES_ENODATA = cares.ARES_ENODATA
- * ARES_EFORMERR = cares.ARES_EFORMERR
- * ARES_ESERVFAIL = cares.ARES_ESERVFAIL # <<<<<<<<<<<<<<
- * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
- * ARES_ENOTIMP = cares.ARES_ENOTIMP
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ESERVFAIL, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":71
- * ARES_EFORMERR = cares.ARES_EFORMERR
- * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
- * ARES_ENOTFOUND = cares.ARES_ENOTFOUND # <<<<<<<<<<<<<<
- * ARES_ENOTIMP = cares.ARES_ENOTIMP
- * ARES_EREFUSED = cares.ARES_EREFUSED
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTFOUND, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":72
- * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
- * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
- * ARES_ENOTIMP = cares.ARES_ENOTIMP # <<<<<<<<<<<<<<
- * ARES_EREFUSED = cares.ARES_EREFUSED
- * ARES_EBADQUERY = cares.ARES_EBADQUERY
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTIMP, __pyx_t_2) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":73
- * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
- * ARES_ENOTIMP = cares.ARES_ENOTIMP
- * ARES_EREFUSED = cares.ARES_EREFUSED # <<<<<<<<<<<<<<
- * ARES_EBADQUERY = cares.ARES_EBADQUERY
- * ARES_EBADNAME = cares.ARES_EBADNAME
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":74
- * ARES_ENOTIMP = cares.ARES_ENOTIMP
- * ARES_EREFUSED = cares.ARES_EREFUSED
- * ARES_EBADQUERY = cares.ARES_EBADQUERY # <<<<<<<<<<<<<<
- * ARES_EBADNAME = cares.ARES_EBADNAME
- * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADQUERY, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":75
- * ARES_EREFUSED = cares.ARES_EREFUSED
- * ARES_EBADQUERY = cares.ARES_EBADQUERY
- * ARES_EBADNAME = cares.ARES_EBADNAME # <<<<<<<<<<<<<<
- * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
- * ARES_EBADRESP = cares.ARES_EBADRESP
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADNAME, __pyx_t_2) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":76
- * ARES_EBADQUERY = cares.ARES_EBADQUERY
- * ARES_EBADNAME = cares.ARES_EBADNAME
- * ARES_EBADFAMILY = cares.ARES_EBADFAMILY # <<<<<<<<<<<<<<
- * ARES_EBADRESP = cares.ARES_EBADRESP
- * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFAMILY, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":77
- * ARES_EBADNAME = cares.ARES_EBADNAME
- * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
- * ARES_EBADRESP = cares.ARES_EBADRESP # <<<<<<<<<<<<<<
- * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
- * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADRESP, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":78
- * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
- * ARES_EBADRESP = cares.ARES_EBADRESP
- * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED # <<<<<<<<<<<<<<
- * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
- * ARES_EOF = cares.ARES_EOF
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECONNREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":79
- * ARES_EBADRESP = cares.ARES_EBADRESP
- * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
- * ARES_ETIMEOUT = cares.ARES_ETIMEOUT # <<<<<<<<<<<<<<
- * ARES_EOF = cares.ARES_EOF
- * ARES_EFILE = cares.ARES_EFILE
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ETIMEOUT, __pyx_t_2) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":80
- * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
- * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
- * ARES_EOF = cares.ARES_EOF # <<<<<<<<<<<<<<
- * ARES_EFILE = cares.ARES_EFILE
- * ARES_ENOMEM = cares.ARES_ENOMEM
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EOF, __pyx_t_2) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":81
- * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
- * ARES_EOF = cares.ARES_EOF
- * ARES_EFILE = cares.ARES_EFILE # <<<<<<<<<<<<<<
- * ARES_ENOMEM = cares.ARES_ENOMEM
- * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFILE, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":82
- * ARES_EOF = cares.ARES_EOF
- * ARES_EFILE = cares.ARES_EFILE
- * ARES_ENOMEM = cares.ARES_ENOMEM # <<<<<<<<<<<<<<
- * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
- * ARES_EBADSTR = cares.ARES_EBADSTR
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOMEM, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":83
- * ARES_EFILE = cares.ARES_EFILE
- * ARES_ENOMEM = cares.ARES_ENOMEM
- * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION # <<<<<<<<<<<<<<
- * ARES_EBADSTR = cares.ARES_EBADSTR
- * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EDESTRUCTION, __pyx_t_2) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":84
- * ARES_ENOMEM = cares.ARES_ENOMEM
- * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
- * ARES_EBADSTR = cares.ARES_EBADSTR # <<<<<<<<<<<<<<
- * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
- * ARES_ENONAME = cares.ARES_ENONAME
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADSTR, __pyx_t_2) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":85
- * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
- * ARES_EBADSTR = cares.ARES_EBADSTR
- * ARES_EBADFLAGS = cares.ARES_EBADFLAGS # <<<<<<<<<<<<<<
- * ARES_ENONAME = cares.ARES_ENONAME
- * ARES_EBADHINTS = cares.ARES_EBADHINTS
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFLAGS, __pyx_t_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":86
- * ARES_EBADSTR = cares.ARES_EBADSTR
- * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
- * ARES_ENONAME = cares.ARES_ENONAME # <<<<<<<<<<<<<<
- * ARES_EBADHINTS = cares.ARES_EBADHINTS
- * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENONAME, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":87
- * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
- * ARES_ENONAME = cares.ARES_ENONAME
- * ARES_EBADHINTS = cares.ARES_EBADHINTS # <<<<<<<<<<<<<<
- * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
- * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADHINTS, __pyx_t_2) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":88
- * ARES_ENONAME = cares.ARES_ENONAME
- * ARES_EBADHINTS = cares.ARES_EBADHINTS
- * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED # <<<<<<<<<<<<<<
- * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
- * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTINITIALIZED, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":89
- * ARES_EBADHINTS = cares.ARES_EBADHINTS
- * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
- * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI # <<<<<<<<<<<<<<
- * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
- * ARES_ECANCELLED = cares.ARES_ECANCELLED
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":90
- * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
- * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
- * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS # <<<<<<<<<<<<<<
- * ARES_ECANCELLED = cares.ARES_ECANCELLED
- *
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":91
- * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
- * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
- * ARES_ECANCELLED = cares.ARES_ECANCELLED # <<<<<<<<<<<<<<
- *
- * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECANCELLED, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":93
- * ARES_ECANCELLED = cares.ARES_ECANCELLED
- *
- * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC # <<<<<<<<<<<<<<
- * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
- * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_USEVC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_USEVC, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":94
- *
- * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
- * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY # <<<<<<<<<<<<<<
- * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
- * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_PRIMARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_PRIMARY, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":95
- * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
- * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
- * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC # <<<<<<<<<<<<<<
- * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
- * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_IGNTC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_IGNTC, __pyx_t_2) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":96
- * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
- * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
- * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE # <<<<<<<<<<<<<<
- * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
- * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NORECURSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NORECURSE, __pyx_t_2) < 0) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":97
- * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
- * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
- * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN # <<<<<<<<<<<<<<
- * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
- * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_STAYOPEN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":98
- * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
- * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
- * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH # <<<<<<<<<<<<<<
- * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
- * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOSEARCH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_t_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":99
- * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
- * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
- * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES # <<<<<<<<<<<<<<
- * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP
- *
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOALIASES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOALIASES, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":100
- * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
- * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
- * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOCHECKRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_t_2) < 0) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":104
- *
- * _ares_errors = dict([
- * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENODATA, 'ARES_ENODATA'),
- * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_SUCCESS);
- __Pyx_GIVEREF(__pyx_n_s_ARES_SUCCESS);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ARES_SUCCESS);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":105
- * _ares_errors = dict([
- * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
- * (cares.ARES_ENODATA, 'ARES_ENODATA'), # <<<<<<<<<<<<<<
- * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
- * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENODATA);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENODATA);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_ARES_ENODATA);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":106
- * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
- * (cares.ARES_ENODATA, 'ARES_ENODATA'),
- * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), # <<<<<<<<<<<<<<
- * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
- * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EFORMERR);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EFORMERR);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_ARES_EFORMERR);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":107
- * (cares.ARES_ENODATA, 'ARES_ENODATA'),
- * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
- * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
- * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ESERVFAIL);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ESERVFAIL);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_ARES_ESERVFAIL);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":108
- * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
- * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
- * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
- * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENOTFOUND);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTFOUND);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ARES_ENOTFOUND);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":109
- * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
- * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
- * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), # <<<<<<<<<<<<<<
- * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
- * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENOTIMP);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTIMP);
- PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_ARES_ENOTIMP);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":110
- * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
- * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
- * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
- * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EREFUSED);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EREFUSED);
- PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_ARES_EREFUSED);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":111
- * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
- * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
- * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
- * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADQUERY);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADQUERY);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_ARES_EBADQUERY);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":112
- * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
- * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
- * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
- * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 112, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADNAME);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADNAME);
- PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_ARES_EBADNAME);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":113
- * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
- * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
- * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
- * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADFAMILY);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFAMILY);
- PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_ARES_EBADFAMILY);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":114
- * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
- * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
- * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), # <<<<<<<<<<<<<<
- * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
- * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 114, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADRESP);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADRESP);
- PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_ARES_EBADRESP);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":115
- * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
- * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
- * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), # <<<<<<<<<<<<<<
- * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
- * (cares.ARES_EOF, 'ARES_EOF'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ECONNREFUSED);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ECONNREFUSED);
- PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_ARES_ECONNREFUSED);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":116
- * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
- * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
- * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), # <<<<<<<<<<<<<<
- * (cares.ARES_EOF, 'ARES_EOF'),
- * (cares.ARES_EFILE, 'ARES_EFILE'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 116, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_15);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ETIMEOUT);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ETIMEOUT);
- PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_ARES_ETIMEOUT);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":117
- * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
- * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
- * (cares.ARES_EOF, 'ARES_EOF'), # <<<<<<<<<<<<<<
- * (cares.ARES_EFILE, 'ARES_EFILE'),
- * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 117, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_16);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EOF);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EOF);
- PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ARES_EOF);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":118
- * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
- * (cares.ARES_EOF, 'ARES_EOF'),
- * (cares.ARES_EFILE, 'ARES_EFILE'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
- * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EFILE);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EFILE);
- PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_ARES_EFILE);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":119
- * (cares.ARES_EOF, 'ARES_EOF'),
- * (cares.ARES_EFILE, 'ARES_EFILE'),
- * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), # <<<<<<<<<<<<<<
- * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
- * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_18);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENOMEM);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENOMEM);
- PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ARES_ENOMEM);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":120
- * (cares.ARES_EFILE, 'ARES_EFILE'),
- * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
- * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
- * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 120, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_19);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EDESTRUCTION);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EDESTRUCTION);
- PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_n_s_ARES_EDESTRUCTION);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":121
- * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
- * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
- * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
- * (cares.ARES_ENONAME, 'ARES_ENONAME'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 121, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_20);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADSTR);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADSTR);
- PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_n_s_ARES_EBADSTR);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":122
- * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
- * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
- * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENONAME, 'ARES_ENONAME'),
- * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 122, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_21);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADFLAGS);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFLAGS);
- PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_n_s_ARES_EBADFLAGS);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":123
- * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
- * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
- * (cares.ARES_ENONAME, 'ARES_ENONAME'), # <<<<<<<<<<<<<<
- * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
- * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 123, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_22);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENONAME);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENONAME);
- PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_n_s_ARES_ENONAME);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":124
- * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
- * (cares.ARES_ENONAME, 'ARES_ENONAME'),
- * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), # <<<<<<<<<<<<<<
- * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
- * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_23);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EBADHINTS);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EBADHINTS);
- PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_n_s_ARES_EBADHINTS);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":125
- * (cares.ARES_ENONAME, 'ARES_ENONAME'),
- * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
- * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), # <<<<<<<<<<<<<<
- * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
- * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_24);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ENOTINITIALIZED);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTINITIALIZED);
- PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_n_s_ARES_ENOTINITIALIZED);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":126
- * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
- * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
- * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), # <<<<<<<<<<<<<<
- * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
- * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')])
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_25);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ELOADIPHLPAPI);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ELOADIPHLPAPI);
- PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_n_s_ARES_ELOADIPHLPAPI);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":127
- * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
- * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
- * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), # <<<<<<<<<<<<<<
- * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')])
- *
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_26 = PyTuple_New(2); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_26);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
- __Pyx_GIVEREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
- PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":128
- * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
- * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
- * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_27);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_ARES_ECANCELLED);
- __Pyx_GIVEREF(__pyx_n_s_ARES_ECANCELLED);
- PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_n_s_ARES_ECANCELLED);
- __pyx_t_2 = 0;
-
- /* "gevent/resolver/cares.pyx":103
- *
- *
- * _ares_errors = dict([ # <<<<<<<<<<<<<<
- * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
- * (cares.ARES_ENODATA, 'ARES_ENODATA'),
- */
- __pyx_t_2 = PyList_New(25); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_8);
- PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8);
- __Pyx_GIVEREF(__pyx_t_9);
- PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_10);
- PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_11);
- PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_12);
- PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12);
- __Pyx_GIVEREF(__pyx_t_13);
- PyList_SET_ITEM(__pyx_t_2, 10, __pyx_t_13);
- __Pyx_GIVEREF(__pyx_t_14);
- PyList_SET_ITEM(__pyx_t_2, 11, __pyx_t_14);
- __Pyx_GIVEREF(__pyx_t_15);
- PyList_SET_ITEM(__pyx_t_2, 12, __pyx_t_15);
- __Pyx_GIVEREF(__pyx_t_16);
- PyList_SET_ITEM(__pyx_t_2, 13, __pyx_t_16);
- __Pyx_GIVEREF(__pyx_t_17);
- PyList_SET_ITEM(__pyx_t_2, 14, __pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_18);
- PyList_SET_ITEM(__pyx_t_2, 15, __pyx_t_18);
- __Pyx_GIVEREF(__pyx_t_19);
- PyList_SET_ITEM(__pyx_t_2, 16, __pyx_t_19);
- __Pyx_GIVEREF(__pyx_t_20);
- PyList_SET_ITEM(__pyx_t_2, 17, __pyx_t_20);
- __Pyx_GIVEREF(__pyx_t_21);
- PyList_SET_ITEM(__pyx_t_2, 18, __pyx_t_21);
- __Pyx_GIVEREF(__pyx_t_22);
- PyList_SET_ITEM(__pyx_t_2, 19, __pyx_t_22);
- __Pyx_GIVEREF(__pyx_t_23);
- PyList_SET_ITEM(__pyx_t_2, 20, __pyx_t_23);
- __Pyx_GIVEREF(__pyx_t_24);
- PyList_SET_ITEM(__pyx_t_2, 21, __pyx_t_24);
- __Pyx_GIVEREF(__pyx_t_25);
- PyList_SET_ITEM(__pyx_t_2, 22, __pyx_t_25);
- __Pyx_GIVEREF(__pyx_t_26);
- PyList_SET_ITEM(__pyx_t_2, 23, __pyx_t_26);
- __Pyx_GIVEREF(__pyx_t_27);
- PyList_SET_ITEM(__pyx_t_2, 24, __pyx_t_27);
- __pyx_t_1 = 0;
- __pyx_t_4 = 0;
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- __pyx_t_8 = 0;
- __pyx_t_9 = 0;
- __pyx_t_10 = 0;
- __pyx_t_11 = 0;
- __pyx_t_12 = 0;
- __pyx_t_13 = 0;
- __pyx_t_14 = 0;
- __pyx_t_15 = 0;
- __pyx_t_16 = 0;
- __pyx_t_17 = 0;
- __pyx_t_18 = 0;
- __pyx_t_19 = 0;
- __pyx_t_20 = 0;
- __pyx_t_21 = 0;
- __pyx_t_22 = 0;
- __pyx_t_23 = 0;
- __pyx_t_24 = 0;
- __pyx_t_25 = 0;
- __pyx_t_26 = 0;
- __pyx_t_27 = 0;
- __pyx_t_27 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_27);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_errors, __pyx_t_27) < 0) __PYX_ERR(0, 103, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
-
- /* "gevent/resolver/cares.pyx":132
- *
- * # maps c-ares flag to _socket module flag
- * _cares_flag_map = None # <<<<<<<<<<<<<<
- *
- *
- */
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, Py_None) < 0) __PYX_ERR(0, 132, __pyx_L1_error)
-
- /* "gevent/resolver/cares.pyx":146
- *
- *
- * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
- * if _cares_flag_map is None:
- * _prepare_cares_flag_map()
- */
- __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE);
- __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE);
-
- /* "gevent/resolver/cares.pyx":162
- *
- *
- * class InvalidIP(ValueError): # <<<<<<<<<<<<<<
- * pass
- *
- */
- __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__6); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_27);
- __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_tuple__6, __pyx_n_s_InvalidIP, __pyx_n_s_InvalidIP, (PyObject *) NULL, __pyx_n_s_gevent_resolver_cares, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_26 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_InvalidIP, __pyx_tuple__6, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_26);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidIP, __pyx_t_26) < 0) __PYX_ERR(0, 162, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
-
- /* "gevent/resolver/cares.pyx":199
- *
- *
- * class ares_host_result(tuple): # <<<<<<<<<<<<<<
- *
- * def __new__(cls, family, iterable):
- */
- __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 199, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_27);
- __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
- __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
- PyTuple_SET_ITEM(__pyx_t_27, 0, ((PyObject *)(&PyTuple_Type)));
- __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_27); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_27, __pyx_n_s_ares_host_result, __pyx_n_s_ares_host_result, (PyObject *) NULL, __pyx_n_s_gevent_resolver_cares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 199, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_26);
-
- /* "gevent/resolver/cares.pyx":201
- * class ares_host_result(tuple):
- *
- * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
- * cdef object self = tuple.__new__(cls, iterable)
- * self.family = family
- */
- __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8resolver_5cares_16ares_host_result_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ares_host_result___new, NULL, __pyx_n_s_gevent_resolver_cares, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 201, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_25);
- if (__Pyx_SetNameInClass(__pyx_t_26, __pyx_n_s_new, __pyx_t_25) < 0) __PYX_ERR(0, 201, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
-
- /* "gevent/resolver/cares.pyx":206
- * return self
- *
- * def __getnewargs__(self): # <<<<<<<<<<<<<<
- * return (self.family, tuple(self))
- *
- */
- __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_8resolver_5cares_16ares_host_result_3__getnewargs__, 0, __pyx_n_s_ares_host_result___getnewargs, NULL, __pyx_n_s_gevent_resolver_cares, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 206, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_25);
- if (__Pyx_SetNameInClass(__pyx_t_26, __pyx_n_s_getnewargs, __pyx_t_25) < 0) __PYX_ERR(0, 206, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
-
- /* "gevent/resolver/cares.pyx":199
- *
- *
- * class ares_host_result(tuple): # <<<<<<<<<<<<<<
- *
- * def __new__(cls, family, iterable):
- */
- __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ares_host_result, __pyx_t_27, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 199, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_25);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_host_result, __pyx_t_25) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
- __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
-
- /* "gevent/resolver/cares.pyx":410
- * cares.ares_process_fd(self.channel, read_fd, write_fd)
- *
- * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
- * if not self.channel:
- * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- */
- __pyx_k__5 = AF_INET;
-
- /* "gevent/resolver/cares.pyx":1
- * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<<
- * # Automatic pickling of cdef classes was added in 0.26. Unfortunately it
- * # seems to be buggy (at least for the `result` class) and produces code that
- */
- __pyx_t_27 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_27);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_27) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_XDECREF(__pyx_t_12);
- __Pyx_XDECREF(__pyx_t_13);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
- __Pyx_XDECREF(__pyx_t_16);
- __Pyx_XDECREF(__pyx_t_17);
- __Pyx_XDECREF(__pyx_t_18);
- __Pyx_XDECREF(__pyx_t_19);
- __Pyx_XDECREF(__pyx_t_20);
- __Pyx_XDECREF(__pyx_t_21);
- __Pyx_XDECREF(__pyx_t_22);
- __Pyx_XDECREF(__pyx_t_23);
- __Pyx_XDECREF(__pyx_t_24);
- __Pyx_XDECREF(__pyx_t_25);
- __Pyx_XDECREF(__pyx_t_26);
- __Pyx_XDECREF(__pyx_t_27);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init gevent.resolver.cares", 0, __pyx_lineno, __pyx_filename);
- }
- Py_DECREF(__pyx_m); __pyx_m = 0;
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init gevent.resolver.cares");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule((char *)modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* Import */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
- PyObject *exc_type = tstate->curexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* GetAttr */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetAttr3 */
-static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* GetModuleGlobalName */
-static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
-#else
- result = PyDict_GetItem(__pyx_d, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- if (!result) {
- PyErr_Clear();
-#endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
-}
-
-/* RaiseTooManyValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
-}
-
-/* PyFunctionFastCall */
- #if CYTHON_FAST_PYCALL
-#include "frameobject.h"
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyCFunctionFastCall */
- #if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyObjectCall */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* RaiseException */
- #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* RaiseDoubleKeywords */
- static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
- static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* RaiseArgTupleInvalid */
- static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* PyObjectCallMethO */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* WriteUnraisableException */
- static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
- CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
- int full_traceback, CYTHON_UNUSED int nogil) {
- PyObject *old_exc, *old_val, *old_tb;
- PyObject *ctx;
- __Pyx_PyThreadState_declare
-#ifdef WITH_THREAD
- PyGILState_STATE state;
- if (nogil)
- state = PyGILState_Ensure();
-#ifdef _MSC_VER
- else state = (PyGILState_STATE)-1;
-#endif
-#endif
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
- if (full_traceback) {
- Py_XINCREF(old_exc);
- Py_XINCREF(old_val);
- Py_XINCREF(old_tb);
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- PyErr_PrintEx(1);
- }
- #if PY_MAJOR_VERSION < 3
- ctx = PyString_FromString(name);
- #else
- ctx = PyUnicode_FromString(name);
- #endif
- __Pyx_ErrRestore(old_exc, old_val, old_tb);
- if (!ctx) {
- PyErr_WriteUnraisable(Py_None);
- } else {
- PyErr_WriteUnraisable(ctx);
- Py_DECREF(ctx);
- }
-#ifdef WITH_THREAD
- if (nogil)
- PyGILState_Release(state);
-#endif
-}
-
-/* PyObjectSetAttrStr */
- #if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* RaiseNoneIterError */
- static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
-}
-
-/* ExtTypeTest */
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* SaveResetException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if PY_VERSION_HEX >= 0x030700A3
- *type = tstate->exc_state.exc_type;
- *value = tstate->exc_state.exc_value;
- *tb = tstate->exc_state.exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = type;
- tstate->exc_state.exc_value = value;
- tstate->exc_state.exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* GetException */
- #if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
-#endif
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = local_type;
- tstate->exc_state.exc_value = local_value;
- tstate->exc_state.exc_traceback = local_tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* PyObjectCallNoArg */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
-#else
- if (likely(PyCFunction_Check(func))) {
-#endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* GetItemInt */
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* pyobject_as_double */
- static double __Pyx__PyObject_AsDouble(PyObject* obj) {
- PyObject* float_value;
-#if !CYTHON_USE_TYPE_SLOTS
- float_value = PyNumber_Float(obj); if (0) goto bad;
-#else
- PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
- if (likely(nb) && likely(nb->nb_float)) {
- float_value = nb->nb_float(obj);
- if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
- PyErr_Format(PyExc_TypeError,
- "__float__ returned non-float (type %.200s)",
- Py_TYPE(float_value)->tp_name);
- Py_DECREF(float_value);
- goto bad;
- }
- } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
-#if PY_MAJOR_VERSION >= 3
- float_value = PyFloat_FromString(obj);
-#else
- float_value = PyFloat_FromString(obj, 0);
-#endif
- } else {
- PyObject* args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- PyTuple_SET_ITEM(args, 0, obj);
- float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
- PyTuple_SET_ITEM(args, 0, 0);
- Py_DECREF(args);
- }
-#endif
- if (likely(float_value)) {
- double value = PyFloat_AS_DOUBLE(float_value);
- Py_DECREF(float_value);
- return value;
- }
-bad:
- return (double)-1;
-}
-
-/* SwapException */
- #if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if PY_VERSION_HEX >= 0x030700A3
- tmp_type = tstate->exc_state.exc_type;
- tmp_value = tstate->exc_state.exc_value;
- tmp_tb = tstate->exc_state.exc_traceback;
- tstate->exc_state.exc_type = *type;
- tstate->exc_state.exc_value = *value;
- tstate->exc_state.exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* UnpackUnboundCMethod */
- static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod1 */
- #if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
- if (likely(cfunc->func)) {
- int flag = cfunc->flag;
- if (flag == METH_O) {
- return (*(cfunc->func))(self, arg);
- } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
- if (PY_VERSION_HEX >= 0x030700A0) {
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
- } else {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- }
- return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(2, self, arg);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* CallUnboundCMethod2 */
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
-static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
- if (likely(cfunc->func)) {
- PyObject *args[2] = {arg1, arg2};
- if (cfunc->flag == METH_FASTCALL) {
- #if PY_VERSION_HEX >= 0x030700A0
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
- #else
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- #if PY_VERSION_HEX >= 0x030700A0
- if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
-}
-#endif
-static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(3);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 1, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 2, arg2);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
-#else
- args = PyTuple_Pack(3, self, arg1, arg2);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
-#endif
-bad:
- Py_XDECREF(args);
- return result;
-}
-
-/* dict_getitem_default */
- static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
- PyObject* value;
-#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
- value = PyDict_GetItemWithError(d, key);
- if (unlikely(!value)) {
- if (unlikely(PyErr_Occurred()))
- return NULL;
- value = default_value;
- }
- Py_INCREF(value);
- if ((1));
-#else
- if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
- value = PyDict_GetItem(d, key);
- if (unlikely(!value)) {
- value = default_value;
- }
- Py_INCREF(value);
- }
-#endif
- else {
- if (default_value == Py_None)
- value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
- else
- value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
- }
- return value;
-}
-
-/* py_dict_pop */
- static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
- if ((1)) {
- return _PyDict_Pop(d, key, default_value);
- } else
-#endif
- if (default_value) {
- return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
- } else {
- return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
- }
-}
-
-/* ArgTypeTest */
- static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* FastTypeChecks */
- #if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i<n; i++) {
- if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
- }
-#endif
- for (i=0; i<n; i++) {
- PyObject *t = PyTuple_GET_ITEM(tuple, i);
- #if PY_MAJOR_VERSION < 3
- if (likely(exc_type == t)) return 1;
- #endif
- if (likely(PyExceptionClass_Check(t))) {
- if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
- } else {
- }
- }
- return 0;
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
- if (likely(err == exc_type)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- if (likely(PyExceptionClass_Check(exc_type))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
- } else if (likely(PyTuple_Check(exc_type))) {
- return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
- } else {
- }
- }
- return PyErr_GivenExceptionMatches(err, exc_type);
-}
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
- assert(PyExceptionClass_Check(exc_type1));
- assert(PyExceptionClass_Check(exc_type2));
- if (likely(err == exc_type1 || err == exc_type2)) return 1;
- if (likely(PyExceptionClass_Check(err))) {
- return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
- }
- return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
-}
-#endif
-
-/* PyObject_GenericGetAttrNoDict */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
- static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* ImportFrom */
- static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* CalculateMetaclass */
- static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
- Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
- for (i=0; i < nbases; i++) {
- PyTypeObject *tmptype;
- PyObject *tmp = PyTuple_GET_ITEM(bases, i);
- tmptype = Py_TYPE(tmp);
-#if PY_MAJOR_VERSION < 3
- if (tmptype == &PyClass_Type)
- continue;
-#endif
- if (!metaclass) {
- metaclass = tmptype;
- continue;
- }
- if (PyType_IsSubtype(metaclass, tmptype))
- continue;
- if (PyType_IsSubtype(tmptype, metaclass)) {
- metaclass = tmptype;
- continue;
- }
- PyErr_SetString(PyExc_TypeError,
- "metaclass conflict: "
- "the metaclass of a derived class "
- "must be a (non-strict) subclass "
- "of the metaclasses of all its bases");
- return NULL;
- }
- if (!metaclass) {
-#if PY_MAJOR_VERSION < 3
- metaclass = &PyClass_Type;
-#else
- metaclass = &PyType_Type;
-#endif
- }
- Py_INCREF((PyObject*) metaclass);
- return (PyObject*) metaclass;
-}
-
-/* Py3ClassCreate */
- static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
- PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
- PyObject *ns;
- if (metaclass) {
- PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
- if (prep) {
- PyObject *pargs = PyTuple_Pack(2, name, bases);
- if (unlikely(!pargs)) {
- Py_DECREF(prep);
- return NULL;
- }
- ns = PyObject_Call(prep, pargs, mkw);
- Py_DECREF(prep);
- Py_DECREF(pargs);
- } else {
- if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- PyErr_Clear();
- ns = PyDict_New();
- }
- } else {
- ns = PyDict_New();
- }
- if (unlikely(!ns))
- return NULL;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
- if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
- return ns;
-bad:
- Py_DECREF(ns);
- return NULL;
-}
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
- PyObject *dict, PyObject *mkw,
- int calculate_metaclass, int allow_py2_metaclass) {
- PyObject *result, *margs;
- PyObject *owned_metaclass = NULL;
- if (allow_py2_metaclass) {
- owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
- if (owned_metaclass) {
- metaclass = owned_metaclass;
- } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
- PyErr_Clear();
- } else {
- return NULL;
- }
- }
- if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
- metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
- Py_XDECREF(owned_metaclass);
- if (unlikely(!metaclass))
- return NULL;
- owned_metaclass = metaclass;
- }
- margs = PyTuple_Pack(3, name, bases, dict);
- if (unlikely(!margs)) {
- result = NULL;
- } else {
- result = PyObject_Call(metaclass, margs, mkw);
- Py_DECREF(margs);
- }
- Py_XDECREF(owned_metaclass);
- return result;
-}
-
-/* FetchCommonType */
- static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunction */
- #include <structmember.h>
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value))) {
-#else
- if (unlikely(value == NULL || !PyString_Check(value))) {
-#endif
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromString(m->func.m_ml->ml_name);
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
- if (op == NULL)
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- PyObject_GC_Track(op);
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("<cyfunction %U at %p>",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("<cyfunction %s at %p>",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* CLineInTraceback */
- #ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (PyObject_Not(use_cline) != 0) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
- static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
- #include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) -1, const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *x) {
- const unsigned short neg_one = (unsigned short) -1, const_zero = (unsigned short) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(unsigned short) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(unsigned short, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (unsigned short) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (unsigned short) 0;
- case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, digits[0])
- case 2:
- if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) >= 2 * PyLong_SHIFT) {
- return (unsigned short) (((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) >= 3 * PyLong_SHIFT) {
- return (unsigned short) (((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) >= 4 * PyLong_SHIFT) {
- return (unsigned short) (((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (unsigned short) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(unsigned short) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned short) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (unsigned short) 0;
- case -1: __PYX_VERIFY_RETURN_INT(unsigned short, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, +digits[0])
- case -2:
- if (8 * sizeof(unsigned short) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
- return (unsigned short) (((unsigned short)-1)*(((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
- return (unsigned short) ((((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
- return (unsigned short) (((unsigned short)-1)*(((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
- return (unsigned short) ((((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) {
- return (unsigned short) (((unsigned short)-1)*(((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) {
- return (unsigned short) ((((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(unsigned short) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned short, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(unsigned short) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(unsigned short, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- unsigned short val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (unsigned short) -1;
- }
- } else {
- unsigned short val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (unsigned short) -1;
- val = __Pyx_PyInt_As_unsigned_short(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to unsigned short");
- return (unsigned short) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to unsigned short");
- return (unsigned short) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) -1, const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* ModuleImport */
- #ifndef __PYX_HAVE_RT_ImportModule
-#define __PYX_HAVE_RT_ImportModule
-static PyObject *__Pyx_ImportModule(const char *name) {
- PyObject *py_name = 0;
- PyObject *py_module = 0;
- py_name = __Pyx_PyIdentifier_FromString(name);
- if (!py_name)
- goto bad;
- py_module = PyImport_Import(py_name);
- Py_DECREF(py_name);
- return py_module;
-bad:
- Py_XDECREF(py_name);
- return 0;
-}
-#endif
-
-/* TypeImport */
- #ifndef __PYX_HAVE_RT_ImportType
-#define __PYX_HAVE_RT_ImportType
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
- size_t size, int strict)
-{
- PyObject *py_module = 0;
- PyObject *result = 0;
- PyObject *py_name = 0;
- char warning[200];
- Py_ssize_t basicsize;
-#ifdef Py_LIMITED_API
- PyObject *py_basicsize;
-#endif
- py_module = __Pyx_ImportModule(module_name);
- if (!py_module)
- goto bad;
- py_name = __Pyx_PyIdentifier_FromString(class_name);
- if (!py_name)
- goto bad;
- result = PyObject_GetAttr(py_module, py_name);
- Py_DECREF(py_name);
- py_name = 0;
- Py_DECREF(py_module);
- py_module = 0;
- if (!result)
- goto bad;
- if (!PyType_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s.%.200s is not a type object",
- module_name, class_name);
- goto bad;
- }
-#ifndef Py_LIMITED_API
- basicsize = ((PyTypeObject *)result)->tp_basicsize;
-#else
- py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
- if (!py_basicsize)
- goto bad;
- basicsize = PyLong_AsSsize_t(py_basicsize);
- Py_DECREF(py_basicsize);
- py_basicsize = 0;
- if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
- goto bad;
-#endif
- if (!strict && (size_t)basicsize > size) {
- PyOS_snprintf(warning, sizeof(warning),
- "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
- }
- else if ((size_t)basicsize != size) {
- PyErr_Format(PyExc_ValueError,
- "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
- module_name, class_name, basicsize, size);
- goto bad;
- }
- return (PyTypeObject *)result;
-bad:
- Py_XDECREF(py_module);
- Py_XDECREF(result);
- return NULL;
-}
-#endif
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(x);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/python/gevent/resolver/cares.cp36-win32.pyd b/python/gevent/resolver/cares.cp36-win32.pyd
deleted file mode 100644
index af58514..0000000
--- a/python/gevent/resolver/cares.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/gevent/resolver/cares.pyx b/python/gevent/resolver/cares.pyx
deleted file mode 100644
index cc43c13..0000000
--- a/python/gevent/resolver/cares.pyx
+++ /dev/null
@@ -1,464 +0,0 @@
-# Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details.
-# Automatic pickling of cdef classes was added in 0.26. Unfortunately it
-# seems to be buggy (at least for the `result` class) and produces code that
-# can't compile ("local variable 'result' referenced before assignment").
-# See https://github.com/cython/cython/issues/1786
-# cython: auto_pickle=False
-cimport libcares as cares
-import sys
-
-from cpython.ref cimport Py_INCREF
-from cpython.ref cimport Py_DECREF
-from cpython.mem cimport PyMem_Malloc
-from cpython.mem cimport PyMem_Free
-
-from _socket import gaierror
-
-
-__all__ = ['channel']
-
-cdef object string_types
-cdef object text_type
-
-if sys.version_info[0] >= 3:
- string_types = str,
- text_type = str
-else:
- string_types = __builtins__.basestring,
- text_type = __builtins__.unicode
-
-TIMEOUT = 1
-
-DEF EV_READ = 1
-DEF EV_WRITE = 2
-
-
-cdef extern from "dnshelper.c":
- int AF_INET
- int AF_INET6
-
- struct hostent:
- char* h_name
- int h_addrtype
-
- struct sockaddr_t "sockaddr":
- pass
-
- struct ares_channeldata:
- pass
-
- object parse_h_name(hostent*)
- object parse_h_aliases(hostent*)
- object parse_h_addr_list(hostent*)
- void* create_object_from_hostent(void*)
-
- # this imports _socket lazily
- object PyUnicode_FromString(char*)
- int PyTuple_Check(object)
- int PyArg_ParseTuple(object, char*, ...) except 0
- struct sockaddr_in6:
- pass
- int gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, sockaddr_in6* sa6)
-
-
- void memset(void*, int, int)
-
-
-ARES_SUCCESS = cares.ARES_SUCCESS
-ARES_ENODATA = cares.ARES_ENODATA
-ARES_EFORMERR = cares.ARES_EFORMERR
-ARES_ESERVFAIL = cares.ARES_ESERVFAIL
-ARES_ENOTFOUND = cares.ARES_ENOTFOUND
-ARES_ENOTIMP = cares.ARES_ENOTIMP
-ARES_EREFUSED = cares.ARES_EREFUSED
-ARES_EBADQUERY = cares.ARES_EBADQUERY
-ARES_EBADNAME = cares.ARES_EBADNAME
-ARES_EBADFAMILY = cares.ARES_EBADFAMILY
-ARES_EBADRESP = cares.ARES_EBADRESP
-ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
-ARES_ETIMEOUT = cares.ARES_ETIMEOUT
-ARES_EOF = cares.ARES_EOF
-ARES_EFILE = cares.ARES_EFILE
-ARES_ENOMEM = cares.ARES_ENOMEM
-ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
-ARES_EBADSTR = cares.ARES_EBADSTR
-ARES_EBADFLAGS = cares.ARES_EBADFLAGS
-ARES_ENONAME = cares.ARES_ENONAME
-ARES_EBADHINTS = cares.ARES_EBADHINTS
-ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
-ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
-ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
-ARES_ECANCELLED = cares.ARES_ECANCELLED
-
-ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
-ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
-ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
-ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
-ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
-ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
-ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
-ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP
-
-
-_ares_errors = dict([
- (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
- (cares.ARES_ENODATA, 'ARES_ENODATA'),
- (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
- (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
- (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
- (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
- (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
- (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
- (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
- (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
- (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
- (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
- (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
- (cares.ARES_EOF, 'ARES_EOF'),
- (cares.ARES_EFILE, 'ARES_EFILE'),
- (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
- (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
- (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
- (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
- (cares.ARES_ENONAME, 'ARES_ENONAME'),
- (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
- (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
- (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
- (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
- (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')])
-
-
-# maps c-ares flag to _socket module flag
-_cares_flag_map = None
-
-
-cdef _prepare_cares_flag_map():
- global _cares_flag_map
- import _socket
- _cares_flag_map = [
- (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
- (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
- (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
- (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
- (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)]
-
-
-cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
- if _cares_flag_map is None:
- _prepare_cares_flag_map()
- for socket_flag, cares_flag in _cares_flag_map:
- if socket_flag & flags:
- default |= cares_flag
- flags &= ~socket_flag
- if not flags:
- return default
- raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
-
-
-cpdef strerror(code):
- return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code))
-
-
-class InvalidIP(ValueError):
- pass
-
-
-cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
- if not data:
- return
- cdef channel ch = <channel>data
- ch._sock_state_callback(s, read, write)
-
-
-cdef class result:
- cdef public object value
- cdef public object exception
-
- def __init__(self, object value=None, object exception=None):
- self.value = value
- self.exception = exception
-
- def __repr__(self):
- if self.exception is None:
- return '%s(%r)' % (self.__class__.__name__, self.value)
- elif self.value is None:
- return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
- else:
- return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception)
- # add repr_recursive precaution
-
- def successful(self):
- return self.exception is None
-
- def get(self):
- if self.exception is not None:
- raise self.exception
- return self.value
-
-
-class ares_host_result(tuple):
-
- def __new__(cls, family, iterable):
- cdef object self = tuple.__new__(cls, iterable)
- self.family = family
- return self
-
- def __getnewargs__(self):
- return (self.family, tuple(self))
-
-
-cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host):
- cdef channel channel
- cdef object callback
- channel, callback = <tuple>arg
- Py_DECREF(<tuple>arg)
- cdef object host_result
- try:
- if status or not host:
- callback(result(None, gaierror(status, strerror(status))))
- else:
- try:
- host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
- except:
- callback(result(None, sys.exc_info()[1]))
- else:
- callback(result(host_result))
- except:
- channel.loop.handle_error(callback, *sys.exc_info())
-
-
-cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service):
- cdef channel channel
- cdef object callback
- channel, callback = <tuple>arg
- Py_DECREF(<tuple>arg)
- cdef object node
- cdef object service
- try:
- if status:
- callback(result(None, gaierror(status, strerror(status))))
- else:
- if c_node:
- node = PyUnicode_FromString(c_node)
- else:
- node = None
- if c_service:
- service = PyUnicode_FromString(c_service)
- else:
- service = None
- callback(result((node, service)))
- except:
- channel.loop.handle_error(callback, *sys.exc_info())
-
-
-cdef class channel:
-
- cdef public object loop
- cdef ares_channeldata* channel
- cdef public dict _watchers
- cdef public object _timer
-
- def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
- udp_port=None, tcp_port=None, servers=None):
- cdef ares_channeldata* channel = NULL
- cdef cares.ares_options options
- memset(&options, 0, sizeof(cares.ares_options))
- cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
- options.sock_state_cb = <void*>gevent_sock_state_callback
- options.sock_state_cb_data = <void*>self
- if flags is not None:
- options.flags = int(flags)
- optmask |= cares.ARES_OPT_FLAGS
- if timeout is not None:
- options.timeout = int(float(timeout) * 1000)
- optmask |= cares.ARES_OPT_TIMEOUTMS
- if tries is not None:
- options.tries = int(tries)
- optmask |= cares.ARES_OPT_TRIES
- if ndots is not None:
- options.ndots = int(ndots)
- optmask |= cares.ARES_OPT_NDOTS
- if udp_port is not None:
- options.udp_port = int(udp_port)
- optmask |= cares.ARES_OPT_UDP_PORT
- if tcp_port is not None:
- options.tcp_port = int(tcp_port)
- optmask |= cares.ARES_OPT_TCP_PORT
- cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
- if result:
- raise gaierror(result, strerror(result))
- result = cares.ares_init_options(&channel, &options, optmask)
- if result:
- raise gaierror(result, strerror(result))
- self._timer = loop.timer(TIMEOUT, TIMEOUT)
- self._watchers = {}
- self.channel = channel
- try:
- if servers is not None:
- self.set_servers(servers)
- self.loop = loop
- except:
- self.destroy()
- raise
-
- def __repr__(self):
- args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
- return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
-
- def destroy(self):
- if self.channel:
- # XXX ares_library_cleanup?
- cares.ares_destroy(self.channel)
- self.channel = NULL
- self._watchers.clear()
- self._timer.stop()
- self.loop = None
-
- def __dealloc__(self):
- if self.channel:
- # XXX ares_library_cleanup?
- cares.ares_destroy(self.channel)
- self.channel = NULL
-
- cpdef set_servers(self, servers=None):
- if not self.channel:
- raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- if not servers:
- servers = []
- if isinstance(servers, string_types):
- servers = servers.split(',')
- cdef int length = len(servers)
- cdef int result, index
- cdef char* string
- cdef cares.ares_addr_node* c_servers
- if length <= 0:
- result = cares.ares_set_servers(self.channel, NULL)
- else:
- c_servers = <cares.ares_addr_node*>PyMem_Malloc(sizeof(cares.ares_addr_node) * length)
- if not c_servers:
- raise MemoryError
- try:
- index = 0
- for server in servers:
- if isinstance(server, unicode):
- server = server.encode('ascii')
- string = <char*?>server
- if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
- c_servers[index].family = AF_INET
- elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
- c_servers[index].family = AF_INET6
- else:
- raise InvalidIP(repr(string))
- c_servers[index].next = &c_servers[index] + 1
- index += 1
- if index >= length:
- break
- c_servers[length - 1].next = NULL
- index = cares.ares_set_servers(self.channel, c_servers)
- if index:
- raise ValueError(strerror(index))
- finally:
- PyMem_Free(c_servers)
-
- # this crashes c-ares
- #def cancel(self):
- # cares.ares_cancel(self.channel)
-
- cdef _sock_state_callback(self, int socket, int read, int write):
- if not self.channel:
- return
- cdef object watcher = self._watchers.get(socket)
- cdef int events = 0
- if read:
- events |= EV_READ
- if write:
- events |= EV_WRITE
- if watcher is None:
- if not events:
- return
- watcher = self.loop.io(socket, events)
- self._watchers[socket] = watcher
- elif events:
- if watcher.events == events:
- return
- watcher.stop()
- watcher.events = events
- else:
- watcher.stop()
- watcher.close()
- self._watchers.pop(socket, None)
- if not self._watchers:
- self._timer.stop()
- return
- watcher.start(self._process_fd, watcher, pass_events=True)
- self._timer.again(self._on_timer)
-
- def _on_timer(self):
- cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
-
- def _process_fd(self, int events, object watcher):
- if not self.channel:
- return
- cdef int read_fd = watcher.fd
- cdef int write_fd = read_fd
- if not (events & EV_READ):
- read_fd = cares.ARES_SOCKET_BAD
- if not (events & EV_WRITE):
- write_fd = cares.ARES_SOCKET_BAD
- cares.ares_process_fd(self.channel, read_fd, write_fd)
-
- def gethostbyname(self, object callback, char* name, int family=AF_INET):
- if not self.channel:
- raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- # note that for file lookups still AF_INET can be returned for AF_INET6 request
- cdef object arg = (self, callback)
- Py_INCREF(arg)
- cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
-
- def gethostbyaddr(self, object callback, char* addr):
- if not self.channel:
- raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- # will guess the family
- cdef char addr_packed[16]
- cdef int family
- cdef int length
- if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0:
- family = AF_INET
- length = 4
- elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
- family = AF_INET6
- length = 16
- else:
- raise InvalidIP(repr(addr))
- cdef object arg = (self, callback)
- Py_INCREF(arg)
- cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
-
- cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
- if not self.channel:
- raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
- cdef char* hostp = NULL
- cdef int port = 0
- cdef int flowinfo = 0
- cdef int scope_id = 0
- cdef sockaddr_in6 sa6
- if not PyTuple_Check(sockaddr):
- raise TypeError('expected a tuple, got %r' % (sockaddr, ))
- PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
- if port < 0 or port > 65535:
- raise gaierror(-8, 'Invalid value for port: %r' % port)
- cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
- if length <= 0:
- raise InvalidIP(repr(hostp))
- cdef object arg = (self, callback)
- Py_INCREF(arg)
- cdef sockaddr_t* x = <sockaddr_t*>&sa6
- cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
-
- def getnameinfo(self, object callback, tuple sockaddr, int flags):
- try:
- flags = _convert_cares_flags(flags)
- except gaierror:
- # The stdlib just ignores bad flags
- flags = 0
- return self._getnameinfo(callback, sockaddr, flags)
diff --git a/python/gevent/resolver/cares_ntop.h b/python/gevent/resolver/cares_ntop.h
deleted file mode 100644
index 9ffc9dd..0000000
--- a/python/gevent/resolver/cares_ntop.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifdef CARES_EMBED
-#include "ares_setup.h"
-#include "ares.h"
-#else
-#include <arpa/inet.h>
-#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z)
-#endif
diff --git a/python/gevent/resolver/cares_pton.h b/python/gevent/resolver/cares_pton.h
deleted file mode 100644
index 85af403..0000000
--- a/python/gevent/resolver/cares_pton.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef CARES_EMBED
-#include "ares_setup.h"
-#include "ares_inet_net_pton.h"
-#else
-#include <arpa/inet.h>
-#define ares_inet_pton(x,y,z) inet_pton(x,y,z)
-#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
-#endif
diff --git a/python/gevent/resolver/dnshelper.c b/python/gevent/resolver/dnshelper.c
deleted file mode 100644
index 3befb69..0000000
--- a/python/gevent/resolver/dnshelper.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright (c) 2011 Denis Bilenko. See LICENSE for details. */
-#include "Python.h"
-#ifdef CARES_EMBED
-#include "ares_setup.h"
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#include "ares.h"
-
-#include "cares_ntop.h"
-#include "cares_pton.h"
-
-#if PY_VERSION_HEX < 0x02060000
- #define PyUnicode_FromString PyString_FromString
-#elif PY_MAJOR_VERSION < 3
- #define PyUnicode_FromString PyBytes_FromString
-#endif
-
-
-static PyObject* _socket_error = 0;
-
-static PyObject*
-get_socket_object(PyObject** pobject, const char* name)
-{
- if (!*pobject) {
- PyObject* _socket;
- _socket = PyImport_ImportModule("_socket");
- if (_socket) {
- *pobject = PyObject_GetAttrString(_socket, name);
- if (!*pobject) {
- PyErr_WriteUnraisable(Py_None);
- }
- Py_DECREF(_socket);
- }
- else {
- PyErr_WriteUnraisable(Py_None);
- }
- if (!*pobject) {
- *pobject = PyExc_IOError;
- }
- }
- return *pobject;
-}
-
-
-static int
-gevent_append_addr(PyObject* list, int family, void* src, char* tmpbuf, size_t tmpsize) {
- int status = -1;
- PyObject* tmp;
- if (ares_inet_ntop(family, src, tmpbuf, tmpsize)) {
- tmp = PyUnicode_FromString(tmpbuf);
- if (tmp) {
- status = PyList_Append(list, tmp);
- Py_DECREF(tmp);
- }
- }
- return status;
-}
-
-
-static PyObject*
-parse_h_name(struct hostent *h)
-{
- return PyUnicode_FromString(h->h_name);
-}
-
-
-static PyObject*
-parse_h_aliases(struct hostent *h)
-{
- char **pch;
- PyObject *result = NULL;
- PyObject *tmp;
-
- result = PyList_New(0);
-
- if (result && h->h_aliases) {
- for (pch = h->h_aliases; *pch != NULL; pch++) {
- if (*pch != h->h_name && strcmp(*pch, h->h_name)) {
- int status;
- tmp = PyUnicode_FromString(*pch);
- if (tmp == NULL) {
- break;
- }
-
- status = PyList_Append(result, tmp);
- Py_DECREF(tmp);
-
- if (status) {
- break;
- }
- }
- }
- }
-
- return result;
-}
-
-
-static PyObject *
-parse_h_addr_list(struct hostent *h)
-{
- char **pch;
- PyObject *result = NULL;
-
- result = PyList_New(0);
-
- if (result) {
- switch (h->h_addrtype) {
- case AF_INET:
- {
- char tmpbuf[sizeof "255.255.255.255"];
- for (pch = h->h_addr_list; *pch != NULL; pch++) {
- if (gevent_append_addr(result, AF_INET, *pch, tmpbuf, sizeof(tmpbuf))) {
- break;
- }
- }
- break;
- }
- case AF_INET6:
- {
- char tmpbuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
- for (pch = h->h_addr_list; *pch != NULL; pch++) {
- if (gevent_append_addr(result, AF_INET6, *pch, tmpbuf, sizeof(tmpbuf))) {
- break;
- }
- }
- break;
- }
- default:
- PyErr_SetString(get_socket_object(&_socket_error, "error"), "unsupported address family");
- Py_DECREF(result);
- result = NULL;
- }
- }
-
- return result;
-}
-
-
-static int
-gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, struct sockaddr_in6* sa6) {
- if ( ares_inet_pton(AF_INET, hostp, &((struct sockaddr_in*)sa6)->sin_addr.s_addr) > 0 ) {
- ((struct sockaddr_in*)sa6)->sin_family = AF_INET;
- ((struct sockaddr_in*)sa6)->sin_port = htons(port);
- return sizeof(struct sockaddr_in);
- }
- else if ( ares_inet_pton(AF_INET6, hostp, &sa6->sin6_addr.s6_addr) > 0 ) {
- sa6->sin6_family = AF_INET6;
- sa6->sin6_port = htons(port);
- sa6->sin6_flowinfo = flowinfo;
- sa6->sin6_scope_id = scope_id;
- return sizeof(struct sockaddr_in6);
- }
- return -1;
-}
diff --git a/python/gevent/resolver/dnspython.py b/python/gevent/resolver/dnspython.py
deleted file mode 100644
index c2ae73b..0000000
--- a/python/gevent/resolver/dnspython.py
+++ /dev/null
@@ -1,662 +0,0 @@
-# Copyright (c) 2018 gevent contributors. See LICENSE for details.
-
-# Portions of this code taken from the gogreen project:
-# http://github.com/slideinc/gogreen
-#
-# Copyright (c) 2005-2010 Slide, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of the author nor the names of other
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Portions of this code taken from the eventlet project:
-# https://github.com/eventlet/eventlet/blob/master/eventlet/support/greendns.py
-
-# Unless otherwise noted, the files in Eventlet are under the following MIT license:
-
-# Copyright (c) 2005-2006, Bob Ippolito
-# Copyright (c) 2007-2010, Linden Research, Inc.
-# Copyright (c) 2008-2010, Eventlet Contributors (see AUTHORS)
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-from __future__ import absolute_import, print_function, division
-
-import time
-import re
-import os
-import sys
-
-import _socket
-from _socket import AI_NUMERICHOST
-from _socket import error
-from _socket import NI_NUMERICSERV
-from _socket import AF_INET
-from _socket import AF_INET6
-from _socket import AF_UNSPEC
-
-import socket
-
-from . import AbstractResolver
-from . import hostname_types
-
-from gevent._compat import string_types
-from gevent._compat import iteritems
-from gevent._patcher import import_patched
-from gevent._config import config
-
-__all__ = [
- 'Resolver',
-]
-
-# Import the DNS packages to use the gevent modules,
-# even if the system is not monkey-patched.
-def _patch_dns():
- top = import_patched('dns')
- for pkg in ('dns',
- 'dns.rdtypes',
- 'dns.rdtypes.IN',
- 'dns.rdtypes.ANY'):
- mod = import_patched(pkg)
- for name in mod.__all__:
- setattr(mod, name, import_patched(pkg + '.' + name))
- return top
-
-dns = _patch_dns()
-
-def _dns_import_patched(name):
- assert name.startswith('dns')
- import_patched(name)
- return dns
-
-# This module tries to dynamically import classes
-# using __import__, and it's important that they match
-# the ones we just created, otherwise exceptions won't be caught
-# as expected. It uses a one-arg __import__ statement and then
-# tries to walk down the sub-modules using getattr, so we can't
-# directly use import_patched as-is.
-dns.rdata.__import__ = _dns_import_patched
-
-resolver = dns.resolver
-dTimeout = dns.resolver.Timeout
-
-_exc_clear = getattr(sys, 'exc_clear', lambda: None)
-
-# This is a copy of resolver._getaddrinfo with the crucial change that it
-# doesn't have a bare except:, because that breaks Timeout and KeyboardInterrupt
-# A secondary change is that calls to sys.exc_clear() have been inserted to avoid
-# failing tests in test__refcount.py (timeouts).
-# See https://github.com/rthalley/dnspython/pull/300
-def _getaddrinfo(host=None, service=None, family=AF_UNSPEC, socktype=0,
- proto=0, flags=0):
- # pylint:disable=too-many-locals,broad-except,too-many-statements
- # pylint:disable=too-many-branches
- # pylint:disable=redefined-argument-from-local
- # pylint:disable=consider-using-in
- if flags & (socket.AI_ADDRCONFIG | socket.AI_V4MAPPED) != 0:
- raise NotImplementedError
- if host is None and service is None:
- raise socket.gaierror(socket.EAI_NONAME)
- v6addrs = []
- v4addrs = []
- canonical_name = None
- try:
- # Is host None or a V6 address literal?
- if host is None:
- canonical_name = 'localhost'
- if flags & socket.AI_PASSIVE != 0:
- v6addrs.append('::')
- v4addrs.append('0.0.0.0')
- else:
- v6addrs.append('::1')
- v4addrs.append('127.0.0.1')
- else:
- parts = host.split('%')
- if len(parts) == 2:
- ahost = parts[0]
- else:
- ahost = host
- addr = dns.ipv6.inet_aton(ahost)
- v6addrs.append(host)
- canonical_name = host
- except Exception:
- _exc_clear()
- try:
- # Is it a V4 address literal?
- addr = dns.ipv4.inet_aton(host)
- v4addrs.append(host)
- canonical_name = host
- except Exception:
- _exc_clear()
- if flags & socket.AI_NUMERICHOST == 0:
- try:
- if family == socket.AF_INET6 or family == socket.AF_UNSPEC:
- v6 = resolver._resolver.query(host, dns.rdatatype.AAAA,
- raise_on_no_answer=False)
- # Note that setting host ensures we query the same name
- # for A as we did for AAAA.
- host = v6.qname
- canonical_name = v6.canonical_name.to_text(True)
- if v6.rrset is not None:
- for rdata in v6.rrset:
- v6addrs.append(rdata.address)
- if family == socket.AF_INET or family == socket.AF_UNSPEC:
- v4 = resolver._resolver.query(host, dns.rdatatype.A,
- raise_on_no_answer=False)
- host = v4.qname
- canonical_name = v4.canonical_name.to_text(True)
- if v4.rrset is not None:
- for rdata in v4.rrset:
- v4addrs.append(rdata.address)
- except dns.resolver.NXDOMAIN:
- _exc_clear()
- raise socket.gaierror(socket.EAI_NONAME)
- except Exception:
- _exc_clear()
- raise socket.gaierror(socket.EAI_SYSTEM)
- port = None
- try:
- # Is it a port literal?
- if service is None:
- port = 0
- else:
- port = int(service)
- except Exception:
- _exc_clear()
- if flags & socket.AI_NUMERICSERV == 0:
- try:
- port = socket.getservbyname(service)
- except Exception:
- _exc_clear()
-
- if port is None:
- raise socket.gaierror(socket.EAI_NONAME)
- tuples = []
- if socktype == 0:
- socktypes = [socket.SOCK_DGRAM, socket.SOCK_STREAM]
- else:
- socktypes = [socktype]
- if flags & socket.AI_CANONNAME != 0:
- cname = canonical_name
- else:
- cname = ''
- if family == socket.AF_INET6 or family == socket.AF_UNSPEC:
- for addr in v6addrs:
- for socktype in socktypes:
- for proto in resolver._protocols_for_socktype[socktype]:
- tuples.append((socket.AF_INET6, socktype, proto,
- cname, (addr, port, 0, 0))) # XXX: gevent: this can get the scopeid wrong
- if family == socket.AF_INET or family == socket.AF_UNSPEC:
- for addr in v4addrs:
- for socktype in socktypes:
- for proto in resolver._protocols_for_socktype[socktype]:
- tuples.append((socket.AF_INET, socktype, proto,
- cname, (addr, port)))
- if len(tuples) == 0: # pylint:disable=len-as-condition
- raise socket.gaierror(socket.EAI_NONAME)
- return tuples
-
-
-resolver._getaddrinfo = _getaddrinfo
-
-HOSTS_TTL = 300.0
-
-def _is_addr(host, parse=dns.ipv4.inet_aton):
- if not host:
- return False
- assert isinstance(host, hostname_types), repr(host)
- try:
- parse(host)
- except dns.exception.SyntaxError:
- return False
- else:
- return True
-
-# Return True if host is a valid IPv4 address
-_is_ipv4_addr = _is_addr
-
-
-def _is_ipv6_addr(host):
- # Return True if host is a valid IPv6 address
- if host:
- s = '%' if isinstance(host, str) else b'%'
- host = host.split(s, 1)[0]
- return _is_addr(host, dns.ipv6.inet_aton)
-
-class HostsFile(object):
- """
- A class to read the contents of a hosts file (/etc/hosts).
- """
-
- LINES_RE = re.compile(r"""
- \s* # Leading space
- ([^\r\n#]+?) # The actual match, non-greedy so as not to include trailing space
- \s* # Trailing space
- (?:[#][^\r\n]+)? # Comments
- (?:$|[\r\n]+) # EOF or newline
- """, re.VERBOSE)
-
- def __init__(self, fname=None):
- self.v4 = {} # name -> ipv4
- self.v6 = {} # name -> ipv6
- self.aliases = {} # name -> canonical_name
- self.reverse = {} # ip addr -> some name
- if fname is None:
- if os.name == 'posix':
- fname = '/etc/hosts'
- elif os.name == 'nt': # pragma: no cover
- fname = os.path.expandvars(
- r'%SystemRoot%\system32\drivers\etc\hosts')
- self.fname = fname
- assert self.fname
- self._last_load = 0
-
-
- def _readlines(self):
- # Read the contents of the hosts file.
- #
- # Return list of lines, comment lines and empty lines are
- # excluded. Note that this performs disk I/O so can be
- # blocking.
- with open(self.fname, 'rb') as fp:
- fdata = fp.read()
-
-
- # XXX: Using default decoding. Is that correct?
- udata = fdata.decode(errors='ignore') if not isinstance(fdata, str) else fdata
-
- return self.LINES_RE.findall(udata)
-
- def load(self): # pylint:disable=too-many-locals
- # Load hosts file
-
- # This will (re)load the data from the hosts
- # file if it has changed.
-
- try:
- load_time = os.stat(self.fname).st_mtime
- needs_load = load_time > self._last_load
- except (IOError, OSError):
- from gevent import get_hub
- get_hub().handle_error(self, *sys.exc_info())
- needs_load = False
-
- if not needs_load:
- return
-
- v4 = {}
- v6 = {}
- aliases = {}
- reverse = {}
-
- for line in self._readlines():
- parts = line.split()
- if len(parts) < 2:
- continue
- ip = parts.pop(0)
- if _is_ipv4_addr(ip):
- ipmap = v4
- elif _is_ipv6_addr(ip):
- if ip.startswith('fe80'):
- # Do not use link-local addresses, OSX stores these here
- continue
- ipmap = v6
- else:
- continue
- cname = parts.pop(0).lower()
- ipmap[cname] = ip
- for alias in parts:
- alias = alias.lower()
- ipmap[alias] = ip
- aliases[alias] = cname
-
- # XXX: This is wrong for ipv6
- if ipmap is v4:
- ptr = '.'.join(reversed(ip.split('.'))) + '.in-addr.arpa'
- else:
- ptr = ip + '.ip6.arpa.'
- if ptr not in reverse:
- reverse[ptr] = cname
-
- self._last_load = load_time
- self.v4 = v4
- self.v6 = v6
- self.aliases = aliases
- self.reverse = reverse
-
- def iter_all_host_addr_pairs(self):
- self.load()
- for name, addr in iteritems(self.v4):
- yield name, addr
- for name, addr in iteritems(self.v6):
- yield name, addr
-
-class _HostsAnswer(dns.resolver.Answer):
- # Answer class for HostsResolver object
-
- def __init__(self, qname, rdtype, rdclass, rrset, raise_on_no_answer=True):
- self.response = None
- self.qname = qname
- self.rdtype = rdtype
- self.rdclass = rdclass
- self.canonical_name = qname
- if not rrset and raise_on_no_answer:
- raise dns.resolver.NoAnswer()
- self.rrset = rrset
- self.expiration = (time.time() +
- rrset.ttl if hasattr(rrset, 'ttl') else 0)
-
-
-class _HostsResolver(object):
- """
- Class to parse the hosts file
- """
-
- def __init__(self, fname=None, interval=HOSTS_TTL):
- self.hosts_file = HostsFile(fname)
- self.interval = interval
- self._last_load = 0
-
- def query(self, qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
- tcp=False, source=None, raise_on_no_answer=True): # pylint:disable=unused-argument
- # Query the hosts file
- #
- # The known rdtypes are dns.rdatatype.A, dns.rdatatype.AAAA and
- # dns.rdatatype.CNAME.
- # The ``rdclass`` parameter must be dns.rdataclass.IN while the
- # ``tcp`` and ``source`` parameters are ignored.
- # Return a HostAnswer instance or raise a dns.resolver.NoAnswer
- # exception.
-
- now = time.time()
- hosts_file = self.hosts_file
- if self._last_load + self.interval < now:
- self._last_load = now
- hosts_file.load()
-
- rdclass = dns.rdataclass.IN # Always
- if isinstance(qname, string_types):
- name = qname
- qname = dns.name.from_text(qname)
- else:
- name = str(qname)
-
- name = name.lower()
- rrset = dns.rrset.RRset(qname, rdclass, rdtype)
- rrset.ttl = self._last_load + self.interval - now
-
- if rdtype == dns.rdatatype.A:
- mapping = hosts_file.v4
- kind = dns.rdtypes.IN.A.A
- elif rdtype == dns.rdatatype.AAAA:
- mapping = hosts_file.v6
- kind = dns.rdtypes.IN.AAAA.AAAA
- elif rdtype == dns.rdatatype.CNAME:
- mapping = hosts_file.aliases
- kind = lambda c, t, addr: dns.rdtypes.ANY.CNAME.CNAME(c, t, dns.name.from_text(addr))
- elif rdtype == dns.rdatatype.PTR:
- mapping = hosts_file.reverse
- kind = lambda c, t, addr: dns.rdtypes.ANY.PTR.PTR(c, t, dns.name.from_text(addr))
-
-
- addr = mapping.get(name)
- if not addr and qname.is_absolute():
- addr = mapping.get(name[:-1])
- if addr:
- rrset.add(kind(rdclass, rdtype, addr))
- return _HostsAnswer(qname, rdtype, rdclass, rrset, raise_on_no_answer)
-
- def getaliases(self, hostname):
- # Return a list of all the aliases of a given cname
-
- # Due to the way store aliases this is a bit inefficient, this
- # clearly was an afterthought. But this is only used by
- # gethostbyname_ex so it's probably fine.
- aliases = self.hosts_file.aliases
- result = []
- if hostname in aliases:
- cannon = aliases[hostname]
- else:
- cannon = hostname
- result.append(cannon)
- for alias, cname in iteritems(aliases):
- if cannon == cname:
- result.append(alias)
- result.remove(hostname)
- return result
-
-class _DualResolver(object):
-
- def __init__(self):
- self.hosts_resolver = _HostsResolver()
- self.network_resolver = resolver.get_default_resolver()
- self.network_resolver.cache = resolver.LRUCache()
-
- def query(self, qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
- tcp=False, source=None, raise_on_no_answer=True,
- _hosts_rdtypes=(dns.rdatatype.A, dns.rdatatype.AAAA, dns.rdatatype.PTR)):
- # Query the resolver, using /etc/hosts
-
- # Behavior:
- # 1. if hosts is enabled and contains answer, return it now
- # 2. query nameservers for qname
- if qname is None:
- qname = '0.0.0.0'
-
- if not isinstance(qname, string_types):
- if isinstance(qname, bytes):
- qname = qname.decode("idna")
-
- if isinstance(qname, string_types):
- qname = dns.name.from_text(qname, None)
-
- if isinstance(rdtype, string_types):
- rdtype = dns.rdatatype.from_text(rdtype)
-
- if rdclass == dns.rdataclass.IN and rdtype in _hosts_rdtypes:
- try:
- answer = self.hosts_resolver.query(qname, rdtype, raise_on_no_answer=False)
- except Exception: # pylint: disable=broad-except
- from gevent import get_hub
- get_hub().handle_error(self, *sys.exc_info())
- else:
- if answer.rrset:
- return answer
-
- return self.network_resolver.query(qname, rdtype, rdclass,
- tcp, source, raise_on_no_answer=raise_on_no_answer)
-
-def _family_to_rdtype(family):
- if family == socket.AF_INET:
- rdtype = dns.rdatatype.A
- elif family == socket.AF_INET6:
- rdtype = dns.rdatatype.AAAA
- else:
- raise socket.gaierror(socket.EAI_FAMILY,
- 'Address family not supported')
- return rdtype
-
-class Resolver(AbstractResolver):
- """
- An *experimental* resolver that uses `dnspython`_.
-
- This is typically slower than the default threaded resolver
- (unless there's a cache hit, in which case it can be much faster).
- It is usually much faster than the c-ares resolver. It tends to
- scale well as more concurrent resolutions are attempted.
-
- Under Python 2, if the ``idna`` package is installed, this
- resolver can resolve Unicode host names that the system resolver
- cannot.
-
- .. note::
-
- This **does not** use dnspython's default resolver object, or share any
- classes with ``import dns``. A separate copy of the objects is imported to
- be able to function in a non monkey-patched process. The documentation for the resolver
- object still applies.
-
- The resolver that we use is available as the :attr:`resolver` attribute
- of this object (typically ``gevent.get_hub().resolver.resolver``).
-
- .. caution::
-
- Many of the same caveats about DNS results apply here as are documented
- for :class:`gevent.resolver.ares.Resolver`.
-
- .. caution::
-
- This resolver is experimental. It may be removed or modified in
- the future. As always, feedback is welcome.
-
- .. versionadded:: 1.3a2
-
- .. _dnspython: http://www.dnspython.org
- """
-
- def __init__(self, hub=None): # pylint: disable=unused-argument
- if resolver._resolver is None:
- _resolver = resolver._resolver = _DualResolver()
- if config.resolver_nameservers:
- _resolver.network_resolver.nameservers[:] = config.resolver_nameservers
- if config.resolver_timeout:
- _resolver.network_resolver.lifetime = config.resolver_timeout
- # Different hubs in different threads could be sharing the same
- # resolver.
- assert isinstance(resolver._resolver, _DualResolver)
- self._resolver = resolver._resolver
-
- @property
- def resolver(self):
- """
- The dnspython resolver object we use.
-
- This object has several useful attributes that can be used to
- adjust the behaviour of the DNS system:
-
- * ``cache`` is a :class:`dns.resolver.LRUCache`. Its maximum size
- can be configured by calling :meth:`resolver.cache.set_max_size`
- * ``nameservers`` controls which nameservers to talk to
- * ``lifetime`` configures a timeout for each individual query.
- """
- return self._resolver.network_resolver
-
- def close(self):
- pass
-
- def _getaliases(self, hostname, family):
- if not isinstance(hostname, str):
- if isinstance(hostname, bytes):
- hostname = hostname.decode("idna")
- aliases = self._resolver.hosts_resolver.getaliases(hostname)
- net_resolver = self._resolver.network_resolver
- rdtype = _family_to_rdtype(family)
- while True:
- try:
- ans = net_resolver.query(hostname, dns.rdatatype.CNAME, rdtype)
- except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN, dns.resolver.NoNameservers):
- break
- except dTimeout:
- break
- else:
- aliases.extend(str(rr.target) for rr in ans.rrset)
- hostname = ans[0].target
- return aliases
-
- def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0):
- if ((host in (u'localhost', b'localhost')
- or (_is_ipv6_addr(host) and host.startswith('fe80')))
- or not isinstance(host, str) or (flags & AI_NUMERICHOST)):
- # this handles cases which do not require network access
- # 1) host is None
- # 2) host is of an invalid type
- # 3) host is localhost or a link-local ipv6; dnspython returns the wrong
- # scope-id for those.
- # 3) AI_NUMERICHOST flag is set
-
- return _socket.getaddrinfo(host, port, family, socktype, proto, flags)
-
- if family == AF_UNSPEC:
- # This tends to raise in the case that a v6 address did not exist
- # but a v4 does. So we break it into two parts.
-
- # Note that if there is no ipv6 in the hosts file, but there *is*
- # an ipv4, and there *is* an ipv6 in the nameservers, we will return
- # both (from the first call). The system resolver on OS X only returns
- # the results from the hosts file. doubleclick.com is one example.
-
- # See also https://github.com/gevent/gevent/issues/1012
- try:
- return _getaddrinfo(host, port, family, socktype, proto, flags)
- except socket.gaierror:
- try:
- return _getaddrinfo(host, port, AF_INET6, socktype, proto, flags)
- except socket.gaierror:
- return _getaddrinfo(host, port, AF_INET, socktype, proto, flags)
- else:
- return _getaddrinfo(host, port, family, socktype, proto, flags)
-
- def getnameinfo(self, sockaddr, flags):
- if (sockaddr
- and isinstance(sockaddr, (list, tuple))
- and sockaddr[0] in ('::1', '127.0.0.1', 'localhost')):
- return _socket.getnameinfo(sockaddr, flags)
- if isinstance(sockaddr, (list, tuple)) and not isinstance(sockaddr[0], hostname_types):
- raise TypeError("getnameinfo(): illegal sockaddr argument")
- try:
- return resolver._getnameinfo(sockaddr, flags)
- except error:
- if not flags:
- # dnspython doesn't like getting ports it can't resolve.
- # We have one test, test__socket_dns.py:Test_getnameinfo_geventorg.test_port_zero
- # that does this. We conservatively fix it here; this could be expanded later.
- return resolver._getnameinfo(sockaddr, NI_NUMERICSERV)
-
- def gethostbyaddr(self, ip_address):
- if ip_address in (u'127.0.0.1', u'::1',
- b'127.0.0.1', b'::1',
- 'localhost'):
- return _socket.gethostbyaddr(ip_address)
-
- if not isinstance(ip_address, hostname_types):
- raise TypeError("argument 1 must be str, bytes or bytearray, not %s" % (type(ip_address),))
-
- return resolver._gethostbyaddr(ip_address)
diff --git a/python/gevent/resolver/libcares.pxd b/python/gevent/resolver/libcares.pxd
deleted file mode 100644
index 7b551a7..0000000
--- a/python/gevent/resolver/libcares.pxd
+++ /dev/null
@@ -1,109 +0,0 @@
-cdef extern from "ares.h":
- struct ares_options:
- int flags
- void* sock_state_cb
- void* sock_state_cb_data
- int timeout
- int tries
- int ndots
- unsigned short udp_port
- unsigned short tcp_port
- char **domains
- int ndomains
- char* lookups
-
- int ARES_OPT_FLAGS
- int ARES_OPT_SOCK_STATE_CB
- int ARES_OPT_TIMEOUTMS
- int ARES_OPT_TRIES
- int ARES_OPT_NDOTS
- int ARES_OPT_TCP_PORT
- int ARES_OPT_UDP_PORT
- int ARES_OPT_SERVERS
- int ARES_OPT_DOMAINS
- int ARES_OPT_LOOKUPS
-
- int ARES_FLAG_USEVC
- int ARES_FLAG_PRIMARY
- int ARES_FLAG_IGNTC
- int ARES_FLAG_NORECURSE
- int ARES_FLAG_STAYOPEN
- int ARES_FLAG_NOSEARCH
- int ARES_FLAG_NOALIASES
- int ARES_FLAG_NOCHECKRESP
-
- int ARES_LIB_INIT_ALL
- int ARES_SOCKET_BAD
-
- int ARES_SUCCESS
- int ARES_ENODATA
- int ARES_EFORMERR
- int ARES_ESERVFAIL
- int ARES_ENOTFOUND
- int ARES_ENOTIMP
- int ARES_EREFUSED
- int ARES_EBADQUERY
- int ARES_EBADNAME
- int ARES_EBADFAMILY
- int ARES_EBADRESP
- int ARES_ECONNREFUSED
- int ARES_ETIMEOUT
- int ARES_EOF
- int ARES_EFILE
- int ARES_ENOMEM
- int ARES_EDESTRUCTION
- int ARES_EBADSTR
- int ARES_EBADFLAGS
- int ARES_ENONAME
- int ARES_EBADHINTS
- int ARES_ENOTINITIALIZED
- int ARES_ELOADIPHLPAPI
- int ARES_EADDRGETNETWORKPARAMS
- int ARES_ECANCELLED
-
- int ARES_NI_NOFQDN
- int ARES_NI_NUMERICHOST
- int ARES_NI_NAMEREQD
- int ARES_NI_NUMERICSERV
- int ARES_NI_DGRAM
- int ARES_NI_TCP
- int ARES_NI_UDP
- int ARES_NI_SCTP
- int ARES_NI_DCCP
- int ARES_NI_NUMERICSCOPE
- int ARES_NI_LOOKUPHOST
- int ARES_NI_LOOKUPSERVICE
-
-
- int ares_library_init(int flags)
- void ares_library_cleanup()
- int ares_init_options(void *channelptr, ares_options *options, int)
- int ares_init(void *channelptr)
- void ares_destroy(void *channelptr)
- void ares_gethostbyname(void* channel, char *name, int family, void* callback, void *arg)
- void ares_gethostbyaddr(void* channel, void *addr, int addrlen, int family, void* callback, void *arg)
- void ares_process_fd(void* channel, int read_fd, int write_fd)
- char* ares_strerror(int code)
- void ares_cancel(void* channel)
- void ares_getnameinfo(void* channel, void* sa, int salen, int flags, void* callback, void *arg)
-
- struct in_addr:
- pass
-
- struct ares_in6_addr:
- pass
-
- struct addr_union:
- in_addr addr4
- ares_in6_addr addr6
-
- struct ares_addr_node:
- ares_addr_node *next
- int family
- addr_union addr
-
- int ares_set_servers(void* channel, ares_addr_node *servers)
-
-
-cdef extern from "cares_pton.h":
- int ares_inet_pton(int af, char *src, void *dst)
diff --git a/python/gevent/resolver/thread.py b/python/gevent/resolver/thread.py
deleted file mode 100644
index df71706..0000000
--- a/python/gevent/resolver/thread.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (c) 2012-2015 Denis Bilenko. See LICENSE for details.
-"""
-Native thread-based hostname resolver.
-"""
-import _socket
-
-from gevent.hub import get_hub
-
-
-__all__ = ['Resolver']
-
-
-# trigger import of encodings.idna to avoid https://github.com/gevent/gevent/issues/349
-u'foo'.encode('idna')
-
-
-class Resolver(object):
- """
- Implementation of the resolver API using native threads and native resolution
- functions.
-
- Using the native resolution mechanisms ensures the highest
- compatibility with what a non-gevent program would return
- including good support for platform specific configuration
- mechanisms. The use of native (non-greenlet) threads ensures that
- a caller doesn't block other greenlets.
-
- This implementation also has the benefit of being very simple in comparison to
- :class:`gevent.resolver_ares.Resolver`.
-
- .. tip::
-
- Most users find this resolver to be quite reliable in a
- properly monkey-patched environment. However, there have been
- some reports of long delays, slow performance or even hangs,
- particularly in long-lived programs that make many, many DNS
- requests. If you suspect that may be happening to you, try the
- dnspython or ares resolver (and submit a bug report).
- """
- def __init__(self, hub=None):
- if hub is None:
- hub = get_hub()
- self.pool = hub.threadpool
- if _socket.gaierror not in hub.NOT_ERROR:
- # Do not cause lookup failures to get printed by the default
- # error handler. This can be very noisy.
- hub.NOT_ERROR += (_socket.gaierror, _socket.herror)
-
- def __repr__(self):
- return '<gevent.resolver_thread.Resolver at 0x%x pool=%r>' % (id(self), self.pool)
-
- def close(self):
- pass
-
- # from briefly reading socketmodule.c, it seems that all of the functions
- # below are thread-safe in Python, even if they are not thread-safe in C.
-
- def gethostbyname(self, *args):
- return self.pool.apply(_socket.gethostbyname, args)
-
- def gethostbyname_ex(self, *args):
- return self.pool.apply(_socket.gethostbyname_ex, args)
-
- def getaddrinfo(self, *args, **kwargs):
- return self.pool.apply(_socket.getaddrinfo, args, kwargs)
-
- def gethostbyaddr(self, *args, **kwargs):
- return self.pool.apply(_socket.gethostbyaddr, args, kwargs)
-
- def getnameinfo(self, *args, **kwargs):
- return self.pool.apply(_socket.getnameinfo, args, kwargs)
diff --git a/python/gevent/resolver_ares.py b/python/gevent/resolver_ares.py
deleted file mode 100644
index f3c992d..0000000
--- a/python/gevent/resolver_ares.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Backwards compatibility alias for :mod:`gevent.resolver.ares`.
-
-.. deprecated:: 1.3
- Use :mod:`gevent.resolver.ares`
-"""
-
-from gevent.resolver.ares import * # pylint:disable=wildcard-import,unused-wildcard-import
-import gevent.resolver.ares as _ares
-__all__ = _ares.__all__
-del _ares
diff --git a/python/gevent/resolver_thread.py b/python/gevent/resolver_thread.py
deleted file mode 100644
index a8687e7..0000000
--- a/python/gevent/resolver_thread.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Backwards compatibility alias for :mod:`gevent.resolver.thread`.
-
-.. deprecated:: 1.3
- Use :mod:`gevent.resolver.cares`
-"""
-
-from gevent.resolver.thread import * # pylint:disable=wildcard-import,unused-wildcard-import
-import gevent.resolver.thread as _thread
-__all__ = _thread.__all__
-del _thread
diff --git a/python/gevent/select.py b/python/gevent/select.py
deleted file mode 100644
index a4c182c..0000000
--- a/python/gevent/select.py
+++ /dev/null
@@ -1,286 +0,0 @@
-# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details.
-"""
-Waiting for I/O completion.
-"""
-from __future__ import absolute_import, division, print_function
-
-import sys
-
-from gevent.event import Event
-from gevent.hub import _get_hub_noargs as get_hub
-from gevent.hub import sleep as _g_sleep
-from gevent._compat import integer_types
-from gevent._compat import iteritems
-from gevent._util import copy_globals
-from gevent._util import _NONE
-
-from errno import EINTR
-from select import select as _real_original_select
-if sys.platform.startswith('win32'):
- def _original_select(r, w, x, t):
- # windows cant handle three empty lists, but we've always
- # accepted that
- if not r and not w and not x:
- return ((), (), ())
- return _real_original_select(r, w, x, t)
-else:
- _original_select = _real_original_select
-
-
-try:
- from select import poll as original_poll
- from select import POLLIN, POLLOUT, POLLNVAL
- __implements__ = ['select', 'poll']
-except ImportError:
- original_poll = None
- __implements__ = ['select']
-
-__all__ = ['error'] + __implements__
-
-import select as __select__
-
-error = __select__.error
-
-__imports__ = copy_globals(__select__, globals(),
- names_to_ignore=__all__,
- dunder_names_to_keep=())
-
-_EV_READ = 1
-_EV_WRITE = 2
-
-def get_fileno(obj):
- try:
- fileno_f = obj.fileno
- except AttributeError:
- if not isinstance(obj, integer_types):
- raise TypeError('argument must be an int, or have a fileno() method: %r' % (obj,))
- return obj
- else:
- return fileno_f()
-
-
-class SelectResult(object):
- __slots__ = ('read', 'write', 'event')
-
- def __init__(self):
- self.read = []
- self.write = []
- self.event = Event()
-
- def add_read(self, socket):
- self.read.append(socket)
- self.event.set()
-
- add_read.event = _EV_READ
-
- def add_write(self, socket):
- self.write.append(socket)
- self.event.set()
-
- add_write.event = _EV_WRITE
-
- def __add_watchers(self, watchers, fdlist, callback, io, pri):
- for fd in fdlist:
- watcher = io(get_fileno(fd), callback.event)
- watcher.priority = pri
- watchers.append(watcher)
- watcher.start(callback, fd)
-
- def _make_watchers(self, watchers, rlist, wlist):
- loop = get_hub().loop
- io = loop.io
- MAXPRI = loop.MAXPRI
-
- try:
- self.__add_watchers(watchers, rlist, self.add_read, io, MAXPRI)
- self.__add_watchers(watchers, wlist, self.add_write, io, MAXPRI)
- except IOError as ex:
- raise error(*ex.args)
-
- def _closeall(self, watchers):
- for watcher in watchers:
- watcher.stop()
- watcher.close()
- del watchers[:]
-
- def select(self, rlist, wlist, timeout):
- watchers = []
- try:
- self._make_watchers(watchers, rlist, wlist)
- self.event.wait(timeout=timeout)
- return self.read, self.write, []
- finally:
- self._closeall(watchers)
-
-
-def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument
- """An implementation of :meth:`select.select` that blocks only the current greenlet.
-
- .. caution:: *xlist* is ignored.
-
- .. versionchanged:: 1.2a1
- Raise a :exc:`ValueError` if timeout is negative. This matches Python 3's
- behaviour (Python 2 would raise a ``select.error``). Previously gevent had
- undefined behaviour.
- .. versionchanged:: 1.2a1
- Raise an exception if any of the file descriptors are invalid.
- """
- if timeout is not None and timeout < 0:
- # Raise an error like the real implementation; which error
- # depends on the version. Python 3, where select.error is OSError,
- # raises a ValueError (which makes sense). Older pythons raise
- # the error from the select syscall...but we don't actually get there.
- # We choose to just raise the ValueError as it makes more sense and is
- # forward compatible
- raise ValueError("timeout must be non-negative")
-
- # First, do a poll with the original select system call. This
- # is the most efficient way to check to see if any of the file descriptors
- # have previously been closed and raise the correct corresponding exception.
- # (Because libev tends to just return them as ready...)
- # We accept the *xlist* here even though we can't below because this is all about
- # error handling.
- sel_results = ((), (), ())
- try:
- sel_results = _original_select(rlist, wlist, xlist, 0)
- except error as e:
- enumber = getattr(e, 'errno', None) or e.args[0]
- if enumber != EINTR:
- # Ignore interrupted syscalls
- raise
-
- if sel_results[0] or sel_results[1] or sel_results[2] or (timeout is not None and timeout == 0):
- # If we actually had stuff ready, go ahead and return it. No need
- # to go through the trouble of doing our own stuff.
-
- # Likewise, if the timeout is 0, we already did a 0 timeout
- # select and we don't need to do it again. Note that in libuv,
- # zero duration timers may be called immediately, without
- # cycling the event loop at all. 2.7/test_telnetlib.py "hangs"
- # calling zero-duration timers if we go to the loop here.
-
- # However, because this is typically a place where scheduling switches
- # can occur, we need to make sure that's still the case; otherwise a single
- # consumer could monopolize the thread. (shows up in test_ftplib.)
- _g_sleep()
- return sel_results
-
- result = SelectResult()
- return result.select(rlist, wlist, timeout)
-
-
-if original_poll is not None:
- class PollResult(object):
- __slots__ = ('events', 'event')
-
- def __init__(self):
- self.events = set()
- self.event = Event()
-
- def add_event(self, events, fd):
- if events < 0:
- result_flags = POLLNVAL
- else:
- result_flags = 0
- if events & _EV_READ:
- result_flags = POLLIN
- if events & _EV_WRITE:
- result_flags |= POLLOUT
-
- self.events.add((fd, result_flags))
- self.event.set()
-
- class poll(object):
- """
- An implementation of :class:`select.poll` that blocks only the current greenlet.
-
- .. caution:: ``POLLPRI`` data is not supported.
-
- .. versionadded:: 1.1b1
- """
- def __init__(self):
- # {int -> flags}
- # We can't keep watcher objects in here because people commonly
- # just drop the poll object when they're done, without calling
- # unregister(). dnspython does this.
- self.fds = {}
- self.loop = get_hub().loop
-
- def register(self, fd, eventmask=_NONE):
- if eventmask is _NONE:
- flags = _EV_READ | _EV_WRITE
- else:
- flags = 0
- if eventmask & POLLIN:
- flags = _EV_READ
- if eventmask & POLLOUT:
- flags |= _EV_WRITE
- # If they ask for POLLPRI, we can't support
- # that. Should we raise an error?
-
- fileno = get_fileno(fd)
- self.fds[fileno] = flags
-
- def modify(self, fd, eventmask):
- self.register(fd, eventmask)
-
- def poll(self, timeout=None):
- """
- poll the registered fds.
-
- .. versionchanged:: 1.2a1
- File descriptors that are closed are reported with POLLNVAL.
-
- .. versionchanged:: 1.3a2
- Under libuv, interpret *timeout* values less than 0 the same as *None*,
- i.e., block. This was always the case with libev.
- """
- result = PollResult()
- watchers = []
- io = self.loop.io
- MAXPRI = self.loop.MAXPRI
- try:
- for fd, flags in iteritems(self.fds):
- watcher = io(fd, flags)
- watchers.append(watcher)
- watcher.priority = MAXPRI
- watcher.start(result.add_event, fd, pass_events=True)
- if timeout is not None:
- if timeout < 0:
- # The docs for python say that an omitted timeout,
- # a negative timeout and a timeout of None are all
- # supposed to block forever. Many, but not all
- # OS's accept any negative number to mean that. Some
- # OS's raise errors for anything negative but not -1.
- # Python 3.7 changes to always pass exactly -1 in that
- # case from selectors.
-
- # Our Timeout class currently does not have a defined behaviour
- # for negative values. On libuv, it uses a check watcher and effectively
- # doesn't block. On libev, it seems to block. In either case, we
- # *want* to block, so turn this into the sure fire block request.
- timeout = None
- elif timeout:
- # The docs for poll.poll say timeout is in
- # milliseconds. Our result objects work in
- # seconds, so this should be *=, shouldn't it?
- timeout /= 1000.0
- result.event.wait(timeout=timeout)
- return list(result.events)
- finally:
- for awatcher in watchers:
- awatcher.stop()
- awatcher.close()
-
- def unregister(self, fd):
- """
- Unregister the *fd*.
-
- .. versionchanged:: 1.2a1
- Raise a `KeyError` if *fd* was not registered, like the standard
- library. Previously gevent did nothing.
- """
- fileno = get_fileno(fd)
- del self.fds[fileno]
-
-del original_poll
diff --git a/python/gevent/server.py b/python/gevent/server.py
deleted file mode 100644
index 4c48bd3..0000000
--- a/python/gevent/server.py
+++ /dev/null
@@ -1,282 +0,0 @@
-# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
-"""TCP/SSL server"""
-
-from contextlib import closing
-
-import sys
-
-from _socket import error as SocketError
-from _socket import SOL_SOCKET
-from _socket import SO_REUSEADDR
-from _socket import AF_INET
-from _socket import SOCK_DGRAM
-
-from gevent.baseserver import BaseServer
-from gevent.socket import EWOULDBLOCK
-from gevent.socket import socket as GeventSocket
-from gevent._compat import PYPY, PY3
-
-__all__ = ['StreamServer', 'DatagramServer']
-
-
-if sys.platform == 'win32':
- # SO_REUSEADDR on Windows does not mean the same thing as on *nix (issue #217)
- DEFAULT_REUSE_ADDR = None
-else:
- DEFAULT_REUSE_ADDR = 1
-
-
-if PY3:
- # sockets and SSL sockets are context managers on Python 3
- def _closing_socket(sock):
- return sock
-else:
- # but they are not guaranteed to be so on Python 2
- _closing_socket = closing
-
-
-class StreamServer(BaseServer):
- """
- A generic TCP server.
-
- Accepts connections on a listening socket and spawns user-provided
- *handle* function for each connection with 2 arguments: the client
- socket and the client address.
-
- Note that although the errors in a successfully spawned handler
- will not affect the server or other connections, the errors raised
- by :func:`accept` and *spawn* cause the server to stop accepting
- for a short amount of time. The exact period depends on the values
- of :attr:`min_delay` and :attr:`max_delay` attributes.
-
- The delay starts with :attr:`min_delay` and doubles with each
- successive error until it reaches :attr:`max_delay`. A successful
- :func:`accept` resets the delay to :attr:`min_delay` again.
-
- See :class:`~gevent.baseserver.BaseServer` for information on defining the *handle*
- function and important restrictions on it.
-
- **SSL Support**
-
- The server can optionally work in SSL mode when given the correct
- keyword arguments. (That is, the presence of any keyword arguments
- will trigger SSL mode.) On Python 2.7.9 and later (any Python
- version that supports the :class:`ssl.SSLContext`), this can be
- done with a configured ``SSLContext``. On any Python version, it
- can be done by passing the appropriate arguments for
- :func:`ssl.wrap_socket`.
-
- The incoming socket will be wrapped into an SSL socket before
- being passed to the *handle* function.
-
- If the *ssl_context* keyword argument is present, it should
- contain an :class:`ssl.SSLContext`. The remaining keyword
- arguments are passed to the :meth:`ssl.SSLContext.wrap_socket`
- method of that object. Depending on the Python version, supported arguments
- may include:
-
- - server_hostname
- - suppress_ragged_eofs
- - do_handshake_on_connect
-
- .. caution:: When using an SSLContext, it should either be
- imported from :mod:`gevent.ssl`, or the process needs to be monkey-patched.
- If the process is not monkey-patched and you pass the standard library
- SSLContext, the resulting client sockets will not cooperate with gevent.
-
- Otherwise, keyword arguments are assumed to apply to :func:`ssl.wrap_socket`.
- These keyword arguments may include:
-
- - keyfile
- - certfile
- - cert_reqs
- - ssl_version
- - ca_certs
- - suppress_ragged_eofs
- - do_handshake_on_connect
- - ciphers
-
- .. versionchanged:: 1.2a2
- Add support for the *ssl_context* keyword argument.
-
- """
- # the default backlog to use if none was provided in __init__
- backlog = 256
-
- reuse_addr = DEFAULT_REUSE_ADDR
-
- def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
- BaseServer.__init__(self, listener, handle=handle, spawn=spawn)
- try:
- if ssl_args:
- ssl_args.setdefault('server_side', True)
- if 'ssl_context' in ssl_args:
- ssl_context = ssl_args.pop('ssl_context')
- self.wrap_socket = ssl_context.wrap_socket
- self.ssl_args = ssl_args
- else:
- from gevent.ssl import wrap_socket
- self.wrap_socket = wrap_socket
- self.ssl_args = ssl_args
- else:
- self.ssl_args = None
- if backlog is not None:
- if hasattr(self, 'socket'):
- raise TypeError('backlog must be None when a socket instance is passed')
- self.backlog = backlog
- except:
- self.close()
- raise
-
- @property
- def ssl_enabled(self):
- return self.ssl_args is not None
-
- def set_listener(self, listener):
- BaseServer.set_listener(self, listener)
- try:
- self.socket = self.socket._sock
- except AttributeError:
- pass
-
- def init_socket(self):
- if not hasattr(self, 'socket'):
- # FIXME: clean up the socket lifetime
- # pylint:disable=attribute-defined-outside-init
- self.socket = self.get_listener(self.address, self.backlog, self.family)
- self.address = self.socket.getsockname()
- if self.ssl_args:
- self._handle = self.wrap_socket_and_handle
- else:
- self._handle = self.handle
-
- @classmethod
- def get_listener(cls, address, backlog=None, family=None):
- if backlog is None:
- backlog = cls.backlog
- return _tcp_listener(address, backlog=backlog, reuse_addr=cls.reuse_addr, family=family)
-
- if PY3:
-
- def do_read(self):
- sock = self.socket
- try:
- fd, address = sock._accept()
- except BlockingIOError: # python 2: pylint: disable=undefined-variable
- if not sock.timeout:
- return
- raise
-
- sock = GeventSocket(sock.family, sock.type, sock.proto, fileno=fd)
- # XXX Python issue #7995?
- return sock, address
-
- else:
-
- def do_read(self):
- try:
- client_socket, address = self.socket.accept()
- except SocketError as err:
- if err.args[0] == EWOULDBLOCK:
- return
- raise
- # XXX: When would this not be the case? In Python 3 it makes sense
- # because we're using the low-level _accept method,
- # but not in Python 2.
- if not isinstance(client_socket, GeventSocket):
- # This leads to a leak of the watchers in client_socket
- sockobj = GeventSocket(_sock=client_socket)
- if PYPY:
- client_socket._drop()
- else:
- sockobj = client_socket
- return sockobj, address
-
- def do_close(self, sock, *args):
- # pylint:disable=arguments-differ
- sock.close()
-
- def wrap_socket_and_handle(self, client_socket, address):
- # used in case of ssl sockets
- with _closing_socket(self.wrap_socket(client_socket, **self.ssl_args)) as ssl_socket:
- return self.handle(ssl_socket, address)
-
-
-class DatagramServer(BaseServer):
- """A UDP server"""
-
- reuse_addr = DEFAULT_REUSE_ADDR
-
- def __init__(self, *args, **kwargs):
- # The raw (non-gevent) socket, if possible
- self._socket = None
- BaseServer.__init__(self, *args, **kwargs)
- from gevent.lock import Semaphore
- self._writelock = Semaphore()
-
- def init_socket(self):
- if not hasattr(self, 'socket'):
- # FIXME: clean up the socket lifetime
- # pylint:disable=attribute-defined-outside-init
- self.socket = self.get_listener(self.address, self.family)
- self.address = self.socket.getsockname()
- self._socket = self.socket
- try:
- self._socket = self._socket._sock
- except AttributeError:
- pass
-
- @classmethod
- def get_listener(cls, address, family=None):
- return _udp_socket(address, reuse_addr=cls.reuse_addr, family=family)
-
- def do_read(self):
- try:
- data, address = self._socket.recvfrom(8192)
- except SocketError as err:
- if err.args[0] == EWOULDBLOCK:
- return
- raise
- return data, address
-
- def sendto(self, *args):
- self._writelock.acquire()
- try:
- self.socket.sendto(*args)
- finally:
- self._writelock.release()
-
-
-def _tcp_listener(address, backlog=50, reuse_addr=None, family=AF_INET):
- """A shortcut to create a TCP socket, bind it and put it into listening state."""
- sock = GeventSocket(family=family)
- if reuse_addr is not None:
- sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, reuse_addr)
- try:
- sock.bind(address)
- except SocketError as ex:
- strerror = getattr(ex, 'strerror', None)
- if strerror is not None:
- ex.strerror = strerror + ': ' + repr(address)
- raise
- sock.listen(backlog)
- sock.setblocking(0)
- return sock
-
-
-def _udp_socket(address, backlog=50, reuse_addr=None, family=AF_INET):
- # backlog argument for compat with tcp_listener
- # pylint:disable=unused-argument
-
- # we want gevent.socket.socket here
- sock = GeventSocket(family=family, type=SOCK_DGRAM)
- if reuse_addr is not None:
- sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, reuse_addr)
- try:
- sock.bind(address)
- except SocketError as ex:
- strerror = getattr(ex, 'strerror', None)
- if strerror is not None:
- ex.strerror = strerror + ': ' + repr(address)
- raise
- return sock
diff --git a/python/gevent/signal.py b/python/gevent/signal.py
deleted file mode 100644
index 0954af8..0000000
--- a/python/gevent/signal.py
+++ /dev/null
@@ -1,137 +0,0 @@
-"""
-Cooperative implementation of special cases of :func:`signal.signal`.
-
-This module is designed to work with libev's child watchers, as used
-by default in :func:`gevent.os.fork` Note that each ``SIGCHLD`` handler
-will be run in a new greenlet when the signal is delivered (just like
-:class:`gevent.hub.signal`)
-
-The implementations in this module are only monkey patched if
-:func:`gevent.os.waitpid` is being used (the default) and if
-:const:`signal.SIGCHLD` is available; see :func:`gevent.os.fork` for
-information on configuring this not to be the case for advanced uses.
-
-.. versionadded:: 1.1b4
-"""
-
-from __future__ import absolute_import
-
-from gevent._util import _NONE as _INITIAL
-from gevent._util import copy_globals
-
-import signal as _signal
-
-__implements__ = []
-__extensions__ = []
-
-
-_child_handler = _INITIAL
-
-_signal_signal = _signal.signal
-_signal_getsignal = _signal.getsignal
-
-
-def getsignal(signalnum):
- """
- Exactly the same as :func:`signal.getsignal` except where
- :const:`signal.SIGCHLD` is concerned.
-
- For :const:`signal.SIGCHLD`, this cooperates with :func:`signal`
- to provide consistent answers.
- """
- if signalnum != _signal.SIGCHLD:
- return _signal_getsignal(signalnum)
-
- global _child_handler
- if _child_handler is _INITIAL:
- _child_handler = _signal_getsignal(_signal.SIGCHLD)
-
- return _child_handler
-
-
-def signal(signalnum, handler):
- """
- Exactly the same as :func:`signal.signal` except where
- :const:`signal.SIGCHLD` is concerned.
-
- .. note::
-
- A :const:`signal.SIGCHLD` handler installed with this function
- will only be triggered for children that are forked using
- :func:`gevent.os.fork` (:func:`gevent.os.fork_and_watch`);
- children forked before monkey patching, or otherwise by the raw
- :func:`os.fork`, will not trigger the handler installed by this
- function. (It's unlikely that a SIGCHLD handler installed with
- the builtin :func:`signal.signal` would be triggered either;
- libev typically overwrites such a handler at the C level. At
- the very least, it's full of race conditions.)
-
- .. note::
-
- Use of ``SIG_IGN`` and ``SIG_DFL`` may also have race conditions
- with libev child watchers and the :mod:`gevent.subprocess` module.
-
- .. versionchanged:: 1.2a1
- If ``SIG_IGN`` or ``SIG_DFL`` are used to ignore ``SIGCHLD``, a
- future use of ``gevent.subprocess`` and libev child watchers
- will once again work. However, on Python 2, use of ``os.popen``
- will fail.
-
- .. versionchanged:: 1.1rc2
- Allow using ``SIG_IGN`` and ``SIG_DFL`` to reset and ignore ``SIGCHLD``.
- However, this allows the possibility of a race condition if ``gevent.subprocess``
- had already been used.
- """
- if signalnum != _signal.SIGCHLD:
- return _signal_signal(signalnum, handler)
-
- # TODO: raise value error if not called from the main
- # greenlet, just like threads
-
- if handler != _signal.SIG_IGN and handler != _signal.SIG_DFL and not callable(handler):
- # exact same error message raised by the stdlib
- raise TypeError("signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object")
-
- old_handler = getsignal(signalnum)
- global _child_handler
- _child_handler = handler
- if handler in (_signal.SIG_IGN, _signal.SIG_DFL):
- # Allow resetting/ignoring this signal at the process level.
- # Note that this conflicts with gevent.subprocess and other users
- # of child watchers, until the next time gevent.subprocess/loop.install_sigchld()
- # is called.
- from gevent.hub import get_hub # Are we always safe to import here?
- _signal_signal(signalnum, handler)
- get_hub().loop.reset_sigchld()
- return old_handler
-
-
-def _on_child_hook():
- # This is called in the hub greenlet. To let the function
- # do more useful work, like use blocking functions,
- # we run it in a new greenlet; see gevent.hub.signal
- if callable(_child_handler):
- # None is a valid value for the frame argument
- from gevent import Greenlet
- greenlet = Greenlet(_child_handler, _signal.SIGCHLD, None)
- greenlet.switch()
-
-
-import gevent.os
-
-if 'waitpid' in gevent.os.__implements__ and hasattr(_signal, 'SIGCHLD'):
- # Tightly coupled here to gevent.os and its waitpid implementation; only use these
- # if necessary.
- gevent.os._on_child_hook = _on_child_hook
- __implements__.append("signal")
- __implements__.append("getsignal")
-else:
- # XXX: This breaks test__all__ on windows
- __extensions__.append("signal")
- __extensions__.append("getsignal")
-
-__imports__ = copy_globals(_signal, globals(),
- names_to_ignore=__implements__ + __extensions__,
- dunder_names_to_keep=())
-
-__all__ = __implements__ + __extensions__
diff --git a/python/gevent/socket.py b/python/gevent/socket.py
deleted file mode 100644
index 1bb039e..0000000
--- a/python/gevent/socket.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details.
-
-"""Cooperative low-level networking interface.
-
-This module provides socket operations and some related functions.
-The API of the functions and classes matches the API of the corresponding
-items in the standard :mod:`socket` module exactly, but the synchronous functions
-in this module only block the current greenlet and let the others run.
-
-For convenience, exceptions (like :class:`error <socket.error>` and :class:`timeout <socket.timeout>`)
-as well as the constants from the :mod:`socket` module are imported into this module.
-"""
-# Our import magic sadly makes this warning useless
-# pylint: disable=undefined-variable
-
-from gevent._compat import PY3
-from gevent._compat import exc_clear
-from gevent._util import copy_globals
-
-
-if PY3:
- from gevent import _socket3 as _source # python 2: pylint:disable=no-name-in-module
-else:
- from gevent import _socket2 as _source
-
-# define some things we're expecting to overwrite; each module
-# needs to define these
-__implements__ = __dns__ = __all__ = __extensions__ = __imports__ = ()
-
-
-class error(Exception):
- errno = None
-
-
-def getfqdn(*args):
- # pylint:disable=unused-argument
- raise NotImplementedError()
-
-copy_globals(_source, globals(),
- dunder_names_to_keep=('__implements__', '__dns__', '__all__',
- '__extensions__', '__imports__', '__socket__'),
- cleanup_globs=False)
-
-# The _socket2 and _socket3 don't import things defined in
-# __extensions__, to help avoid confusing reference cycles in the
-# documentation and to prevent importing from the wrong place, but we
-# *do* need to expose them here. (NOTE: This may lead to some sphinx
-# warnings like:
-# WARNING: missing attribute mentioned in :members: or __all__:
-# module gevent._socket2, attribute cancel_wait
-# These can be ignored.)
-from gevent import _socketcommon
-copy_globals(_socketcommon, globals(),
- only_names=_socketcommon.__extensions__)
-
-try:
- _GLOBAL_DEFAULT_TIMEOUT = __socket__._GLOBAL_DEFAULT_TIMEOUT
-except AttributeError:
- _GLOBAL_DEFAULT_TIMEOUT = object()
-
-
-def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None):
- """
- create_connection(address, timeout=None, source_address=None) -> socket
-
- Connect to *address* and return the :class:`gevent.socket.socket`
- object.
-
- Convenience function. Connect to *address* (a 2-tuple ``(host,
- port)``) and return the socket object. Passing the optional
- *timeout* parameter will set the timeout on the socket instance
- before attempting to connect. If no *timeout* is supplied, the
- global default timeout setting returned by
- :func:`getdefaulttimeout` is used. If *source_address* is set it
- must be a tuple of (host, port) for the socket to bind as a source
- address before making the connection. A host of '' or port 0 tells
- the OS to use the default.
- """
-
- host, port = address
- # getaddrinfo is documented as returning a list, but our interface
- # is pluggable, so be sure it does.
- addrs = list(getaddrinfo(host, port, 0, SOCK_STREAM))
- if not addrs:
- raise error("getaddrinfo returns an empty list")
-
- for res in addrs:
- af, socktype, proto, _, sa = res
- sock = None
- try:
- sock = socket(af, socktype, proto)
- if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
- sock.settimeout(timeout)
- if source_address:
- sock.bind(source_address)
- sock.connect(sa)
- except error:
- if sock is not None:
- sock.close()
- sock = None
- if res is addrs[-1]:
- raise
- # without exc_clear(), if connect() fails once, the socket
- # is referenced by the frame in exc_info and the next
- # bind() fails (see test__socket.TestCreateConnection)
- # that does not happen with regular sockets though,
- # because _socket.socket.connect() is a built-in. this is
- # similar to "getnameinfo loses a reference" failure in
- # test_socket.py
- exc_clear()
- except BaseException:
- # Things like GreenletExit, Timeout and KeyboardInterrupt.
- # These get raised immediately, being sure to
- # close the socket
- if sock is not None:
- sock.close()
- sock = None
- raise
- else:
- try:
- return sock
- finally:
- sock = None
-
-
-# This is promised to be in the __all__ of the _source, but, for circularity reasons,
-# we implement it in this module. Mostly for documentation purposes, put it
-# in the _source too.
-_source.create_connection = create_connection
diff --git a/python/gevent/ssl.py b/python/gevent/ssl.py
deleted file mode 100644
index 42f2b1b..0000000
--- a/python/gevent/ssl.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-Secure Sockets Layer (SSL/TLS) module.
-"""
-from gevent._compat import PY2
-from gevent._util import copy_globals
-
-# things we expect to override, here for static analysis
-def wrap_socket(_sock, **_kwargs):
- # pylint:disable=unused-argument
- raise NotImplementedError()
-
-if PY2:
- if hasattr(__import__('ssl'), 'SSLContext'):
- # It's not sufficient to check for >= 2.7.9; some distributions
- # have backported most of PEP 466. Try to accommodate them. See Issue #702.
- # We're just about to import ssl anyway so it's fine to import it here, just
- # don't pollute the namespace
- from gevent import _sslgte279 as _source
- else:
- from gevent import _ssl2 as _source # pragma: no cover
-else:
- # Py3
- from gevent import _ssl3 as _source # pragma: no cover
-
-
-copy_globals(_source, globals())
diff --git a/python/gevent/subprocess.py b/python/gevent/subprocess.py
deleted file mode 100644
index e1e28ef..0000000
--- a/python/gevent/subprocess.py
+++ /dev/null
@@ -1,1672 +0,0 @@
-"""
-Cooperative ``subprocess`` module.
-
-.. caution:: On POSIX platforms, this module is not usable from native
- threads other than the main thread; attempting to do so will raise
- a :exc:`TypeError`. This module depends on libev's fork watchers.
- On POSIX systems, fork watchers are implemented using signals, and
- the thread to which process-directed signals are delivered `is not
- defined`_. Because each native thread has its own gevent/libev
- loop, this means that a fork watcher registered with one loop
- (thread) may never see the signal about a child it spawned if the
- signal is sent to a different thread.
-
-.. note:: The interface of this module is intended to match that of
- the standard library :mod:`subprocess` module (with many backwards
- compatible extensions from Python 3 backported to Python 2). There
- are some small differences between the Python 2 and Python 3
- versions of that module (the Python 2 ``TimeoutExpired`` exception,
- notably, extends ``Timeout`` and there is no ``SubprocessError``) and between the
- POSIX and Windows versions. The HTML documentation here can only
- describe one version; for definitive documentation, see the
- standard library or the source code.
-
-.. _is not defined: http://www.linuxprogrammingblog.com/all-about-linux-signals?page=11
-"""
-from __future__ import absolute_import, print_function
-# Can we split this up to make it cleaner? See https://github.com/gevent/gevent/issues/748
-# pylint: disable=too-many-lines
-# Import magic
-# pylint: disable=undefined-all-variable,undefined-variable
-# Most of this we inherit from the standard lib
-# pylint: disable=bare-except,too-many-locals,too-many-statements,attribute-defined-outside-init
-# pylint: disable=too-many-branches,too-many-instance-attributes
-# Most of this is cross-platform
-# pylint: disable=no-member,expression-not-assigned,unused-argument,unused-variable
-import errno
-import gc
-import os
-import signal
-import sys
-import traceback
-from gevent.event import AsyncResult
-from gevent.hub import _get_hub_noargs as get_hub
-from gevent.hub import linkproxy
-from gevent.hub import sleep
-from gevent.hub import getcurrent
-from gevent._compat import integer_types, string_types, xrange
-from gevent._compat import PY3
-from gevent._compat import reraise
-from gevent._compat import fspath
-from gevent._compat import fsencode
-from gevent._util import _NONE
-from gevent._util import copy_globals
-from gevent.fileobject import FileObject
-from gevent.greenlet import Greenlet, joinall
-spawn = Greenlet.spawn
-import subprocess as __subprocess__
-
-
-# Standard functions and classes that this module re-implements in a gevent-aware way.
-__implements__ = [
- 'Popen',
- 'call',
- 'check_call',
- 'check_output',
-]
-if PY3 and not sys.platform.startswith('win32'):
- __implements__.append("_posixsubprocess")
- _posixsubprocess = None
-
-# Some symbols we define that we expect to export;
-# useful for static analysis
-PIPE = "PIPE should be imported"
-
-# Standard functions and classes that this module re-imports.
-__imports__ = [
- 'PIPE',
- 'STDOUT',
- 'CalledProcessError',
- # Windows:
- 'CREATE_NEW_CONSOLE',
- 'CREATE_NEW_PROCESS_GROUP',
- 'STD_INPUT_HANDLE',
- 'STD_OUTPUT_HANDLE',
- 'STD_ERROR_HANDLE',
- 'SW_HIDE',
- 'STARTF_USESTDHANDLES',
- 'STARTF_USESHOWWINDOW',
-]
-
-
-__extra__ = [
- 'MAXFD',
- '_eintr_retry_call',
- 'STARTUPINFO',
- 'pywintypes',
- 'list2cmdline',
- '_subprocess',
- '_winapi',
- # Python 2.5 does not have _subprocess, so we don't use it
- # XXX We don't run on Py 2.5 anymore; can/could/should we use _subprocess?
- # It's only used on mswindows
- 'WAIT_OBJECT_0',
- 'WaitForSingleObject',
- 'GetExitCodeProcess',
- 'GetStdHandle',
- 'CreatePipe',
- 'DuplicateHandle',
- 'GetCurrentProcess',
- 'DUPLICATE_SAME_ACCESS',
- 'GetModuleFileName',
- 'GetVersion',
- 'CreateProcess',
- 'INFINITE',
- 'TerminateProcess',
- 'STILL_ACTIVE',
-
- # These were added for 3.5, but we make them available everywhere.
- 'run',
- 'CompletedProcess',
-]
-
-if sys.version_info[:2] >= (3, 3):
- __imports__ += [
- 'DEVNULL',
- 'getstatusoutput',
- 'getoutput',
- 'SubprocessError',
- 'TimeoutExpired',
- ]
-else:
- __extra__.append("TimeoutExpired")
-
-
-if sys.version_info[:2] >= (3, 5):
- __extra__.remove('run')
- __extra__.remove('CompletedProcess')
- __implements__.append('run')
- __implements__.append('CompletedProcess')
-
- # Removed in Python 3.5; this is the exact code that was removed:
- # https://hg.python.org/cpython/rev/f98b0a5e5ef5
- __extra__.remove('MAXFD')
- try:
- MAXFD = os.sysconf("SC_OPEN_MAX")
- except:
- MAXFD = 256
-
-if sys.version_info[:2] >= (3, 6):
- # This was added to __all__ for windows in 3.6
- __extra__.remove('STARTUPINFO')
- __imports__.append('STARTUPINFO')
-
-if sys.version_info[:2] >= (3, 7):
- __imports__.extend([
- 'ABOVE_NORMAL_PRIORITY_CLASS', 'BELOW_NORMAL_PRIORITY_CLASS',
- 'HIGH_PRIORITY_CLASS', 'IDLE_PRIORITY_CLASS',
- 'NORMAL_PRIORITY_CLASS',
- 'REALTIME_PRIORITY_CLASS',
- 'CREATE_NO_WINDOW', 'DETACHED_PROCESS',
- 'CREATE_DEFAULT_ERROR_MODE',
- 'CREATE_BREAKAWAY_FROM_JOB'
- ])
-
-actually_imported = copy_globals(__subprocess__, globals(),
- only_names=__imports__,
- ignore_missing_names=True)
-# anything we couldn't import from here we may need to find
-# elsewhere
-__extra__.extend(set(__imports__).difference(set(actually_imported)))
-__imports__ = actually_imported
-del actually_imported
-
-
-# In Python 3 on Windows, a lot of the functions previously
-# in _subprocess moved to _winapi
-_subprocess = getattr(__subprocess__, '_subprocess', _NONE)
-_winapi = getattr(__subprocess__, '_winapi', _NONE)
-
-_attr_resolution_order = [__subprocess__, _subprocess, _winapi]
-
-for name in list(__extra__):
- if name in globals():
- continue
- value = _NONE
- for place in _attr_resolution_order:
- value = getattr(place, name, _NONE)
- if value is not _NONE:
- break
-
- if value is _NONE:
- __extra__.remove(name)
- else:
- globals()[name] = value
-
-del _attr_resolution_order
-__all__ = __implements__ + __imports__
-# Some other things we want to document
-for _x in ('run', 'CompletedProcess', 'TimeoutExpired'):
- if _x not in __all__:
- __all__.append(_x)
-
-
-mswindows = sys.platform == 'win32'
-if mswindows:
- import msvcrt # pylint: disable=import-error
- if PY3:
- class Handle(int):
- closed = False
-
- def Close(self):
- if not self.closed:
- self.closed = True
- _winapi.CloseHandle(self)
-
- def Detach(self):
- if not self.closed:
- self.closed = True
- return int(self)
- raise ValueError("already closed")
-
- def __repr__(self):
- return "Handle(%d)" % int(self)
-
- __del__ = Close
- __str__ = __repr__
-else:
- import fcntl
- import pickle
- from gevent import monkey
- fork = monkey.get_original('os', 'fork')
- from gevent.os import fork_and_watch
-
-def call(*popenargs, **kwargs):
- """
- call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) -> returncode
-
- Run command with arguments. Wait for command to complete or
- timeout, then return the returncode attribute.
-
- The arguments are the same as for the Popen constructor. Example::
-
- retcode = call(["ls", "-l"])
-
- .. versionchanged:: 1.2a1
- The ``timeout`` keyword argument is now accepted on all supported
- versions of Python (not just Python 3) and if it expires will raise a
- :exc:`TimeoutExpired` exception (under Python 2 this is a subclass of :exc:`~.Timeout`).
- """
- timeout = kwargs.pop('timeout', None)
- with Popen(*popenargs, **kwargs) as p:
- try:
- return p.wait(timeout=timeout, _raise_exc=True)
- except:
- p.kill()
- p.wait()
- raise
-
-def check_call(*popenargs, **kwargs):
- """
- check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) -> 0
-
- Run command with arguments. Wait for command to complete. If
- the exit code was zero then return, otherwise raise
- :exc:`CalledProcessError`. The ``CalledProcessError`` object will have the
- return code in the returncode attribute.
-
- The arguments are the same as for the Popen constructor. Example::
-
- retcode = check_call(["ls", "-l"])
- """
- retcode = call(*popenargs, **kwargs)
- if retcode:
- cmd = kwargs.get("args")
- if cmd is None:
- cmd = popenargs[0]
- raise CalledProcessError(retcode, cmd)
- return 0
-
-def check_output(*popenargs, **kwargs):
- r"""
- check_output(args, *, input=None, stdin=None, stderr=None, shell=False, universal_newlines=False, timeout=None) -> output
-
- Run command with arguments and return its output.
-
- If the exit code was non-zero it raises a :exc:`CalledProcessError`. The
- ``CalledProcessError`` object will have the return code in the returncode
- attribute and output in the output attribute.
-
-
- The arguments are the same as for the Popen constructor. Example::
-
- >>> check_output(["ls", "-1", "/dev/null"])
- '/dev/null\n'
-
- The ``stdout`` argument is not allowed as it is used internally.
-
- To capture standard error in the result, use ``stderr=STDOUT``::
-
- >>> check_output(["/bin/sh", "-c",
- ... "ls -l non_existent_file ; exit 0"],
- ... stderr=STDOUT)
- 'ls: non_existent_file: No such file or directory\n'
-
- There is an additional optional argument, "input", allowing you to
- pass a string to the subprocess's stdin. If you use this argument
- you may not also use the Popen constructor's "stdin" argument, as
- it too will be used internally. Example::
-
- >>> check_output(["sed", "-e", "s/foo/bar/"],
- ... input=b"when in the course of fooman events\n")
- 'when in the course of barman events\n'
-
- If ``universal_newlines=True`` is passed, the return value will be a
- string rather than bytes.
-
- .. versionchanged:: 1.2a1
- The ``timeout`` keyword argument is now accepted on all supported
- versions of Python (not just Python 3) and if it expires will raise a
- :exc:`TimeoutExpired` exception (under Python 2 this is a subclass of :exc:`~.Timeout`).
- .. versionchanged:: 1.2a1
- The ``input`` keyword argument is now accepted on all supported
- versions of Python, not just Python 3
- """
- timeout = kwargs.pop('timeout', None)
- if 'stdout' in kwargs:
- raise ValueError('stdout argument not allowed, it will be overridden.')
- if 'input' in kwargs:
- if 'stdin' in kwargs:
- raise ValueError('stdin and input arguments may not both be used.')
- inputdata = kwargs['input']
- del kwargs['input']
- kwargs['stdin'] = PIPE
- else:
- inputdata = None
- with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
- try:
- output, unused_err = process.communicate(inputdata, timeout=timeout)
- except TimeoutExpired:
- process.kill()
- output, unused_err = process.communicate()
- raise TimeoutExpired(process.args, timeout, output=output)
- except:
- process.kill()
- process.wait()
- raise
- retcode = process.poll()
- if retcode:
- raise CalledProcessError(retcode, process.args, output=output)
- return output
-
-_PLATFORM_DEFAULT_CLOSE_FDS = object()
-
-if 'TimeoutExpired' not in globals():
- # Python 2
-
- # Make TimeoutExpired inherit from _Timeout so it can be caught
- # the way we used to throw things (except Timeout), but make sure it doesn't
- # init a timer. Note that we can't have a fake 'SubprocessError' that inherits
- # from exception, because we need TimeoutExpired to just be a BaseException for
- # bwc.
- from gevent.timeout import Timeout as _Timeout
-
- class TimeoutExpired(_Timeout):
- """
- This exception is raised when the timeout expires while waiting for
- a child process in `communicate`.
-
- Under Python 2, this is a gevent extension with the same name as the
- Python 3 class for source-code forward compatibility. However, it extends
- :class:`gevent.timeout.Timeout` for backwards compatibility (because
- we used to just raise a plain ``Timeout``); note that ``Timeout`` is a
- ``BaseException``, *not* an ``Exception``.
-
- .. versionadded:: 1.2a1
- """
-
- def __init__(self, cmd, timeout, output=None):
- _Timeout.__init__(self, None)
- self.cmd = cmd
- self.seconds = timeout
- self.output = output
-
- @property
- def timeout(self):
- return self.seconds
-
- def __str__(self):
- return ("Command '%s' timed out after %s seconds" %
- (self.cmd, self.timeout))
-
-
-if hasattr(os, 'set_inheritable'):
- _set_inheritable = os.set_inheritable
-else:
- _set_inheritable = lambda i, v: True
-
-
-class Popen(object):
- """
- The underlying process creation and management in this module is
- handled by the Popen class. It offers a lot of flexibility so that
- developers are able to handle the less common cases not covered by
- the convenience functions.
-
- .. seealso:: :class:`subprocess.Popen`
- This class should have the same interface as the standard library class.
-
- .. versionchanged:: 1.2a1
- Instances can now be used as context managers under Python 2.7. Previously
- this was restricted to Python 3.
-
- .. versionchanged:: 1.2a1
- Instances now save the ``args`` attribute under Python 2.7. Previously this was
- restricted to Python 3.
-
- .. versionchanged:: 1.2b1
- Add the ``encoding`` and ``errors`` parameters for Python 3.
-
- .. versionchanged:: 1.3a1
- Accept "path-like" objects for the *cwd* parameter on all platforms.
- This was added to Python 3.6. Previously with gevent, it only worked
- on POSIX platforms on 3.6.
-
- .. versionchanged:: 1.3a1
- Add the ``text`` argument as a synonym for ``universal_newlines``,
- as added on Python 3.7.
-
- .. versionchanged:: 1.3a2
- Allow the same keyword arguments under Python 2 as Python 3:
- ``pass_fds``, ``start_new_session``, ``restore_signals``, ``encoding``
- and ``errors``. Under Python 2, ``encoding`` and ``errors`` are ignored
- because native handling of universal newlines is used.
-
- .. versionchanged:: 1.3a2
- Under Python 2, ``restore_signals`` defaults to ``False``. Previously it
- defaulted to ``True``, the same as it did in Python 3.
- """
-
- # The value returned from communicate() when there was nothing to read.
- # Changes if we're in text mode or universal newlines mode.
- _communicate_empty_value = b''
-
- def __init__(self, args,
- bufsize=-1 if PY3 else 0,
- executable=None,
- stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS, shell=False,
- cwd=None, env=None, universal_newlines=None,
- startupinfo=None, creationflags=0,
- restore_signals=PY3, start_new_session=False,
- pass_fds=(),
- # Added in 3.6. These are kept as ivars
- encoding=None, errors=None,
- # Added in 3.7. Not an ivar directly.
- text=None,
- # gevent additions
- threadpool=None):
-
- self.encoding = encoding
- self.errors = errors
-
- hub = get_hub()
-
- if bufsize is None:
- # Python 2 doesn't allow None at all, but Python 3 treats
- # it the same as the default. We do as well.
- bufsize = -1 if PY3 else 0
- if not isinstance(bufsize, integer_types):
- raise TypeError("bufsize must be an integer")
-
- if mswindows:
- if preexec_fn is not None:
- raise ValueError("preexec_fn is not supported on Windows "
- "platforms")
- if sys.version_info[:2] >= (3, 7):
- if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
- close_fds = True
- else:
- any_stdio_set = (stdin is not None or stdout is not None or
- stderr is not None)
- if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
- if any_stdio_set:
- close_fds = False
- else:
- close_fds = True
- elif close_fds and any_stdio_set:
- raise ValueError("close_fds is not supported on Windows "
- "platforms if you redirect stdin/stdout/stderr")
- if threadpool is None:
- threadpool = hub.threadpool
- self.threadpool = threadpool
- self._waiting = False
- else:
- # POSIX
- if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
- # close_fds has different defaults on Py3/Py2
- if PY3: # pylint: disable=simplifiable-if-statement
- close_fds = True
- else:
- close_fds = False
-
- if pass_fds and not close_fds:
- import warnings
- warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
- close_fds = True
- if startupinfo is not None:
- raise ValueError("startupinfo is only supported on Windows "
- "platforms")
- if creationflags != 0:
- raise ValueError("creationflags is only supported on Windows "
- "platforms")
- assert threadpool is None
- self._loop = hub.loop
-
- # Validate the combinations of text and universal_newlines
- if (text is not None and universal_newlines is not None
- and bool(universal_newlines) != bool(text)):
- raise SubprocessError('Cannot disambiguate when both text '
- 'and universal_newlines are supplied but '
- 'different. Pass one or the other.')
-
- self.args = args # Previously this was Py3 only.
- self.stdin = None
- self.stdout = None
- self.stderr = None
- self.pid = None
- self.returncode = None
- self.universal_newlines = universal_newlines
- self.result = AsyncResult()
-
- # Input and output objects. The general principle is like
- # this:
- #
- # Parent Child
- # ------ -----
- # p2cwrite ---stdin---> p2cread
- # c2pread <--stdout--- c2pwrite
- # errread <--stderr--- errwrite
- #
- # On POSIX, the child objects are file descriptors. On
- # Windows, these are Windows file handles. The parent objects
- # are file descriptors on both platforms. The parent objects
- # are -1 when not using PIPEs. The child objects are -1
- # when not redirecting.
-
- (p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite) = self._get_handles(stdin, stdout, stderr)
-
- # We wrap OS handles *before* launching the child, otherwise a
- # quickly terminating child could make our fds unwrappable
- # (see #8458).
- if mswindows:
- if p2cwrite != -1:
- p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0)
- if c2pread != -1:
- c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0)
- if errread != -1:
- errread = msvcrt.open_osfhandle(errread.Detach(), 0)
-
- text_mode = PY3 and (self.encoding or self.errors or universal_newlines or text)
- if text_mode or universal_newlines:
- # Always a native str in universal_newlines mode, even when that
- # str type is bytes. Additionally, text_mode is only true under
- # Python 3, so it's actually a unicode str
- self._communicate_empty_value = ''
-
- if p2cwrite != -1:
- if PY3 and text_mode:
- # Under Python 3, if we left on the 'b' we'd get different results
- # depending on whether we used FileObjectPosix or FileObjectThread
- self.stdin = FileObject(p2cwrite, 'wb', bufsize)
- self.stdin.translate_newlines(None,
- write_through=True,
- line_buffering=(bufsize == 1),
- encoding=self.encoding, errors=self.errors)
- else:
- self.stdin = FileObject(p2cwrite, 'wb', bufsize)
- if c2pread != -1:
- if universal_newlines or text_mode:
- if PY3:
- # FileObjectThread doesn't support the 'U' qualifier
- # with a bufsize of 0
- self.stdout = FileObject(c2pread, 'rb', bufsize)
- # NOTE: Universal Newlines are broken on Windows/Py3, at least
- # in some cases. This is true in the stdlib subprocess module
- # as well; the following line would fix the test cases in
- # test__subprocess.py that depend on python_universal_newlines,
- # but would be inconsistent with the stdlib:
- #msvcrt.setmode(self.stdout.fileno(), os.O_TEXT)
- self.stdout.translate_newlines('r', encoding=self.encoding, errors=self.errors)
- else:
- self.stdout = FileObject(c2pread, 'rU', bufsize)
- else:
- self.stdout = FileObject(c2pread, 'rb', bufsize)
- if errread != -1:
- if universal_newlines or text_mode:
- if PY3:
- self.stderr = FileObject(errread, 'rb', bufsize)
- self.stderr.translate_newlines(None, encoding=encoding, errors=errors)
- else:
- self.stderr = FileObject(errread, 'rU', bufsize)
- else:
- self.stderr = FileObject(errread, 'rb', bufsize)
-
- self._closed_child_pipe_fds = False
- # Convert here for the sake of all platforms. os.chdir accepts
- # path-like objects natively under 3.6, but CreateProcess
- # doesn't.
- cwd = fspath(cwd) if cwd is not None else None
- try:
- self._execute_child(args, executable, preexec_fn, close_fds,
- pass_fds, cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite,
- restore_signals, start_new_session)
- except:
- # Cleanup if the child failed starting.
- # (gevent: New in python3, but reported as gevent bug in #347.
- # Note that under Py2, any error raised below will replace the
- # original error so we have to use reraise)
- if not PY3:
- exc_info = sys.exc_info()
- for f in filter(None, (self.stdin, self.stdout, self.stderr)):
- try:
- f.close()
- except (OSError, IOError):
- pass # Ignore EBADF or other errors.
-
- if not self._closed_child_pipe_fds:
- to_close = []
- if stdin == PIPE:
- to_close.append(p2cread)
- if stdout == PIPE:
- to_close.append(c2pwrite)
- if stderr == PIPE:
- to_close.append(errwrite)
- if hasattr(self, '_devnull'):
- to_close.append(self._devnull)
- for fd in to_close:
- try:
- os.close(fd)
- except (OSError, IOError):
- pass
- if not PY3:
- try:
- reraise(*exc_info)
- finally:
- del exc_info
- raise
-
- def __repr__(self):
- return '<%s at 0x%x pid=%r returncode=%r>' % (self.__class__.__name__, id(self), self.pid, self.returncode)
-
- def _on_child(self, watcher):
- watcher.stop()
- status = watcher.rstatus
- if os.WIFSIGNALED(status):
- self.returncode = -os.WTERMSIG(status)
- else:
- self.returncode = os.WEXITSTATUS(status)
- self.result.set(self.returncode)
-
- def _get_devnull(self):
- if not hasattr(self, '_devnull'):
- self._devnull = os.open(os.devnull, os.O_RDWR)
- return self._devnull
-
- _stdout_buffer = None
- _stderr_buffer = None
-
- def communicate(self, input=None, timeout=None):
- """Interact with process: Send data to stdin. Read data from
- stdout and stderr, until end-of-file is reached. Wait for
- process to terminate. The optional input argument should be a
- string to be sent to the child process, or None, if no data
- should be sent to the child.
-
- communicate() returns a tuple (stdout, stderr).
-
- :keyword timeout: Under Python 2, this is a gevent extension; if
- given and it expires, we will raise :exc:`TimeoutExpired`, which
- extends :exc:`gevent.timeout.Timeout` (note that this only extends :exc:`BaseException`,
- *not* :exc:`Exception`)
- Under Python 3, this raises the standard :exc:`TimeoutExpired` exception.
-
- .. versionchanged:: 1.1a2
- Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout`
- exception. Previously, we silently returned.
- .. versionchanged:: 1.1b5
- Honor a *timeout* even if there's no way to communicate with the child
- (stdin, stdout, and stderr are not pipes).
- """
- greenlets = []
- if self.stdin:
- greenlets.append(spawn(write_and_close, self.stdin, input))
-
- # If the timeout parameter is used, and the caller calls back after
- # getting a TimeoutExpired exception, we can wind up with multiple
- # greenlets trying to run and read from and close stdout/stderr.
- # That's bad because it can lead to 'RuntimeError: reentrant call in io.BufferedReader'.
- # We can't just kill the previous greenlets when a timeout happens,
- # though, because we risk losing the output collected by that greenlet
- # (and Python 3, where timeout is an official parameter, explicitly says
- # that no output should be lost in the event of a timeout.) Instead, we're
- # watching for the exception and ignoring it. It's not elegant,
- # but it works
- def _make_pipe_reader(pipe_name):
- pipe = getattr(self, pipe_name)
- buf_name = '_' + pipe_name + '_buffer'
-
- def _read():
- try:
- data = pipe.read()
- except RuntimeError:
- return
- if not data:
- return
- the_buffer = getattr(self, buf_name)
- if the_buffer:
- the_buffer.append(data)
- else:
- setattr(self, buf_name, [data])
- return _read
-
- if self.stdout:
- _read_out = _make_pipe_reader('stdout')
- stdout = spawn(_read_out)
- greenlets.append(stdout)
- else:
- stdout = None
-
- if self.stderr:
- _read_err = _make_pipe_reader('stderr')
- stderr = spawn(_read_err)
- greenlets.append(stderr)
- else:
- stderr = None
-
- # If we were given stdin=stdout=stderr=None, we have no way to
- # communicate with the child, and thus no greenlets to wait
- # on. This is a nonsense case, but it comes up in the test
- # case for Python 3.5 (test_subprocess.py
- # RunFuncTestCase.test_timeout). Instead, we go directly to
- # self.wait
- if not greenlets and timeout is not None:
- self.wait(timeout=timeout, _raise_exc=True)
-
- done = joinall(greenlets, timeout=timeout)
- if timeout is not None and len(done) != len(greenlets):
- raise TimeoutExpired(self.args, timeout)
-
- for pipe in (self.stdout, self.stderr):
- if pipe:
- try:
- pipe.close()
- except RuntimeError:
- pass
-
- self.wait()
-
- def _get_output_value(pipe_name):
- buf_name = '_' + pipe_name + '_buffer'
- buf_value = getattr(self, buf_name)
- setattr(self, buf_name, None)
- if buf_value:
- buf_value = self._communicate_empty_value.join(buf_value)
- else:
- buf_value = self._communicate_empty_value
- return buf_value
-
- stdout_value = _get_output_value('stdout')
- stderr_value = _get_output_value('stderr')
-
- return (None if stdout is None else stdout_value,
- None if stderr is None else stderr_value)
-
- def poll(self):
- """Check if child process has terminated. Set and return :attr:`returncode` attribute."""
- return self._internal_poll()
-
- def __enter__(self):
- return self
-
- def __exit__(self, t, v, tb):
- if self.stdout:
- self.stdout.close()
- if self.stderr:
- self.stderr.close()
- try: # Flushing a BufferedWriter may raise an error
- if self.stdin:
- self.stdin.close()
- finally:
- # Wait for the process to terminate, to avoid zombies.
- # JAM: gevent: If the process never terminates, this
- # blocks forever.
- self.wait()
-
- def _gevent_result_wait(self, timeout=None, raise_exc=PY3):
- result = self.result.wait(timeout=timeout)
- if raise_exc and timeout is not None and not self.result.ready():
- raise TimeoutExpired(self.args, timeout)
- return result
-
-
- if mswindows:
- #
- # Windows methods
- #
- def _get_handles(self, stdin, stdout, stderr):
- """Construct and return tuple with IO objects:
- p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
- """
- if stdin is None and stdout is None and stderr is None:
- return (-1, -1, -1, -1, -1, -1)
-
- p2cread, p2cwrite = -1, -1
- c2pread, c2pwrite = -1, -1
- errread, errwrite = -1, -1
-
- try:
- DEVNULL
- except NameError:
- _devnull = object()
- else:
- _devnull = DEVNULL
-
- if stdin is None:
- p2cread = GetStdHandle(STD_INPUT_HANDLE)
- if p2cread is None:
- p2cread, _ = CreatePipe(None, 0)
- if PY3:
- p2cread = Handle(p2cread)
- _winapi.CloseHandle(_)
- elif stdin == PIPE:
- p2cread, p2cwrite = CreatePipe(None, 0)
- if PY3:
- p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite)
- elif stdin == _devnull:
- p2cread = msvcrt.get_osfhandle(self._get_devnull())
- elif isinstance(stdin, int):
- p2cread = msvcrt.get_osfhandle(stdin)
- else:
- # Assuming file-like object
- p2cread = msvcrt.get_osfhandle(stdin.fileno())
- p2cread = self._make_inheritable(p2cread)
-
- if stdout is None:
- c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE)
- if c2pwrite is None:
- _, c2pwrite = CreatePipe(None, 0)
- if PY3:
- c2pwrite = Handle(c2pwrite)
- _winapi.CloseHandle(_)
- elif stdout == PIPE:
- c2pread, c2pwrite = CreatePipe(None, 0)
- if PY3:
- c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite)
- elif stdout == _devnull:
- c2pwrite = msvcrt.get_osfhandle(self._get_devnull())
- elif isinstance(stdout, int):
- c2pwrite = msvcrt.get_osfhandle(stdout)
- else:
- # Assuming file-like object
- c2pwrite = msvcrt.get_osfhandle(stdout.fileno())
- c2pwrite = self._make_inheritable(c2pwrite)
-
- if stderr is None:
- errwrite = GetStdHandle(STD_ERROR_HANDLE)
- if errwrite is None:
- _, errwrite = CreatePipe(None, 0)
- if PY3:
- errwrite = Handle(errwrite)
- _winapi.CloseHandle(_)
- elif stderr == PIPE:
- errread, errwrite = CreatePipe(None, 0)
- if PY3:
- errread, errwrite = Handle(errread), Handle(errwrite)
- elif stderr == STDOUT:
- errwrite = c2pwrite
- elif stderr == _devnull:
- errwrite = msvcrt.get_osfhandle(self._get_devnull())
- elif isinstance(stderr, int):
- errwrite = msvcrt.get_osfhandle(stderr)
- else:
- # Assuming file-like object
- errwrite = msvcrt.get_osfhandle(stderr.fileno())
- errwrite = self._make_inheritable(errwrite)
-
- return (p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite)
-
- def _make_inheritable(self, handle):
- """Return a duplicate of handle, which is inheritable"""
- return DuplicateHandle(GetCurrentProcess(),
- handle, GetCurrentProcess(), 0, 1,
- DUPLICATE_SAME_ACCESS)
-
- def _find_w9xpopen(self):
- """Find and return absolute path to w9xpopen.exe"""
- w9xpopen = os.path.join(os.path.dirname(GetModuleFileName(0)),
- "w9xpopen.exe")
- if not os.path.exists(w9xpopen):
- # Eeek - file-not-found - possibly an embedding
- # situation - see if we can locate it in sys.exec_prefix
- w9xpopen = os.path.join(os.path.dirname(sys.exec_prefix),
- "w9xpopen.exe")
- if not os.path.exists(w9xpopen):
- raise RuntimeError("Cannot locate w9xpopen.exe, which is "
- "needed for Popen to work with your "
- "shell or platform.")
- return w9xpopen
-
-
- def _filter_handle_list(self, handle_list):
- """Filter out console handles that can't be used
- in lpAttributeList["handle_list"] and make sure the list
- isn't empty. This also removes duplicate handles."""
- # An handle with it's lowest two bits set might be a special console
- # handle that if passed in lpAttributeList["handle_list"], will
- # cause it to fail.
- # Only works on 3.7+
- return list({handle for handle in handle_list
- if handle & 0x3 != 0x3
- or _winapi.GetFileType(handle) !=
- _winapi.FILE_TYPE_CHAR})
-
-
- def _execute_child(self, args, executable, preexec_fn, close_fds,
- pass_fds, cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite,
- unused_restore_signals, unused_start_new_session):
- """Execute program (MS Windows version)"""
-
- assert not pass_fds, "pass_fds not supported on Windows."
-
- if not isinstance(args, string_types):
- args = list2cmdline(args)
-
- # Process startup details
- if startupinfo is None:
- startupinfo = STARTUPINFO()
- use_std_handles = -1 not in (p2cread, c2pwrite, errwrite)
- if use_std_handles:
- startupinfo.dwFlags |= STARTF_USESTDHANDLES
- startupinfo.hStdInput = p2cread
- startupinfo.hStdOutput = c2pwrite
- startupinfo.hStdError = errwrite
-
- if hasattr(startupinfo, 'lpAttributeList'):
- # Support for Python >= 3.7
-
- attribute_list = startupinfo.lpAttributeList
- have_handle_list = bool(attribute_list and
- "handle_list" in attribute_list and
- attribute_list["handle_list"])
-
- # If we were given an handle_list or need to create one
- if have_handle_list or (use_std_handles and close_fds):
- if attribute_list is None:
- attribute_list = startupinfo.lpAttributeList = {}
- handle_list = attribute_list["handle_list"] = \
- list(attribute_list.get("handle_list", []))
-
- if use_std_handles:
- handle_list += [int(p2cread), int(c2pwrite), int(errwrite)]
-
- handle_list[:] = self._filter_handle_list(handle_list)
-
- if handle_list:
- if not close_fds:
- import warnings
- warnings.warn("startupinfo.lpAttributeList['handle_list'] "
- "overriding close_fds", RuntimeWarning)
-
- # When using the handle_list we always request to inherit
- # handles but the only handles that will be inherited are
- # the ones in the handle_list
- close_fds = False
-
- if shell:
- startupinfo.dwFlags |= STARTF_USESHOWWINDOW
- startupinfo.wShowWindow = SW_HIDE
- comspec = os.environ.get("COMSPEC", "cmd.exe")
- args = '{} /c "{}"'.format(comspec, args)
- if GetVersion() >= 0x80000000 or os.path.basename(comspec).lower() == "command.com":
- # Win9x, or using command.com on NT. We need to
- # use the w9xpopen intermediate program. For more
- # information, see KB Q150956
- # (http://web.archive.org/web/20011105084002/http://support.microsoft.com/support/kb/articles/Q150/9/56.asp)
- w9xpopen = self._find_w9xpopen()
- args = '"%s" %s' % (w9xpopen, args)
- # Not passing CREATE_NEW_CONSOLE has been known to
- # cause random failures on win9x. Specifically a
- # dialog: "Your program accessed mem currently in
- # use at xxx" and a hopeful warning about the
- # stability of your system. Cost is Ctrl+C wont
- # kill children.
- creationflags |= CREATE_NEW_CONSOLE
-
- # Start the process
- try:
- hp, ht, pid, tid = CreateProcess(executable, args,
- # no special security
- None, None,
- int(not close_fds),
- creationflags,
- env,
- cwd,
- startupinfo)
- except IOError as e: # From 2.6 on, pywintypes.error was defined as IOError
- # Translate pywintypes.error to WindowsError, which is
- # a subclass of OSError. FIXME: We should really
- # translate errno using _sys_errlist (or similar), but
- # how can this be done from Python?
- if PY3:
- raise # don't remap here
- raise WindowsError(*e.args)
- finally:
- # Child is launched. Close the parent's copy of those pipe
- # handles that only the child should have open. You need
- # to make sure that no handles to the write end of the
- # output pipe are maintained in this process or else the
- # pipe will not close when the child process exits and the
- # ReadFile will hang.
- def _close(x):
- if x is not None and x != -1:
- if hasattr(x, 'Close'):
- x.Close()
- else:
- _winapi.CloseHandle(x)
-
- _close(p2cread)
- _close(c2pwrite)
- _close(errwrite)
- if hasattr(self, '_devnull'):
- os.close(self._devnull)
-
- # Retain the process handle, but close the thread handle
- self._child_created = True
- self._handle = Handle(hp) if not hasattr(hp, 'Close') else hp
- self.pid = pid
- _winapi.CloseHandle(ht) if not hasattr(ht, 'Close') else ht.Close()
-
- def _internal_poll(self):
- """Check if child process has terminated. Returns returncode
- attribute.
- """
- if self.returncode is None:
- if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0:
- self.returncode = GetExitCodeProcess(self._handle)
- self.result.set(self.returncode)
- return self.returncode
-
- def rawlink(self, callback):
- if not self.result.ready() and not self._waiting:
- self._waiting = True
- Greenlet.spawn(self._wait)
- self.result.rawlink(linkproxy(callback, self))
- # XXX unlink
-
- def _blocking_wait(self):
- WaitForSingleObject(self._handle, INFINITE)
- self.returncode = GetExitCodeProcess(self._handle)
- return self.returncode
-
- def _wait(self):
- self.threadpool.spawn(self._blocking_wait).rawlink(self.result)
-
- def wait(self, timeout=None, _raise_exc=PY3):
- """Wait for child process to terminate. Returns returncode
- attribute."""
- if self.returncode is None:
- if not self._waiting:
- self._waiting = True
- self._wait()
- return self._gevent_result_wait(timeout, _raise_exc)
-
- def send_signal(self, sig):
- """Send a signal to the process
- """
- if sig == signal.SIGTERM:
- self.terminate()
- elif sig == signal.CTRL_C_EVENT:
- os.kill(self.pid, signal.CTRL_C_EVENT)
- elif sig == signal.CTRL_BREAK_EVENT:
- os.kill(self.pid, signal.CTRL_BREAK_EVENT)
- else:
- raise ValueError("Unsupported signal: {}".format(sig))
-
- def terminate(self):
- """Terminates the process
- """
- # Don't terminate a process that we know has already died.
- if self.returncode is not None:
- return
- try:
- TerminateProcess(self._handle, 1)
- except OSError as e:
- # ERROR_ACCESS_DENIED (winerror 5) is received when the
- # process already died.
- if e.winerror != 5:
- raise
- rc = GetExitCodeProcess(self._handle)
- if rc == STILL_ACTIVE:
- raise
- self.returncode = rc
- self.result.set(self.returncode)
-
- kill = terminate
-
- else:
- #
- # POSIX methods
- #
-
- def rawlink(self, callback):
- # Not public documented, part of the link protocol
- self.result.rawlink(linkproxy(callback, self))
- # XXX unlink
-
- def _get_handles(self, stdin, stdout, stderr):
- """Construct and return tuple with IO objects:
- p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
- """
- p2cread, p2cwrite = -1, -1
- c2pread, c2pwrite = -1, -1
- errread, errwrite = -1, -1
-
- try:
- DEVNULL
- except NameError:
- _devnull = object()
- else:
- _devnull = DEVNULL
-
- if stdin is None:
- pass
- elif stdin == PIPE:
- p2cread, p2cwrite = self.pipe_cloexec()
- elif stdin == _devnull:
- p2cread = self._get_devnull()
- elif isinstance(stdin, int):
- p2cread = stdin
- else:
- # Assuming file-like object
- p2cread = stdin.fileno()
-
- if stdout is None:
- pass
- elif stdout == PIPE:
- c2pread, c2pwrite = self.pipe_cloexec()
- elif stdout == _devnull:
- c2pwrite = self._get_devnull()
- elif isinstance(stdout, int):
- c2pwrite = stdout
- else:
- # Assuming file-like object
- c2pwrite = stdout.fileno()
-
- if stderr is None:
- pass
- elif stderr == PIPE:
- errread, errwrite = self.pipe_cloexec()
- elif stderr == STDOUT:
- if c2pwrite != -1:
- errwrite = c2pwrite
- else: # child's stdout is not set, use parent's stdout
- errwrite = sys.__stdout__.fileno()
- elif stderr == _devnull:
- errwrite = self._get_devnull()
- elif isinstance(stderr, int):
- errwrite = stderr
- else:
- # Assuming file-like object
- errwrite = stderr.fileno()
-
- return (p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite)
-
- def _set_cloexec_flag(self, fd, cloexec=True):
- try:
- cloexec_flag = fcntl.FD_CLOEXEC
- except AttributeError:
- cloexec_flag = 1
-
- old = fcntl.fcntl(fd, fcntl.F_GETFD)
- if cloexec:
- fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
- else:
- fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
-
- def _remove_nonblock_flag(self, fd):
- flags = fcntl.fcntl(fd, fcntl.F_GETFL) & (~os.O_NONBLOCK)
- fcntl.fcntl(fd, fcntl.F_SETFL, flags)
-
- def pipe_cloexec(self):
- """Create a pipe with FDs set CLOEXEC."""
- # Pipes' FDs are set CLOEXEC by default because we don't want them
- # to be inherited by other subprocesses: the CLOEXEC flag is removed
- # from the child's FDs by _dup2(), between fork() and exec().
- # This is not atomic: we would need the pipe2() syscall for that.
- r, w = os.pipe()
- self._set_cloexec_flag(r)
- self._set_cloexec_flag(w)
- return r, w
-
- _POSSIBLE_FD_DIRS = (
- '/proc/self/fd', # Linux
- '/dev/fd', # BSD, including macOS
- )
-
- @classmethod
- def _close_fds(cls, keep, errpipe_write):
- # From the C code:
- # errpipe_write is part of keep. It must be closed at
- # exec(), but kept open in the child process until exec() is
- # called.
- for path in cls._POSSIBLE_FD_DIRS:
- if os.path.isdir(path):
- return cls._close_fds_from_path(path, keep, errpipe_write)
- return cls._close_fds_brute_force(keep, errpipe_write)
-
- @classmethod
- def _close_fds_from_path(cls, path, keep, errpipe_write):
- # path names a directory whose only entries have
- # names that are ascii strings of integers in base10,
- # corresponding to the fds the current process has open
- try:
- fds = [int(fname) for fname in os.listdir(path)]
- except (ValueError, OSError):
- cls._close_fds_brute_force(keep, errpipe_write)
- else:
- for i in keep:
- if i == errpipe_write:
- continue
- _set_inheritable(i, True)
-
- for fd in fds:
- if fd in keep or fd < 3:
- continue
- try:
- os.close(fd)
- except:
- pass
-
- @classmethod
- def _close_fds_brute_force(cls, keep, errpipe_write):
- # `keep` is a set of fds, so we
- # use os.closerange from 3 to min(keep)
- # and then from max(keep + 1) to MAXFD and
- # loop through filling in the gaps.
-
- # Under new python versions, we need to explicitly set
- # passed fds to be inheritable or they will go away on exec
-
- # XXX: Bug: We implicitly rely on errpipe_write being the largest open
- # FD so that we don't change its cloexec flag.
-
- assert hasattr(os, 'closerange') # Added in 2.7
- keep = sorted(keep)
- min_keep = min(keep)
- max_keep = max(keep)
- os.closerange(3, min_keep)
- os.closerange(max_keep + 1, MAXFD)
-
- for i in xrange(min_keep, max_keep):
- if i in keep:
- _set_inheritable(i, True)
- continue
-
- try:
- os.close(i)
- except:
- pass
-
- def _execute_child(self, args, executable, preexec_fn, close_fds,
- pass_fds, cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite,
- restore_signals, start_new_session):
- """Execute program (POSIX version)"""
-
- if PY3 and isinstance(args, (str, bytes)):
- args = [args]
- elif not PY3 and isinstance(args, string_types):
- args = [args]
- else:
- try:
- args = list(args)
- except TypeError: # os.PathLike instead of a sequence?
- args = [fsencode(args)] # os.PathLike -> [str]
-
- if shell:
- args = ["/bin/sh", "-c"] + args
- if executable:
- args[0] = executable
-
- if executable is None:
- executable = args[0]
-
- self._loop.install_sigchld()
-
- # For transferring possible exec failure from child to parent
- # The first char specifies the exception type: 0 means
- # OSError, 1 means some other error.
- errpipe_read, errpipe_write = self.pipe_cloexec()
- # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
- low_fds_to_close = []
- while errpipe_write < 3:
- low_fds_to_close.append(errpipe_write)
- errpipe_write = os.dup(errpipe_write)
- for low_fd in low_fds_to_close:
- os.close(low_fd)
- try:
- try:
- gc_was_enabled = gc.isenabled()
- # Disable gc to avoid bug where gc -> file_dealloc ->
- # write to stderr -> hang. http://bugs.python.org/issue1336
- gc.disable()
- try:
- self.pid = fork_and_watch(self._on_child, self._loop, True, fork)
- except:
- if gc_was_enabled:
- gc.enable()
- raise
- if self.pid == 0:
- # Child
-
- # XXX: Technically we're doing a lot of stuff here that
- # may not be safe to do before a exec(), depending on the OS.
- # CPython 3 goes to great lengths to precompute a lot
- # of this info before the fork and pass it all to C functions that
- # try hard not to call things like malloc(). (Of course,
- # CPython 2 pretty much did what we're doing.)
- try:
- # Close parent's pipe ends
- if p2cwrite != -1:
- os.close(p2cwrite)
- if c2pread != -1:
- os.close(c2pread)
- if errread != -1:
- os.close(errread)
- os.close(errpipe_read)
-
- # When duping fds, if there arises a situation
- # where one of the fds is either 0, 1 or 2, it
- # is possible that it is overwritten (#12607).
- if c2pwrite == 0:
- c2pwrite = os.dup(c2pwrite)
- while errwrite in (0, 1):
- errwrite = os.dup(errwrite)
-
- # Dup fds for child
- def _dup2(existing, desired):
- # dup2() removes the CLOEXEC flag but
- # we must do it ourselves if dup2()
- # would be a no-op (issue #10806).
- if existing == desired:
- self._set_cloexec_flag(existing, False)
- elif existing != -1:
- os.dup2(existing, desired)
- try:
- self._remove_nonblock_flag(desired)
- except OSError:
- # Ignore EBADF, it may not actually be
- # open yet.
- # Tested beginning in 3.7.0b3 test_subprocess.py
- pass
- _dup2(p2cread, 0)
- _dup2(c2pwrite, 1)
- _dup2(errwrite, 2)
-
- # Close pipe fds. Make sure we don't close the
- # same fd more than once, or standard fds.
- closed = set([None])
- for fd in [p2cread, c2pwrite, errwrite]:
- if fd not in closed and fd > 2:
- os.close(fd)
- closed.add(fd)
-
- if cwd is not None:
- try:
- os.chdir(cwd)
- except OSError as e:
- e._failed_chdir = True
- raise
-
- if preexec_fn:
- preexec_fn()
-
- # Close all other fds, if asked for. This must be done
- # after preexec_fn runs.
- if close_fds:
- fds_to_keep = set(pass_fds)
- fds_to_keep.add(errpipe_write)
- self._close_fds(fds_to_keep, errpipe_write)
-
- if restore_signals:
- # restore the documented signals back to sig_dfl;
- # not all will be defined on every platform
- for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ':
- sig = getattr(signal, sig, None)
- if sig is not None:
- signal.signal(sig, signal.SIG_DFL)
-
- if start_new_session:
- os.setsid()
-
- if env is None:
- os.execvp(executable, args)
- else:
- if PY3:
- # Python 3.6 started testing for
- # bytes values in the env; it also
- # started encoding strs using
- # fsencode and using a lower-level
- # API that takes a list of keys
- # and values. We don't have access
- # to that API, so we go the reverse direction.
- env = {os.fsdecode(k) if isinstance(k, bytes) else k:
- os.fsdecode(v) if isinstance(v, bytes) else v
- for k, v in env.items()}
- os.execvpe(executable, args, env)
-
- except:
- exc_type, exc_value, tb = sys.exc_info()
- # Save the traceback and attach it to the exception object
- exc_lines = traceback.format_exception(exc_type,
- exc_value,
- tb)
- exc_value.child_traceback = ''.join(exc_lines)
- os.write(errpipe_write, pickle.dumps(exc_value))
-
- finally:
- # Make sure that the process exits no matter what.
- # The return code does not matter much as it won't be
- # reported to the application
- os._exit(1)
-
- # Parent
- self._child_created = True
- if gc_was_enabled:
- gc.enable()
- finally:
- # be sure the FD is closed no matter what
- os.close(errpipe_write)
-
- # self._devnull is not always defined.
- devnull_fd = getattr(self, '_devnull', None)
- if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
- os.close(p2cread)
- if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
- os.close(c2pwrite)
- if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
- os.close(errwrite)
- if devnull_fd is not None:
- os.close(devnull_fd)
- # Prevent a double close of these fds from __init__ on error.
- self._closed_child_pipe_fds = True
-
- # Wait for exec to fail or succeed; possibly raising exception
- errpipe_read = FileObject(errpipe_read, 'rb')
- data = errpipe_read.read()
- finally:
- if hasattr(errpipe_read, 'close'):
- errpipe_read.close()
- else:
- os.close(errpipe_read)
-
- if data != b"":
- self.wait()
- child_exception = pickle.loads(data)
- for fd in (p2cwrite, c2pread, errread):
- if fd is not None and fd != -1:
- os.close(fd)
- if isinstance(child_exception, OSError):
- child_exception.filename = executable
- if hasattr(child_exception, '_failed_chdir'):
- child_exception.filename = cwd
- raise child_exception
-
- def _handle_exitstatus(self, sts):
- if os.WIFSIGNALED(sts):
- self.returncode = -os.WTERMSIG(sts)
- elif os.WIFEXITED(sts):
- self.returncode = os.WEXITSTATUS(sts)
- else:
- # Should never happen
- raise RuntimeError("Unknown child exit status!")
-
- def _internal_poll(self):
- """Check if child process has terminated. Returns returncode
- attribute.
- """
- if self.returncode is None:
- if get_hub() is not getcurrent():
- sig_pending = getattr(self._loop, 'sig_pending', True)
- if sig_pending:
- sleep(0.00001)
- return self.returncode
-
- def wait(self, timeout=None, _raise_exc=PY3):
- """
- Wait for child process to terminate. Returns :attr:`returncode`
- attribute.
-
- :keyword timeout: The floating point number of seconds to
- wait. Under Python 2, this is a gevent extension, and
- we simply return if it expires. Under Python 3, if
- this time elapses without finishing the process,
- :exc:`TimeoutExpired` is raised.
- """
- return self._gevent_result_wait(timeout, _raise_exc)
-
- def send_signal(self, sig):
- """Send a signal to the process
- """
- # Skip signalling a process that we know has already died.
- if self.returncode is None:
- os.kill(self.pid, sig)
-
- def terminate(self):
- """Terminate the process with SIGTERM
- """
- self.send_signal(signal.SIGTERM)
-
- def kill(self):
- """Kill the process with SIGKILL
- """
- self.send_signal(signal.SIGKILL)
-
-
-def write_and_close(fobj, data):
- try:
- if data:
- fobj.write(data)
- if hasattr(fobj, 'flush'):
- # 3.6 started expecting flush to be called.
- fobj.flush()
- except (OSError, IOError) as ex:
- if ex.errno != errno.EPIPE and ex.errno != errno.EINVAL:
- raise
- finally:
- try:
- fobj.close()
- except EnvironmentError:
- pass
-
-def _with_stdout_stderr(exc, stderr):
- # Prior to Python 3.5, most exceptions didn't have stdout
- # and stderr attributes and can't take the stderr attribute in their
- # constructor
- exc.stdout = exc.output
- exc.stderr = stderr
- return exc
-
-class CompletedProcess(object):
- """
- A process that has finished running.
-
- This is returned by run().
-
- Attributes:
- - args: The list or str args passed to run().
- - returncode: The exit code of the process, negative for signals.
- - stdout: The standard output (None if not captured).
- - stderr: The standard error (None if not captured).
-
- .. versionadded:: 1.2a1
- This first appeared in Python 3.5 and is available to all
- Python versions in gevent.
- """
- def __init__(self, args, returncode, stdout=None, stderr=None):
- self.args = args
- self.returncode = returncode
- self.stdout = stdout
- self.stderr = stderr
-
- def __repr__(self):
- args = ['args={!r}'.format(self.args),
- 'returncode={!r}'.format(self.returncode)]
- if self.stdout is not None:
- args.append('stdout={!r}'.format(self.stdout))
- if self.stderr is not None:
- args.append('stderr={!r}'.format(self.stderr))
- return "{}({})".format(type(self).__name__, ', '.join(args))
-
- def check_returncode(self):
- """Raise CalledProcessError if the exit code is non-zero."""
- if self.returncode:
- raise _with_stdout_stderr(CalledProcessError(self.returncode, self.args, self.stdout), self.stderr)
-
-
-def run(*popenargs, **kwargs):
- """
- run(args, *, stdin=None, input=None, stdout=None, stderr=None, shell=False, timeout=None, check=False) -> CompletedProcess
-
- Run command with arguments and return a CompletedProcess instance.
-
- The returned instance will have attributes args, returncode, stdout and
- stderr. By default, stdout and stderr are not captured, and those attributes
- will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
- If check is True and the exit code was non-zero, it raises a
- CalledProcessError. The CalledProcessError object will have the return code
- in the returncode attribute, and output & stderr attributes if those streams
- were captured.
-
- If timeout is given, and the process takes too long, a TimeoutExpired
- exception will be raised.
-
- There is an optional argument "input", allowing you to
- pass a string to the subprocess's stdin. If you use this argument
- you may not also use the Popen constructor's "stdin" argument, as
- it will be used internally.
- The other arguments are the same as for the Popen constructor.
- If universal_newlines=True is passed, the "input" argument must be a
- string and stdout/stderr in the returned object will be strings rather than
- bytes.
-
- .. versionadded:: 1.2a1
- This function first appeared in Python 3.5. It is available on all Python
- versions gevent supports.
-
- .. versionchanged:: 1.3a2
- Add the ``capture_output`` argument from Python 3.7. It automatically sets
- ``stdout`` and ``stderr`` to ``PIPE``. It is an error to pass either
- of those arguments along with ``capture_output``.
- """
- input = kwargs.pop('input', None)
- timeout = kwargs.pop('timeout', None)
- check = kwargs.pop('check', False)
- capture_output = kwargs.pop('capture_output', False)
-
- if input is not None:
- if 'stdin' in kwargs:
- raise ValueError('stdin and input arguments may not both be used.')
- kwargs['stdin'] = PIPE
-
- if capture_output:
- if ('stdout' in kwargs) or ('stderr' in kwargs):
- raise ValueError('stdout and stderr arguments may not be used '
- 'with capture_output.')
- kwargs['stdout'] = PIPE
- kwargs['stderr'] = PIPE
-
- with Popen(*popenargs, **kwargs) as process:
- try:
- stdout, stderr = process.communicate(input, timeout=timeout)
- except TimeoutExpired:
- process.kill()
- stdout, stderr = process.communicate()
- raise _with_stdout_stderr(TimeoutExpired(process.args, timeout, output=stdout), stderr)
- except:
- process.kill()
- process.wait()
- raise
- retcode = process.poll()
- if check and retcode:
- raise _with_stdout_stderr(CalledProcessError(retcode, process.args, stdout), stderr)
-
- return CompletedProcess(process.args, retcode, stdout, stderr)
diff --git a/python/gevent/thread.py b/python/gevent/thread.py
deleted file mode 100644
index cceaf48..0000000
--- a/python/gevent/thread.py
+++ /dev/null
@@ -1,114 +0,0 @@
-"""
-Implementation of the standard :mod:`thread` module that spawns greenlets.
-
-.. note::
-
- This module is a helper for :mod:`gevent.monkey` and is not
- intended to be used directly. For spawning greenlets in your
- applications, prefer higher level constructs like
- :class:`gevent.Greenlet` class or :func:`gevent.spawn`.
-"""
-from __future__ import absolute_import
-import sys
-
-__implements__ = ['allocate_lock',
- 'get_ident',
- 'exit',
- 'LockType',
- 'stack_size',
- 'start_new_thread',
- '_local']
-
-__imports__ = ['error']
-if sys.version_info[0] <= 2:
- import thread as __thread__ # pylint:disable=import-error
-else:
- import _thread as __thread__ # pylint:disable=import-error
- __target__ = '_thread'
- __imports__ += ['RLock',
- 'TIMEOUT_MAX',
- 'allocate',
- 'exit_thread',
- 'interrupt_main',
- 'start_new']
-error = __thread__.error
-from gevent._compat import PY3
-from gevent._compat import PYPY
-from gevent._util import copy_globals
-from gevent.hub import getcurrent, GreenletExit
-from gevent.greenlet import Greenlet
-from gevent.lock import BoundedSemaphore
-from gevent.local import local as _local
-
-
-def get_ident(gr=None):
- if gr is None:
- gr = getcurrent()
- return id(gr)
-
-
-def start_new_thread(function, args=(), kwargs=None):
- if kwargs is not None:
- greenlet = Greenlet.spawn(function, *args, **kwargs)
- else:
- greenlet = Greenlet.spawn(function, *args)
- return get_ident(greenlet)
-
-
-class LockType(BoundedSemaphore):
- # Change the ValueError into the appropriate thread error
- # and any other API changes we need to make to match behaviour
- _OVER_RELEASE_ERROR = __thread__.error
-
- if PYPY and PY3:
- _OVER_RELEASE_ERROR = RuntimeError
-
- if PY3:
- _TIMEOUT_MAX = __thread__.TIMEOUT_MAX # python 2: pylint:disable=no-member
-
- def acquire(self, blocking=True, timeout=-1):
- # Transform the default -1 argument into the None that our
- # semaphore implementation expects, and raise the same error
- # the stdlib implementation does.
- if timeout == -1:
- timeout = None
- if not blocking and timeout is not None:
- raise ValueError("can't specify a timeout for a non-blocking call")
- if timeout is not None:
- if timeout < 0:
- # in C: if(timeout < 0 && timeout != -1)
- raise ValueError("timeout value must be strictly positive")
- if timeout > self._TIMEOUT_MAX:
- raise OverflowError('timeout value is too large')
-
- return BoundedSemaphore.acquire(self, blocking, timeout)
-
-allocate_lock = LockType
-
-
-def exit():
- raise GreenletExit
-
-
-if hasattr(__thread__, 'stack_size'):
- _original_stack_size = __thread__.stack_size
-
- def stack_size(size=None):
- if size is None:
- return _original_stack_size()
- if size > _original_stack_size():
- return _original_stack_size(size)
- # not going to decrease stack_size, because otherwise other
- # greenlets in this thread will suffer
-else:
- __implements__.remove('stack_size')
-
-__imports__ = copy_globals(__thread__, globals(),
- only_names=__imports__,
- ignore_missing_names=True)
-
-__all__ = __implements__ + __imports__
-__all__.remove('_local')
-
-# XXX interrupt_main
-# XXX _count()
diff --git a/python/gevent/threading.py b/python/gevent/threading.py
deleted file mode 100644
index 570ccd6..0000000
--- a/python/gevent/threading.py
+++ /dev/null
@@ -1,235 +0,0 @@
-"""
-Implementation of the standard :mod:`threading` using greenlets.
-
-.. note::
-
- This module is a helper for :mod:`gevent.monkey` and is not
- intended to be used directly. For spawning greenlets in your
- applications, prefer higher level constructs like
- :class:`gevent.Greenlet` class or :func:`gevent.spawn`. Attributes
- in this module like ``__threading__`` are implementation artifacts subject
- to change at any time.
-
-.. versionchanged:: 1.2.3
-
- Defer adjusting the stdlib's list of active threads until we are
- monkey patched. Previously this was done at import time. We are
- documented to only be used as a helper for monkey patching, so this should
- functionally be the same, but some applications ignore the documentation and
- directly import this module anyway.
-
- A positive consequence is that ``import gevent.threading,
- threading; threading.current_thread()`` will no longer return a DummyThread
- before monkey-patching.
-"""
-from __future__ import absolute_import
-
-
-__implements__ = [
- 'local',
- '_start_new_thread',
- '_allocate_lock',
- 'Lock',
- '_get_ident',
- '_sleep',
- '_DummyThread',
-]
-
-
-import threading as __threading__
-_DummyThread_ = __threading__._DummyThread
-from gevent.local import local
-from gevent.thread import start_new_thread as _start_new_thread, allocate_lock as _allocate_lock, get_ident as _get_ident
-from gevent.hub import sleep as _sleep, getcurrent
-
-# Exports, prevent unused import warnings
-local = local
-start_new_thread = _start_new_thread
-allocate_lock = _allocate_lock
-_get_ident = _get_ident
-_sleep = _sleep
-getcurrent = getcurrent
-
-Lock = _allocate_lock
-
-
-def _cleanup(g):
- __threading__._active.pop(_get_ident(g), None)
-
-def _make_cleanup_id(gid):
- def _(_r):
- __threading__._active.pop(gid, None)
- return _
-
-_weakref = None
-
-class _DummyThread(_DummyThread_):
- # We avoid calling the superclass constructor. This makes us about
- # twice as fast (1.16 vs 0.68usec on PyPy, 29.3 vs 17.7usec on
- # CPython 2.7), and has the important effect of avoiding
- # allocation and then immediate deletion of _Thread__block, a
- # lock. This is especially important on PyPy where locks go
- # through the cpyext API and Cython, which is known to be slow and
- # potentially buggy (e.g.,
- # https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22347393)
-
- # These objects are constructed quite frequently in some cases, so
- # the optimization matters: for example, in gunicorn, which uses
- # pywsgi.WSGIServer, every request is handled in a new greenlet,
- # and every request uses a logging.Logger to write the access log,
- # and every call to a log method captures the current thread (by
- # default).
- #
- # (Obviously we have to duplicate the effects of the constructor,
- # at least for external state purposes, which is potentially
- # slightly fragile.)
-
- # For the same reason, instances of this class will cleanup their own entry
- # in ``threading._active``
-
- # This class also solves a problem forking process with subprocess: after forking,
- # Thread.__stop is called, which throws an exception when __block doesn't
- # exist.
-
- # Capture the static things as class vars to save on memory/
- # construction time.
- # In Py2, they're all private; in Py3, they become protected
- _Thread__stopped = _is_stopped = _stopped = False
- _Thread__initialized = _initialized = True
- _Thread__daemonic = _daemonic = True
- _Thread__args = _args = ()
- _Thread__kwargs = _kwargs = None
- _Thread__target = _target = None
- _Thread_ident = _ident = None
- _Thread__started = _started = __threading__.Event()
- _Thread__started.set()
- _tstate_lock = None
-
- def __init__(self): # pylint:disable=super-init-not-called
- #_DummyThread_.__init__(self)
-
- # It'd be nice to use a pattern like "greenlet-%d", but maybe somebody out
- # there is checking thread names...
- self._name = self._Thread__name = __threading__._newname("DummyThread-%d")
- # All dummy threads in the same native thread share the same ident
- # (that of the native thread)
- self._set_ident()
-
- g = getcurrent()
- gid = _get_ident(g)
- __threading__._active[gid] = self
- rawlink = getattr(g, 'rawlink', None)
- if rawlink is not None:
- # raw greenlet.greenlet greenlets don't
- # have rawlink...
- rawlink(_cleanup)
- else:
- # ... so for them we use weakrefs.
- # See https://github.com/gevent/gevent/issues/918
- global _weakref
- if _weakref is None:
- _weakref = __import__('weakref')
- ref = _weakref.ref(g, _make_cleanup_id(gid))
- self.__raw_ref = ref
-
- def _Thread__stop(self):
- pass
-
- _stop = _Thread__stop # py3
-
- def _wait_for_tstate_lock(self, *args, **kwargs):
- # pylint:disable=arguments-differ
- pass
-
-if hasattr(__threading__, 'main_thread'): # py 3.4+
- def main_native_thread():
- return __threading__.main_thread() # pylint:disable=no-member
-else:
- def main_native_thread():
- main_threads = [v for v in __threading__._active.values()
- if isinstance(v, __threading__._MainThread)]
- assert len(main_threads) == 1, "Too many main threads"
-
- return main_threads[0]
-
-import sys
-if sys.version_info[:2] >= (3, 4):
- # XXX: Issue 18808 breaks us on Python 3.4.
- # Thread objects now expect a callback from the interpreter itself
- # (threadmodule.c:release_sentinel). Because this never happens
- # when a greenlet exits, join() and friends will block forever.
- # The solution below involves capturing the greenlet when it is
- # started and deferring the known broken methods to it.
-
- class Thread(__threading__.Thread):
- _greenlet = None
-
- def is_alive(self):
- return bool(self._greenlet)
-
- isAlive = is_alive
-
- def _set_tstate_lock(self):
- self._greenlet = getcurrent()
-
- def run(self):
- try:
- super(Thread, self).run()
- finally:
- # avoid ref cycles, but keep in __dict__ so we can
- # distinguish the started/never-started case
- self._greenlet = None
- self._stop() # mark as finished
-
- def join(self, timeout=None):
- if '_greenlet' not in self.__dict__:
- raise RuntimeError("Cannot join an inactive thread")
- if self._greenlet is None:
- return
- self._greenlet.join(timeout=timeout)
-
- def _wait_for_tstate_lock(self, *args, **kwargs):
- # pylint:disable=arguments-differ
- raise NotImplementedError()
-
- __implements__.append('Thread')
-
- class Timer(Thread, __threading__.Timer): # pylint:disable=abstract-method,inherit-non-class
- pass
-
- __implements__.append('Timer')
-
- # The main thread is patched up with more care
- # in _gevent_will_monkey_patch
-
-if sys.version_info[:2] >= (3, 3):
- __implements__.remove('_get_ident')
- __implements__.append('get_ident')
- get_ident = _get_ident
- __implements__.remove('_sleep')
-
- # Python 3 changed the implementation of threading.RLock
- # Previously it was a factory function around threading._RLock
- # which in turn used _allocate_lock. Now, it wants to use
- # threading._CRLock, which is imported from _thread.RLock and as such
- # is implemented in C. So it bypasses our _allocate_lock function.
- # Fortunately they left the Python fallback in place
- assert hasattr(__threading__, '_CRLock'), "Unsupported Python version"
- _CRLock = None
- __implements__.append('_CRLock')
-
-def _gevent_will_monkey_patch(native_module, items, warn): # pylint:disable=unused-argument
- # Make sure the MainThread can be found by our current greenlet ID,
- # otherwise we get a new DummyThread, which cannot be joined.
- # Fixes tests in test_threading_2 under PyPy.
- main_thread = main_native_thread()
- if __threading__.current_thread() != main_thread:
- warn("Monkey-patching outside the main native thread. Some APIs "
- "will not be available. Expect a KeyError to be printed at shutdown.")
- return
-
- if _get_ident() not in __threading__._active:
- main_id = main_thread.ident
- del __threading__._active[main_id]
- main_thread._ident = main_thread._Thread__ident = _get_ident()
- __threading__._active[_get_ident()] = main_thread
diff --git a/python/gevent/threadpool.py b/python/gevent/threadpool.py
deleted file mode 100644
index c983390..0000000
--- a/python/gevent/threadpool.py
+++ /dev/null
@@ -1,580 +0,0 @@
-# Copyright (c) 2012 Denis Bilenko. See LICENSE for details.
-from __future__ import absolute_import
-import sys
-import os
-
-from weakref import ref as wref
-
-from greenlet import greenlet as RawGreenlet
-
-from gevent._compat import integer_types
-from gevent.hub import _get_hub_noargs as get_hub
-from gevent.hub import getcurrent
-from gevent.hub import sleep
-from gevent.hub import _get_hub
-from gevent.event import AsyncResult
-from gevent.greenlet import Greenlet
-from gevent.pool import GroupMappingMixin
-from gevent.lock import Semaphore
-
-from gevent._threading import Lock
-from gevent._threading import Queue
-from gevent._threading import start_new_thread
-from gevent._threading import get_thread_ident
-
-
-__all__ = [
- 'ThreadPool',
- 'ThreadResult',
-]
-
-
-class _WorkerGreenlet(RawGreenlet):
- # Exists to produce a more useful repr for worker pool
- # threads/greenlets.
-
- def __init__(self, threadpool):
- RawGreenlet.__init__(self, threadpool._worker)
- self.thread_ident = get_thread_ident()
- self._threadpool_wref = wref(threadpool)
-
- # Inform the gevent.util.GreenletTree that this should be
- # considered the root (for printing purposes) and to
- # ignore the parent attribute. (We can't set parent to None.)
- self.greenlet_tree_is_root = True
- self.parent.greenlet_tree_is_ignored = True
-
- def __repr__(self):
- return "<ThreadPoolWorker at 0x%x thread_ident=0x%x %s>" % (
- id(self),
- self.thread_ident,
- self._threadpool_wref())
-
-class ThreadPool(GroupMappingMixin):
- """
- .. note:: The method :meth:`apply_async` will always return a new
- greenlet, bypassing the threadpool entirely.
- .. caution:: Instances of this class are only true if they have
- unfinished tasks.
- """
-
- def __init__(self, maxsize, hub=None):
- if hub is None:
- hub = get_hub()
- self.hub = hub
- self._maxsize = 0
- self.manager = None
- self.pid = os.getpid()
- self.fork_watcher = hub.loop.fork(ref=False)
- try:
- self._init(maxsize)
- except:
- self.fork_watcher.close()
- raise
-
- def _set_maxsize(self, maxsize):
- if not isinstance(maxsize, integer_types):
- raise TypeError('maxsize must be integer: %r' % (maxsize, ))
- if maxsize < 0:
- raise ValueError('maxsize must not be negative: %r' % (maxsize, ))
- difference = maxsize - self._maxsize
- self._semaphore.counter += difference
- self._maxsize = maxsize
- self.adjust()
- # make sure all currently blocking spawn() start unlocking if maxsize increased
- self._semaphore._start_notify()
-
- def _get_maxsize(self):
- return self._maxsize
-
- maxsize = property(_get_maxsize, _set_maxsize)
-
- def __repr__(self):
- return '<%s at 0x%x %s/%s/%s hub=<%s at 0x%x thread_ident=0x%s>>' % (
- self.__class__.__name__,
- id(self),
- len(self), self.size, self.maxsize,
- self.hub.__class__.__name__, id(self.hub), self.hub.thread_ident)
-
- def __len__(self):
- # XXX just do unfinished_tasks property
- # Note that this becomes the boolean value of this class,
- # that's probably not what we want!
- return self.task_queue.unfinished_tasks
-
- def _get_size(self):
- return self._size
-
- def _set_size(self, size):
- if size < 0:
- raise ValueError('Size of the pool cannot be negative: %r' % (size, ))
- if size > self._maxsize:
- raise ValueError('Size of the pool cannot be bigger than maxsize: %r > %r' % (size, self._maxsize))
- if self.manager:
- self.manager.kill()
- while self._size < size:
- self._add_thread()
- delay = getattr(self.hub.loop, 'min_sleep_time', 0.0001) # For libuv
- while self._size > size:
- while self._size - size > self.task_queue.unfinished_tasks:
- self.task_queue.put(None)
- if getcurrent() is self.hub:
- break
- sleep(delay)
- delay = min(delay * 2, .05)
- if self._size:
- self.fork_watcher.start(self._on_fork)
- else:
- self.fork_watcher.stop()
-
- size = property(_get_size, _set_size)
-
- def _init(self, maxsize):
- self._size = 0
- self._semaphore = Semaphore(1)
- self._lock = Lock()
- self.task_queue = Queue()
- self._set_maxsize(maxsize)
-
- def _on_fork(self):
- # fork() only leaves one thread; also screws up locks;
- # let's re-create locks and threads.
- # NOTE: See comment in gevent.hub.reinit.
- pid = os.getpid()
- if pid != self.pid:
- self.pid = pid
- # Do not mix fork() and threads; since fork() only copies one thread
- # all objects referenced by other threads has refcount that will never
- # go down to 0.
- self._init(self._maxsize)
-
- def join(self):
- """Waits until all outstanding tasks have been completed."""
- delay = 0.0005
- while self.task_queue.unfinished_tasks > 0:
- sleep(delay)
- delay = min(delay * 2, .05)
-
- def kill(self):
- self.size = 0
- self.fork_watcher.close()
-
- def _adjust_step(self):
- # if there is a possibility & necessity for adding a thread, do it
- while self._size < self._maxsize and self.task_queue.unfinished_tasks > self._size:
- self._add_thread()
- # while the number of threads is more than maxsize, kill one
- # we do not check what's already in task_queue - it could be all Nones
- while self._size - self._maxsize > self.task_queue.unfinished_tasks:
- self.task_queue.put(None)
- if self._size:
- self.fork_watcher.start(self._on_fork)
- else:
- self.fork_watcher.stop()
-
- def _adjust_wait(self):
- delay = 0.0001
- while True:
- self._adjust_step()
- if self._size <= self._maxsize:
- return
- sleep(delay)
- delay = min(delay * 2, .05)
-
- def adjust(self):
- self._adjust_step()
- if not self.manager and self._size > self._maxsize:
- # might need to feed more Nones into the pool
- self.manager = Greenlet.spawn(self._adjust_wait)
-
- def _add_thread(self):
- with self._lock:
- self._size += 1
- try:
- start_new_thread(self.__trampoline, ())
- except:
- with self._lock:
- self._size -= 1
- raise
-
- def spawn(self, func, *args, **kwargs):
- """
- Add a new task to the threadpool that will run ``func(*args, **kwargs)``.
-
- Waits until a slot is available. Creates a new thread if necessary.
-
- :return: A :class:`gevent.event.AsyncResult`.
- """
- while 1:
- semaphore = self._semaphore
- semaphore.acquire()
- if semaphore is self._semaphore:
- break
-
- thread_result = None
- try:
- task_queue = self.task_queue
- result = AsyncResult()
- # XXX We're calling the semaphore release function in the hub, otherwise
- # we get LoopExit (why?). Previously it was done with a rawlink on the
- # AsyncResult and the comment that it is "competing for order with get(); this is not
- # good, just make ThreadResult release the semaphore before doing anything else"
- thread_result = ThreadResult(result, self.hub, semaphore.release)
- task_queue.put((func, args, kwargs, thread_result))
- self.adjust()
- except:
- if thread_result is not None:
- thread_result.destroy()
- semaphore.release()
- raise
- return result
-
- def _decrease_size(self):
- if sys is None:
- return
- _lock = getattr(self, '_lock', None)
- if _lock is not None:
- with _lock:
- self._size -= 1
-
- # XXX: This used to be false by default. It really seems like
- # it should be true to avoid leaking resources.
- _destroy_worker_hub = True
-
-
- def __ignore_current_greenlet_blocking(self, hub):
- if hub is not None and hub.periodic_monitoring_thread is not None:
- hub.periodic_monitoring_thread.ignore_current_greenlet_blocking()
-
- def __trampoline(self):
- # The target that we create new threads with. It exists
- # solely to create the _WorkerGreenlet and switch to it.
- # (the __class__ of a raw greenlet cannot be changed.)
- g = _WorkerGreenlet(self)
- g.switch()
-
- def _worker(self):
- # pylint:disable=too-many-branches
- need_decrease = True
- try:
- while 1: # tiny bit faster than True on Py2
- h = _get_hub()
- if h is not None:
- h.name = 'ThreadPool Worker Hub'
- task_queue = self.task_queue
- # While we block, don't let the monitoring thread, if any,
- # report us as blocked. Indeed, so long as we never
- # try to switch greenlets, don't report us as blocked---
- # the threadpool is *meant* to run blocking tasks
- self.__ignore_current_greenlet_blocking(h)
- task = task_queue.get()
- try:
- if task is None:
- need_decrease = False
- self._decrease_size()
- # we want first to decrease size, then decrease unfinished_tasks
- # otherwise, _adjust might think there's one more idle thread that
- # needs to be killed
- return
- func, args, kwargs, thread_result = task
- try:
- value = func(*args, **kwargs)
- except: # pylint:disable=bare-except
- exc_info = getattr(sys, 'exc_info', None)
- if exc_info is None:
- return
- thread_result.handle_error((self, func), exc_info())
- else:
- if sys is None:
- return
- thread_result.set(value)
- del value
- finally:
- del func, args, kwargs, thread_result, task
- finally:
- if sys is None:
- return # pylint:disable=lost-exception
- task_queue.task_done()
- finally:
- if need_decrease:
- self._decrease_size()
- if sys is not None and self._destroy_worker_hub:
- hub = _get_hub()
- if hub is not None:
- hub.destroy(True)
- del hub
-
- def apply_e(self, expected_errors, function, args=None, kwargs=None):
- """
- .. deprecated:: 1.1a2
- Identical to :meth:`apply`; the ``expected_errors`` argument is ignored.
- """
- # pylint:disable=unused-argument
- # Deprecated but never documented. In the past, before
- # self.apply() allowed all errors to be raised to the caller,
- # expected_errors allowed a caller to specify a set of errors
- # they wanted to be raised, through the wrap_errors function.
- # In practice, it always took the value Exception or
- # BaseException.
- return self.apply(function, args, kwargs)
-
- def _apply_immediately(self):
- # If we're being called from a different thread than the one that
- # created us, e.g., because a worker task is trying to use apply()
- # recursively, we have no choice but to run the task immediately;
- # if we try to AsyncResult.get() in the worker thread, it's likely to have
- # nothing to switch to and lead to a LoopExit.
- return get_hub() is not self.hub
-
- def _apply_async_cb_spawn(self, callback, result):
- callback(result)
-
- def _apply_async_use_greenlet(self):
- # Always go to Greenlet because our self.spawn uses threads
- return True
-
-class _FakeAsync(object):
-
- def send(self):
- pass
- close = stop = send
-
- def __call_(self, result):
- "fake out for 'receiver'"
-
- def __bool__(self):
- return False
-
- __nonzero__ = __bool__
-
-_FakeAsync = _FakeAsync()
-
-class ThreadResult(object):
-
- # Using slots here helps to debug reference cycles/leaks
- __slots__ = ('exc_info', 'async_watcher', '_call_when_ready', 'value',
- 'context', 'hub', 'receiver')
-
- def __init__(self, receiver, hub, call_when_ready):
- self.receiver = receiver
- self.hub = hub
- self.context = None
- self.value = None
- self.exc_info = ()
- self.async_watcher = hub.loop.async_()
- self._call_when_ready = call_when_ready
- self.async_watcher.start(self._on_async)
-
- @property
- def exception(self):
- return self.exc_info[1] if self.exc_info else None
-
- def _on_async(self):
- self.async_watcher.stop()
- self.async_watcher.close()
-
- # Typically this is pool.semaphore.release and we have to
- # call this in the Hub; if we don't we get the dreaded
- # LoopExit (XXX: Why?)
- self._call_when_ready()
-
- try:
- if self.exc_info:
- self.hub.handle_error(self.context, *self.exc_info)
- self.context = None
- self.async_watcher = _FakeAsync
- self.hub = None
- self._call_when_ready = _FakeAsync
-
- self.receiver(self)
- finally:
- self.receiver = _FakeAsync
- self.value = None
- if self.exc_info:
- self.exc_info = (self.exc_info[0], self.exc_info[1], None)
-
- def destroy(self):
- self.async_watcher.stop()
- self.async_watcher.close()
- self.async_watcher = _FakeAsync
-
- self.context = None
- self.hub = None
- self._call_when_ready = _FakeAsync
- self.receiver = _FakeAsync
-
- def set(self, value):
- self.value = value
- self.async_watcher.send()
-
- def handle_error(self, context, exc_info):
- self.context = context
- self.exc_info = exc_info
- self.async_watcher.send()
-
- # link protocol:
- def successful(self):
- return self.exception is None
-
-
-def wrap_errors(errors, function, args, kwargs):
- """
- .. deprecated:: 1.1a2
- Previously used by ThreadPool.apply_e.
- """
- try:
- return True, function(*args, **kwargs)
- except errors as ex:
- return False, ex
-
-try:
- import concurrent.futures
-except ImportError:
- pass
-else:
- __all__.append("ThreadPoolExecutor")
-
- from gevent.timeout import Timeout as GTimeout
- from gevent._util import Lazy
- from concurrent.futures import _base as cfb
-
- def _wrap_error(future, fn):
- def cbwrap(_):
- del _
- # we're called with the async result, but
- # be sure to pass in ourself. Also automatically
- # unlink ourself so that we don't get called multiple
- # times.
- try:
- fn(future)
- except Exception: # pylint: disable=broad-except
- future.hub.print_exception((fn, future), *sys.exc_info())
- cbwrap.auto_unlink = True
- return cbwrap
-
- def _wrap(future, fn):
- def f(_):
- fn(future)
- f.auto_unlink = True
- return f
-
- class _FutureProxy(object):
- def __init__(self, asyncresult):
- self.asyncresult = asyncresult
-
- # Internal implementation details of a c.f.Future
-
- @Lazy
- def _condition(self):
- from gevent import monkey
- if monkey.is_module_patched('threading') or self.done():
- import threading
- return threading.Condition()
- # We can only properly work with conditions
- # when we've been monkey-patched. This is necessary
- # for the wait/as_completed module functions.
- raise AttributeError("_condition")
-
- @Lazy
- def _waiters(self):
- self.asyncresult.rawlink(self.__when_done)
- return []
-
- def __when_done(self, _):
- # We should only be called when _waiters has
- # already been accessed.
- waiters = getattr(self, '_waiters')
- for w in waiters: # pylint:disable=not-an-iterable
- if self.successful():
- w.add_result(self)
- else:
- w.add_exception(self)
-
- __when_done.auto_unlink = True
-
- @property
- def _state(self):
- if self.done():
- return cfb.FINISHED
- return cfb.RUNNING
-
- def set_running_or_notify_cancel(self):
- # Does nothing, not even any consistency checks. It's
- # meant to be internal to the executor and we don't use it.
- return
-
- def result(self, timeout=None):
- try:
- return self.asyncresult.result(timeout=timeout)
- except GTimeout:
- # XXX: Theoretically this could be a completely
- # unrelated timeout instance. Do we care about that?
- raise concurrent.futures.TimeoutError()
-
- def exception(self, timeout=None):
- try:
- self.asyncresult.get(timeout=timeout)
- return self.asyncresult.exception
- except GTimeout:
- raise concurrent.futures.TimeoutError()
-
- def add_done_callback(self, fn):
- if self.done():
- fn(self)
- else:
- self.asyncresult.rawlink(_wrap_error(self, fn))
-
- def rawlink(self, fn):
- self.asyncresult.rawlink(_wrap(self, fn))
-
- def __str__(self):
- return str(self.asyncresult)
-
- def __getattr__(self, name):
- return getattr(self.asyncresult, name)
-
- class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):
- """
- A version of :class:`concurrent.futures.ThreadPoolExecutor` that
- always uses native threads, even when threading is monkey-patched.
-
- The ``Future`` objects returned from this object can be used
- with gevent waiting primitives like :func:`gevent.wait`.
-
- .. caution:: If threading is *not* monkey-patched, then the ``Future``
- objects returned by this object are not guaranteed to work with
- :func:`~concurrent.futures.as_completed` and :func:`~concurrent.futures.wait`.
- The individual blocking methods like :meth:`~concurrent.futures.Future.result`
- and :meth:`~concurrent.futures.Future.exception` will always work.
-
- .. versionadded:: 1.2a1
- This is a provisional API.
- """
-
- def __init__(self, max_workers):
- super(ThreadPoolExecutor, self).__init__(max_workers)
- self._threadpool = ThreadPool(max_workers)
- self._threadpool._destroy_worker_hub = True
-
- def submit(self, fn, *args, **kwargs):
- with self._shutdown_lock: # pylint:disable=not-context-manager
- if self._shutdown:
- raise RuntimeError('cannot schedule new futures after shutdown')
-
- future = self._threadpool.spawn(fn, *args, **kwargs)
- return _FutureProxy(future)
-
- def shutdown(self, wait=True):
- super(ThreadPoolExecutor, self).shutdown(wait)
- # XXX: We don't implement wait properly
- kill = getattr(self._threadpool, 'kill', None)
- if kill: # pylint:disable=using-constant-test
- self._threadpool.kill()
- self._threadpool = None
-
- kill = shutdown # greentest compat
-
- def _adjust_thread_count(self):
- # Does nothing. We don't want to spawn any "threads",
- # let the threadpool handle that.
- pass
diff --git a/python/gevent/time.py b/python/gevent/time.py
deleted file mode 100644
index 34abf85..0000000
--- a/python/gevent/time.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (c) 2018 gevent. See LICENSE for details.
-"""
-The standard library :mod:`time` module, but :func:`sleep` is
-gevent-aware.
-
-.. versionadded:: 1.3a2
-"""
-
-from __future__ import absolute_import
-
-__implements__ = [
- 'sleep',
-]
-
-__all__ = __implements__
-
-import time as __time__
-
-from gevent._util import copy_globals
-
-__imports__ = copy_globals(__time__, globals(),
- names_to_ignore=__implements__)
-
-
-
-from gevent.hub import sleep
-sleep = sleep # pylint
diff --git a/python/gevent/timeout.py b/python/gevent/timeout.py
deleted file mode 100644
index 1cc05e4..0000000
--- a/python/gevent/timeout.py
+++ /dev/null
@@ -1,373 +0,0 @@
-# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details.
-"""
-Timeouts.
-
-Many functions in :mod:`gevent` have a *timeout* argument that allows
-limiting the time the function will block. When that is not available,
-the :class:`Timeout` class and :func:`with_timeout` function in this
-module add timeouts to arbitrary code.
-
-.. warning::
-
- Timeouts can only work when the greenlet switches to the hub.
- If a blocking function is called or an intense calculation is ongoing during
- which no switches occur, :class:`Timeout` is powerless.
-"""
-from __future__ import absolute_import, print_function, division
-
-from gevent._compat import string_types
-from gevent._util import _NONE
-
-from greenlet import getcurrent
-from gevent._hub_local import get_hub_noargs as get_hub
-
-__all__ = [
- 'Timeout',
- 'with_timeout',
-]
-
-
-class _FakeTimer(object):
- # An object that mimics the API of get_hub().loop.timer, but
- # without allocating any native resources. This is useful for timeouts
- # that will never expire.
- # Also partially mimics the API of Timeout itself for use in _start_new_or_dummy
-
- # This object is used as a singleton, so it should be
- # immutable.
- __slots__ = ()
-
- @property
- def pending(self):
- return False
-
- active = pending
-
- @property
- def seconds(self):
- return None
-
- timer = exception = seconds
-
- def start(self, *args, **kwargs):
- # pylint:disable=unused-argument
- raise AssertionError("non-expiring timer cannot be started")
-
- def stop(self):
- return
-
- cancel = stop
-
- stop = close = cancel
-
- def __enter__(self):
- return self
-
- def __exit__(self, _t, _v, _tb):
- return
-
-_FakeTimer = _FakeTimer()
-
-
-class Timeout(BaseException):
- """
- Timeout(seconds=None, exception=None, ref=True, priority=-1)
-
- Raise *exception* in the current greenlet after *seconds*
- have elapsed::
-
- timeout = Timeout(seconds, exception)
- timeout.start()
- try:
- ... # exception will be raised here, after *seconds* passed since start() call
- finally:
- timeout.close()
-
- .. note::
-
- If the code that the timeout was protecting finishes
- executing before the timeout elapses, be sure to ``close`` the
- timeout so it is not unexpectedly raised in the future. Even if it
- is raised, it is a best practice to close it. This ``try/finally``
- construct or a ``with`` statement is a recommended pattern. (If
- the timeout object will be started again, use ``cancel`` instead
- of ``close``; this is rare.)
-
- When *exception* is omitted or ``None``, the ``Timeout`` instance
- itself is raised::
-
- >>> import gevent
- >>> gevent.Timeout(0.1).start()
- >>> gevent.sleep(0.2) #doctest: +IGNORE_EXCEPTION_DETAIL
- Traceback (most recent call last):
- ...
- Timeout: 0.1 seconds
-
- If the *seconds* argument is not given or is ``None`` (e.g.,
- ``Timeout()``), then the timeout will never expire and never raise
- *exception*. This is convenient for creating functions which take
- an optional timeout parameter of their own. (Note that this is **not**
- the same thing as a *seconds* value of ``0``.)
-
- ::
-
- def function(args, timeout=None):
- "A function with an optional timeout."
- timer = Timeout(timeout)
- with timer:
- ...
-
- .. caution::
-
- A *seconds* value less than ``0.0`` (e.g., ``-1``) is poorly defined. In the future,
- support for negative values is likely to do the same thing as a value
- of ``None`` or ``0``
-
- A *seconds* value of ``0`` requests that the event loop spin and poll for I/O;
- it will immediately expire as soon as control returns to the event loop.
-
- .. rubric:: Use As A Context Manager
-
- To simplify starting and canceling timeouts, the ``with``
- statement can be used::
-
- with gevent.Timeout(seconds, exception) as timeout:
- pass # ... code block ...
-
- This is equivalent to the try/finally block above with one
- additional feature: if *exception* is the literal ``False``, the
- timeout is still raised, but the context manager suppresses it, so
- the code outside the with-block won't see it.
-
- This is handy for adding a timeout to the functions that don't
- support a *timeout* parameter themselves::
-
- data = None
- with gevent.Timeout(5, False):
- data = mysock.makefile().readline()
- if data is None:
- ... # 5 seconds passed without reading a line
- else:
- ... # a line was read within 5 seconds
-
- .. caution::
-
- If ``readline()`` above catches and doesn't re-raise
- :exc:`BaseException` (for example, with a bare ``except:``), then
- your timeout will fail to function and control won't be returned
- to you when you expect.
-
- .. rubric:: Catching Timeouts
-
- When catching timeouts, keep in mind that the one you catch may
- not be the one you have set (a calling function may have set its
- own timeout); if you going to silence a timeout, always check that
- it's the instance you need::
-
- timeout = Timeout(1)
- timeout.start()
- try:
- ...
- except Timeout as t:
- if t is not timeout:
- raise # not my timeout
- finally:
- timeout.close()
-
-
- .. versionchanged:: 1.1b2
-
- If *seconds* is not given or is ``None``, no longer allocate a
- native timer object that will never be started.
-
- .. versionchanged:: 1.1
-
- Add warning about negative *seconds* values.
-
- .. versionchanged:: 1.3a1
-
- Timeout objects now have a :meth:`close`
- method that must be called when the timeout will no longer be
- used to properly clean up native resources.
- The ``with`` statement does this automatically.
-
- """
-
- # We inherit a __dict__ from BaseException, so __slots__ actually
- # makes us larger.
-
- def __init__(self, seconds=None, exception=None, ref=True, priority=-1,
- _one_shot=False):
- BaseException.__init__(self)
- self.seconds = seconds
- self.exception = exception
- self._one_shot = _one_shot
- if seconds is None:
- # Avoid going through the timer codepath if no timeout is
- # desired; this avoids some CFFI interactions on PyPy that can lead to a
- # RuntimeError if this implementation is used during an `import` statement. See
- # https://bitbucket.org/pypy/pypy/issues/2089/crash-in-pypy-260-linux64-with-gevent-11b1
- # and https://github.com/gevent/gevent/issues/618.
- # Plus, in general, it should be more efficient
-
- self.timer = _FakeTimer
- else:
- # XXX: A timer <= 0 could cause libuv to block the loop; we catch
- # that case in libuv/loop.py
- self.timer = get_hub().loop.timer(seconds or 0.0, ref=ref, priority=priority)
-
- def start(self):
- """Schedule the timeout."""
- if self.pending:
- raise AssertionError('%r is already started; to restart it, cancel it first' % self)
-
- if self.seconds is None:
- # "fake" timeout (never expires)
- return
-
- if self.exception is None or self.exception is False or isinstance(self.exception, string_types):
- # timeout that raises self
- throws = self
- else:
- # regular timeout with user-provided exception
- throws = self.exception
-
- # Make sure the timer updates the current time so that we don't
- # expire prematurely.
- self.timer.start(getcurrent().throw, throws, update=True)
-
- @classmethod
- def start_new(cls, timeout=None, exception=None, ref=True, _one_shot=False):
- """Create a started :class:`Timeout`.
-
- This is a shortcut, the exact action depends on *timeout*'s type:
-
- * If *timeout* is a :class:`Timeout`, then call its :meth:`start` method
- if it's not already begun.
- * Otherwise, create a new :class:`Timeout` instance, passing (*timeout*, *exception*) as
- arguments, then call its :meth:`start` method.
-
- Returns the :class:`Timeout` instance.
- """
- if isinstance(timeout, Timeout):
- if not timeout.pending:
- timeout.start()
- return timeout
- timeout = cls(timeout, exception, ref=ref, _one_shot=_one_shot)
- timeout.start()
- return timeout
-
- @staticmethod
- def _start_new_or_dummy(timeout, exception=None, ref=True):
- # Internal use only in 1.1
- # Return an object with a 'cancel' method; if timeout is None,
- # this will be a shared instance object that does nothing. Otherwise,
- # return an actual Timeout. Because negative values are hard to reason about,
- # and are often used as sentinels in Python APIs, in the future it's likely
- # that a negative timeout will also return the shared instance.
- # This saves the previously common idiom of 'timer = Timeout.start_new(t) if t is not None else None'
- # followed by 'if timer is not None: timer.cancel()'.
- # That idiom was used to avoid any object allocations.
- # A staticmethod is slightly faster under CPython, compared to a classmethod;
- # under PyPy in synthetic benchmarks it makes no difference.
- if timeout is None:
- return _FakeTimer
- return Timeout.start_new(timeout, exception, ref, _one_shot=True)
-
- @property
- def pending(self):
- """True if the timeout is scheduled to be raised."""
- return self.timer.pending or self.timer.active
-
- def cancel(self):
- """
- If the timeout is pending, cancel it. Otherwise, do nothing.
-
- The timeout object can be :meth:`started <start>` again. If
- you will not start the timeout again, you should use
- :meth:`close` instead.
- """
- self.timer.stop()
- if self._one_shot:
- self.close()
-
- def close(self):
- """
- Close the timeout and free resources. The timer cannot be started again
- after this method has been used.
- """
- self.timer.stop()
- self.timer.close()
- self.timer = _FakeTimer
-
- def __repr__(self):
- classname = type(self).__name__
- if self.pending:
- pending = ' pending'
- else:
- pending = ''
- if self.exception is None:
- exception = ''
- else:
- exception = ' exception=%r' % self.exception
- return '<%s at %s seconds=%s%s%s>' % (classname, hex(id(self)), self.seconds, exception, pending)
-
- def __str__(self):
- """
- >>> raise Timeout #doctest: +IGNORE_EXCEPTION_DETAIL
- Traceback (most recent call last):
- ...
- Timeout
- """
- if self.seconds is None:
- return ''
-
- suffix = '' if self.seconds == 1 else 's'
-
- if self.exception is None:
- return '%s second%s' % (self.seconds, suffix)
- if self.exception is False:
- return '%s second%s (silent)' % (self.seconds, suffix)
- return '%s second%s: %s' % (self.seconds, suffix, self.exception)
-
- def __enter__(self):
- """
- Start and return the timer. If the timer is already started, just return it.
- """
- if not self.pending:
- self.start()
- return self
-
- def __exit__(self, typ, value, tb):
- """
- Stop the timer.
-
- .. versionchanged:: 1.3a1
- The underlying native timer is also stopped. This object cannot be
- used again.
- """
- self.close()
- if value is self and self.exception is False:
- return True # Suppress the exception
-
-
-def with_timeout(seconds, function, *args, **kwds):
- """Wrap a call to *function* with a timeout; if the called
- function fails to return before the timeout, cancel it and return a
- flag value, provided by *timeout_value* keyword argument.
-
- If timeout expires but *timeout_value* is not provided, raise :class:`Timeout`.
-
- Keyword argument *timeout_value* is not passed to *function*.
- """
- timeout_value = kwds.pop("timeout_value", _NONE)
- timeout = Timeout.start_new(seconds, _one_shot=True)
- try:
- try:
- return function(*args, **kwds)
- except Timeout as ex:
- if ex is timeout and timeout_value is not _NONE:
- return timeout_value
- raise
- finally:
- timeout.cancel()
diff --git a/python/gevent/util.py b/python/gevent/util.py
deleted file mode 100644
index f15bd07..0000000
--- a/python/gevent/util.py
+++ /dev/null
@@ -1,592 +0,0 @@
-# Copyright (c) 2009 Denis Bilenko. See LICENSE for details.
-"""
-Low-level utilities.
-"""
-
-from __future__ import absolute_import, print_function, division
-
-import functools
-import gc
-import pprint
-import sys
-import traceback
-
-from greenlet import getcurrent
-from greenlet import greenlet as RawGreenlet
-
-from gevent._compat import PYPY
-from gevent._compat import thread_mod_name
-from gevent._util import _NONE
-
-__all__ = [
- 'format_run_info',
- 'print_run_info',
- 'GreenletTree',
- 'wrap_errors',
- 'assert_switches',
-]
-
-# PyPy is very slow at formatting stacks
-# for some reason.
-_STACK_LIMIT = 20 if PYPY else None
-
-
-def _noop():
- return None
-
-def _ready():
- return False
-
-class wrap_errors(object):
- """
- Helper to make function return an exception, rather than raise it.
-
- Because every exception that is unhandled by greenlet will be logged,
- it is desirable to prevent non-error exceptions from leaving a greenlet.
- This can done with a simple ``try/except`` construct::
-
- def wrapped_func(*args, **kwargs):
- try:
- return func(*args, **kwargs)
- except (TypeError, ValueError, AttributeError) as ex:
- return ex
-
- This class provides a shortcut to write that in one line::
-
- wrapped_func = wrap_errors((TypeError, ValueError, AttributeError), func)
-
- It also preserves ``__str__`` and ``__repr__`` of the original function.
- """
- # QQQ could also support using wrap_errors as a decorator
-
- def __init__(self, errors, func):
- """
- Calling this makes a new function from *func*, such that it catches *errors* (an
- :exc:`BaseException` subclass, or a tuple of :exc:`BaseException` subclasses) and
- return it as a value.
- """
- self.__errors = errors
- self.__func = func
- # Set __doc__, __wrapped__, etc, especially useful on Python 3.
- functools.update_wrapper(self, func)
-
- def __call__(self, *args, **kwargs):
- func = self.__func
- try:
- return func(*args, **kwargs)
- except self.__errors as ex:
- return ex
-
- def __str__(self):
- return str(self.__func)
-
- def __repr__(self):
- return repr(self.__func)
-
- def __getattr__(self, name):
- return getattr(self.__func, name)
-
-
-def print_run_info(thread_stacks=True, greenlet_stacks=True, limit=_NONE, file=None):
- """
- Call `format_run_info` and print the results to *file*.
-
- If *file* is not given, `sys.stderr` will be used.
-
- .. versionadded:: 1.3b1
- """
- lines = format_run_info(thread_stacks=thread_stacks,
- greenlet_stacks=greenlet_stacks,
- limit=limit)
- file = sys.stderr if file is None else file
- for l in lines:
- print(l, file=file)
-
-
-def format_run_info(thread_stacks=True,
- greenlet_stacks=True,
- limit=_NONE,
- current_thread_ident=None):
- """
- format_run_info(thread_stacks=True, greenlet_stacks=True, limit=None) -> [str]
-
- Request information about the running threads of the current process.
-
- This is a debugging utility. Its output has no guarantees other than being
- intended for human consumption.
-
- :keyword bool thread_stacks: If true, then include the stacks for
- running threads.
- :keyword bool greenlet_stacks: If true, then include the stacks for
- running greenlets. (Spawning stacks will always be printed.)
- Setting this to False can reduce the output volume considerably
- without reducing the overall information if *thread_stacks* is true
- and you can associate a greenlet to a thread (using ``thread_ident``
- printed values).
- :keyword int limit: If given, passed directly to `traceback.format_stack`.
- If not given, this defaults to the whole stack under CPython, and a
- smaller stack under PyPy.
-
- :return: A sequence of text lines detailing the stacks of running
- threads and greenlets. (One greenlet will duplicate one thread,
- the current thread and greenlet. If there are multiple running threads,
- the stack for the current greenlet may be incorrectly duplicated in multiple
- greenlets.)
- Extra information about
- :class:`gevent.Greenlet` object will also be returned.
-
- .. versionadded:: 1.3a1
- .. versionchanged:: 1.3a2
- Renamed from ``dump_stacks`` to reflect the fact that this
- prints additional information about greenlets, including their
- spawning stack, parent, locals, and any spawn tree locals.
- .. versionchanged:: 1.3b1
- Added the *thread_stacks*, *greenlet_stacks*, and *limit* params.
- """
- if current_thread_ident is None:
- from gevent import monkey
- current_thread_ident = monkey.get_original(thread_mod_name, 'get_ident')()
-
- lines = []
-
- limit = _STACK_LIMIT if limit is _NONE else limit
- _format_thread_info(lines, thread_stacks, limit, current_thread_ident)
- _format_greenlet_info(lines, greenlet_stacks, limit)
- return lines
-
-
-def _format_thread_info(lines, thread_stacks, limit, current_thread_ident):
- import threading
-
- threads = {th.ident: th for th in threading.enumerate()}
-
- lines.append('*' * 80)
- lines.append('* Threads')
-
- thread = None
- frame = None
- for thread_ident, frame in sys._current_frames().items():
- lines.append("*" * 80)
- thread = threads.get(thread_ident)
- name = thread.name if thread else None
- if getattr(thread, 'gevent_monitoring_thread', None):
- name = repr(thread.gevent_monitoring_thread())
- if current_thread_ident == thread_ident:
- name = '%s) (CURRENT' % (name,)
- lines.append('Thread 0x%x (%s)\n' % (thread_ident, name))
- if thread_stacks:
- lines.append(''.join(traceback.format_stack(frame, limit)))
- else:
- lines.append('\t...stack elided...')
-
- # We may have captured our own frame, creating a reference
- # cycle, so clear it out.
- del thread
- del frame
- del lines
- del threads
-
-def _format_greenlet_info(lines, greenlet_stacks, limit):
- # Use the gc module to inspect all objects to find the greenlets
- # since there isn't a global registry
- lines.append('*' * 80)
- lines.append('* Greenlets')
- lines.append('*' * 80)
- for tree in GreenletTree.forest():
- lines.extend(tree.format_lines(details={
- 'running_stacks': greenlet_stacks,
- 'running_stack_limit': limit,
- }))
-
- del lines
-
-dump_stacks = format_run_info
-
-def _line(f):
- @functools.wraps(f)
- def w(self, *args, **kwargs):
- r = f(self, *args, **kwargs)
- self.lines.append(r)
-
- return w
-
-class _TreeFormatter(object):
- UP_AND_RIGHT = '+'
- HORIZONTAL = '-'
- VERTICAL = '|'
- VERTICAL_AND_RIGHT = '+'
- DATA = ':'
-
- label_space = 1
- horiz_width = 3
- indent = 1
-
- def __init__(self, details, depth=0):
- self.lines = []
- self.depth = depth
- self.details = details
- if not details:
- self.child_data = lambda *args, **kwargs: None
-
- def deeper(self):
- return type(self)(self.details, self.depth + 1)
-
- @_line
- def node_label(self, text):
- return text
-
- @_line
- def child_head(self, label, right=VERTICAL_AND_RIGHT):
- return (
- ' ' * self.indent
- + right
- + self.HORIZONTAL * self.horiz_width
- + ' ' * self.label_space
- + label
- )
-
- def last_child_head(self, label):
- return self.child_head(label, self.UP_AND_RIGHT)
-
- @_line
- def child_tail(self, line, vertical=VERTICAL):
- return (
- ' ' * self.indent
- + vertical
- + ' ' * self.horiz_width
- + line
- )
-
- def last_child_tail(self, line):
- return self.child_tail(line, vertical=' ' * len(self.VERTICAL))
-
- @_line
- def child_data(self, data, data_marker=DATA): # pylint:disable=method-hidden
- return ((
- ' ' * self.indent
- + (data_marker if not self.depth else ' ')
- + ' ' * self.horiz_width
- + ' ' * self.label_space
- + data
- ),)
-
- def last_child_data(self, data):
- return self.child_data(data, ' ')
-
- def child_multidata(self, data):
- # Remove embedded newlines
- for l in data.splitlines():
- self.child_data(l)
-
-
-class GreenletTree(object):
- """
- Represents a tree of greenlets.
-
- In gevent, the *parent* of a greenlet is usually the hub, so this
- tree is primarily arganized along the *spawning_greenlet* dimension.
-
- This object has a small str form showing this hierarchy. The `format`
- method can output more details. The exact output is unspecified but is
- intended to be human readable.
-
- Use the `forest` method to get the root greenlet trees for
- all threads, and the `current_tree` to get the root greenlet tree for
- the current thread.
- """
-
- #: The greenlet this tree represents.
- greenlet = None
-
-
- def __init__(self, greenlet):
- self.greenlet = greenlet
- self.child_trees = []
-
- def add_child(self, tree):
- if tree is self:
- return
- self.child_trees.append(tree)
-
- @property
- def root(self):
- return self.greenlet.parent is None
-
- def __getattr__(self, name):
- return getattr(self.greenlet, name)
-
- DEFAULT_DETAILS = {
- 'running_stacks': True,
- 'running_stack_limit': _STACK_LIMIT,
- 'spawning_stacks': True,
- 'locals': True,
- }
-
- def format_lines(self, details=True):
- """
- Return a sequence of lines for the greenlet tree.
-
- :keyword bool details: If true (the default),
- then include more informative details in the output.
- """
- if not isinstance(details, dict):
- if not details:
- details = {}
- else:
- details = self.DEFAULT_DETAILS.copy()
- else:
- params = details
- details = self.DEFAULT_DETAILS.copy()
- details.update(params)
- tree = _TreeFormatter(details, depth=0)
- lines = [l[0] if isinstance(l, tuple) else l
- for l in self._render(tree)]
- return lines
-
- def format(self, details=True):
- """
- Like `format_lines` but returns a string.
- """
- lines = self.format_lines(details)
- return '\n'.join(lines)
-
- def __str__(self):
- return self.format(False)
-
- @staticmethod
- def __render_tb(tree, label, frame, limit):
- tree.child_data(label)
- tb = ''.join(traceback.format_stack(frame, limit))
- tree.child_multidata(tb)
-
- @staticmethod
- def __spawning_parent(greenlet):
- return (getattr(greenlet, 'spawning_greenlet', None) or _noop)()
-
- def __render_locals(self, tree):
- # Defer the import to avoid cycles
- from gevent.local import all_local_dicts_for_greenlet
-
- gr_locals = all_local_dicts_for_greenlet(self.greenlet)
- if gr_locals:
- tree.child_data("Greenlet Locals:")
- for (kind, idl), vals in gr_locals:
- tree.child_data(" Local %s at %s" % (kind, hex(idl)))
- tree.child_multidata(" " + pprint.pformat(vals))
-
- def _render(self, tree):
- label = repr(self.greenlet)
- if not self.greenlet: # Not running or dead
- # raw greenlets do not have ready
- if getattr(self.greenlet, 'ready', _ready)():
- label += '; finished'
- if self.greenlet.value is not None:
- label += ' with value ' + repr(self.greenlet.value)[:30]
- elif getattr(self.greenlet, 'exception', None) is not None:
- label += ' with exception ' + repr(self.greenlet.exception)
- else:
- label += '; not running'
- tree.node_label(label)
-
- tree.child_data('Parent: ' + repr(self.greenlet.parent))
-
- if getattr(self.greenlet, 'gevent_monitoring_thread', None) is not None:
- tree.child_data('Monitoring Thread:' + repr(self.greenlet.gevent_monitoring_thread()))
-
- if self.greenlet and tree.details and tree.details['running_stacks']:
- self.__render_tb(tree, 'Running:', self.greenlet.gr_frame,
- tree.details['running_stack_limit'])
-
-
- spawning_stack = getattr(self.greenlet, 'spawning_stack', None)
- if spawning_stack and tree.details and tree.details['spawning_stacks']:
- # We already placed a limit on the spawning stack when we captured it.
- self.__render_tb(tree, 'Spawned at:', spawning_stack, None)
-
- spawning_parent = self.__spawning_parent(self.greenlet)
- tree_locals = getattr(self.greenlet, 'spawn_tree_locals', None)
- if tree_locals and tree_locals is not getattr(spawning_parent, 'spawn_tree_locals', None):
- tree.child_data('Spawn Tree Locals')
- tree.child_multidata(pprint.pformat(tree_locals))
-
- self.__render_locals(tree)
- self.__render_children(tree)
- return tree.lines
-
- def __render_children(self, tree):
- children = sorted(self.child_trees,
- key=lambda c: (
- # raw greenlets first
- getattr(c, 'minimal_ident', -1),
- # running greenlets first
- getattr(c, 'ready', _ready)(),
- id(c.parent)))
- for n, child in enumerate(children):
- child_tree = child._render(tree.deeper())
-
- head = tree.child_head
- tail = tree.child_tail
- data = tree.child_data
-
- if n == len(children) - 1:
- # last child does not get the line drawn
- head = tree.last_child_head
- tail = tree.last_child_tail
- data = tree.last_child_data
-
- head(child_tree.pop(0))
- for child_data in child_tree:
- if isinstance(child_data, tuple):
- data(child_data[0])
- else:
- tail(child_data)
-
- return tree.lines
-
-
- @staticmethod
- def _root_greenlet(greenlet):
- while greenlet.parent is not None and not getattr(greenlet, 'greenlet_tree_is_root', False):
- greenlet = greenlet.parent
- return greenlet
-
- @classmethod
- def _forest(cls):
- main_greenlet = cls._root_greenlet(getcurrent())
-
- trees = {}
- roots = {}
- current_tree = roots[main_greenlet] = trees[main_greenlet] = cls(main_greenlet)
-
-
-
- for ob in gc.get_objects():
- if not isinstance(ob, RawGreenlet):
- continue
- if getattr(ob, 'greenlet_tree_is_ignored', False):
- continue
-
- spawn_parent = cls.__spawning_parent(ob)
-
- if spawn_parent is None:
- root = cls._root_greenlet(ob)
- try:
- tree = roots[root]
- except KeyError: # pragma: no cover
- tree = GreenletTree(root)
- roots[root] = trees[root] = tree
- else:
- try:
- tree = trees[spawn_parent]
- except KeyError: # pragma: no cover
- tree = trees[spawn_parent] = cls(spawn_parent)
-
- try:
- child_tree = trees[ob]
- except KeyError:
- trees[ob] = child_tree = cls(ob)
- tree.add_child(child_tree)
-
- return roots, current_tree
-
- @classmethod
- def forest(cls):
- """
- forest() -> sequence
-
- Return a sequence of `GreenletTree`, one for each running
- native thread.
- """
-
- return list(cls._forest()[0].values())
-
- @classmethod
- def current_tree(cls):
- """
- current_tree() -> GreenletTree
-
- Returns the `GreenletTree` for the current thread.
- """
- return cls._forest()[1]
-
-class _FailedToSwitch(AssertionError):
- pass
-
-class assert_switches(object):
- """
- A context manager for ensuring a block of code switches greenlets.
-
- This performs a similar function as the :doc:`monitoring thread
- </monitoring>`, but the scope is limited to the body of the with
- statement. If the code within the body doesn't yield to the hub
- (and doesn't raise an exception), then upon exiting the
- context manager an :exc:`AssertionError` will be raised.
-
- This is useful in unit tests and for debugging purposes.
-
- :keyword float max_blocking_time: If given, the body is allowed
- to block for up to this many fractional seconds before
- an error is raised.
- :keyword bool hub_only: If True, then *max_blocking_time* only
- refers to the amount of time spent between switches into the
- hub. If False, then it refers to the maximum time between
- *any* switches. If *max_blocking_time* is not given, has no
- effect.
-
- Example::
-
- # This will always raise an exception: nothing switched
- with assert_switches():
- pass
-
- # This will never raise an exception; nothing switched,
- # but it happened very fast
- with assert_switches(max_blocking_time=1.0):
- pass
-
- .. versionadded:: 1.3
- """
-
- hub = None
- tracer = None
-
-
- def __init__(self, max_blocking_time=None, hub_only=False):
- self.max_blocking_time = max_blocking_time
- self.hub_only = hub_only
-
- def __enter__(self):
- from gevent import get_hub
- from gevent import _tracer
-
- self.hub = hub = get_hub()
-
- # TODO: We could optimize this to use the GreenletTracer
- # installed by the monitoring thread, if there is one.
- # As it is, we will chain trace calls back to it.
- if not self.max_blocking_time:
- self.tracer = _tracer.GreenletTracer()
- elif self.hub_only:
- self.tracer = _tracer.HubSwitchTracer(hub, self.max_blocking_time)
- else:
- self.tracer = _tracer.MaxSwitchTracer(hub, self.max_blocking_time)
-
- self.tracer.monitor_current_greenlet_blocking()
- return self
-
- def __exit__(self, t, v, tb):
- self.tracer.kill()
- hub = self.hub; self.hub = None
- tracer = self.tracer; self.tracer = None
-
- # Only check if there was no exception raised, we
- # don't want to hide anything
- if t is not None:
- return
-
-
- did_block = tracer.did_block_hub(hub)
- if did_block:
- active_greenlet = did_block[1]
- report_lines = tracer.did_block_hub_report(hub, active_greenlet, {})
- raise _FailedToSwitch('\n'.join(report_lines))
diff --git a/python/gevent/win32util.py b/python/gevent/win32util.py
deleted file mode 100644
index 7158d69..0000000
--- a/python/gevent/win32util.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright (c) 2001-2007 Twisted Matrix Laboratories.
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Error formatting function for Windows.
-
-The code is taken from twisted.python.win32 module.
-"""
-
-from __future__ import absolute_import
-import os
-
-
-__all__ = ['formatError']
-
-
-class _ErrorFormatter(object):
- """
- Formatter for Windows error messages.
-
- @ivar winError: A callable which takes one integer error number argument
- and returns an L{exceptions.WindowsError} instance for that error (like
- L{ctypes.WinError}).
-
- @ivar formatMessage: A callable which takes one integer error number
- argument and returns a C{str} giving the message for that error (like
- L{win32api.FormatMessage}).
-
- @ivar errorTab: A mapping from integer error numbers to C{str} messages
- which correspond to those errors (like L{socket.errorTab}).
- """
- def __init__(self, WinError, FormatMessage, errorTab):
- self.winError = WinError
- self.formatMessage = FormatMessage
- self.errorTab = errorTab
-
- @classmethod
- def fromEnvironment(cls):
- """
- Get as many of the platform-specific error translation objects as
- possible and return an instance of C{cls} created with them.
- """
- try:
- from ctypes import WinError
- except ImportError:
- WinError = None
- try:
- from win32api import FormatMessage
- except ImportError:
- FormatMessage = None
- try:
- from socket import errorTab
- except ImportError:
- errorTab = None
- return cls(WinError, FormatMessage, errorTab)
-
- def formatError(self, errorcode):
- """
- Returns the string associated with a Windows error message, such as the
- ones found in socket.error.
-
- Attempts direct lookup against the win32 API via ctypes and then
- pywin32 if available), then in the error table in the socket module,
- then finally defaulting to C{os.strerror}.
-
- @param errorcode: the Windows error code
- @type errorcode: C{int}
-
- @return: The error message string
- @rtype: C{str}
- """
- if self.winError is not None:
- return str(self.winError(errorcode))
- if self.formatMessage is not None:
- return self.formatMessage(errorcode)
- if self.errorTab is not None:
- result = self.errorTab.get(errorcode)
- if result is not None:
- return result
- return os.strerror(errorcode)
-
-formatError = _ErrorFormatter.fromEnvironment().formatError
diff --git a/python/greenlet.cp36-win32.pyd b/python/greenlet.cp36-win32.pyd
deleted file mode 100644
index 256390d..0000000
--- a/python/greenlet.cp36-win32.pyd
+++ /dev/null
Binary files differ
diff --git a/python/itsdangerous/__init__.py b/python/itsdangerous/__init__.py
deleted file mode 100644
index 0fcd8c1..0000000
--- a/python/itsdangerous/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from ._json import json
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .encoding import want_bytes
-from .exc import BadData
-from .exc import BadHeader
-from .exc import BadPayload
-from .exc import BadSignature
-from .exc import BadTimeSignature
-from .exc import SignatureExpired
-from .jws import JSONWebSignatureSerializer
-from .jws import TimedJSONWebSignatureSerializer
-from .serializer import Serializer
-from .signer import HMACAlgorithm
-from .signer import NoneAlgorithm
-from .signer import Signer
-from .timed import TimedSerializer
-from .timed import TimestampSigner
-from .url_safe import URLSafeSerializer
-from .url_safe import URLSafeTimedSerializer
-
-__version__ = "1.1.0"
diff --git a/python/itsdangerous/_compat.py b/python/itsdangerous/_compat.py
deleted file mode 100644
index 2291bce..0000000
--- a/python/itsdangerous/_compat.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import decimal
-import hmac
-import numbers
-import sys
-
-PY2 = sys.version_info[0] == 2
-
-if PY2:
- from itertools import izip
-
- text_type = unicode # noqa: 821
-else:
- izip = zip
- text_type = str
-
-number_types = (numbers.Real, decimal.Decimal)
-
-
-def _constant_time_compare(val1, val2):
- """Return ``True`` if the two strings are equal, ``False``
- otherwise.
-
- The time taken is independent of the number of characters that
- match. Do not use this function for anything else than comparision
- with known length targets.
-
- This is should be implemented in C in order to get it completely
- right.
-
- This is an alias of :func:`hmac.compare_digest` on Python>=2.7,3.3.
- """
- len_eq = len(val1) == len(val2)
- if len_eq:
- result = 0
- left = val1
- else:
- result = 1
- left = val2
- for x, y in izip(bytearray(left), bytearray(val2)):
- result |= x ^ y
- return result == 0
-
-
-# Starting with 2.7/3.3 the standard library has a c-implementation for
-# constant time string compares.
-constant_time_compare = getattr(hmac, "compare_digest", _constant_time_compare)
diff --git a/python/itsdangerous/_json.py b/python/itsdangerous/_json.py
deleted file mode 100644
index 426b36e..0000000
--- a/python/itsdangerous/_json.py
+++ /dev/null
@@ -1,18 +0,0 @@
-try:
- import simplejson as json
-except ImportError:
- import json
-
-
-class _CompactJSON(object):
- """Wrapper around json module that strips whitespace."""
-
- @staticmethod
- def loads(payload):
- return json.loads(payload)
-
- @staticmethod
- def dumps(obj, **kwargs):
- kwargs.setdefault("ensure_ascii", False)
- kwargs.setdefault("separators", (",", ":"))
- return json.dumps(obj, **kwargs)
diff --git a/python/itsdangerous/encoding.py b/python/itsdangerous/encoding.py
deleted file mode 100644
index 1e28969..0000000
--- a/python/itsdangerous/encoding.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import base64
-import string
-import struct
-
-from ._compat import text_type
-from .exc import BadData
-
-
-def want_bytes(s, encoding="utf-8", errors="strict"):
- if isinstance(s, text_type):
- s = s.encode(encoding, errors)
- return s
-
-
-def base64_encode(string):
- """Base64 encode a string of bytes or text. The resulting bytes are
- safe to use in URLs.
- """
- string = want_bytes(string)
- return base64.urlsafe_b64encode(string).rstrip(b"=")
-
-
-def base64_decode(string):
- """Base64 decode a URL-safe string of bytes or text. The result is
- bytes.
- """
- string = want_bytes(string, encoding="ascii", errors="ignore")
- string += b"=" * (-len(string) % 4)
-
- try:
- return base64.urlsafe_b64decode(string)
- except (TypeError, ValueError):
- raise BadData("Invalid base64-encoded data")
-
-
-# The alphabet used by base64.urlsafe_*
-_base64_alphabet = (string.ascii_letters + string.digits + "-_=").encode("ascii")
-
-_int64_struct = struct.Struct(">Q")
-_int_to_bytes = _int64_struct.pack
-_bytes_to_int = _int64_struct.unpack
-
-
-def int_to_bytes(num):
- return _int_to_bytes(num).lstrip(b"\x00")
-
-
-def bytes_to_int(bytestr):
- return _bytes_to_int(bytestr.rjust(8, b"\x00"))[0]
diff --git a/python/itsdangerous/exc.py b/python/itsdangerous/exc.py
deleted file mode 100644
index 287d691..0000000
--- a/python/itsdangerous/exc.py
+++ /dev/null
@@ -1,98 +0,0 @@
-from ._compat import PY2
-from ._compat import text_type
-
-
-class BadData(Exception):
- """Raised if bad data of any sort was encountered. This is the base
- for all exceptions that itsdangerous defines.
-
- .. versionadded:: 0.15
- """
-
- message = None
-
- def __init__(self, message):
- super(BadData, self).__init__(self, message)
- self.message = message
-
- def __str__(self):
- return text_type(self.message)
-
- if PY2:
- __unicode__ = __str__
-
- def __str__(self):
- return self.__unicode__().encode("utf-8")
-
-
-class BadSignature(BadData):
- """Raised if a signature does not match."""
-
- def __init__(self, message, payload=None):
- BadData.__init__(self, message)
-
- #: The payload that failed the signature test. In some
- #: situations you might still want to inspect this, even if
- #: you know it was tampered with.
- #:
- #: .. versionadded:: 0.14
- self.payload = payload
-
-
-class BadTimeSignature(BadSignature):
- """Raised if a time-based signature is invalid. This is a subclass
- of :class:`BadSignature`.
- """
-
- def __init__(self, message, payload=None, date_signed=None):
- BadSignature.__init__(self, message, payload)
-
- #: If the signature expired this exposes the date of when the
- #: signature was created. This can be helpful in order to
- #: tell the user how long a link has been gone stale.
- #:
- #: .. versionadded:: 0.14
- self.date_signed = date_signed
-
-
-class SignatureExpired(BadTimeSignature):
- """Raised if a signature timestamp is older than ``max_age``. This
- is a subclass of :exc:`BadTimeSignature`.
- """
-
-
-class BadHeader(BadSignature):
- """Raised if a signed header is invalid in some form. This only
- happens for serializers that have a header that goes with the
- signature.
-
- .. versionadded:: 0.24
- """
-
- def __init__(self, message, payload=None, header=None, original_error=None):
- BadSignature.__init__(self, message, payload)
-
- #: If the header is actually available but just malformed it
- #: might be stored here.
- self.header = header
-
- #: If available, the error that indicates why the payload was
- #: not valid. This might be ``None``.
- self.original_error = original_error
-
-
-class BadPayload(BadData):
- """Raised if a payload is invalid. This could happen if the payload
- is loaded despite an invalid signature, or if there is a mismatch
- between the serializer and deserializer. The original exception
- that occurred during loading is stored on as :attr:`original_error`.
-
- .. versionadded:: 0.15
- """
-
- def __init__(self, message, original_error=None):
- BadData.__init__(self, message)
-
- #: If available, the error that indicates why the payload was
- #: not valid. This might be ``None``.
- self.original_error = original_error
diff --git a/python/itsdangerous/jws.py b/python/itsdangerous/jws.py
deleted file mode 100644
index 92e9ec8..0000000
--- a/python/itsdangerous/jws.py
+++ /dev/null
@@ -1,218 +0,0 @@
-import hashlib
-import time
-from datetime import datetime
-
-from ._compat import number_types
-from ._json import _CompactJSON
-from ._json import json
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .encoding import want_bytes
-from .exc import BadData
-from .exc import BadHeader
-from .exc import BadPayload
-from .exc import BadSignature
-from .exc import SignatureExpired
-from .serializer import Serializer
-from .signer import HMACAlgorithm
-from .signer import NoneAlgorithm
-
-
-class JSONWebSignatureSerializer(Serializer):
- """This serializer implements JSON Web Signature (JWS) support. Only
- supports the JWS Compact Serialization.
- """
-
- jws_algorithms = {
- "HS256": HMACAlgorithm(hashlib.sha256),
- "HS384": HMACAlgorithm(hashlib.sha384),
- "HS512": HMACAlgorithm(hashlib.sha512),
- "none": NoneAlgorithm(),
- }
-
- #: The default algorithm to use for signature generation
- default_algorithm = "HS512"
-
- default_serializer = _CompactJSON
-
- def __init__(
- self,
- secret_key,
- salt=None,
- serializer=None,
- serializer_kwargs=None,
- signer=None,
- signer_kwargs=None,
- algorithm_name=None,
- ):
- Serializer.__init__(
- self,
- secret_key=secret_key,
- salt=salt,
- serializer=serializer,
- serializer_kwargs=serializer_kwargs,
- signer=signer,
- signer_kwargs=signer_kwargs,
- )
- if algorithm_name is None:
- algorithm_name = self.default_algorithm
- self.algorithm_name = algorithm_name
- self.algorithm = self.make_algorithm(algorithm_name)
-
- def load_payload(self, payload, serializer=None, return_header=False):
- payload = want_bytes(payload)
- if b"." not in payload:
- raise BadPayload('No "." found in value')
- base64d_header, base64d_payload = payload.split(b".", 1)
- try:
- json_header = base64_decode(base64d_header)
- except Exception as e:
- raise BadHeader(
- "Could not base64 decode the header because of an exception",
- original_error=e,
- )
- try:
- json_payload = base64_decode(base64d_payload)
- except Exception as e:
- raise BadPayload(
- "Could not base64 decode the payload because of an exception",
- original_error=e,
- )
- try:
- header = Serializer.load_payload(self, json_header, serializer=json)
- except BadData as e:
- raise BadHeader(
- "Could not unserialize header because it was malformed",
- original_error=e,
- )
- if not isinstance(header, dict):
- raise BadHeader("Header payload is not a JSON object", header=header)
- payload = Serializer.load_payload(self, json_payload, serializer=serializer)
- if return_header:
- return payload, header
- return payload
-
- def dump_payload(self, header, obj):
- base64d_header = base64_encode(
- self.serializer.dumps(header, **self.serializer_kwargs)
- )
- base64d_payload = base64_encode(
- self.serializer.dumps(obj, **self.serializer_kwargs)
- )
- return base64d_header + b"." + base64d_payload
-
- def make_algorithm(self, algorithm_name):
- try:
- return self.jws_algorithms[algorithm_name]
- except KeyError:
- raise NotImplementedError("Algorithm not supported")
-
- def make_signer(self, salt=None, algorithm=None):
- if salt is None:
- salt = self.salt
- key_derivation = "none" if salt is None else None
- if algorithm is None:
- algorithm = self.algorithm
- return self.signer(
- self.secret_key,
- salt=salt,
- sep=".",
- key_derivation=key_derivation,
- algorithm=algorithm,
- )
-
- def make_header(self, header_fields):
- header = header_fields.copy() if header_fields else {}
- header["alg"] = self.algorithm_name
- return header
-
- def dumps(self, obj, salt=None, header_fields=None):
- """Like :meth:`.Serializer.dumps` but creates a JSON Web
- Signature. It also allows for specifying additional fields to be
- included in the JWS header.
- """
- header = self.make_header(header_fields)
- signer = self.make_signer(salt, self.algorithm)
- return signer.sign(self.dump_payload(header, obj))
-
- def loads(self, s, salt=None, return_header=False):
- """Reverse of :meth:`dumps`. If requested via ``return_header``
- it will return a tuple of payload and header.
- """
- payload, header = self.load_payload(
- self.make_signer(salt, self.algorithm).unsign(want_bytes(s)),
- return_header=True,
- )
- if header.get("alg") != self.algorithm_name:
- raise BadHeader("Algorithm mismatch", header=header, payload=payload)
- if return_header:
- return payload, header
- return payload
-
- def loads_unsafe(self, s, salt=None, return_header=False):
- kwargs = {"return_header": return_header}
- return self._loads_unsafe_impl(s, salt, kwargs, kwargs)
-
-
-class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer):
- """Works like the regular :class:`JSONWebSignatureSerializer` but
- also records the time of the signing and can be used to expire
- signatures.
-
- JWS currently does not specify this behavior but it mentions a
- possible extension like this in the spec. Expiry date is encoded
- into the header similar to what's specified in `draft-ietf-oauth
- -json-web-token <http://self-issued.info/docs/draft-ietf-oauth-json
- -web-token.html#expDef>`_.
- """
-
- DEFAULT_EXPIRES_IN = 3600
-
- def __init__(self, secret_key, expires_in=None, **kwargs):
- JSONWebSignatureSerializer.__init__(self, secret_key, **kwargs)
- if expires_in is None:
- expires_in = self.DEFAULT_EXPIRES_IN
- self.expires_in = expires_in
-
- def make_header(self, header_fields):
- header = JSONWebSignatureSerializer.make_header(self, header_fields)
- iat = self.now()
- exp = iat + self.expires_in
- header["iat"] = iat
- header["exp"] = exp
- return header
-
- def loads(self, s, salt=None, return_header=False):
- payload, header = JSONWebSignatureSerializer.loads(
- self, s, salt, return_header=True
- )
-
- if "exp" not in header:
- raise BadSignature("Missing expiry date", payload=payload)
-
- int_date_error = BadHeader("Expiry date is not an IntDate", payload=payload)
- try:
- header["exp"] = int(header["exp"])
- except ValueError:
- raise int_date_error
- if header["exp"] < 0:
- raise int_date_error
-
- if header["exp"] < self.now():
- raise SignatureExpired(
- "Signature expired",
- payload=payload,
- date_signed=self.get_issue_date(header),
- )
-
- if return_header:
- return payload, header
- return payload
-
- def get_issue_date(self, header):
- rv = header.get("iat")
- if isinstance(rv, number_types):
- return datetime.utcfromtimestamp(int(rv))
-
- def now(self):
- return int(time.time())
diff --git a/python/itsdangerous/serializer.py b/python/itsdangerous/serializer.py
deleted file mode 100644
index 12c20f4..0000000
--- a/python/itsdangerous/serializer.py
+++ /dev/null
@@ -1,233 +0,0 @@
-import hashlib
-
-from ._compat import text_type
-from ._json import json
-from .encoding import want_bytes
-from .exc import BadPayload
-from .exc import BadSignature
-from .signer import Signer
-
-
-def is_text_serializer(serializer):
- """Checks whether a serializer generates text or binary."""
- return isinstance(serializer.dumps({}), text_type)
-
-
-class Serializer(object):
- """This class provides a serialization interface on top of the
- signer. It provides a similar API to json/pickle and other modules
- but is structured differently internally. If you want to change the
- underlying implementation for parsing and loading you have to
- override the :meth:`load_payload` and :meth:`dump_payload`
- functions.
-
- This implementation uses simplejson if available for dumping and
- loading and will fall back to the standard library's json module if
- it's not available.
-
- You do not need to subclass this class in order to switch out or
- customize the :class:`.Signer`. You can instead pass a different
- class to the constructor as well as keyword arguments as a dict that
- should be forwarded.
-
- .. code-block:: python
-
- s = Serializer(signer_kwargs={'key_derivation': 'hmac'})
-
- You may want to upgrade the signing parameters without invalidating
- existing signatures that are in use. Fallback signatures can be
- given that will be tried if unsigning with the current signer fails.
-
- Fallback signers can be defined by providing a list of
- ``fallback_signers``. Each item can be one of the following: a
- signer class (which is instantiated with ``signer_kwargs``,
- ``salt``, and ``secret_key``), a tuple
- ``(signer_class, signer_kwargs)``, or a dict of ``signer_kwargs``.
-
- For example, this is a serializer that signs using SHA-512, but will
- unsign using either SHA-512 or SHA1:
-
- .. code-block:: python
-
- s = Serializer(
- signer_kwargs={"digest_method": hashlib.sha512},
- fallback_signers=[{"digest_method": hashlib.sha1}]
- )
-
- .. versionchanged:: 0.14:
- The ``signer`` and ``signer_kwargs`` parameters were added to
- the constructor.
-
- .. versionchanged:: 1.1.0:
- Added support for ``fallback_signers`` and configured a default
- SHA-512 fallback. This fallback is for users who used the yanked
- 1.0.0 release which defaulted to SHA-512.
- """
-
- #: If a serializer module or class is not passed to the constructor
- #: this one is picked up. This currently defaults to :mod:`json`.
- default_serializer = json
-
- #: The default :class:`Signer` class that is being used by this
- #: serializer.
- #:
- #: .. versionadded:: 0.14
- default_signer = Signer
-
- #: The default fallback signers.
- default_fallback_signers = [{"digest_method": hashlib.sha512}]
-
- def __init__(
- self,
- secret_key,
- salt=b"itsdangerous",
- serializer=None,
- serializer_kwargs=None,
- signer=None,
- signer_kwargs=None,
- fallback_signers=None,
- ):
- self.secret_key = want_bytes(secret_key)
- self.salt = want_bytes(salt)
- if serializer is None:
- serializer = self.default_serializer
- self.serializer = serializer
- self.is_text_serializer = is_text_serializer(serializer)
- if signer is None:
- signer = self.default_signer
- self.signer = signer
- self.signer_kwargs = signer_kwargs or {}
- if fallback_signers is None:
- fallback_signers = list(self.default_fallback_signers or ())
- self.fallback_signers = fallback_signers
- self.serializer_kwargs = serializer_kwargs or {}
-
- def load_payload(self, payload, serializer=None):
- """Loads the encoded object. This function raises
- :class:`.BadPayload` if the payload is not valid. The
- ``serializer`` parameter can be used to override the serializer
- stored on the class. The encoded ``payload`` should always be
- bytes.
- """
- if serializer is None:
- serializer = self.serializer
- is_text = self.is_text_serializer
- else:
- is_text = is_text_serializer(serializer)
- try:
- if is_text:
- payload = payload.decode("utf-8")
- return serializer.loads(payload)
- except Exception as e:
- raise BadPayload(
- "Could not load the payload because an exception"
- " occurred on unserializing the data.",
- original_error=e,
- )
-
- def dump_payload(self, obj):
- """Dumps the encoded object. The return value is always bytes.
- If the internal serializer returns text, the value will be
- encoded as UTF-8.
- """
- return want_bytes(self.serializer.dumps(obj, **self.serializer_kwargs))
-
- def make_signer(self, salt=None):
- """Creates a new instance of the signer to be used. The default
- implementation uses the :class:`.Signer` base class.
- """
- if salt is None:
- salt = self.salt
- return self.signer(self.secret_key, salt=salt, **self.signer_kwargs)
-
- def iter_unsigners(self, salt=None):
- """Iterates over all signers to be tried for unsigning. Starts
- with the configured signer, then constructs each signer
- specified in ``fallback_signers``.
- """
- if salt is None:
- salt = self.salt
- yield self.make_signer(salt)
- for fallback in self.fallback_signers:
- if type(fallback) is dict:
- kwargs = fallback
- fallback = self.signer
- elif type(fallback) is tuple:
- fallback, kwargs = fallback
- else:
- kwargs = self.signer_kwargs
- yield fallback(self.secret_key, salt=salt, **kwargs)
-
- def dumps(self, obj, salt=None):
- """Returns a signed string serialized with the internal
- serializer. The return value can be either a byte or unicode
- string depending on the format of the internal serializer.
- """
- payload = want_bytes(self.dump_payload(obj))
- rv = self.make_signer(salt).sign(payload)
- if self.is_text_serializer:
- rv = rv.decode("utf-8")
- return rv
-
- def dump(self, obj, f, salt=None):
- """Like :meth:`dumps` but dumps into a file. The file handle has
- to be compatible with what the internal serializer expects.
- """
- f.write(self.dumps(obj, salt))
-
- def loads(self, s, salt=None):
- """Reverse of :meth:`dumps`. Raises :exc:`.BadSignature` if the
- signature validation fails.
- """
- s = want_bytes(s)
- last_exception = None
- for signer in self.iter_unsigners(salt):
- try:
- return self.load_payload(signer.unsign(s))
- except BadSignature as err:
- last_exception = err
- raise last_exception
-
- def load(self, f, salt=None):
- """Like :meth:`loads` but loads from a file."""
- return self.loads(f.read(), salt)
-
- def loads_unsafe(self, s, salt=None):
- """Like :meth:`loads` but without verifying the signature. This
- is potentially very dangerous to use depending on how your
- serializer works. The return value is ``(signature_valid,
- payload)`` instead of just the payload. The first item will be a
- boolean that indicates if the signature is valid. This function
- never fails.
-
- Use it for debugging only and if you know that your serializer
- module is not exploitable (for example, do not use it with a
- pickle serializer).
-
- .. versionadded:: 0.15
- """
- return self._loads_unsafe_impl(s, salt)
-
- def _loads_unsafe_impl(self, s, salt, load_kwargs=None, load_payload_kwargs=None):
- """Low level helper function to implement :meth:`loads_unsafe`
- in serializer subclasses.
- """
- try:
- return True, self.loads(s, salt=salt, **(load_kwargs or {}))
- except BadSignature as e:
- if e.payload is None:
- return False, None
- try:
- return (
- False,
- self.load_payload(e.payload, **(load_payload_kwargs or {})),
- )
- except BadPayload:
- return False, None
-
- def load_unsafe(self, f, *args, **kwargs):
- """Like :meth:`loads_unsafe` but loads from a file.
-
- .. versionadded:: 0.15
- """
- return self.loads_unsafe(f.read(), *args, **kwargs)
diff --git a/python/itsdangerous/signer.py b/python/itsdangerous/signer.py
deleted file mode 100644
index 6bddc03..0000000
--- a/python/itsdangerous/signer.py
+++ /dev/null
@@ -1,179 +0,0 @@
-import hashlib
-import hmac
-
-from ._compat import constant_time_compare
-from .encoding import _base64_alphabet
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .encoding import want_bytes
-from .exc import BadSignature
-
-
-class SigningAlgorithm(object):
- """Subclasses must implement :meth:`get_signature` to provide
- signature generation functionality.
- """
-
- def get_signature(self, key, value):
- """Returns the signature for the given key and value."""
- raise NotImplementedError()
-
- def verify_signature(self, key, value, sig):
- """Verifies the given signature matches the expected
- signature.
- """
- return constant_time_compare(sig, self.get_signature(key, value))
-
-
-class NoneAlgorithm(SigningAlgorithm):
- """Provides an algorithm that does not perform any signing and
- returns an empty signature.
- """
-
- def get_signature(self, key, value):
- return b""
-
-
-class HMACAlgorithm(SigningAlgorithm):
- """Provides signature generation using HMACs."""
-
- #: The digest method to use with the MAC algorithm. This defaults to
- #: SHA1, but can be changed to any other function in the hashlib
- #: module.
- default_digest_method = staticmethod(hashlib.sha1)
-
- def __init__(self, digest_method=None):
- if digest_method is None:
- digest_method = self.default_digest_method
- self.digest_method = digest_method
-
- def get_signature(self, key, value):
- mac = hmac.new(key, msg=value, digestmod=self.digest_method)
- return mac.digest()
-
-
-class Signer(object):
- """This class can sign and unsign bytes, validating the signature
- provided.
-
- Salt can be used to namespace the hash, so that a signed string is
- only valid for a given namespace. Leaving this at the default value
- or re-using a salt value across different parts of your application
- where the same signed value in one part can mean something different
- in another part is a security risk.
-
- See :ref:`the-salt` for an example of what the salt is doing and how
- you can utilize it.
-
- .. versionadded:: 0.14
- ``key_derivation`` and ``digest_method`` were added as arguments
- to the class constructor.
-
- .. versionadded:: 0.18
- ``algorithm`` was added as an argument to the class constructor.
- """
-
- #: The digest method to use for the signer. This defaults to
- #: SHA1 but can be changed to any other function in the hashlib
- #: module.
- #:
- #: .. versionadded:: 0.14
- default_digest_method = staticmethod(hashlib.sha1)
-
- #: Controls how the key is derived. The default is Django-style
- #: concatenation. Possible values are ``concat``, ``django-concat``
- #: and ``hmac``. This is used for deriving a key from the secret key
- #: with an added salt.
- #:
- #: .. versionadded:: 0.14
- default_key_derivation = "django-concat"
-
- def __init__(
- self,
- secret_key,
- salt=None,
- sep=".",
- key_derivation=None,
- digest_method=None,
- algorithm=None,
- ):
- self.secret_key = want_bytes(secret_key)
- self.sep = want_bytes(sep)
- if self.sep in _base64_alphabet:
- raise ValueError(
- "The given separator cannot be used because it may be"
- " contained in the signature itself. Alphanumeric"
- " characters and `-_=` must not be used."
- )
- self.salt = "itsdangerous.Signer" if salt is None else salt
- if key_derivation is None:
- key_derivation = self.default_key_derivation
- self.key_derivation = key_derivation
- if digest_method is None:
- digest_method = self.default_digest_method
- self.digest_method = digest_method
- if algorithm is None:
- algorithm = HMACAlgorithm(self.digest_method)
- self.algorithm = algorithm
-
- def derive_key(self):
- """This method is called to derive the key. The default key
- derivation choices can be overridden here. Key derivation is not
- intended to be used as a security method to make a complex key
- out of a short password. Instead you should use large random
- secret keys.
- """
- salt = want_bytes(self.salt)
- if self.key_derivation == "concat":
- return self.digest_method(salt + self.secret_key).digest()
- elif self.key_derivation == "django-concat":
- return self.digest_method(salt + b"signer" + self.secret_key).digest()
- elif self.key_derivation == "hmac":
- mac = hmac.new(self.secret_key, digestmod=self.digest_method)
- mac.update(salt)
- return mac.digest()
- elif self.key_derivation == "none":
- return self.secret_key
- else:
- raise TypeError("Unknown key derivation method")
-
- def get_signature(self, value):
- """Returns the signature for the given value."""
- value = want_bytes(value)
- key = self.derive_key()
- sig = self.algorithm.get_signature(key, value)
- return base64_encode(sig)
-
- def sign(self, value):
- """Signs the given string."""
- return want_bytes(value) + want_bytes(self.sep) + self.get_signature(value)
-
- def verify_signature(self, value, sig):
- """Verifies the signature for the given value."""
- key = self.derive_key()
- try:
- sig = base64_decode(sig)
- except Exception:
- return False
- return self.algorithm.verify_signature(key, value, sig)
-
- def unsign(self, signed_value):
- """Unsigns the given string."""
- signed_value = want_bytes(signed_value)
- sep = want_bytes(self.sep)
- if sep not in signed_value:
- raise BadSignature("No %r found in value" % self.sep)
- value, sig = signed_value.rsplit(sep, 1)
- if self.verify_signature(value, sig):
- return value
- raise BadSignature("Signature %r does not match" % sig, payload=value)
-
- def validate(self, signed_value):
- """Only validates the given signed value. Returns ``True`` if
- the signature exists and is valid.
- """
- try:
- self.unsign(signed_value)
- return True
- except BadSignature:
- return False
diff --git a/python/itsdangerous/timed.py b/python/itsdangerous/timed.py
deleted file mode 100644
index 4c117e4..0000000
--- a/python/itsdangerous/timed.py
+++ /dev/null
@@ -1,147 +0,0 @@
-import time
-from datetime import datetime
-
-from ._compat import text_type
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .encoding import bytes_to_int
-from .encoding import int_to_bytes
-from .encoding import want_bytes
-from .exc import BadSignature
-from .exc import BadTimeSignature
-from .exc import SignatureExpired
-from .serializer import Serializer
-from .signer import Signer
-
-
-class TimestampSigner(Signer):
- """Works like the regular :class:`.Signer` but also records the time
- of the signing and can be used to expire signatures. The
- :meth:`unsign` method can raise :exc:`.SignatureExpired` if the
- unsigning failed because the signature is expired.
- """
-
- def get_timestamp(self):
- """Returns the current timestamp. The function must return an
- integer.
- """
- return int(time.time())
-
- def timestamp_to_datetime(self, ts):
- """Used to convert the timestamp from :meth:`get_timestamp` into
- a datetime object.
- """
- return datetime.utcfromtimestamp(ts)
-
- def sign(self, value):
- """Signs the given string and also attaches time information."""
- value = want_bytes(value)
- timestamp = base64_encode(int_to_bytes(self.get_timestamp()))
- sep = want_bytes(self.sep)
- value = value + sep + timestamp
- return value + sep + self.get_signature(value)
-
- def unsign(self, value, max_age=None, return_timestamp=False):
- """Works like the regular :meth:`.Signer.unsign` but can also
- validate the time. See the base docstring of the class for
- the general behavior. If ``return_timestamp`` is ``True`` the
- timestamp of the signature will be returned as a naive
- :class:`datetime.datetime` object in UTC.
- """
- try:
- result = Signer.unsign(self, value)
- sig_error = None
- except BadSignature as e:
- sig_error = e
- result = e.payload or b""
- sep = want_bytes(self.sep)
-
- # If there is no timestamp in the result there is something
- # seriously wrong. In case there was a signature error, we raise
- # that one directly, otherwise we have a weird situation in
- # which we shouldn't have come except someone uses a time-based
- # serializer on non-timestamp data, so catch that.
- if sep not in result:
- if sig_error:
- raise sig_error
- raise BadTimeSignature("timestamp missing", payload=result)
-
- value, timestamp = result.rsplit(sep, 1)
- try:
- timestamp = bytes_to_int(base64_decode(timestamp))
- except Exception:
- timestamp = None
-
- # Signature is *not* okay. Raise a proper error now that we have
- # split the value and the timestamp.
- if sig_error is not None:
- raise BadTimeSignature(
- text_type(sig_error), payload=value, date_signed=timestamp
- )
-
- # Signature was okay but the timestamp is actually not there or
- # malformed. Should not happen, but we handle it anyway.
- if timestamp is None:
- raise BadTimeSignature("Malformed timestamp", payload=value)
-
- # Check timestamp is not older than max_age
- if max_age is not None:
- age = self.get_timestamp() - timestamp
- if age > max_age:
- raise SignatureExpired(
- "Signature age %s > %s seconds" % (age, max_age),
- payload=value,
- date_signed=self.timestamp_to_datetime(timestamp),
- )
-
- if return_timestamp:
- return value, self.timestamp_to_datetime(timestamp)
- return value
-
- def validate(self, signed_value, max_age=None):
- """Only validates the given signed value. Returns ``True`` if
- the signature exists and is valid."""
- try:
- self.unsign(signed_value, max_age=max_age)
- return True
- except BadSignature:
- return False
-
-
-class TimedSerializer(Serializer):
- """Uses :class:`TimestampSigner` instead of the default
- :class:`.Signer`.
- """
-
- default_signer = TimestampSigner
-
- def loads(self, s, max_age=None, return_timestamp=False, salt=None):
- """Reverse of :meth:`dumps`, raises :exc:`.BadSignature` if the
- signature validation fails. If a ``max_age`` is provided it will
- ensure the signature is not older than that time in seconds. In
- case the signature is outdated, :exc:`.SignatureExpired` is
- raised. All arguments are forwarded to the signer's
- :meth:`~TimestampSigner.unsign` method.
- """
- s = want_bytes(s)
- last_exception = None
- for signer in self.iter_unsigners(salt):
- try:
- base64d, timestamp = signer.unsign(s, max_age, return_timestamp=True)
- payload = self.load_payload(base64d)
- if return_timestamp:
- return payload, timestamp
- return payload
- # If we get a signature expired it means we could read the
- # signature but it's invalid. In that case we do not want to
- # try the next signer.
- except SignatureExpired:
- raise
- except BadSignature as err:
- last_exception = err
- raise last_exception
-
- def loads_unsafe(self, s, max_age=None, salt=None):
- load_kwargs = {"max_age": max_age}
- load_payload_kwargs = {}
- return self._loads_unsafe_impl(s, salt, load_kwargs, load_payload_kwargs)
diff --git a/python/itsdangerous/url_safe.py b/python/itsdangerous/url_safe.py
deleted file mode 100644
index fcaa011..0000000
--- a/python/itsdangerous/url_safe.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import zlib
-
-from ._json import _CompactJSON
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .exc import BadPayload
-from .serializer import Serializer
-from .timed import TimedSerializer
-
-
-class URLSafeSerializerMixin(object):
- """Mixed in with a regular serializer it will attempt to zlib
- compress the string to make it shorter if necessary. It will also
- base64 encode the string so that it can safely be placed in a URL.
- """
-
- default_serializer = _CompactJSON
-
- def load_payload(self, payload, *args, **kwargs):
- decompress = False
- if payload.startswith(b"."):
- payload = payload[1:]
- decompress = True
- try:
- json = base64_decode(payload)
- except Exception as e:
- raise BadPayload(
- "Could not base64 decode the payload because of an exception",
- original_error=e,
- )
- if decompress:
- try:
- json = zlib.decompress(json)
- except Exception as e:
- raise BadPayload(
- "Could not zlib decompress the payload before decoding the payload",
- original_error=e,
- )
- return super(URLSafeSerializerMixin, self).load_payload(json, *args, **kwargs)
-
- def dump_payload(self, obj):
- json = super(URLSafeSerializerMixin, self).dump_payload(obj)
- is_compressed = False
- compressed = zlib.compress(json)
- if len(compressed) < (len(json) - 1):
- json = compressed
- is_compressed = True
- base64d = base64_encode(json)
- if is_compressed:
- base64d = b"." + base64d
- return base64d
-
-
-class URLSafeSerializer(URLSafeSerializerMixin, Serializer):
- """Works like :class:`.Serializer` but dumps and loads into a URL
- safe string consisting of the upper and lowercase character of the
- alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
- """
-
-
-class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer):
- """Works like :class:`.TimedSerializer` but dumps and loads into a
- URL safe string consisting of the upper and lowercase character of
- the alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
- """
diff --git a/python/jinja2/__init__.py b/python/jinja2/__init__.py
deleted file mode 100644
index 15e13b6..0000000
--- a/python/jinja2/__init__.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2
- ~~~~~~
-
- Jinja2 is a template engine written in pure Python. It provides a
- Django inspired non-XML syntax but supports inline expressions and
- an optional sandboxed environment.
-
- Nutshell
- --------
-
- Here a small example of a Jinja2 template::
-
- {% extends 'base.html' %}
- {% block title %}Memberlist{% endblock %}
- {% block content %}
- <ul>
- {% for user in users %}
- <li><a href="{{ user.url }}">{{ user.username }}</a></li>
- {% endfor %}
- </ul>
- {% endblock %}
-
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-__docformat__ = 'restructuredtext en'
-__version__ = '2.10.1'
-
-# high level interface
-from jinja2.environment import Environment, Template
-
-# loaders
-from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
- DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
- ModuleLoader
-
-# bytecode caches
-from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
- MemcachedBytecodeCache
-
-# undefined types
-from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined, \
- make_logging_undefined
-
-# exceptions
-from jinja2.exceptions import TemplateError, UndefinedError, \
- TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
- TemplateAssertionError, TemplateRuntimeError
-
-# decorators and public utilities
-from jinja2.filters import environmentfilter, contextfilter, \
- evalcontextfilter
-from jinja2.utils import Markup, escape, clear_caches, \
- environmentfunction, evalcontextfunction, contextfunction, \
- is_undefined, select_autoescape
-
-__all__ = [
- 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
- 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
- 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
- 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
- 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
- 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
- 'TemplateRuntimeError',
- 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
- 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
- 'evalcontextfilter', 'evalcontextfunction', 'make_logging_undefined',
- 'select_autoescape',
-]
-
-
-def _patch_async():
- from jinja2.utils import have_async_gen
- if have_async_gen:
- from jinja2.asyncsupport import patch_all
- patch_all()
-
-
-_patch_async()
-del _patch_async
diff --git a/python/jinja2/_compat.py b/python/jinja2/_compat.py
deleted file mode 100644
index 61d8530..0000000
--- a/python/jinja2/_compat.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2._compat
- ~~~~~~~~~~~~~~
-
- Some py2/py3 compatibility support based on a stripped down
- version of six so we don't have to depend on a specific version
- of it.
-
- :copyright: Copyright 2013 by the Jinja team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-import sys
-
-PY2 = sys.version_info[0] == 2
-PYPY = hasattr(sys, 'pypy_translation_info')
-_identity = lambda x: x
-
-
-if not PY2:
- unichr = chr
- range_type = range
- text_type = str
- string_types = (str,)
- integer_types = (int,)
-
- iterkeys = lambda d: iter(d.keys())
- itervalues = lambda d: iter(d.values())
- iteritems = lambda d: iter(d.items())
-
- import pickle
- from io import BytesIO, StringIO
- NativeStringIO = StringIO
-
- def reraise(tp, value, tb=None):
- if value.__traceback__ is not tb:
- raise value.with_traceback(tb)
- raise value
-
- ifilter = filter
- imap = map
- izip = zip
- intern = sys.intern
-
- implements_iterator = _identity
- implements_to_string = _identity
- encode_filename = _identity
-
-else:
- unichr = unichr
- text_type = unicode
- range_type = xrange
- string_types = (str, unicode)
- integer_types = (int, long)
-
- iterkeys = lambda d: d.iterkeys()
- itervalues = lambda d: d.itervalues()
- iteritems = lambda d: d.iteritems()
-
- import cPickle as pickle
- from cStringIO import StringIO as BytesIO, StringIO
- NativeStringIO = BytesIO
-
- exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
-
- from itertools import imap, izip, ifilter
- intern = intern
-
- def implements_iterator(cls):
- cls.next = cls.__next__
- del cls.__next__
- return cls
-
- def implements_to_string(cls):
- cls.__unicode__ = cls.__str__
- cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
- return cls
-
- def encode_filename(filename):
- if isinstance(filename, unicode):
- return filename.encode('utf-8')
- return filename
-
-
-def with_metaclass(meta, *bases):
- """Create a base class with a metaclass."""
- # This requires a bit of explanation: the basic idea is to make a
- # dummy metaclass for one level of class instantiation that replaces
- # itself with the actual metaclass.
- class metaclass(type):
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
- return type.__new__(metaclass, 'temporary_class', (), {})
-
-
-try:
- from urllib.parse import quote_from_bytes as url_quote
-except ImportError:
- from urllib import quote as url_quote
diff --git a/python/jinja2/_identifier.py b/python/jinja2/_identifier.py
deleted file mode 100644
index 2eac35d..0000000
--- a/python/jinja2/_identifier.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# generated by scripts/generate_identifier_pattern.py
-pattern = '·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఀ-ఃా-ౄె-ైొ-్ౕౖౢౣಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝᠋-᠍ᢅᢆᢩᤠ-ᤫᤰ-᤻ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼᪰-᪽ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-ᮭ᯦-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰℘℮⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣠-꣱ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꧥꨩ-ꨶꩃꩌꩍꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︯︳︴﹍-﹏_𐇽𐋠𐍶-𐍺𐨁-𐨃𐨅𐨆𐨌-𐨏𐨸-𐨿𐨺𐫦𐫥𑀀-𑀂𑀸-𑁆𑁿-𑂂𑂰-𑂺𑄀-𑄂𑄧-𑅳𑄴𑆀-𑆂𑆳-𑇊𑇀-𑇌𑈬-𑈷𑈾𑋟-𑋪𑌀-𑌃𑌼𑌾-𑍄𑍇𑍈𑍋-𑍍𑍗𑍢𑍣𑍦-𑍬𑍰-𑍴𑐵-𑑆𑒰-𑓃𑖯-𑖵𑖸-𑗀𑗜𑗝𑘰-𑙀𑚫-𑚷𑜝-𑜫𑰯-𑰶𑰸-𑰿𑲒-𑲧𑲩-𑲶𖫰-𖫴𖬰-𖬶𖽑-𖽾𖾏-𖾒𛲝𛲞𝅥-𝅩𝅭-𝅲𝅻-𝆂𝆅-𝆋𝆪-𝆭𝉂-𝉄𝨀-𝨶𝨻-𝩬𝩵𝪄𝪛-𝪟𝪡-𝪯𞀀-𞀆𞀈-𞀘𞀛-𞀡𞀣𞀤𞀦-𞣐𞀪-𞣖𞥄-𞥊󠄀-󠇯'
diff --git a/python/jinja2/asyncfilters.py b/python/jinja2/asyncfilters.py
deleted file mode 100644
index 5c1f46d..0000000
--- a/python/jinja2/asyncfilters.py
+++ /dev/null
@@ -1,146 +0,0 @@
-from functools import wraps
-
-from jinja2.asyncsupport import auto_aiter
-from jinja2 import filters
-
-
-async def auto_to_seq(value):
- seq = []
- if hasattr(value, '__aiter__'):
- async for item in value:
- seq.append(item)
- else:
- for item in value:
- seq.append(item)
- return seq
-
-
-async def async_select_or_reject(args, kwargs, modfunc, lookup_attr):
- seq, func = filters.prepare_select_or_reject(
- args, kwargs, modfunc, lookup_attr)
- if seq:
- async for item in auto_aiter(seq):
- if func(item):
- yield item
-
-
-def dualfilter(normal_filter, async_filter):
- wrap_evalctx = False
- if getattr(normal_filter, 'environmentfilter', False):
- is_async = lambda args: args[0].is_async
- wrap_evalctx = False
- else:
- if not getattr(normal_filter, 'evalcontextfilter', False) and \
- not getattr(normal_filter, 'contextfilter', False):
- wrap_evalctx = True
- is_async = lambda args: args[0].environment.is_async
-
- @wraps(normal_filter)
- def wrapper(*args, **kwargs):
- b = is_async(args)
- if wrap_evalctx:
- args = args[1:]
- if b:
- return async_filter(*args, **kwargs)
- return normal_filter(*args, **kwargs)
-
- if wrap_evalctx:
- wrapper.evalcontextfilter = True
-
- wrapper.asyncfiltervariant = True
-
- return wrapper
-
-
-def asyncfiltervariant(original):
- def decorator(f):
- return dualfilter(original, f)
- return decorator
-
-
-@asyncfiltervariant(filters.do_first)
-async def do_first(environment, seq):
- try:
- return await auto_aiter(seq).__anext__()
- except StopAsyncIteration:
- return environment.undefined('No first item, sequence was empty.')
-
-
-@asyncfiltervariant(filters.do_groupby)
-async def do_groupby(environment, value, attribute):
- expr = filters.make_attrgetter(environment, attribute)
- return [filters._GroupTuple(key, await auto_to_seq(values))
- for key, values in filters.groupby(sorted(
- await auto_to_seq(value), key=expr), expr)]
-
-
-@asyncfiltervariant(filters.do_join)
-async def do_join(eval_ctx, value, d=u'', attribute=None):
- return filters.do_join(eval_ctx, await auto_to_seq(value), d, attribute)
-
-
-@asyncfiltervariant(filters.do_list)
-async def do_list(value):
- return await auto_to_seq(value)
-
-
-@asyncfiltervariant(filters.do_reject)
-async def do_reject(*args, **kwargs):
- return async_select_or_reject(args, kwargs, lambda x: not x, False)
-
-
-@asyncfiltervariant(filters.do_rejectattr)
-async def do_rejectattr(*args, **kwargs):
- return async_select_or_reject(args, kwargs, lambda x: not x, True)
-
-
-@asyncfiltervariant(filters.do_select)
-async def do_select(*args, **kwargs):
- return async_select_or_reject(args, kwargs, lambda x: x, False)
-
-
-@asyncfiltervariant(filters.do_selectattr)
-async def do_selectattr(*args, **kwargs):
- return async_select_or_reject(args, kwargs, lambda x: x, True)
-
-
-@asyncfiltervariant(filters.do_map)
-async def do_map(*args, **kwargs):
- seq, func = filters.prepare_map(args, kwargs)
- if seq:
- async for item in auto_aiter(seq):
- yield func(item)
-
-
-@asyncfiltervariant(filters.do_sum)
-async def do_sum(environment, iterable, attribute=None, start=0):
- rv = start
- if attribute is not None:
- func = filters.make_attrgetter(environment, attribute)
- else:
- func = lambda x: x
- async for item in auto_aiter(iterable):
- rv += func(item)
- return rv
-
-
-@asyncfiltervariant(filters.do_slice)
-async def do_slice(value, slices, fill_with=None):
- return filters.do_slice(await auto_to_seq(value), slices, fill_with)
-
-
-ASYNC_FILTERS = {
- 'first': do_first,
- 'groupby': do_groupby,
- 'join': do_join,
- 'list': do_list,
- # we intentionally do not support do_last because that would be
- # ridiculous
- 'reject': do_reject,
- 'rejectattr': do_rejectattr,
- 'map': do_map,
- 'select': do_select,
- 'selectattr': do_selectattr,
- 'sum': do_sum,
- 'slice': do_slice,
-}
diff --git a/python/jinja2/asyncsupport.py b/python/jinja2/asyncsupport.py
deleted file mode 100644
index b1e7b5c..0000000
--- a/python/jinja2/asyncsupport.py
+++ /dev/null
@@ -1,256 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.asyncsupport
- ~~~~~~~~~~~~~~~~~~~
-
- Has all the code for async support which is implemented as a patch
- for supported Python versions.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import sys
-import asyncio
-import inspect
-from functools import update_wrapper
-
-from jinja2.utils import concat, internalcode, Markup
-from jinja2.environment import TemplateModule
-from jinja2.runtime import LoopContextBase, _last_iteration
-
-
-async def concat_async(async_gen):
- rv = []
- async def collect():
- async for event in async_gen:
- rv.append(event)
- await collect()
- return concat(rv)
-
-
-async def generate_async(self, *args, **kwargs):
- vars = dict(*args, **kwargs)
- try:
- async for event in self.root_render_func(self.new_context(vars)):
- yield event
- except Exception:
- exc_info = sys.exc_info()
- else:
- return
- yield self.environment.handle_exception(exc_info, True)
-
-
-def wrap_generate_func(original_generate):
- def _convert_generator(self, loop, args, kwargs):
- async_gen = self.generate_async(*args, **kwargs)
- try:
- while 1:
- yield loop.run_until_complete(async_gen.__anext__())
- except StopAsyncIteration:
- pass
- def generate(self, *args, **kwargs):
- if not self.environment.is_async:
- return original_generate(self, *args, **kwargs)
- return _convert_generator(self, asyncio.get_event_loop(), args, kwargs)
- return update_wrapper(generate, original_generate)
-
-
-async def render_async(self, *args, **kwargs):
- if not self.environment.is_async:
- raise RuntimeError('The environment was not created with async mode '
- 'enabled.')
-
- vars = dict(*args, **kwargs)
- ctx = self.new_context(vars)
-
- try:
- return await concat_async(self.root_render_func(ctx))
- except Exception:
- exc_info = sys.exc_info()
- return self.environment.handle_exception(exc_info, True)
-
-
-def wrap_render_func(original_render):
- def render(self, *args, **kwargs):
- if not self.environment.is_async:
- return original_render(self, *args, **kwargs)
- loop = asyncio.get_event_loop()
- return loop.run_until_complete(self.render_async(*args, **kwargs))
- return update_wrapper(render, original_render)
-
-
-def wrap_block_reference_call(original_call):
- @internalcode
- async def async_call(self):
- rv = await concat_async(self._stack[self._depth](self._context))
- if self._context.eval_ctx.autoescape:
- rv = Markup(rv)
- return rv
-
- @internalcode
- def __call__(self):
- if not self._context.environment.is_async:
- return original_call(self)
- return async_call(self)
-
- return update_wrapper(__call__, original_call)
-
-
-def wrap_macro_invoke(original_invoke):
- @internalcode
- async def async_invoke(self, arguments, autoescape):
- rv = await self._func(*arguments)
- if autoescape:
- rv = Markup(rv)
- return rv
-
- @internalcode
- def _invoke(self, arguments, autoescape):
- if not self._environment.is_async:
- return original_invoke(self, arguments, autoescape)
- return async_invoke(self, arguments, autoescape)
- return update_wrapper(_invoke, original_invoke)
-
-
-@internalcode
-async def get_default_module_async(self):
- if self._module is not None:
- return self._module
- self._module = rv = await self.make_module_async()
- return rv
-
-
-def wrap_default_module(original_default_module):
- @internalcode
- def _get_default_module(self):
- if self.environment.is_async:
- raise RuntimeError('Template module attribute is unavailable '
- 'in async mode')
- return original_default_module(self)
- return _get_default_module
-
-
-async def make_module_async(self, vars=None, shared=False, locals=None):
- context = self.new_context(vars, shared, locals)
- body_stream = []
- async for item in self.root_render_func(context):
- body_stream.append(item)
- return TemplateModule(self, context, body_stream)
-
-
-def patch_template():
- from jinja2 import Template
- Template.generate = wrap_generate_func(Template.generate)
- Template.generate_async = update_wrapper(
- generate_async, Template.generate_async)
- Template.render_async = update_wrapper(
- render_async, Template.render_async)
- Template.render = wrap_render_func(Template.render)
- Template._get_default_module = wrap_default_module(
- Template._get_default_module)
- Template._get_default_module_async = get_default_module_async
- Template.make_module_async = update_wrapper(
- make_module_async, Template.make_module_async)
-
-
-def patch_runtime():
- from jinja2.runtime import BlockReference, Macro
- BlockReference.__call__ = wrap_block_reference_call(
- BlockReference.__call__)
- Macro._invoke = wrap_macro_invoke(Macro._invoke)
-
-
-def patch_filters():
- from jinja2.filters import FILTERS
- from jinja2.asyncfilters import ASYNC_FILTERS
- FILTERS.update(ASYNC_FILTERS)
-
-
-def patch_all():
- patch_template()
- patch_runtime()
- patch_filters()
-
-
-async def auto_await(value):
- if inspect.isawaitable(value):
- return await value
- return value
-
-
-async def auto_aiter(iterable):
- if hasattr(iterable, '__aiter__'):
- async for item in iterable:
- yield item
- return
- for item in iterable:
- yield item
-
-
-class AsyncLoopContext(LoopContextBase):
-
- def __init__(self, async_iterator, undefined, after, length, recurse=None,
- depth0=0):
- LoopContextBase.__init__(self, undefined, recurse, depth0)
- self._async_iterator = async_iterator
- self._after = after
- self._length = length
-
- @property
- def length(self):
- if self._length is None:
- raise TypeError('Loop length for some iterators cannot be '
- 'lazily calculated in async mode')
- return self._length
-
- def __aiter__(self):
- return AsyncLoopContextIterator(self)
-
-
-class AsyncLoopContextIterator(object):
- __slots__ = ('context',)
-
- def __init__(self, context):
- self.context = context
-
- def __aiter__(self):
- return self
-
- async def __anext__(self):
- ctx = self.context
- ctx.index0 += 1
- if ctx._after is _last_iteration:
- raise StopAsyncIteration()
- ctx._before = ctx._current
- ctx._current = ctx._after
- try:
- ctx._after = await ctx._async_iterator.__anext__()
- except StopAsyncIteration:
- ctx._after = _last_iteration
- return ctx._current, ctx
-
-
-async def make_async_loop_context(iterable, undefined, recurse=None, depth0=0):
- # Length is more complicated and less efficient in async mode. The
- # reason for this is that we cannot know if length will be used
- # upfront but because length is a property we cannot lazily execute it
- # later. This means that we need to buffer it up and measure :(
- #
- # We however only do this for actual iterators, not for async
- # iterators as blocking here does not seem like the best idea in the
- # world.
- try:
- length = len(iterable)
- except (TypeError, AttributeError):
- if not hasattr(iterable, '__aiter__'):
- iterable = tuple(iterable)
- length = len(iterable)
- else:
- length = None
- async_iterator = auto_aiter(iterable)
- try:
- after = await async_iterator.__anext__()
- except StopAsyncIteration:
- after = _last_iteration
- return AsyncLoopContext(async_iterator, undefined, after, length, recurse,
- depth0)
diff --git a/python/jinja2/bccache.py b/python/jinja2/bccache.py
deleted file mode 100644
index 080e527..0000000
--- a/python/jinja2/bccache.py
+++ /dev/null
@@ -1,362 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.bccache
- ~~~~~~~~~~~~~~
-
- This module implements the bytecode cache system Jinja is optionally
- using. This is useful if you have very complex template situations and
- the compiliation of all those templates slow down your application too
- much.
-
- Situations where this is useful are often forking web applications that
- are initialized on the first request.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-from os import path, listdir
-import os
-import sys
-import stat
-import errno
-import marshal
-import tempfile
-import fnmatch
-from hashlib import sha1
-from jinja2.utils import open_if_exists
-from jinja2._compat import BytesIO, pickle, PY2, text_type
-
-
-# marshal works better on 3.x, one hack less required
-if not PY2:
- marshal_dump = marshal.dump
- marshal_load = marshal.load
-else:
-
- def marshal_dump(code, f):
- if isinstance(f, file):
- marshal.dump(code, f)
- else:
- f.write(marshal.dumps(code))
-
- def marshal_load(f):
- if isinstance(f, file):
- return marshal.load(f)
- return marshal.loads(f.read())
-
-
-bc_version = 3
-
-# magic version used to only change with new jinja versions. With 2.6
-# we change this to also take Python version changes into account. The
-# reason for this is that Python tends to segfault if fed earlier bytecode
-# versions because someone thought it would be a good idea to reuse opcodes
-# or make Python incompatible with earlier versions.
-bc_magic = 'j2'.encode('ascii') + \
- pickle.dumps(bc_version, 2) + \
- pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1])
-
-
-class Bucket(object):
- """Buckets are used to store the bytecode for one template. It's created
- and initialized by the bytecode cache and passed to the loading functions.
-
- The buckets get an internal checksum from the cache assigned and use this
- to automatically reject outdated cache material. Individual bytecode
- cache subclasses don't have to care about cache invalidation.
- """
-
- def __init__(self, environment, key, checksum):
- self.environment = environment
- self.key = key
- self.checksum = checksum
- self.reset()
-
- def reset(self):
- """Resets the bucket (unloads the bytecode)."""
- self.code = None
-
- def load_bytecode(self, f):
- """Loads bytecode from a file or file like object."""
- # make sure the magic header is correct
- magic = f.read(len(bc_magic))
- if magic != bc_magic:
- self.reset()
- return
- # the source code of the file changed, we need to reload
- checksum = pickle.load(f)
- if self.checksum != checksum:
- self.reset()
- return
- # if marshal_load fails then we need to reload
- try:
- self.code = marshal_load(f)
- except (EOFError, ValueError, TypeError):
- self.reset()
- return
-
- def write_bytecode(self, f):
- """Dump the bytecode into the file or file like object passed."""
- if self.code is None:
- raise TypeError('can\'t write empty bucket')
- f.write(bc_magic)
- pickle.dump(self.checksum, f, 2)
- marshal_dump(self.code, f)
-
- def bytecode_from_string(self, string):
- """Load bytecode from a string."""
- self.load_bytecode(BytesIO(string))
-
- def bytecode_to_string(self):
- """Return the bytecode as string."""
- out = BytesIO()
- self.write_bytecode(out)
- return out.getvalue()
-
-
-class BytecodeCache(object):
- """To implement your own bytecode cache you have to subclass this class
- and override :meth:`load_bytecode` and :meth:`dump_bytecode`. Both of
- these methods are passed a :class:`~jinja2.bccache.Bucket`.
-
- A very basic bytecode cache that saves the bytecode on the file system::
-
- from os import path
-
- class MyCache(BytecodeCache):
-
- def __init__(self, directory):
- self.directory = directory
-
- def load_bytecode(self, bucket):
- filename = path.join(self.directory, bucket.key)
- if path.exists(filename):
- with open(filename, 'rb') as f:
- bucket.load_bytecode(f)
-
- def dump_bytecode(self, bucket):
- filename = path.join(self.directory, bucket.key)
- with open(filename, 'wb') as f:
- bucket.write_bytecode(f)
-
- A more advanced version of a filesystem based bytecode cache is part of
- Jinja2.
- """
-
- def load_bytecode(self, bucket):
- """Subclasses have to override this method to load bytecode into a
- bucket. If they are not able to find code in the cache for the
- bucket, it must not do anything.
- """
- raise NotImplementedError()
-
- def dump_bytecode(self, bucket):
- """Subclasses have to override this method to write the bytecode
- from a bucket back to the cache. If it unable to do so it must not
- fail silently but raise an exception.
- """
- raise NotImplementedError()
-
- def clear(self):
- """Clears the cache. This method is not used by Jinja2 but should be
- implemented to allow applications to clear the bytecode cache used
- by a particular environment.
- """
-
- def get_cache_key(self, name, filename=None):
- """Returns the unique hash key for this template name."""
- hash = sha1(name.encode('utf-8'))
- if filename is not None:
- filename = '|' + filename
- if isinstance(filename, text_type):
- filename = filename.encode('utf-8')
- hash.update(filename)
- return hash.hexdigest()
-
- def get_source_checksum(self, source):
- """Returns a checksum for the source."""
- return sha1(source.encode('utf-8')).hexdigest()
-
- def get_bucket(self, environment, name, filename, source):
- """Return a cache bucket for the given template. All arguments are
- mandatory but filename may be `None`.
- """
- key = self.get_cache_key(name, filename)
- checksum = self.get_source_checksum(source)
- bucket = Bucket(environment, key, checksum)
- self.load_bytecode(bucket)
- return bucket
-
- def set_bucket(self, bucket):
- """Put the bucket into the cache."""
- self.dump_bytecode(bucket)
-
-
-class FileSystemBytecodeCache(BytecodeCache):
- """A bytecode cache that stores bytecode on the filesystem. It accepts
- two arguments: The directory where the cache items are stored and a
- pattern string that is used to build the filename.
-
- If no directory is specified a default cache directory is selected. On
- Windows the user's temp directory is used, on UNIX systems a directory
- is created for the user in the system temp directory.
-
- The pattern can be used to have multiple separate caches operate on the
- same directory. The default pattern is ``'__jinja2_%s.cache'``. ``%s``
- is replaced with the cache key.
-
- >>> bcc = FileSystemBytecodeCache('/tmp/jinja_cache', '%s.cache')
-
- This bytecode cache supports clearing of the cache using the clear method.
- """
-
- def __init__(self, directory=None, pattern='__jinja2_%s.cache'):
- if directory is None:
- directory = self._get_default_cache_dir()
- self.directory = directory
- self.pattern = pattern
-
- def _get_default_cache_dir(self):
- def _unsafe_dir():
- raise RuntimeError('Cannot determine safe temp directory. You '
- 'need to explicitly provide one.')
-
- tmpdir = tempfile.gettempdir()
-
- # On windows the temporary directory is used specific unless
- # explicitly forced otherwise. We can just use that.
- if os.name == 'nt':
- return tmpdir
- if not hasattr(os, 'getuid'):
- _unsafe_dir()
-
- dirname = '_jinja2-cache-%d' % os.getuid()
- actual_dir = os.path.join(tmpdir, dirname)
-
- try:
- os.mkdir(actual_dir, stat.S_IRWXU)
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise
- try:
- os.chmod(actual_dir, stat.S_IRWXU)
- actual_dir_stat = os.lstat(actual_dir)
- if actual_dir_stat.st_uid != os.getuid() \
- or not stat.S_ISDIR(actual_dir_stat.st_mode) \
- or stat.S_IMODE(actual_dir_stat.st_mode) != stat.S_IRWXU:
- _unsafe_dir()
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise
-
- actual_dir_stat = os.lstat(actual_dir)
- if actual_dir_stat.st_uid != os.getuid() \
- or not stat.S_ISDIR(actual_dir_stat.st_mode) \
- or stat.S_IMODE(actual_dir_stat.st_mode) != stat.S_IRWXU:
- _unsafe_dir()
-
- return actual_dir
-
- def _get_cache_filename(self, bucket):
- return path.join(self.directory, self.pattern % bucket.key)
-
- def load_bytecode(self, bucket):
- f = open_if_exists(self._get_cache_filename(bucket), 'rb')
- if f is not None:
- try:
- bucket.load_bytecode(f)
- finally:
- f.close()
-
- def dump_bytecode(self, bucket):
- f = open(self._get_cache_filename(bucket), 'wb')
- try:
- bucket.write_bytecode(f)
- finally:
- f.close()
-
- def clear(self):
- # imported lazily here because google app-engine doesn't support
- # write access on the file system and the function does not exist
- # normally.
- from os import remove
- files = fnmatch.filter(listdir(self.directory), self.pattern % '*')
- for filename in files:
- try:
- remove(path.join(self.directory, filename))
- except OSError:
- pass
-
-
-class MemcachedBytecodeCache(BytecodeCache):
- """This class implements a bytecode cache that uses a memcache cache for
- storing the information. It does not enforce a specific memcache library
- (tummy's memcache or cmemcache) but will accept any class that provides
- the minimal interface required.
-
- Libraries compatible with this class:
-
- - `werkzeug <http://werkzeug.pocoo.org/>`_.contrib.cache
- - `python-memcached <https://www.tummy.com/Community/software/python-memcached/>`_
- - `cmemcache <http://gijsbert.org/cmemcache/>`_
-
- (Unfortunately the django cache interface is not compatible because it
- does not support storing binary data, only unicode. You can however pass
- the underlying cache client to the bytecode cache which is available
- as `django.core.cache.cache._client`.)
-
- The minimal interface for the client passed to the constructor is this:
-
- .. class:: MinimalClientInterface
-
- .. method:: set(key, value[, timeout])
-
- Stores the bytecode in the cache. `value` is a string and
- `timeout` the timeout of the key. If timeout is not provided
- a default timeout or no timeout should be assumed, if it's
- provided it's an integer with the number of seconds the cache
- item should exist.
-
- .. method:: get(key)
-
- Returns the value for the cache key. If the item does not
- exist in the cache the return value must be `None`.
-
- The other arguments to the constructor are the prefix for all keys that
- is added before the actual cache key and the timeout for the bytecode in
- the cache system. We recommend a high (or no) timeout.
-
- This bytecode cache does not support clearing of used items in the cache.
- The clear method is a no-operation function.
-
- .. versionadded:: 2.7
- Added support for ignoring memcache errors through the
- `ignore_memcache_errors` parameter.
- """
-
- def __init__(self, client, prefix='jinja2/bytecode/', timeout=None,
- ignore_memcache_errors=True):
- self.client = client
- self.prefix = prefix
- self.timeout = timeout
- self.ignore_memcache_errors = ignore_memcache_errors
-
- def load_bytecode(self, bucket):
- try:
- code = self.client.get(self.prefix + bucket.key)
- except Exception:
- if not self.ignore_memcache_errors:
- raise
- code = None
- if code is not None:
- bucket.bytecode_from_string(code)
-
- def dump_bytecode(self, bucket):
- args = (self.prefix + bucket.key, bucket.bytecode_to_string())
- if self.timeout is not None:
- args += (self.timeout,)
- try:
- self.client.set(*args)
- except Exception:
- if not self.ignore_memcache_errors:
- raise
diff --git a/python/jinja2/compiler.py b/python/jinja2/compiler.py
deleted file mode 100644
index d534a82..0000000
--- a/python/jinja2/compiler.py
+++ /dev/null
@@ -1,1721 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.compiler
- ~~~~~~~~~~~~~~~
-
- Compiles nodes into python code.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-from itertools import chain
-from copy import deepcopy
-from keyword import iskeyword as is_python_keyword
-from functools import update_wrapper
-from jinja2 import nodes
-from jinja2.nodes import EvalContext
-from jinja2.visitor import NodeVisitor
-from jinja2.optimizer import Optimizer
-from jinja2.exceptions import TemplateAssertionError
-from jinja2.utils import Markup, concat, escape
-from jinja2._compat import range_type, text_type, string_types, \
- iteritems, NativeStringIO, imap, izip
-from jinja2.idtracking import Symbols, VAR_LOAD_PARAMETER, \
- VAR_LOAD_RESOLVE, VAR_LOAD_ALIAS, VAR_LOAD_UNDEFINED
-
-
-operators = {
- 'eq': '==',
- 'ne': '!=',
- 'gt': '>',
- 'gteq': '>=',
- 'lt': '<',
- 'lteq': '<=',
- 'in': 'in',
- 'notin': 'not in'
-}
-
-# what method to iterate over items do we want to use for dict iteration
-# in generated code? on 2.x let's go with iteritems, on 3.x with items
-if hasattr(dict, 'iteritems'):
- dict_item_iter = 'iteritems'
-else:
- dict_item_iter = 'items'
-
-code_features = ['division']
-
-# does this python version support generator stops? (PEP 0479)
-try:
- exec('from __future__ import generator_stop')
- code_features.append('generator_stop')
-except SyntaxError:
- pass
-
-# does this python version support yield from?
-try:
- exec('def f(): yield from x()')
-except SyntaxError:
- supports_yield_from = False
-else:
- supports_yield_from = True
-
-
-def optimizeconst(f):
- def new_func(self, node, frame, **kwargs):
- # Only optimize if the frame is not volatile
- if self.optimized and not frame.eval_ctx.volatile:
- new_node = self.optimizer.visit(node, frame.eval_ctx)
- if new_node != node:
- return self.visit(new_node, frame)
- return f(self, node, frame, **kwargs)
- return update_wrapper(new_func, f)
-
-
-def generate(node, environment, name, filename, stream=None,
- defer_init=False, optimized=True):
- """Generate the python source for a node tree."""
- if not isinstance(node, nodes.Template):
- raise TypeError('Can\'t compile non template nodes')
- generator = environment.code_generator_class(environment, name, filename,
- stream, defer_init,
- optimized)
- generator.visit(node)
- if stream is None:
- return generator.stream.getvalue()
-
-
-def has_safe_repr(value):
- """Does the node have a safe representation?"""
- if value is None or value is NotImplemented or value is Ellipsis:
- return True
- if type(value) in (bool, int, float, complex, range_type, Markup) + string_types:
- return True
- if type(value) in (tuple, list, set, frozenset):
- for item in value:
- if not has_safe_repr(item):
- return False
- return True
- elif type(value) is dict:
- for key, value in iteritems(value):
- if not has_safe_repr(key):
- return False
- if not has_safe_repr(value):
- return False
- return True
- return False
-
-
-def find_undeclared(nodes, names):
- """Check if the names passed are accessed undeclared. The return value
- is a set of all the undeclared names from the sequence of names found.
- """
- visitor = UndeclaredNameVisitor(names)
- try:
- for node in nodes:
- visitor.visit(node)
- except VisitorExit:
- pass
- return visitor.undeclared
-
-
-class MacroRef(object):
-
- def __init__(self, node):
- self.node = node
- self.accesses_caller = False
- self.accesses_kwargs = False
- self.accesses_varargs = False
-
-
-class Frame(object):
- """Holds compile time information for us."""
-
- def __init__(self, eval_ctx, parent=None, level=None):
- self.eval_ctx = eval_ctx
- self.symbols = Symbols(parent and parent.symbols or None,
- level=level)
-
- # a toplevel frame is the root + soft frames such as if conditions.
- self.toplevel = False
-
- # the root frame is basically just the outermost frame, so no if
- # conditions. This information is used to optimize inheritance
- # situations.
- self.rootlevel = False
-
- # in some dynamic inheritance situations the compiler needs to add
- # write tests around output statements.
- self.require_output_check = parent and parent.require_output_check
-
- # inside some tags we are using a buffer rather than yield statements.
- # this for example affects {% filter %} or {% macro %}. If a frame
- # is buffered this variable points to the name of the list used as
- # buffer.
- self.buffer = None
-
- # the name of the block we're in, otherwise None.
- self.block = parent and parent.block or None
-
- # the parent of this frame
- self.parent = parent
-
- if parent is not None:
- self.buffer = parent.buffer
-
- def copy(self):
- """Create a copy of the current one."""
- rv = object.__new__(self.__class__)
- rv.__dict__.update(self.__dict__)
- rv.symbols = self.symbols.copy()
- return rv
-
- def inner(self, isolated=False):
- """Return an inner frame."""
- if isolated:
- return Frame(self.eval_ctx, level=self.symbols.level + 1)
- return Frame(self.eval_ctx, self)
-
- def soft(self):
- """Return a soft frame. A soft frame may not be modified as
- standalone thing as it shares the resources with the frame it
- was created of, but it's not a rootlevel frame any longer.
-
- This is only used to implement if-statements.
- """
- rv = self.copy()
- rv.rootlevel = False
- return rv
-
- __copy__ = copy
-
-
-class VisitorExit(RuntimeError):
- """Exception used by the `UndeclaredNameVisitor` to signal a stop."""
-
-
-class DependencyFinderVisitor(NodeVisitor):
- """A visitor that collects filter and test calls."""
-
- def __init__(self):
- self.filters = set()
- self.tests = set()
-
- def visit_Filter(self, node):
- self.generic_visit(node)
- self.filters.add(node.name)
-
- def visit_Test(self, node):
- self.generic_visit(node)
- self.tests.add(node.name)
-
- def visit_Block(self, node):
- """Stop visiting at blocks."""
-
-
-class UndeclaredNameVisitor(NodeVisitor):
- """A visitor that checks if a name is accessed without being
- declared. This is different from the frame visitor as it will
- not stop at closure frames.
- """
-
- def __init__(self, names):
- self.names = set(names)
- self.undeclared = set()
-
- def visit_Name(self, node):
- if node.ctx == 'load' and node.name in self.names:
- self.undeclared.add(node.name)
- if self.undeclared == self.names:
- raise VisitorExit()
- else:
- self.names.discard(node.name)
-
- def visit_Block(self, node):
- """Stop visiting a blocks."""
-
-
-class CompilerExit(Exception):
- """Raised if the compiler encountered a situation where it just
- doesn't make sense to further process the code. Any block that
- raises such an exception is not further processed.
- """
-
-
-class CodeGenerator(NodeVisitor):
-
- def __init__(self, environment, name, filename, stream=None,
- defer_init=False, optimized=True):
- if stream is None:
- stream = NativeStringIO()
- self.environment = environment
- self.name = name
- self.filename = filename
- self.stream = stream
- self.created_block_context = False
- self.defer_init = defer_init
- self.optimized = optimized
- if optimized:
- self.optimizer = Optimizer(environment)
-
- # aliases for imports
- self.import_aliases = {}
-
- # a registry for all blocks. Because blocks are moved out
- # into the global python scope they are registered here
- self.blocks = {}
-
- # the number of extends statements so far
- self.extends_so_far = 0
-
- # some templates have a rootlevel extends. In this case we
- # can safely assume that we're a child template and do some
- # more optimizations.
- self.has_known_extends = False
-
- # the current line number
- self.code_lineno = 1
-
- # registry of all filters and tests (global, not block local)
- self.tests = {}
- self.filters = {}
-
- # the debug information
- self.debug_info = []
- self._write_debug_info = None
-
- # the number of new lines before the next write()
- self._new_lines = 0
-
- # the line number of the last written statement
- self._last_line = 0
-
- # true if nothing was written so far.
- self._first_write = True
-
- # used by the `temporary_identifier` method to get new
- # unique, temporary identifier
- self._last_identifier = 0
-
- # the current indentation
- self._indentation = 0
-
- # Tracks toplevel assignments
- self._assign_stack = []
-
- # Tracks parameter definition blocks
- self._param_def_block = []
-
- # Tracks the current context.
- self._context_reference_stack = ['context']
-
- # -- Various compilation helpers
-
- def fail(self, msg, lineno):
- """Fail with a :exc:`TemplateAssertionError`."""
- raise TemplateAssertionError(msg, lineno, self.name, self.filename)
-
- def temporary_identifier(self):
- """Get a new unique identifier."""
- self._last_identifier += 1
- return 't_%d' % self._last_identifier
-
- def buffer(self, frame):
- """Enable buffering for the frame from that point onwards."""
- frame.buffer = self.temporary_identifier()
- self.writeline('%s = []' % frame.buffer)
-
- def return_buffer_contents(self, frame, force_unescaped=False):
- """Return the buffer contents of the frame."""
- if not force_unescaped:
- if frame.eval_ctx.volatile:
- self.writeline('if context.eval_ctx.autoescape:')
- self.indent()
- self.writeline('return Markup(concat(%s))' % frame.buffer)
- self.outdent()
- self.writeline('else:')
- self.indent()
- self.writeline('return concat(%s)' % frame.buffer)
- self.outdent()
- return
- elif frame.eval_ctx.autoescape:
- self.writeline('return Markup(concat(%s))' % frame.buffer)
- return
- self.writeline('return concat(%s)' % frame.buffer)
-
- def indent(self):
- """Indent by one."""
- self._indentation += 1
-
- def outdent(self, step=1):
- """Outdent by step."""
- self._indentation -= step
-
- def start_write(self, frame, node=None):
- """Yield or write into the frame buffer."""
- if frame.buffer is None:
- self.writeline('yield ', node)
- else:
- self.writeline('%s.append(' % frame.buffer, node)
-
- def end_write(self, frame):
- """End the writing process started by `start_write`."""
- if frame.buffer is not None:
- self.write(')')
-
- def simple_write(self, s, frame, node=None):
- """Simple shortcut for start_write + write + end_write."""
- self.start_write(frame, node)
- self.write(s)
- self.end_write(frame)
-
- def blockvisit(self, nodes, frame):
- """Visit a list of nodes as block in a frame. If the current frame
- is no buffer a dummy ``if 0: yield None`` is written automatically.
- """
- try:
- self.writeline('pass')
- for node in nodes:
- self.visit(node, frame)
- except CompilerExit:
- pass
-
- def write(self, x):
- """Write a string into the output stream."""
- if self._new_lines:
- if not self._first_write:
- self.stream.write('\n' * self._new_lines)
- self.code_lineno += self._new_lines
- if self._write_debug_info is not None:
- self.debug_info.append((self._write_debug_info,
- self.code_lineno))
- self._write_debug_info = None
- self._first_write = False
- self.stream.write(' ' * self._indentation)
- self._new_lines = 0
- self.stream.write(x)
-
- def writeline(self, x, node=None, extra=0):
- """Combination of newline and write."""
- self.newline(node, extra)
- self.write(x)
-
- def newline(self, node=None, extra=0):
- """Add one or more newlines before the next write."""
- self._new_lines = max(self._new_lines, 1 + extra)
- if node is not None and node.lineno != self._last_line:
- self._write_debug_info = node.lineno
- self._last_line = node.lineno
-
- def signature(self, node, frame, extra_kwargs=None):
- """Writes a function call to the stream for the current node.
- A leading comma is added automatically. The extra keyword
- arguments may not include python keywords otherwise a syntax
- error could occour. The extra keyword arguments should be given
- as python dict.
- """
- # if any of the given keyword arguments is a python keyword
- # we have to make sure that no invalid call is created.
- kwarg_workaround = False
- for kwarg in chain((x.key for x in node.kwargs), extra_kwargs or ()):
- if is_python_keyword(kwarg):
- kwarg_workaround = True
- break
-
- for arg in node.args:
- self.write(', ')
- self.visit(arg, frame)
-
- if not kwarg_workaround:
- for kwarg in node.kwargs:
- self.write(', ')
- self.visit(kwarg, frame)
- if extra_kwargs is not None:
- for key, value in iteritems(extra_kwargs):
- self.write(', %s=%s' % (key, value))
- if node.dyn_args:
- self.write(', *')
- self.visit(node.dyn_args, frame)
-
- if kwarg_workaround:
- if node.dyn_kwargs is not None:
- self.write(', **dict({')
- else:
- self.write(', **{')
- for kwarg in node.kwargs:
- self.write('%r: ' % kwarg.key)
- self.visit(kwarg.value, frame)
- self.write(', ')
- if extra_kwargs is not None:
- for key, value in iteritems(extra_kwargs):
- self.write('%r: %s, ' % (key, value))
- if node.dyn_kwargs is not None:
- self.write('}, **')
- self.visit(node.dyn_kwargs, frame)
- self.write(')')
- else:
- self.write('}')
-
- elif node.dyn_kwargs is not None:
- self.write(', **')
- self.visit(node.dyn_kwargs, frame)
-
- def pull_dependencies(self, nodes):
- """Pull all the dependencies."""
- visitor = DependencyFinderVisitor()
- for node in nodes:
- visitor.visit(node)
- for dependency in 'filters', 'tests':
- mapping = getattr(self, dependency)
- for name in getattr(visitor, dependency):
- if name not in mapping:
- mapping[name] = self.temporary_identifier()
- self.writeline('%s = environment.%s[%r]' %
- (mapping[name], dependency, name))
-
- def enter_frame(self, frame):
- undefs = []
- for target, (action, param) in iteritems(frame.symbols.loads):
- if action == VAR_LOAD_PARAMETER:
- pass
- elif action == VAR_LOAD_RESOLVE:
- self.writeline('%s = %s(%r)' %
- (target, self.get_resolve_func(), param))
- elif action == VAR_LOAD_ALIAS:
- self.writeline('%s = %s' % (target, param))
- elif action == VAR_LOAD_UNDEFINED:
- undefs.append(target)
- else:
- raise NotImplementedError('unknown load instruction')
- if undefs:
- self.writeline('%s = missing' % ' = '.join(undefs))
-
- def leave_frame(self, frame, with_python_scope=False):
- if not with_python_scope:
- undefs = []
- for target, _ in iteritems(frame.symbols.loads):
- undefs.append(target)
- if undefs:
- self.writeline('%s = missing' % ' = '.join(undefs))
-
- def func(self, name):
- if self.environment.is_async:
- return 'async def %s' % name
- return 'def %s' % name
-
- def macro_body(self, node, frame):
- """Dump the function def of a macro or call block."""
- frame = frame.inner()
- frame.symbols.analyze_node(node)
- macro_ref = MacroRef(node)
-
- explicit_caller = None
- skip_special_params = set()
- args = []
- for idx, arg in enumerate(node.args):
- if arg.name == 'caller':
- explicit_caller = idx
- if arg.name in ('kwargs', 'varargs'):
- skip_special_params.add(arg.name)
- args.append(frame.symbols.ref(arg.name))
-
- undeclared = find_undeclared(node.body, ('caller', 'kwargs', 'varargs'))
-
- if 'caller' in undeclared:
- # In older Jinja2 versions there was a bug that allowed caller
- # to retain the special behavior even if it was mentioned in
- # the argument list. However thankfully this was only really
- # working if it was the last argument. So we are explicitly
- # checking this now and error out if it is anywhere else in
- # the argument list.
- if explicit_caller is not None:
- try:
- node.defaults[explicit_caller - len(node.args)]
- except IndexError:
- self.fail('When defining macros or call blocks the '
- 'special "caller" argument must be omitted '
- 'or be given a default.', node.lineno)
- else:
- args.append(frame.symbols.declare_parameter('caller'))
- macro_ref.accesses_caller = True
- if 'kwargs' in undeclared and not 'kwargs' in skip_special_params:
- args.append(frame.symbols.declare_parameter('kwargs'))
- macro_ref.accesses_kwargs = True
- if 'varargs' in undeclared and not 'varargs' in skip_special_params:
- args.append(frame.symbols.declare_parameter('varargs'))
- macro_ref.accesses_varargs = True
-
- # macros are delayed, they never require output checks
- frame.require_output_check = False
- frame.symbols.analyze_node(node)
- self.writeline('%s(%s):' % (self.func('macro'), ', '.join(args)), node)
- self.indent()
-
- self.buffer(frame)
- self.enter_frame(frame)
-
- self.push_parameter_definitions(frame)
- for idx, arg in enumerate(node.args):
- ref = frame.symbols.ref(arg.name)
- self.writeline('if %s is missing:' % ref)
- self.indent()
- try:
- default = node.defaults[idx - len(node.args)]
- except IndexError:
- self.writeline('%s = undefined(%r, name=%r)' % (
- ref,
- 'parameter %r was not provided' % arg.name,
- arg.name))
- else:
- self.writeline('%s = ' % ref)
- self.visit(default, frame)
- self.mark_parameter_stored(ref)
- self.outdent()
- self.pop_parameter_definitions()
-
- self.blockvisit(node.body, frame)
- self.return_buffer_contents(frame, force_unescaped=True)
- self.leave_frame(frame, with_python_scope=True)
- self.outdent()
-
- return frame, macro_ref
-
- def macro_def(self, macro_ref, frame):
- """Dump the macro definition for the def created by macro_body."""
- arg_tuple = ', '.join(repr(x.name) for x in macro_ref.node.args)
- name = getattr(macro_ref.node, 'name', None)
- if len(macro_ref.node.args) == 1:
- arg_tuple += ','
- self.write('Macro(environment, macro, %r, (%s), %r, %r, %r, '
- 'context.eval_ctx.autoescape)' %
- (name, arg_tuple, macro_ref.accesses_kwargs,
- macro_ref.accesses_varargs, macro_ref.accesses_caller))
-
- def position(self, node):
- """Return a human readable position for the node."""
- rv = 'line %d' % node.lineno
- if self.name is not None:
- rv += ' in ' + repr(self.name)
- return rv
-
- def dump_local_context(self, frame):
- return '{%s}' % ', '.join(
- '%r: %s' % (name, target) for name, target
- in iteritems(frame.symbols.dump_stores()))
-
- def write_commons(self):
- """Writes a common preamble that is used by root and block functions.
- Primarily this sets up common local helpers and enforces a generator
- through a dead branch.
- """
- self.writeline('resolve = context.resolve_or_missing')
- self.writeline('undefined = environment.undefined')
- self.writeline('if 0: yield None')
-
- def push_parameter_definitions(self, frame):
- """Pushes all parameter targets from the given frame into a local
- stack that permits tracking of yet to be assigned parameters. In
- particular this enables the optimization from `visit_Name` to skip
- undefined expressions for parameters in macros as macros can reference
- otherwise unbound parameters.
- """
- self._param_def_block.append(frame.symbols.dump_param_targets())
-
- def pop_parameter_definitions(self):
- """Pops the current parameter definitions set."""
- self._param_def_block.pop()
-
- def mark_parameter_stored(self, target):
- """Marks a parameter in the current parameter definitions as stored.
- This will skip the enforced undefined checks.
- """
- if self._param_def_block:
- self._param_def_block[-1].discard(target)
-
- def push_context_reference(self, target):
- self._context_reference_stack.append(target)
-
- def pop_context_reference(self):
- self._context_reference_stack.pop()
-
- def get_context_ref(self):
- return self._context_reference_stack[-1]
-
- def get_resolve_func(self):
- target = self._context_reference_stack[-1]
- if target == 'context':
- return 'resolve'
- return '%s.resolve' % target
-
- def derive_context(self, frame):
- return '%s.derived(%s)' % (
- self.get_context_ref(),
- self.dump_local_context(frame),
- )
-
- def parameter_is_undeclared(self, target):
- """Checks if a given target is an undeclared parameter."""
- if not self._param_def_block:
- return False
- return target in self._param_def_block[-1]
-
- def push_assign_tracking(self):
- """Pushes a new layer for assignment tracking."""
- self._assign_stack.append(set())
-
- def pop_assign_tracking(self, frame):
- """Pops the topmost level for assignment tracking and updates the
- context variables if necessary.
- """
- vars = self._assign_stack.pop()
- if not frame.toplevel or not vars:
- return
- public_names = [x for x in vars if x[:1] != '_']
- if len(vars) == 1:
- name = next(iter(vars))
- ref = frame.symbols.ref(name)
- self.writeline('context.vars[%r] = %s' % (name, ref))
- else:
- self.writeline('context.vars.update({')
- for idx, name in enumerate(vars):
- if idx:
- self.write(', ')
- ref = frame.symbols.ref(name)
- self.write('%r: %s' % (name, ref))
- self.write('})')
- if public_names:
- if len(public_names) == 1:
- self.writeline('context.exported_vars.add(%r)' %
- public_names[0])
- else:
- self.writeline('context.exported_vars.update((%s))' %
- ', '.join(imap(repr, public_names)))
-
- # -- Statement Visitors
-
- def visit_Template(self, node, frame=None):
- assert frame is None, 'no root frame allowed'
- eval_ctx = EvalContext(self.environment, self.name)
-
- from jinja2.runtime import __all__ as exported
- self.writeline('from __future__ import %s' % ', '.join(code_features))
- self.writeline('from jinja2.runtime import ' + ', '.join(exported))
-
- if self.environment.is_async:
- self.writeline('from jinja2.asyncsupport import auto_await, '
- 'auto_aiter, make_async_loop_context')
-
- # if we want a deferred initialization we cannot move the
- # environment into a local name
- envenv = not self.defer_init and ', environment=environment' or ''
-
- # do we have an extends tag at all? If not, we can save some
- # overhead by just not processing any inheritance code.
- have_extends = node.find(nodes.Extends) is not None
-
- # find all blocks
- for block in node.find_all(nodes.Block):
- if block.name in self.blocks:
- self.fail('block %r defined twice' % block.name, block.lineno)
- self.blocks[block.name] = block
-
- # find all imports and import them
- for import_ in node.find_all(nodes.ImportedName):
- if import_.importname not in self.import_aliases:
- imp = import_.importname
- self.import_aliases[imp] = alias = self.temporary_identifier()
- if '.' in imp:
- module, obj = imp.rsplit('.', 1)
- self.writeline('from %s import %s as %s' %
- (module, obj, alias))
- else:
- self.writeline('import %s as %s' % (imp, alias))
-
- # add the load name
- self.writeline('name = %r' % self.name)
-
- # generate the root render function.
- self.writeline('%s(context, missing=missing%s):' %
- (self.func('root'), envenv), extra=1)
- self.indent()
- self.write_commons()
-
- # process the root
- frame = Frame(eval_ctx)
- if 'self' in find_undeclared(node.body, ('self',)):
- ref = frame.symbols.declare_parameter('self')
- self.writeline('%s = TemplateReference(context)' % ref)
- frame.symbols.analyze_node(node)
- frame.toplevel = frame.rootlevel = True
- frame.require_output_check = have_extends and not self.has_known_extends
- if have_extends:
- self.writeline('parent_template = None')
- self.enter_frame(frame)
- self.pull_dependencies(node.body)
- self.blockvisit(node.body, frame)
- self.leave_frame(frame, with_python_scope=True)
- self.outdent()
-
- # make sure that the parent root is called.
- if have_extends:
- if not self.has_known_extends:
- self.indent()
- self.writeline('if parent_template is not None:')
- self.indent()
- if supports_yield_from and not self.environment.is_async:
- self.writeline('yield from parent_template.'
- 'root_render_func(context)')
- else:
- self.writeline('%sfor event in parent_template.'
- 'root_render_func(context):' %
- (self.environment.is_async and 'async ' or ''))
- self.indent()
- self.writeline('yield event')
- self.outdent()
- self.outdent(1 + (not self.has_known_extends))
-
- # at this point we now have the blocks collected and can visit them too.
- for name, block in iteritems(self.blocks):
- self.writeline('%s(context, missing=missing%s):' %
- (self.func('block_' + name), envenv),
- block, 1)
- self.indent()
- self.write_commons()
- # It's important that we do not make this frame a child of the
- # toplevel template. This would cause a variety of
- # interesting issues with identifier tracking.
- block_frame = Frame(eval_ctx)
- undeclared = find_undeclared(block.body, ('self', 'super'))
- if 'self' in undeclared:
- ref = block_frame.symbols.declare_parameter('self')
- self.writeline('%s = TemplateReference(context)' % ref)
- if 'super' in undeclared:
- ref = block_frame.symbols.declare_parameter('super')
- self.writeline('%s = context.super(%r, '
- 'block_%s)' % (ref, name, name))
- block_frame.symbols.analyze_node(block)
- block_frame.block = name
- self.enter_frame(block_frame)
- self.pull_dependencies(block.body)
- self.blockvisit(block.body, block_frame)
- self.leave_frame(block_frame, with_python_scope=True)
- self.outdent()
-
- self.writeline('blocks = {%s}' % ', '.join('%r: block_%s' % (x, x)
- for x in self.blocks),
- extra=1)
-
- # add a function that returns the debug info
- self.writeline('debug_info = %r' % '&'.join('%s=%s' % x for x
- in self.debug_info))
-
- def visit_Block(self, node, frame):
- """Call a block and register it for the template."""
- level = 0
- if frame.toplevel:
- # if we know that we are a child template, there is no need to
- # check if we are one
- if self.has_known_extends:
- return
- if self.extends_so_far > 0:
- self.writeline('if parent_template is None:')
- self.indent()
- level += 1
-
- if node.scoped:
- context = self.derive_context(frame)
- else:
- context = self.get_context_ref()
-
- if supports_yield_from and not self.environment.is_async and \
- frame.buffer is None:
- self.writeline('yield from context.blocks[%r][0](%s)' % (
- node.name, context), node)
- else:
- loop = self.environment.is_async and 'async for' or 'for'
- self.writeline('%s event in context.blocks[%r][0](%s):' % (
- loop, node.name, context), node)
- self.indent()
- self.simple_write('event', frame)
- self.outdent()
-
- self.outdent(level)
-
- def visit_Extends(self, node, frame):
- """Calls the extender."""
- if not frame.toplevel:
- self.fail('cannot use extend from a non top-level scope',
- node.lineno)
-
- # if the number of extends statements in general is zero so
- # far, we don't have to add a check if something extended
- # the template before this one.
- if self.extends_so_far > 0:
-
- # if we have a known extends we just add a template runtime
- # error into the generated code. We could catch that at compile
- # time too, but i welcome it not to confuse users by throwing the
- # same error at different times just "because we can".
- if not self.has_known_extends:
- self.writeline('if parent_template is not None:')
- self.indent()
- self.writeline('raise TemplateRuntimeError(%r)' %
- 'extended multiple times')
-
- # if we have a known extends already we don't need that code here
- # as we know that the template execution will end here.
- if self.has_known_extends:
- raise CompilerExit()
- else:
- self.outdent()
-
- self.writeline('parent_template = environment.get_template(', node)
- self.visit(node.template, frame)
- self.write(', %r)' % self.name)
- self.writeline('for name, parent_block in parent_template.'
- 'blocks.%s():' % dict_item_iter)
- self.indent()
- self.writeline('context.blocks.setdefault(name, []).'
- 'append(parent_block)')
- self.outdent()
-
- # if this extends statement was in the root level we can take
- # advantage of that information and simplify the generated code
- # in the top level from this point onwards
- if frame.rootlevel:
- self.has_known_extends = True
-
- # and now we have one more
- self.extends_so_far += 1
-
- def visit_Include(self, node, frame):
- """Handles includes."""
- if node.ignore_missing:
- self.writeline('try:')
- self.indent()
-
- func_name = 'get_or_select_template'
- if isinstance(node.template, nodes.Const):
- if isinstance(node.template.value, string_types):
- func_name = 'get_template'
- elif isinstance(node.template.value, (tuple, list)):
- func_name = 'select_template'
- elif isinstance(node.template, (nodes.Tuple, nodes.List)):
- func_name = 'select_template'
-
- self.writeline('template = environment.%s(' % func_name, node)
- self.visit(node.template, frame)
- self.write(', %r)' % self.name)
- if node.ignore_missing:
- self.outdent()
- self.writeline('except TemplateNotFound:')
- self.indent()
- self.writeline('pass')
- self.outdent()
- self.writeline('else:')
- self.indent()
-
- skip_event_yield = False
- if node.with_context:
- loop = self.environment.is_async and 'async for' or 'for'
- self.writeline('%s event in template.root_render_func('
- 'template.new_context(context.get_all(), True, '
- '%s)):' % (loop, self.dump_local_context(frame)))
- elif self.environment.is_async:
- self.writeline('for event in (await '
- 'template._get_default_module_async())'
- '._body_stream:')
- else:
- if supports_yield_from:
- self.writeline('yield from template._get_default_module()'
- '._body_stream')
- skip_event_yield = True
- else:
- self.writeline('for event in template._get_default_module()'
- '._body_stream:')
-
- if not skip_event_yield:
- self.indent()
- self.simple_write('event', frame)
- self.outdent()
-
- if node.ignore_missing:
- self.outdent()
-
- def visit_Import(self, node, frame):
- """Visit regular imports."""
- self.writeline('%s = ' % frame.symbols.ref(node.target), node)
- if frame.toplevel:
- self.write('context.vars[%r] = ' % node.target)
- if self.environment.is_async:
- self.write('await ')
- self.write('environment.get_template(')
- self.visit(node.template, frame)
- self.write(', %r).' % self.name)
- if node.with_context:
- self.write('make_module%s(context.get_all(), True, %s)'
- % (self.environment.is_async and '_async' or '',
- self.dump_local_context(frame)))
- elif self.environment.is_async:
- self.write('_get_default_module_async()')
- else:
- self.write('_get_default_module()')
- if frame.toplevel and not node.target.startswith('_'):
- self.writeline('context.exported_vars.discard(%r)' % node.target)
-
- def visit_FromImport(self, node, frame):
- """Visit named imports."""
- self.newline(node)
- self.write('included_template = %senvironment.get_template('
- % (self.environment.is_async and 'await ' or ''))
- self.visit(node.template, frame)
- self.write(', %r).' % self.name)
- if node.with_context:
- self.write('make_module%s(context.get_all(), True, %s)'
- % (self.environment.is_async and '_async' or '',
- self.dump_local_context(frame)))
- elif self.environment.is_async:
- self.write('_get_default_module_async()')
- else:
- self.write('_get_default_module()')
-
- var_names = []
- discarded_names = []
- for name in node.names:
- if isinstance(name, tuple):
- name, alias = name
- else:
- alias = name
- self.writeline('%s = getattr(included_template, '
- '%r, missing)' % (frame.symbols.ref(alias), name))
- self.writeline('if %s is missing:' % frame.symbols.ref(alias))
- self.indent()
- self.writeline('%s = undefined(%r %% '
- 'included_template.__name__, '
- 'name=%r)' %
- (frame.symbols.ref(alias),
- 'the template %%r (imported on %s) does '
- 'not export the requested name %s' % (
- self.position(node),
- repr(name)
- ), name))
- self.outdent()
- if frame.toplevel:
- var_names.append(alias)
- if not alias.startswith('_'):
- discarded_names.append(alias)
-
- if var_names:
- if len(var_names) == 1:
- name = var_names[0]
- self.writeline('context.vars[%r] = %s' %
- (name, frame.symbols.ref(name)))
- else:
- self.writeline('context.vars.update({%s})' % ', '.join(
- '%r: %s' % (name, frame.symbols.ref(name)) for name in var_names
- ))
- if discarded_names:
- if len(discarded_names) == 1:
- self.writeline('context.exported_vars.discard(%r)' %
- discarded_names[0])
- else:
- self.writeline('context.exported_vars.difference_'
- 'update((%s))' % ', '.join(imap(repr, discarded_names)))
-
- def visit_For(self, node, frame):
- loop_frame = frame.inner()
- test_frame = frame.inner()
- else_frame = frame.inner()
-
- # try to figure out if we have an extended loop. An extended loop
- # is necessary if the loop is in recursive mode if the special loop
- # variable is accessed in the body.
- extended_loop = node.recursive or 'loop' in \
- find_undeclared(node.iter_child_nodes(
- only=('body',)), ('loop',))
-
- loop_ref = None
- if extended_loop:
- loop_ref = loop_frame.symbols.declare_parameter('loop')
-
- loop_frame.symbols.analyze_node(node, for_branch='body')
- if node.else_:
- else_frame.symbols.analyze_node(node, for_branch='else')
-
- if node.test:
- loop_filter_func = self.temporary_identifier()
- test_frame.symbols.analyze_node(node, for_branch='test')
- self.writeline('%s(fiter):' % self.func(loop_filter_func), node.test)
- self.indent()
- self.enter_frame(test_frame)
- self.writeline(self.environment.is_async and 'async for ' or 'for ')
- self.visit(node.target, loop_frame)
- self.write(' in ')
- self.write(self.environment.is_async and 'auto_aiter(fiter)' or 'fiter')
- self.write(':')
- self.indent()
- self.writeline('if ', node.test)
- self.visit(node.test, test_frame)
- self.write(':')
- self.indent()
- self.writeline('yield ')
- self.visit(node.target, loop_frame)
- self.outdent(3)
- self.leave_frame(test_frame, with_python_scope=True)
-
- # if we don't have an recursive loop we have to find the shadowed
- # variables at that point. Because loops can be nested but the loop
- # variable is a special one we have to enforce aliasing for it.
- if node.recursive:
- self.writeline('%s(reciter, loop_render_func, depth=0):' %
- self.func('loop'), node)
- self.indent()
- self.buffer(loop_frame)
-
- # Use the same buffer for the else frame
- else_frame.buffer = loop_frame.buffer
-
- # make sure the loop variable is a special one and raise a template
- # assertion error if a loop tries to write to loop
- if extended_loop:
- self.writeline('%s = missing' % loop_ref)
-
- for name in node.find_all(nodes.Name):
- if name.ctx == 'store' and name.name == 'loop':
- self.fail('Can\'t assign to special loop variable '
- 'in for-loop target', name.lineno)
-
- if node.else_:
- iteration_indicator = self.temporary_identifier()
- self.writeline('%s = 1' % iteration_indicator)
-
- self.writeline(self.environment.is_async and 'async for ' or 'for ', node)
- self.visit(node.target, loop_frame)
- if extended_loop:
- if self.environment.is_async:
- self.write(', %s in await make_async_loop_context(' % loop_ref)
- else:
- self.write(', %s in LoopContext(' % loop_ref)
- else:
- self.write(' in ')
-
- if node.test:
- self.write('%s(' % loop_filter_func)
- if node.recursive:
- self.write('reciter')
- else:
- if self.environment.is_async and not extended_loop:
- self.write('auto_aiter(')
- self.visit(node.iter, frame)
- if self.environment.is_async and not extended_loop:
- self.write(')')
- if node.test:
- self.write(')')
-
- if node.recursive:
- self.write(', undefined, loop_render_func, depth):')
- else:
- self.write(extended_loop and ', undefined):' or ':')
-
- self.indent()
- self.enter_frame(loop_frame)
-
- self.blockvisit(node.body, loop_frame)
- if node.else_:
- self.writeline('%s = 0' % iteration_indicator)
- self.outdent()
- self.leave_frame(loop_frame, with_python_scope=node.recursive
- and not node.else_)
-
- if node.else_:
- self.writeline('if %s:' % iteration_indicator)
- self.indent()
- self.enter_frame(else_frame)
- self.blockvisit(node.else_, else_frame)
- self.leave_frame(else_frame)
- self.outdent()
-
- # if the node was recursive we have to return the buffer contents
- # and start the iteration code
- if node.recursive:
- self.return_buffer_contents(loop_frame)
- self.outdent()
- self.start_write(frame, node)
- if self.environment.is_async:
- self.write('await ')
- self.write('loop(')
- if self.environment.is_async:
- self.write('auto_aiter(')
- self.visit(node.iter, frame)
- if self.environment.is_async:
- self.write(')')
- self.write(', loop)')
- self.end_write(frame)
-
- def visit_If(self, node, frame):
- if_frame = frame.soft()
- self.writeline('if ', node)
- self.visit(node.test, if_frame)
- self.write(':')
- self.indent()
- self.blockvisit(node.body, if_frame)
- self.outdent()
- for elif_ in node.elif_:
- self.writeline('elif ', elif_)
- self.visit(elif_.test, if_frame)
- self.write(':')
- self.indent()
- self.blockvisit(elif_.body, if_frame)
- self.outdent()
- if node.else_:
- self.writeline('else:')
- self.indent()
- self.blockvisit(node.else_, if_frame)
- self.outdent()
-
- def visit_Macro(self, node, frame):
- macro_frame, macro_ref = self.macro_body(node, frame)
- self.newline()
- if frame.toplevel:
- if not node.name.startswith('_'):
- self.write('context.exported_vars.add(%r)' % node.name)
- ref = frame.symbols.ref(node.name)
- self.writeline('context.vars[%r] = ' % node.name)
- self.write('%s = ' % frame.symbols.ref(node.name))
- self.macro_def(macro_ref, macro_frame)
-
- def visit_CallBlock(self, node, frame):
- call_frame, macro_ref = self.macro_body(node, frame)
- self.writeline('caller = ')
- self.macro_def(macro_ref, call_frame)
- self.start_write(frame, node)
- self.visit_Call(node.call, frame, forward_caller=True)
- self.end_write(frame)
-
- def visit_FilterBlock(self, node, frame):
- filter_frame = frame.inner()
- filter_frame.symbols.analyze_node(node)
- self.enter_frame(filter_frame)
- self.buffer(filter_frame)
- self.blockvisit(node.body, filter_frame)
- self.start_write(frame, node)
- self.visit_Filter(node.filter, filter_frame)
- self.end_write(frame)
- self.leave_frame(filter_frame)
-
- def visit_With(self, node, frame):
- with_frame = frame.inner()
- with_frame.symbols.analyze_node(node)
- self.enter_frame(with_frame)
- for idx, (target, expr) in enumerate(izip(node.targets, node.values)):
- self.newline()
- self.visit(target, with_frame)
- self.write(' = ')
- self.visit(expr, frame)
- self.blockvisit(node.body, with_frame)
- self.leave_frame(with_frame)
-
- def visit_ExprStmt(self, node, frame):
- self.newline(node)
- self.visit(node.node, frame)
-
- def visit_Output(self, node, frame):
- # if we have a known extends statement, we don't output anything
- # if we are in a require_output_check section
- if self.has_known_extends and frame.require_output_check:
- return
-
- allow_constant_finalize = True
- if self.environment.finalize:
- func = self.environment.finalize
- if getattr(func, 'contextfunction', False) or \
- getattr(func, 'evalcontextfunction', False):
- allow_constant_finalize = False
- elif getattr(func, 'environmentfunction', False):
- finalize = lambda x: text_type(
- self.environment.finalize(self.environment, x))
- else:
- finalize = lambda x: text_type(self.environment.finalize(x))
- else:
- finalize = text_type
-
- # if we are inside a frame that requires output checking, we do so
- outdent_later = False
- if frame.require_output_check:
- self.writeline('if parent_template is None:')
- self.indent()
- outdent_later = True
-
- # try to evaluate as many chunks as possible into a static
- # string at compile time.
- body = []
- for child in node.nodes:
- try:
- if not allow_constant_finalize:
- raise nodes.Impossible()
- const = child.as_const(frame.eval_ctx)
- except nodes.Impossible:
- body.append(child)
- continue
- # the frame can't be volatile here, becaus otherwise the
- # as_const() function would raise an Impossible exception
- # at that point.
- try:
- if frame.eval_ctx.autoescape:
- if hasattr(const, '__html__'):
- const = const.__html__()
- else:
- const = escape(const)
- const = finalize(const)
- except Exception:
- # if something goes wrong here we evaluate the node
- # at runtime for easier debugging
- body.append(child)
- continue
- if body and isinstance(body[-1], list):
- body[-1].append(const)
- else:
- body.append([const])
-
- # if we have less than 3 nodes or a buffer we yield or extend/append
- if len(body) < 3 or frame.buffer is not None:
- if frame.buffer is not None:
- # for one item we append, for more we extend
- if len(body) == 1:
- self.writeline('%s.append(' % frame.buffer)
- else:
- self.writeline('%s.extend((' % frame.buffer)
- self.indent()
- for item in body:
- if isinstance(item, list):
- val = repr(concat(item))
- if frame.buffer is None:
- self.writeline('yield ' + val)
- else:
- self.writeline(val + ',')
- else:
- if frame.buffer is None:
- self.writeline('yield ', item)
- else:
- self.newline(item)
- close = 1
- if frame.eval_ctx.volatile:
- self.write('(escape if context.eval_ctx.autoescape'
- ' else to_string)(')
- elif frame.eval_ctx.autoescape:
- self.write('escape(')
- else:
- self.write('to_string(')
- if self.environment.finalize is not None:
- self.write('environment.finalize(')
- if getattr(self.environment.finalize,
- "contextfunction", False):
- self.write('context, ')
- close += 1
- self.visit(item, frame)
- self.write(')' * close)
- if frame.buffer is not None:
- self.write(',')
- if frame.buffer is not None:
- # close the open parentheses
- self.outdent()
- self.writeline(len(body) == 1 and ')' or '))')
-
- # otherwise we create a format string as this is faster in that case
- else:
- format = []
- arguments = []
- for item in body:
- if isinstance(item, list):
- format.append(concat(item).replace('%', '%%'))
- else:
- format.append('%s')
- arguments.append(item)
- self.writeline('yield ')
- self.write(repr(concat(format)) + ' % (')
- self.indent()
- for argument in arguments:
- self.newline(argument)
- close = 0
- if frame.eval_ctx.volatile:
- self.write('(escape if context.eval_ctx.autoescape else'
- ' to_string)(')
- close += 1
- elif frame.eval_ctx.autoescape:
- self.write('escape(')
- close += 1
- if self.environment.finalize is not None:
- self.write('environment.finalize(')
- if getattr(self.environment.finalize,
- 'contextfunction', False):
- self.write('context, ')
- elif getattr(self.environment.finalize,
- 'evalcontextfunction', False):
- self.write('context.eval_ctx, ')
- elif getattr(self.environment.finalize,
- 'environmentfunction', False):
- self.write('environment, ')
- close += 1
- self.visit(argument, frame)
- self.write(')' * close + ', ')
- self.outdent()
- self.writeline(')')
-
- if outdent_later:
- self.outdent()
-
- def visit_Assign(self, node, frame):
- self.push_assign_tracking()
- self.newline(node)
- self.visit(node.target, frame)
- self.write(' = ')
- self.visit(node.node, frame)
- self.pop_assign_tracking(frame)
-
- def visit_AssignBlock(self, node, frame):
- self.push_assign_tracking()
- block_frame = frame.inner()
- # This is a special case. Since a set block always captures we
- # will disable output checks. This way one can use set blocks
- # toplevel even in extended templates.
- block_frame.require_output_check = False
- block_frame.symbols.analyze_node(node)
- self.enter_frame(block_frame)
- self.buffer(block_frame)
- self.blockvisit(node.body, block_frame)
- self.newline(node)
- self.visit(node.target, frame)
- self.write(' = (Markup if context.eval_ctx.autoescape '
- 'else identity)(')
- if node.filter is not None:
- self.visit_Filter(node.filter, block_frame)
- else:
- self.write('concat(%s)' % block_frame.buffer)
- self.write(')')
- self.pop_assign_tracking(frame)
- self.leave_frame(block_frame)
-
- # -- Expression Visitors
-
- def visit_Name(self, node, frame):
- if node.ctx == 'store' and frame.toplevel:
- if self._assign_stack:
- self._assign_stack[-1].add(node.name)
- ref = frame.symbols.ref(node.name)
-
- # If we are looking up a variable we might have to deal with the
- # case where it's undefined. We can skip that case if the load
- # instruction indicates a parameter which are always defined.
- if node.ctx == 'load':
- load = frame.symbols.find_load(ref)
- if not (load is not None and load[0] == VAR_LOAD_PARAMETER and \
- not self.parameter_is_undeclared(ref)):
- self.write('(undefined(name=%r) if %s is missing else %s)' %
- (node.name, ref, ref))
- return
-
- self.write(ref)
-
- def visit_NSRef(self, node, frame):
- # NSRefs can only be used to store values; since they use the normal
- # `foo.bar` notation they will be parsed as a normal attribute access
- # when used anywhere but in a `set` context
- ref = frame.symbols.ref(node.name)
- self.writeline('if not isinstance(%s, Namespace):' % ref)
- self.indent()
- self.writeline('raise TemplateRuntimeError(%r)' %
- 'cannot assign attribute on non-namespace object')
- self.outdent()
- self.writeline('%s[%r]' % (ref, node.attr))
-
- def visit_Const(self, node, frame):
- val = node.as_const(frame.eval_ctx)
- if isinstance(val, float):
- self.write(str(val))
- else:
- self.write(repr(val))
-
- def visit_TemplateData(self, node, frame):
- try:
- self.write(repr(node.as_const(frame.eval_ctx)))
- except nodes.Impossible:
- self.write('(Markup if context.eval_ctx.autoescape else identity)(%r)'
- % node.data)
-
- def visit_Tuple(self, node, frame):
- self.write('(')
- idx = -1
- for idx, item in enumerate(node.items):
- if idx:
- self.write(', ')
- self.visit(item, frame)
- self.write(idx == 0 and ',)' or ')')
-
- def visit_List(self, node, frame):
- self.write('[')
- for idx, item in enumerate(node.items):
- if idx:
- self.write(', ')
- self.visit(item, frame)
- self.write(']')
-
- def visit_Dict(self, node, frame):
- self.write('{')
- for idx, item in enumerate(node.items):
- if idx:
- self.write(', ')
- self.visit(item.key, frame)
- self.write(': ')
- self.visit(item.value, frame)
- self.write('}')
-
- def binop(operator, interceptable=True):
- @optimizeconst
- def visitor(self, node, frame):
- if self.environment.sandboxed and \
- operator in self.environment.intercepted_binops:
- self.write('environment.call_binop(context, %r, ' % operator)
- self.visit(node.left, frame)
- self.write(', ')
- self.visit(node.right, frame)
- else:
- self.write('(')
- self.visit(node.left, frame)
- self.write(' %s ' % operator)
- self.visit(node.right, frame)
- self.write(')')
- return visitor
-
- def uaop(operator, interceptable=True):
- @optimizeconst
- def visitor(self, node, frame):
- if self.environment.sandboxed and \
- operator in self.environment.intercepted_unops:
- self.write('environment.call_unop(context, %r, ' % operator)
- self.visit(node.node, frame)
- else:
- self.write('(' + operator)
- self.visit(node.node, frame)
- self.write(')')
- return visitor
-
- visit_Add = binop('+')
- visit_Sub = binop('-')
- visit_Mul = binop('*')
- visit_Div = binop('/')
- visit_FloorDiv = binop('//')
- visit_Pow = binop('**')
- visit_Mod = binop('%')
- visit_And = binop('and', interceptable=False)
- visit_Or = binop('or', interceptable=False)
- visit_Pos = uaop('+')
- visit_Neg = uaop('-')
- visit_Not = uaop('not ', interceptable=False)
- del binop, uaop
-
- @optimizeconst
- def visit_Concat(self, node, frame):
- if frame.eval_ctx.volatile:
- func_name = '(context.eval_ctx.volatile and' \
- ' markup_join or unicode_join)'
- elif frame.eval_ctx.autoescape:
- func_name = 'markup_join'
- else:
- func_name = 'unicode_join'
- self.write('%s((' % func_name)
- for arg in node.nodes:
- self.visit(arg, frame)
- self.write(', ')
- self.write('))')
-
- @optimizeconst
- def visit_Compare(self, node, frame):
- self.visit(node.expr, frame)
- for op in node.ops:
- self.visit(op, frame)
-
- def visit_Operand(self, node, frame):
- self.write(' %s ' % operators[node.op])
- self.visit(node.expr, frame)
-
- @optimizeconst
- def visit_Getattr(self, node, frame):
- self.write('environment.getattr(')
- self.visit(node.node, frame)
- self.write(', %r)' % node.attr)
-
- @optimizeconst
- def visit_Getitem(self, node, frame):
- # slices bypass the environment getitem method.
- if isinstance(node.arg, nodes.Slice):
- self.visit(node.node, frame)
- self.write('[')
- self.visit(node.arg, frame)
- self.write(']')
- else:
- self.write('environment.getitem(')
- self.visit(node.node, frame)
- self.write(', ')
- self.visit(node.arg, frame)
- self.write(')')
-
- def visit_Slice(self, node, frame):
- if node.start is not None:
- self.visit(node.start, frame)
- self.write(':')
- if node.stop is not None:
- self.visit(node.stop, frame)
- if node.step is not None:
- self.write(':')
- self.visit(node.step, frame)
-
- @optimizeconst
- def visit_Filter(self, node, frame):
- if self.environment.is_async:
- self.write('await auto_await(')
- self.write(self.filters[node.name] + '(')
- func = self.environment.filters.get(node.name)
- if func is None:
- self.fail('no filter named %r' % node.name, node.lineno)
- if getattr(func, 'contextfilter', False):
- self.write('context, ')
- elif getattr(func, 'evalcontextfilter', False):
- self.write('context.eval_ctx, ')
- elif getattr(func, 'environmentfilter', False):
- self.write('environment, ')
-
- # if the filter node is None we are inside a filter block
- # and want to write to the current buffer
- if node.node is not None:
- self.visit(node.node, frame)
- elif frame.eval_ctx.volatile:
- self.write('(context.eval_ctx.autoescape and'
- ' Markup(concat(%s)) or concat(%s))' %
- (frame.buffer, frame.buffer))
- elif frame.eval_ctx.autoescape:
- self.write('Markup(concat(%s))' % frame.buffer)
- else:
- self.write('concat(%s)' % frame.buffer)
- self.signature(node, frame)
- self.write(')')
- if self.environment.is_async:
- self.write(')')
-
- @optimizeconst
- def visit_Test(self, node, frame):
- self.write(self.tests[node.name] + '(')
- if node.name not in self.environment.tests:
- self.fail('no test named %r' % node.name, node.lineno)
- self.visit(node.node, frame)
- self.signature(node, frame)
- self.write(')')
-
- @optimizeconst
- def visit_CondExpr(self, node, frame):
- def write_expr2():
- if node.expr2 is not None:
- return self.visit(node.expr2, frame)
- self.write('undefined(%r)' % ('the inline if-'
- 'expression on %s evaluated to false and '
- 'no else section was defined.' % self.position(node)))
-
- self.write('(')
- self.visit(node.expr1, frame)
- self.write(' if ')
- self.visit(node.test, frame)
- self.write(' else ')
- write_expr2()
- self.write(')')
-
- @optimizeconst
- def visit_Call(self, node, frame, forward_caller=False):
- if self.environment.is_async:
- self.write('await auto_await(')
- if self.environment.sandboxed:
- self.write('environment.call(context, ')
- else:
- self.write('context.call(')
- self.visit(node.node, frame)
- extra_kwargs = forward_caller and {'caller': 'caller'} or None
- self.signature(node, frame, extra_kwargs)
- self.write(')')
- if self.environment.is_async:
- self.write(')')
-
- def visit_Keyword(self, node, frame):
- self.write(node.key + '=')
- self.visit(node.value, frame)
-
- # -- Unused nodes for extensions
-
- def visit_MarkSafe(self, node, frame):
- self.write('Markup(')
- self.visit(node.expr, frame)
- self.write(')')
-
- def visit_MarkSafeIfAutoescape(self, node, frame):
- self.write('(context.eval_ctx.autoescape and Markup or identity)(')
- self.visit(node.expr, frame)
- self.write(')')
-
- def visit_EnvironmentAttribute(self, node, frame):
- self.write('environment.' + node.name)
-
- def visit_ExtensionAttribute(self, node, frame):
- self.write('environment.extensions[%r].%s' % (node.identifier, node.name))
-
- def visit_ImportedName(self, node, frame):
- self.write(self.import_aliases[node.importname])
-
- def visit_InternalName(self, node, frame):
- self.write(node.name)
-
- def visit_ContextReference(self, node, frame):
- self.write('context')
-
- def visit_Continue(self, node, frame):
- self.writeline('continue', node)
-
- def visit_Break(self, node, frame):
- self.writeline('break', node)
-
- def visit_Scope(self, node, frame):
- scope_frame = frame.inner()
- scope_frame.symbols.analyze_node(node)
- self.enter_frame(scope_frame)
- self.blockvisit(node.body, scope_frame)
- self.leave_frame(scope_frame)
-
- def visit_OverlayScope(self, node, frame):
- ctx = self.temporary_identifier()
- self.writeline('%s = %s' % (ctx, self.derive_context(frame)))
- self.writeline('%s.vars = ' % ctx)
- self.visit(node.context, frame)
- self.push_context_reference(ctx)
-
- scope_frame = frame.inner(isolated=True)
- scope_frame.symbols.analyze_node(node)
- self.enter_frame(scope_frame)
- self.blockvisit(node.body, scope_frame)
- self.leave_frame(scope_frame)
- self.pop_context_reference()
-
- def visit_EvalContextModifier(self, node, frame):
- for keyword in node.options:
- self.writeline('context.eval_ctx.%s = ' % keyword.key)
- self.visit(keyword.value, frame)
- try:
- val = keyword.value.as_const(frame.eval_ctx)
- except nodes.Impossible:
- frame.eval_ctx.volatile = True
- else:
- setattr(frame.eval_ctx, keyword.key, val)
-
- def visit_ScopedEvalContextModifier(self, node, frame):
- old_ctx_name = self.temporary_identifier()
- saved_ctx = frame.eval_ctx.save()
- self.writeline('%s = context.eval_ctx.save()' % old_ctx_name)
- self.visit_EvalContextModifier(node, frame)
- for child in node.body:
- self.visit(child, frame)
- frame.eval_ctx.revert(saved_ctx)
- self.writeline('context.eval_ctx.revert(%s)' % old_ctx_name)
diff --git a/python/jinja2/constants.py b/python/jinja2/constants.py
deleted file mode 100644
index 11efd1e..0000000
--- a/python/jinja2/constants.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja.constants
- ~~~~~~~~~~~~~~~
-
- Various constants.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-
-
-#: list of lorem ipsum words used by the lipsum() helper function
-LOREM_IPSUM_WORDS = u'''\
-a ac accumsan ad adipiscing aenean aliquam aliquet amet ante aptent arcu at
-auctor augue bibendum blandit class commodo condimentum congue consectetuer
-consequat conubia convallis cras cubilia cum curabitur curae cursus dapibus
-diam dictum dictumst dignissim dis dolor donec dui duis egestas eget eleifend
-elementum elit enim erat eros est et etiam eu euismod facilisi facilisis fames
-faucibus felis fermentum feugiat fringilla fusce gravida habitant habitasse hac
-hendrerit hymenaeos iaculis id imperdiet in inceptos integer interdum ipsum
-justo lacinia lacus laoreet lectus leo libero ligula litora lobortis lorem
-luctus maecenas magna magnis malesuada massa mattis mauris metus mi molestie
-mollis montes morbi mus nam nascetur natoque nec neque netus nibh nisi nisl non
-nonummy nostra nulla nullam nunc odio orci ornare parturient pede pellentesque
-penatibus per pharetra phasellus placerat platea porta porttitor posuere
-potenti praesent pretium primis proin pulvinar purus quam quis quisque rhoncus
-ridiculus risus rutrum sagittis sapien scelerisque sed sem semper senectus sit
-sociis sociosqu sodales sollicitudin suscipit suspendisse taciti tellus tempor
-tempus tincidunt torquent tortor tristique turpis ullamcorper ultrices
-ultricies urna ut varius vehicula vel velit venenatis vestibulum vitae vivamus
-viverra volutpat vulputate'''
diff --git a/python/jinja2/debug.py b/python/jinja2/debug.py
deleted file mode 100644
index b61139f..0000000
--- a/python/jinja2/debug.py
+++ /dev/null
@@ -1,372 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.debug
- ~~~~~~~~~~~~
-
- Implements the debug interface for Jinja. This module does some pretty
- ugly stuff with the Python traceback system in order to achieve tracebacks
- with correct line numbers, locals and contents.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import sys
-import traceback
-from types import TracebackType, CodeType
-from jinja2.utils import missing, internal_code
-from jinja2.exceptions import TemplateSyntaxError
-from jinja2._compat import iteritems, reraise, PY2
-
-# on pypy we can take advantage of transparent proxies
-try:
- from __pypy__ import tproxy
-except ImportError:
- tproxy = None
-
-
-# how does the raise helper look like?
-try:
- exec("raise TypeError, 'foo'")
-except SyntaxError:
- raise_helper = 'raise __jinja_exception__[1]'
-except TypeError:
- raise_helper = 'raise __jinja_exception__[0], __jinja_exception__[1]'
-
-
-class TracebackFrameProxy(object):
- """Proxies a traceback frame."""
-
- def __init__(self, tb):
- self.tb = tb
- self._tb_next = None
-
- @property
- def tb_next(self):
- return self._tb_next
-
- def set_next(self, next):
- if tb_set_next is not None:
- try:
- tb_set_next(self.tb, next and next.tb or None)
- except Exception:
- # this function can fail due to all the hackery it does
- # on various python implementations. We just catch errors
- # down and ignore them if necessary.
- pass
- self._tb_next = next
-
- @property
- def is_jinja_frame(self):
- return '__jinja_template__' in self.tb.tb_frame.f_globals
-
- def __getattr__(self, name):
- return getattr(self.tb, name)
-
-
-def make_frame_proxy(frame):
- proxy = TracebackFrameProxy(frame)
- if tproxy is None:
- return proxy
- def operation_handler(operation, *args, **kwargs):
- if operation in ('__getattribute__', '__getattr__'):
- return getattr(proxy, args[0])
- elif operation == '__setattr__':
- proxy.__setattr__(*args, **kwargs)
- else:
- return getattr(proxy, operation)(*args, **kwargs)
- return tproxy(TracebackType, operation_handler)
-
-
-class ProcessedTraceback(object):
- """Holds a Jinja preprocessed traceback for printing or reraising."""
-
- def __init__(self, exc_type, exc_value, frames):
- assert frames, 'no frames for this traceback?'
- self.exc_type = exc_type
- self.exc_value = exc_value
- self.frames = frames
-
- # newly concatenate the frames (which are proxies)
- prev_tb = None
- for tb in self.frames:
- if prev_tb is not None:
- prev_tb.set_next(tb)
- prev_tb = tb
- prev_tb.set_next(None)
-
- def render_as_text(self, limit=None):
- """Return a string with the traceback."""
- lines = traceback.format_exception(self.exc_type, self.exc_value,
- self.frames[0], limit=limit)
- return ''.join(lines).rstrip()
-
- def render_as_html(self, full=False):
- """Return a unicode string with the traceback as rendered HTML."""
- from jinja2.debugrenderer import render_traceback
- return u'%s\n\n<!--\n%s\n-->' % (
- render_traceback(self, full=full),
- self.render_as_text().decode('utf-8', 'replace')
- )
-
- @property
- def is_template_syntax_error(self):
- """`True` if this is a template syntax error."""
- return isinstance(self.exc_value, TemplateSyntaxError)
-
- @property
- def exc_info(self):
- """Exception info tuple with a proxy around the frame objects."""
- return self.exc_type, self.exc_value, self.frames[0]
-
- @property
- def standard_exc_info(self):
- """Standard python exc_info for re-raising"""
- tb = self.frames[0]
- # the frame will be an actual traceback (or transparent proxy) if
- # we are on pypy or a python implementation with support for tproxy
- if type(tb) is not TracebackType:
- tb = tb.tb
- return self.exc_type, self.exc_value, tb
-
-
-def make_traceback(exc_info, source_hint=None):
- """Creates a processed traceback object from the exc_info."""
- exc_type, exc_value, tb = exc_info
- if isinstance(exc_value, TemplateSyntaxError):
- exc_info = translate_syntax_error(exc_value, source_hint)
- initial_skip = 0
- else:
- initial_skip = 1
- return translate_exception(exc_info, initial_skip)
-
-
-def translate_syntax_error(error, source=None):
- """Rewrites a syntax error to please traceback systems."""
- error.source = source
- error.translated = True
- exc_info = (error.__class__, error, None)
- filename = error.filename
- if filename is None:
- filename = '<unknown>'
- return fake_exc_info(exc_info, filename, error.lineno)
-
-
-def translate_exception(exc_info, initial_skip=0):
- """If passed an exc_info it will automatically rewrite the exceptions
- all the way down to the correct line numbers and frames.
- """
- tb = exc_info[2]
- frames = []
-
- # skip some internal frames if wanted
- for x in range(initial_skip):
- if tb is not None:
- tb = tb.tb_next
- initial_tb = tb
-
- while tb is not None:
- # skip frames decorated with @internalcode. These are internal
- # calls we can't avoid and that are useless in template debugging
- # output.
- if tb.tb_frame.f_code in internal_code:
- tb = tb.tb_next
- continue
-
- # save a reference to the next frame if we override the current
- # one with a faked one.
- next = tb.tb_next
-
- # fake template exceptions
- template = tb.tb_frame.f_globals.get('__jinja_template__')
- if template is not None:
- lineno = template.get_corresponding_lineno(tb.tb_lineno)
- tb = fake_exc_info(exc_info[:2] + (tb,), template.filename,
- lineno)[2]
-
- frames.append(make_frame_proxy(tb))
- tb = next
-
- # if we don't have any exceptions in the frames left, we have to
- # reraise it unchanged.
- # XXX: can we backup here? when could this happen?
- if not frames:
- reraise(exc_info[0], exc_info[1], exc_info[2])
-
- return ProcessedTraceback(exc_info[0], exc_info[1], frames)
-
-
-def get_jinja_locals(real_locals):
- ctx = real_locals.get('context')
- if ctx:
- locals = ctx.get_all().copy()
- else:
- locals = {}
-
- local_overrides = {}
-
- for name, value in iteritems(real_locals):
- if not name.startswith('l_') or value is missing:
- continue
- try:
- _, depth, name = name.split('_', 2)
- depth = int(depth)
- except ValueError:
- continue
- cur_depth = local_overrides.get(name, (-1,))[0]
- if cur_depth < depth:
- local_overrides[name] = (depth, value)
-
- for name, (_, value) in iteritems(local_overrides):
- if value is missing:
- locals.pop(name, None)
- else:
- locals[name] = value
-
- return locals
-
-
-def fake_exc_info(exc_info, filename, lineno):
- """Helper for `translate_exception`."""
- exc_type, exc_value, tb = exc_info
-
- # figure the real context out
- if tb is not None:
- locals = get_jinja_locals(tb.tb_frame.f_locals)
-
- # if there is a local called __jinja_exception__, we get
- # rid of it to not break the debug functionality.
- locals.pop('__jinja_exception__', None)
- else:
- locals = {}
-
- # assamble fake globals we need
- globals = {
- '__name__': filename,
- '__file__': filename,
- '__jinja_exception__': exc_info[:2],
-
- # we don't want to keep the reference to the template around
- # to not cause circular dependencies, but we mark it as Jinja
- # frame for the ProcessedTraceback
- '__jinja_template__': None
- }
-
- # and fake the exception
- code = compile('\n' * (lineno - 1) + raise_helper, filename, 'exec')
-
- # if it's possible, change the name of the code. This won't work
- # on some python environments such as google appengine
- try:
- if tb is None:
- location = 'template'
- else:
- function = tb.tb_frame.f_code.co_name
- if function == 'root':
- location = 'top-level template code'
- elif function.startswith('block_'):
- location = 'block "%s"' % function[6:]
- else:
- location = 'template'
-
- if PY2:
- code = CodeType(0, code.co_nlocals, code.co_stacksize,
- code.co_flags, code.co_code, code.co_consts,
- code.co_names, code.co_varnames, filename,
- location, code.co_firstlineno,
- code.co_lnotab, (), ())
- else:
- code = CodeType(0, code.co_kwonlyargcount,
- code.co_nlocals, code.co_stacksize,
- code.co_flags, code.co_code, code.co_consts,
- code.co_names, code.co_varnames, filename,
- location, code.co_firstlineno,
- code.co_lnotab, (), ())
- except Exception as e:
- pass
-
- # execute the code and catch the new traceback
- try:
- exec(code, globals, locals)
- except:
- exc_info = sys.exc_info()
- new_tb = exc_info[2].tb_next
-
- # return without this frame
- return exc_info[:2] + (new_tb,)
-
-
-def _init_ugly_crap():
- """This function implements a few ugly things so that we can patch the
- traceback objects. The function returned allows resetting `tb_next` on
- any python traceback object. Do not attempt to use this on non cpython
- interpreters
- """
- import ctypes
- from types import TracebackType
-
- if PY2:
- # figure out size of _Py_ssize_t for Python 2:
- if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
- _Py_ssize_t = ctypes.c_int64
- else:
- _Py_ssize_t = ctypes.c_int
- else:
- # platform ssize_t on Python 3
- _Py_ssize_t = ctypes.c_ssize_t
-
- # regular python
- class _PyObject(ctypes.Structure):
- pass
- _PyObject._fields_ = [
- ('ob_refcnt', _Py_ssize_t),
- ('ob_type', ctypes.POINTER(_PyObject))
- ]
-
- # python with trace
- if hasattr(sys, 'getobjects'):
- class _PyObject(ctypes.Structure):
- pass
- _PyObject._fields_ = [
- ('_ob_next', ctypes.POINTER(_PyObject)),
- ('_ob_prev', ctypes.POINTER(_PyObject)),
- ('ob_refcnt', _Py_ssize_t),
- ('ob_type', ctypes.POINTER(_PyObject))
- ]
-
- class _Traceback(_PyObject):
- pass
- _Traceback._fields_ = [
- ('tb_next', ctypes.POINTER(_Traceback)),
- ('tb_frame', ctypes.POINTER(_PyObject)),
- ('tb_lasti', ctypes.c_int),
- ('tb_lineno', ctypes.c_int)
- ]
-
- def tb_set_next(tb, next):
- """Set the tb_next attribute of a traceback object."""
- if not (isinstance(tb, TracebackType) and
- (next is None or isinstance(next, TracebackType))):
- raise TypeError('tb_set_next arguments must be traceback objects')
- obj = _Traceback.from_address(id(tb))
- if tb.tb_next is not None:
- old = _Traceback.from_address(id(tb.tb_next))
- old.ob_refcnt -= 1
- if next is None:
- obj.tb_next = ctypes.POINTER(_Traceback)()
- else:
- next = _Traceback.from_address(id(next))
- next.ob_refcnt += 1
- obj.tb_next = ctypes.pointer(next)
-
- return tb_set_next
-
-
-# try to get a tb_set_next implementation if we don't have transparent
-# proxies.
-tb_set_next = None
-if tproxy is None:
- try:
- tb_set_next = _init_ugly_crap()
- except:
- pass
- del _init_ugly_crap
diff --git a/python/jinja2/defaults.py b/python/jinja2/defaults.py
deleted file mode 100644
index 7c93dec..0000000
--- a/python/jinja2/defaults.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.defaults
- ~~~~~~~~~~~~~~~
-
- Jinja default filters and tags.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-from jinja2._compat import range_type
-from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner, Namespace
-
-
-# defaults for the parser / lexer
-BLOCK_START_STRING = '{%'
-BLOCK_END_STRING = '%}'
-VARIABLE_START_STRING = '{{'
-VARIABLE_END_STRING = '}}'
-COMMENT_START_STRING = '{#'
-COMMENT_END_STRING = '#}'
-LINE_STATEMENT_PREFIX = None
-LINE_COMMENT_PREFIX = None
-TRIM_BLOCKS = False
-LSTRIP_BLOCKS = False
-NEWLINE_SEQUENCE = '\n'
-KEEP_TRAILING_NEWLINE = False
-
-
-# default filters, tests and namespace
-from jinja2.filters import FILTERS as DEFAULT_FILTERS
-from jinja2.tests import TESTS as DEFAULT_TESTS
-DEFAULT_NAMESPACE = {
- 'range': range_type,
- 'dict': dict,
- 'lipsum': generate_lorem_ipsum,
- 'cycler': Cycler,
- 'joiner': Joiner,
- 'namespace': Namespace
-}
-
-
-# default policies
-DEFAULT_POLICIES = {
- 'compiler.ascii_str': True,
- 'urlize.rel': 'noopener',
- 'urlize.target': None,
- 'truncate.leeway': 5,
- 'json.dumps_function': None,
- 'json.dumps_kwargs': {'sort_keys': True},
- 'ext.i18n.trimmed': False,
-}
-
-
-# export all constants
-__all__ = tuple(x for x in locals().keys() if x.isupper())
diff --git a/python/jinja2/environment.py b/python/jinja2/environment.py
deleted file mode 100644
index 549d9af..0000000
--- a/python/jinja2/environment.py
+++ /dev/null
@@ -1,1276 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.environment
- ~~~~~~~~~~~~~~~~~~
-
- Provides a class that holds runtime and parsing time options.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import os
-import sys
-import weakref
-from functools import reduce, partial
-from jinja2 import nodes
-from jinja2.defaults import BLOCK_START_STRING, \
- BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \
- COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \
- LINE_COMMENT_PREFIX, TRIM_BLOCKS, NEWLINE_SEQUENCE, \
- DEFAULT_FILTERS, DEFAULT_TESTS, DEFAULT_NAMESPACE, \
- DEFAULT_POLICIES, KEEP_TRAILING_NEWLINE, LSTRIP_BLOCKS
-from jinja2.lexer import get_lexer, TokenStream
-from jinja2.parser import Parser
-from jinja2.nodes import EvalContext
-from jinja2.compiler import generate, CodeGenerator
-from jinja2.runtime import Undefined, new_context, Context
-from jinja2.exceptions import TemplateSyntaxError, TemplateNotFound, \
- TemplatesNotFound, TemplateRuntimeError
-from jinja2.utils import import_string, LRUCache, Markup, missing, \
- concat, consume, internalcode, have_async_gen
-from jinja2._compat import imap, ifilter, string_types, iteritems, \
- text_type, reraise, implements_iterator, implements_to_string, \
- encode_filename, PY2, PYPY
-
-
-# for direct template usage we have up to ten living environments
-_spontaneous_environments = LRUCache(10)
-
-# the function to create jinja traceback objects. This is dynamically
-# imported on the first exception in the exception handler.
-_make_traceback = None
-
-
-def get_spontaneous_environment(*args):
- """Return a new spontaneous environment. A spontaneous environment is an
- unnamed and unaccessible (in theory) environment that is used for
- templates generated from a string and not from the file system.
- """
- try:
- env = _spontaneous_environments.get(args)
- except TypeError:
- return Environment(*args)
- if env is not None:
- return env
- _spontaneous_environments[args] = env = Environment(*args)
- env.shared = True
- return env
-
-
-def create_cache(size):
- """Return the cache class for the given size."""
- if size == 0:
- return None
- if size < 0:
- return {}
- return LRUCache(size)
-
-
-def copy_cache(cache):
- """Create an empty copy of the given cache."""
- if cache is None:
- return None
- elif type(cache) is dict:
- return {}
- return LRUCache(cache.capacity)
-
-
-def load_extensions(environment, extensions):
- """Load the extensions from the list and bind it to the environment.
- Returns a dict of instantiated environments.
- """
- result = {}
- for extension in extensions:
- if isinstance(extension, string_types):
- extension = import_string(extension)
- result[extension.identifier] = extension(environment)
- return result
-
-
-def fail_for_missing_callable(string, name):
- msg = string % name
- if isinstance(name, Undefined):
- try:
- name._fail_with_undefined_error()
- except Exception as e:
- msg = '%s (%s; did you forget to quote the callable name?)' % (msg, e)
- raise TemplateRuntimeError(msg)
-
-
-def _environment_sanity_check(environment):
- """Perform a sanity check on the environment."""
- assert issubclass(environment.undefined, Undefined), 'undefined must ' \
- 'be a subclass of undefined because filters depend on it.'
- assert environment.block_start_string != \
- environment.variable_start_string != \
- environment.comment_start_string, 'block, variable and comment ' \
- 'start strings must be different'
- assert environment.newline_sequence in ('\r', '\r\n', '\n'), \
- 'newline_sequence set to unknown line ending string.'
- return environment
-
-
-class Environment(object):
- r"""The core component of Jinja is the `Environment`. It contains
- important shared variables like configuration, filters, tests,
- globals and others. Instances of this class may be modified if
- they are not shared and if no template was loaded so far.
- Modifications on environments after the first template was loaded
- will lead to surprising effects and undefined behavior.
-
- Here are the possible initialization parameters:
-
- `block_start_string`
- The string marking the beginning of a block. Defaults to ``'{%'``.
-
- `block_end_string`
- The string marking the end of a block. Defaults to ``'%}'``.
-
- `variable_start_string`
- The string marking the beginning of a print statement.
- Defaults to ``'{{'``.
-
- `variable_end_string`
- The string marking the end of a print statement. Defaults to
- ``'}}'``.
-
- `comment_start_string`
- The string marking the beginning of a comment. Defaults to ``'{#'``.
-
- `comment_end_string`
- The string marking the end of a comment. Defaults to ``'#}'``.
-
- `line_statement_prefix`
- If given and a string, this will be used as prefix for line based
- statements. See also :ref:`line-statements`.
-
- `line_comment_prefix`
- If given and a string, this will be used as prefix for line based
- comments. See also :ref:`line-statements`.
-
- .. versionadded:: 2.2
-
- `trim_blocks`
- If this is set to ``True`` the first newline after a block is
- removed (block, not variable tag!). Defaults to `False`.
-
- `lstrip_blocks`
- If this is set to ``True`` leading spaces and tabs are stripped
- from the start of a line to a block. Defaults to `False`.
-
- `newline_sequence`
- The sequence that starts a newline. Must be one of ``'\r'``,
- ``'\n'`` or ``'\r\n'``. The default is ``'\n'`` which is a
- useful default for Linux and OS X systems as well as web
- applications.
-
- `keep_trailing_newline`
- Preserve the trailing newline when rendering templates.
- The default is ``False``, which causes a single newline,
- if present, to be stripped from the end of the template.
-
- .. versionadded:: 2.7
-
- `extensions`
- List of Jinja extensions to use. This can either be import paths
- as strings or extension classes. For more information have a
- look at :ref:`the extensions documentation <jinja-extensions>`.
-
- `optimized`
- should the optimizer be enabled? Default is ``True``.
-
- `undefined`
- :class:`Undefined` or a subclass of it that is used to represent
- undefined values in the template.
-
- `finalize`
- A callable that can be used to process the result of a variable
- expression before it is output. For example one can convert
- ``None`` implicitly into an empty string here.
-
- `autoescape`
- If set to ``True`` the XML/HTML autoescaping feature is enabled by
- default. For more details about autoescaping see
- :class:`~jinja2.utils.Markup`. As of Jinja 2.4 this can also
- be a callable that is passed the template name and has to
- return ``True`` or ``False`` depending on autoescape should be
- enabled by default.
-
- .. versionchanged:: 2.4
- `autoescape` can now be a function
-
- `loader`
- The template loader for this environment.
-
- `cache_size`
- The size of the cache. Per default this is ``400`` which means
- that if more than 400 templates are loaded the loader will clean
- out the least recently used template. If the cache size is set to
- ``0`` templates are recompiled all the time, if the cache size is
- ``-1`` the cache will not be cleaned.
-
- .. versionchanged:: 2.8
- The cache size was increased to 400 from a low 50.
-
- `auto_reload`
- Some loaders load templates from locations where the template
- sources may change (ie: file system or database). If
- ``auto_reload`` is set to ``True`` (default) every time a template is
- requested the loader checks if the source changed and if yes, it
- will reload the template. For higher performance it's possible to
- disable that.
-
- `bytecode_cache`
- If set to a bytecode cache object, this object will provide a
- cache for the internal Jinja bytecode so that templates don't
- have to be parsed if they were not changed.
-
- See :ref:`bytecode-cache` for more information.
-
- `enable_async`
- If set to true this enables async template execution which allows
- you to take advantage of newer Python features. This requires
- Python 3.6 or later.
- """
-
- #: if this environment is sandboxed. Modifying this variable won't make
- #: the environment sandboxed though. For a real sandboxed environment
- #: have a look at jinja2.sandbox. This flag alone controls the code
- #: generation by the compiler.
- sandboxed = False
-
- #: True if the environment is just an overlay
- overlayed = False
-
- #: the environment this environment is linked to if it is an overlay
- linked_to = None
-
- #: shared environments have this set to `True`. A shared environment
- #: must not be modified
- shared = False
-
- #: these are currently EXPERIMENTAL undocumented features.
- exception_handler = None
- exception_formatter = None
-
- #: the class that is used for code generation. See
- #: :class:`~jinja2.compiler.CodeGenerator` for more information.
- code_generator_class = CodeGenerator
-
- #: the context class thatis used for templates. See
- #: :class:`~jinja2.runtime.Context` for more information.
- context_class = Context
-
- def __init__(self,
- block_start_string=BLOCK_START_STRING,
- block_end_string=BLOCK_END_STRING,
- variable_start_string=VARIABLE_START_STRING,
- variable_end_string=VARIABLE_END_STRING,
- comment_start_string=COMMENT_START_STRING,
- comment_end_string=COMMENT_END_STRING,
- line_statement_prefix=LINE_STATEMENT_PREFIX,
- line_comment_prefix=LINE_COMMENT_PREFIX,
- trim_blocks=TRIM_BLOCKS,
- lstrip_blocks=LSTRIP_BLOCKS,
- newline_sequence=NEWLINE_SEQUENCE,
- keep_trailing_newline=KEEP_TRAILING_NEWLINE,
- extensions=(),
- optimized=True,
- undefined=Undefined,
- finalize=None,
- autoescape=False,
- loader=None,
- cache_size=400,
- auto_reload=True,
- bytecode_cache=None,
- enable_async=False):
- # !!Important notice!!
- # The constructor accepts quite a few arguments that should be
- # passed by keyword rather than position. However it's important to
- # not change the order of arguments because it's used at least
- # internally in those cases:
- # - spontaneous environments (i18n extension and Template)
- # - unittests
- # If parameter changes are required only add parameters at the end
- # and don't change the arguments (or the defaults!) of the arguments
- # existing already.
-
- # lexer / parser information
- self.block_start_string = block_start_string
- self.block_end_string = block_end_string
- self.variable_start_string = variable_start_string
- self.variable_end_string = variable_end_string
- self.comment_start_string = comment_start_string
- self.comment_end_string = comment_end_string
- self.line_statement_prefix = line_statement_prefix
- self.line_comment_prefix = line_comment_prefix
- self.trim_blocks = trim_blocks
- self.lstrip_blocks = lstrip_blocks
- self.newline_sequence = newline_sequence
- self.keep_trailing_newline = keep_trailing_newline
-
- # runtime information
- self.undefined = undefined
- self.optimized = optimized
- self.finalize = finalize
- self.autoescape = autoescape
-
- # defaults
- self.filters = DEFAULT_FILTERS.copy()
- self.tests = DEFAULT_TESTS.copy()
- self.globals = DEFAULT_NAMESPACE.copy()
-
- # set the loader provided
- self.loader = loader
- self.cache = create_cache(cache_size)
- self.bytecode_cache = bytecode_cache
- self.auto_reload = auto_reload
-
- # configurable policies
- self.policies = DEFAULT_POLICIES.copy()
-
- # load extensions
- self.extensions = load_extensions(self, extensions)
-
- self.enable_async = enable_async
- self.is_async = self.enable_async and have_async_gen
-
- _environment_sanity_check(self)
-
- def add_extension(self, extension):
- """Adds an extension after the environment was created.
-
- .. versionadded:: 2.5
- """
- self.extensions.update(load_extensions(self, [extension]))
-
- def extend(self, **attributes):
- """Add the items to the instance of the environment if they do not exist
- yet. This is used by :ref:`extensions <writing-extensions>` to register
- callbacks and configuration values without breaking inheritance.
- """
- for key, value in iteritems(attributes):
- if not hasattr(self, key):
- setattr(self, key, value)
-
- def overlay(self, block_start_string=missing, block_end_string=missing,
- variable_start_string=missing, variable_end_string=missing,
- comment_start_string=missing, comment_end_string=missing,
- line_statement_prefix=missing, line_comment_prefix=missing,
- trim_blocks=missing, lstrip_blocks=missing,
- extensions=missing, optimized=missing,
- undefined=missing, finalize=missing, autoescape=missing,
- loader=missing, cache_size=missing, auto_reload=missing,
- bytecode_cache=missing):
- """Create a new overlay environment that shares all the data with the
- current environment except for cache and the overridden attributes.
- Extensions cannot be removed for an overlayed environment. An overlayed
- environment automatically gets all the extensions of the environment it
- is linked to plus optional extra extensions.
-
- Creating overlays should happen after the initial environment was set
- up completely. Not all attributes are truly linked, some are just
- copied over so modifications on the original environment may not shine
- through.
- """
- args = dict(locals())
- del args['self'], args['cache_size'], args['extensions']
-
- rv = object.__new__(self.__class__)
- rv.__dict__.update(self.__dict__)
- rv.overlayed = True
- rv.linked_to = self
-
- for key, value in iteritems(args):
- if value is not missing:
- setattr(rv, key, value)
-
- if cache_size is not missing:
- rv.cache = create_cache(cache_size)
- else:
- rv.cache = copy_cache(self.cache)
-
- rv.extensions = {}
- for key, value in iteritems(self.extensions):
- rv.extensions[key] = value.bind(rv)
- if extensions is not missing:
- rv.extensions.update(load_extensions(rv, extensions))
-
- return _environment_sanity_check(rv)
-
- lexer = property(get_lexer, doc="The lexer for this environment.")
-
- def iter_extensions(self):
- """Iterates over the extensions by priority."""
- return iter(sorted(self.extensions.values(),
- key=lambda x: x.priority))
-
- def getitem(self, obj, argument):
- """Get an item or attribute of an object but prefer the item."""
- try:
- return obj[argument]
- except (AttributeError, TypeError, LookupError):
- if isinstance(argument, string_types):
- try:
- attr = str(argument)
- except Exception:
- pass
- else:
- try:
- return getattr(obj, attr)
- except AttributeError:
- pass
- return self.undefined(obj=obj, name=argument)
-
- def getattr(self, obj, attribute):
- """Get an item or attribute of an object but prefer the attribute.
- Unlike :meth:`getitem` the attribute *must* be a bytestring.
- """
- try:
- return getattr(obj, attribute)
- except AttributeError:
- pass
- try:
- return obj[attribute]
- except (TypeError, LookupError, AttributeError):
- return self.undefined(obj=obj, name=attribute)
-
- def call_filter(self, name, value, args=None, kwargs=None,
- context=None, eval_ctx=None):
- """Invokes a filter on a value the same way the compiler does it.
-
- Note that on Python 3 this might return a coroutine in case the
- filter is running from an environment in async mode and the filter
- supports async execution. It's your responsibility to await this
- if needed.
-
- .. versionadded:: 2.7
- """
- func = self.filters.get(name)
- if func is None:
- fail_for_missing_callable('no filter named %r', name)
- args = [value] + list(args or ())
- if getattr(func, 'contextfilter', False):
- if context is None:
- raise TemplateRuntimeError('Attempted to invoke context '
- 'filter without context')
- args.insert(0, context)
- elif getattr(func, 'evalcontextfilter', False):
- if eval_ctx is None:
- if context is not None:
- eval_ctx = context.eval_ctx
- else:
- eval_ctx = EvalContext(self)
- args.insert(0, eval_ctx)
- elif getattr(func, 'environmentfilter', False):
- args.insert(0, self)
- return func(*args, **(kwargs or {}))
-
- def call_test(self, name, value, args=None, kwargs=None):
- """Invokes a test on a value the same way the compiler does it.
-
- .. versionadded:: 2.7
- """
- func = self.tests.get(name)
- if func is None:
- fail_for_missing_callable('no test named %r', name)
- return func(value, *(args or ()), **(kwargs or {}))
-
- @internalcode
- def parse(self, source, name=None, filename=None):
- """Parse the sourcecode and return the abstract syntax tree. This
- tree of nodes is used by the compiler to convert the template into
- executable source- or bytecode. This is useful for debugging or to
- extract information from templates.
-
- If you are :ref:`developing Jinja2 extensions <writing-extensions>`
- this gives you a good overview of the node tree generated.
- """
- try:
- return self._parse(source, name, filename)
- except TemplateSyntaxError:
- exc_info = sys.exc_info()
- self.handle_exception(exc_info, source_hint=source)
-
- def _parse(self, source, name, filename):
- """Internal parsing function used by `parse` and `compile`."""
- return Parser(self, source, name, encode_filename(filename)).parse()
-
- def lex(self, source, name=None, filename=None):
- """Lex the given sourcecode and return a generator that yields
- tokens as tuples in the form ``(lineno, token_type, value)``.
- This can be useful for :ref:`extension development <writing-extensions>`
- and debugging templates.
-
- This does not perform preprocessing. If you want the preprocessing
- of the extensions to be applied you have to filter source through
- the :meth:`preprocess` method.
- """
- source = text_type(source)
- try:
- return self.lexer.tokeniter(source, name, filename)
- except TemplateSyntaxError:
- exc_info = sys.exc_info()
- self.handle_exception(exc_info, source_hint=source)
-
- def preprocess(self, source, name=None, filename=None):
- """Preprocesses the source with all extensions. This is automatically
- called for all parsing and compiling methods but *not* for :meth:`lex`
- because there you usually only want the actual source tokenized.
- """
- return reduce(lambda s, e: e.preprocess(s, name, filename),
- self.iter_extensions(), text_type(source))
-
- def _tokenize(self, source, name, filename=None, state=None):
- """Called by the parser to do the preprocessing and filtering
- for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`.
- """
- source = self.preprocess(source, name, filename)
- stream = self.lexer.tokenize(source, name, filename, state)
- for ext in self.iter_extensions():
- stream = ext.filter_stream(stream)
- if not isinstance(stream, TokenStream):
- stream = TokenStream(stream, name, filename)
- return stream
-
- def _generate(self, source, name, filename, defer_init=False):
- """Internal hook that can be overridden to hook a different generate
- method in.
-
- .. versionadded:: 2.5
- """
- return generate(source, self, name, filename, defer_init=defer_init,
- optimized=self.optimized)
-
- def _compile(self, source, filename):
- """Internal hook that can be overridden to hook a different compile
- method in.
-
- .. versionadded:: 2.5
- """
- return compile(source, filename, 'exec')
-
- @internalcode
- def compile(self, source, name=None, filename=None, raw=False,
- defer_init=False):
- """Compile a node or template source code. The `name` parameter is
- the load name of the template after it was joined using
- :meth:`join_path` if necessary, not the filename on the file system.
- the `filename` parameter is the estimated filename of the template on
- the file system. If the template came from a database or memory this
- can be omitted.
-
- The return value of this method is a python code object. If the `raw`
- parameter is `True` the return value will be a string with python
- code equivalent to the bytecode returned otherwise. This method is
- mainly used internally.
-
- `defer_init` is use internally to aid the module code generator. This
- causes the generated code to be able to import without the global
- environment variable to be set.
-
- .. versionadded:: 2.4
- `defer_init` parameter added.
- """
- source_hint = None
- try:
- if isinstance(source, string_types):
- source_hint = source
- source = self._parse(source, name, filename)
- source = self._generate(source, name, filename,
- defer_init=defer_init)
- if raw:
- return source
- if filename is None:
- filename = '<template>'
- else:
- filename = encode_filename(filename)
- return self._compile(source, filename)
- except TemplateSyntaxError:
- exc_info = sys.exc_info()
- self.handle_exception(exc_info, source_hint=source_hint)
-
- def compile_expression(self, source, undefined_to_none=True):
- """A handy helper method that returns a callable that accepts keyword
- arguments that appear as variables in the expression. If called it
- returns the result of the expression.
-
- This is useful if applications want to use the same rules as Jinja
- in template "configuration files" or similar situations.
-
- Example usage:
-
- >>> env = Environment()
- >>> expr = env.compile_expression('foo == 42')
- >>> expr(foo=23)
- False
- >>> expr(foo=42)
- True
-
- Per default the return value is converted to `None` if the
- expression returns an undefined value. This can be changed
- by setting `undefined_to_none` to `False`.
-
- >>> env.compile_expression('var')() is None
- True
- >>> env.compile_expression('var', undefined_to_none=False)()
- Undefined
-
- .. versionadded:: 2.1
- """
- parser = Parser(self, source, state='variable')
- exc_info = None
- try:
- expr = parser.parse_expression()
- if not parser.stream.eos:
- raise TemplateSyntaxError('chunk after expression',
- parser.stream.current.lineno,
- None, None)
- expr.set_environment(self)
- except TemplateSyntaxError:
- exc_info = sys.exc_info()
- if exc_info is not None:
- self.handle_exception(exc_info, source_hint=source)
- body = [nodes.Assign(nodes.Name('result', 'store'), expr, lineno=1)]
- template = self.from_string(nodes.Template(body, lineno=1))
- return TemplateExpression(template, undefined_to_none)
-
- def compile_templates(self, target, extensions=None, filter_func=None,
- zip='deflated', log_function=None,
- ignore_errors=True, py_compile=False):
- """Finds all the templates the loader can find, compiles them
- and stores them in `target`. If `zip` is `None`, instead of in a
- zipfile, the templates will be stored in a directory.
- By default a deflate zip algorithm is used. To switch to
- the stored algorithm, `zip` can be set to ``'stored'``.
-
- `extensions` and `filter_func` are passed to :meth:`list_templates`.
- Each template returned will be compiled to the target folder or
- zipfile.
-
- By default template compilation errors are ignored. In case a
- log function is provided, errors are logged. If you want template
- syntax errors to abort the compilation you can set `ignore_errors`
- to `False` and you will get an exception on syntax errors.
-
- If `py_compile` is set to `True` .pyc files will be written to the
- target instead of standard .py files. This flag does not do anything
- on pypy and Python 3 where pyc files are not picked up by itself and
- don't give much benefit.
-
- .. versionadded:: 2.4
- """
- from jinja2.loaders import ModuleLoader
-
- if log_function is None:
- log_function = lambda x: None
-
- if py_compile:
- if not PY2 or PYPY:
- from warnings import warn
- warn(Warning('py_compile has no effect on pypy or Python 3'))
- py_compile = False
- else:
- import imp
- import marshal
- py_header = imp.get_magic() + \
- u'\xff\xff\xff\xff'.encode('iso-8859-15')
-
- # Python 3.3 added a source filesize to the header
- if sys.version_info >= (3, 3):
- py_header += u'\x00\x00\x00\x00'.encode('iso-8859-15')
-
- def write_file(filename, data, mode):
- if zip:
- info = ZipInfo(filename)
- info.external_attr = 0o755 << 16
- zip_file.writestr(info, data)
- else:
- f = open(os.path.join(target, filename), mode)
- try:
- f.write(data)
- finally:
- f.close()
-
- if zip is not None:
- from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED, ZIP_STORED
- zip_file = ZipFile(target, 'w', dict(deflated=ZIP_DEFLATED,
- stored=ZIP_STORED)[zip])
- log_function('Compiling into Zip archive "%s"' % target)
- else:
- if not os.path.isdir(target):
- os.makedirs(target)
- log_function('Compiling into folder "%s"' % target)
-
- try:
- for name in self.list_templates(extensions, filter_func):
- source, filename, _ = self.loader.get_source(self, name)
- try:
- code = self.compile(source, name, filename, True, True)
- except TemplateSyntaxError as e:
- if not ignore_errors:
- raise
- log_function('Could not compile "%s": %s' % (name, e))
- continue
-
- filename = ModuleLoader.get_module_filename(name)
-
- if py_compile:
- c = self._compile(code, encode_filename(filename))
- write_file(filename + 'c', py_header +
- marshal.dumps(c), 'wb')
- log_function('Byte-compiled "%s" as %s' %
- (name, filename + 'c'))
- else:
- write_file(filename, code, 'w')
- log_function('Compiled "%s" as %s' % (name, filename))
- finally:
- if zip:
- zip_file.close()
-
- log_function('Finished compiling templates')
-
- def list_templates(self, extensions=None, filter_func=None):
- """Returns a list of templates for this environment. This requires
- that the loader supports the loader's
- :meth:`~BaseLoader.list_templates` method.
-
- If there are other files in the template folder besides the
- actual templates, the returned list can be filtered. There are two
- ways: either `extensions` is set to a list of file extensions for
- templates, or a `filter_func` can be provided which is a callable that
- is passed a template name and should return `True` if it should end up
- in the result list.
-
- If the loader does not support that, a :exc:`TypeError` is raised.
-
- .. versionadded:: 2.4
- """
- x = self.loader.list_templates()
- if extensions is not None:
- if filter_func is not None:
- raise TypeError('either extensions or filter_func '
- 'can be passed, but not both')
- filter_func = lambda x: '.' in x and \
- x.rsplit('.', 1)[1] in extensions
- if filter_func is not None:
- x = list(ifilter(filter_func, x))
- return x
-
- def handle_exception(self, exc_info=None, rendered=False, source_hint=None):
- """Exception handling helper. This is used internally to either raise
- rewritten exceptions or return a rendered traceback for the template.
- """
- global _make_traceback
- if exc_info is None:
- exc_info = sys.exc_info()
-
- # the debugging module is imported when it's used for the first time.
- # we're doing a lot of stuff there and for applications that do not
- # get any exceptions in template rendering there is no need to load
- # all of that.
- if _make_traceback is None:
- from jinja2.debug import make_traceback as _make_traceback
- traceback = _make_traceback(exc_info, source_hint)
- if rendered and self.exception_formatter is not None:
- return self.exception_formatter(traceback)
- if self.exception_handler is not None:
- self.exception_handler(traceback)
- exc_type, exc_value, tb = traceback.standard_exc_info
- reraise(exc_type, exc_value, tb)
-
- def join_path(self, template, parent):
- """Join a template with the parent. By default all the lookups are
- relative to the loader root so this method returns the `template`
- parameter unchanged, but if the paths should be relative to the
- parent template, this function can be used to calculate the real
- template name.
-
- Subclasses may override this method and implement template path
- joining here.
- """
- return template
-
- @internalcode
- def _load_template(self, name, globals):
- if self.loader is None:
- raise TypeError('no loader for this environment specified')
- cache_key = (weakref.ref(self.loader), name)
- if self.cache is not None:
- template = self.cache.get(cache_key)
- if template is not None and (not self.auto_reload or
- template.is_up_to_date):
- return template
- template = self.loader.load(self, name, globals)
- if self.cache is not None:
- self.cache[cache_key] = template
- return template
-
- @internalcode
- def get_template(self, name, parent=None, globals=None):
- """Load a template from the loader. If a loader is configured this
- method asks the loader for the template and returns a :class:`Template`.
- If the `parent` parameter is not `None`, :meth:`join_path` is called
- to get the real template name before loading.
-
- The `globals` parameter can be used to provide template wide globals.
- These variables are available in the context at render time.
-
- If the template does not exist a :exc:`TemplateNotFound` exception is
- raised.
-
- .. versionchanged:: 2.4
- If `name` is a :class:`Template` object it is returned from the
- function unchanged.
- """
- if isinstance(name, Template):
- return name
- if parent is not None:
- name = self.join_path(name, parent)
- return self._load_template(name, self.make_globals(globals))
-
- @internalcode
- def select_template(self, names, parent=None, globals=None):
- """Works like :meth:`get_template` but tries a number of templates
- before it fails. If it cannot find any of the templates, it will
- raise a :exc:`TemplatesNotFound` exception.
-
- .. versionadded:: 2.3
-
- .. versionchanged:: 2.4
- If `names` contains a :class:`Template` object it is returned
- from the function unchanged.
- """
- if not names:
- raise TemplatesNotFound(message=u'Tried to select from an empty list '
- u'of templates.')
- globals = self.make_globals(globals)
- for name in names:
- if isinstance(name, Template):
- return name
- if parent is not None:
- name = self.join_path(name, parent)
- try:
- return self._load_template(name, globals)
- except TemplateNotFound:
- pass
- raise TemplatesNotFound(names)
-
- @internalcode
- def get_or_select_template(self, template_name_or_list,
- parent=None, globals=None):
- """Does a typecheck and dispatches to :meth:`select_template`
- if an iterable of template names is given, otherwise to
- :meth:`get_template`.
-
- .. versionadded:: 2.3
- """
- if isinstance(template_name_or_list, string_types):
- return self.get_template(template_name_or_list, parent, globals)
- elif isinstance(template_name_or_list, Template):
- return template_name_or_list
- return self.select_template(template_name_or_list, parent, globals)
-
- def from_string(self, source, globals=None, template_class=None):
- """Load a template from a string. This parses the source given and
- returns a :class:`Template` object.
- """
- globals = self.make_globals(globals)
- cls = template_class or self.template_class
- return cls.from_code(self, self.compile(source), globals, None)
-
- def make_globals(self, d):
- """Return a dict for the globals."""
- if not d:
- return self.globals
- return dict(self.globals, **d)
-
-
-class Template(object):
- """The central template object. This class represents a compiled template
- and is used to evaluate it.
-
- Normally the template object is generated from an :class:`Environment` but
- it also has a constructor that makes it possible to create a template
- instance directly using the constructor. It takes the same arguments as
- the environment constructor but it's not possible to specify a loader.
-
- Every template object has a few methods and members that are guaranteed
- to exist. However it's important that a template object should be
- considered immutable. Modifications on the object are not supported.
-
- Template objects created from the constructor rather than an environment
- do have an `environment` attribute that points to a temporary environment
- that is probably shared with other templates created with the constructor
- and compatible settings.
-
- >>> template = Template('Hello {{ name }}!')
- >>> template.render(name='John Doe') == u'Hello John Doe!'
- True
- >>> stream = template.stream(name='John Doe')
- >>> next(stream) == u'Hello John Doe!'
- True
- >>> next(stream)
- Traceback (most recent call last):
- ...
- StopIteration
- """
-
- def __new__(cls, source,
- block_start_string=BLOCK_START_STRING,
- block_end_string=BLOCK_END_STRING,
- variable_start_string=VARIABLE_START_STRING,
- variable_end_string=VARIABLE_END_STRING,
- comment_start_string=COMMENT_START_STRING,
- comment_end_string=COMMENT_END_STRING,
- line_statement_prefix=LINE_STATEMENT_PREFIX,
- line_comment_prefix=LINE_COMMENT_PREFIX,
- trim_blocks=TRIM_BLOCKS,
- lstrip_blocks=LSTRIP_BLOCKS,
- newline_sequence=NEWLINE_SEQUENCE,
- keep_trailing_newline=KEEP_TRAILING_NEWLINE,
- extensions=(),
- optimized=True,
- undefined=Undefined,
- finalize=None,
- autoescape=False,
- enable_async=False):
- env = get_spontaneous_environment(
- block_start_string, block_end_string, variable_start_string,
- variable_end_string, comment_start_string, comment_end_string,
- line_statement_prefix, line_comment_prefix, trim_blocks,
- lstrip_blocks, newline_sequence, keep_trailing_newline,
- frozenset(extensions), optimized, undefined, finalize, autoescape,
- None, 0, False, None, enable_async)
- return env.from_string(source, template_class=cls)
-
- @classmethod
- def from_code(cls, environment, code, globals, uptodate=None):
- """Creates a template object from compiled code and the globals. This
- is used by the loaders and environment to create a template object.
- """
- namespace = {
- 'environment': environment,
- '__file__': code.co_filename
- }
- exec(code, namespace)
- rv = cls._from_namespace(environment, namespace, globals)
- rv._uptodate = uptodate
- return rv
-
- @classmethod
- def from_module_dict(cls, environment, module_dict, globals):
- """Creates a template object from a module. This is used by the
- module loader to create a template object.
-
- .. versionadded:: 2.4
- """
- return cls._from_namespace(environment, module_dict, globals)
-
- @classmethod
- def _from_namespace(cls, environment, namespace, globals):
- t = object.__new__(cls)
- t.environment = environment
- t.globals = globals
- t.name = namespace['name']
- t.filename = namespace['__file__']
- t.blocks = namespace['blocks']
-
- # render function and module
- t.root_render_func = namespace['root']
- t._module = None
-
- # debug and loader helpers
- t._debug_info = namespace['debug_info']
- t._uptodate = None
-
- # store the reference
- namespace['environment'] = environment
- namespace['__jinja_template__'] = t
-
- return t
-
- def render(self, *args, **kwargs):
- """This method accepts the same arguments as the `dict` constructor:
- A dict, a dict subclass or some keyword arguments. If no arguments
- are given the context will be empty. These two calls do the same::
-
- template.render(knights='that say nih')
- template.render({'knights': 'that say nih'})
-
- This will return the rendered template as unicode string.
- """
- vars = dict(*args, **kwargs)
- try:
- return concat(self.root_render_func(self.new_context(vars)))
- except Exception:
- exc_info = sys.exc_info()
- return self.environment.handle_exception(exc_info, True)
-
- def render_async(self, *args, **kwargs):
- """This works similar to :meth:`render` but returns a coroutine
- that when awaited returns the entire rendered template string. This
- requires the async feature to be enabled.
-
- Example usage::
-
- await template.render_async(knights='that say nih; asynchronously')
- """
- # see asyncsupport for the actual implementation
- raise NotImplementedError('This feature is not available for this '
- 'version of Python')
-
- def stream(self, *args, **kwargs):
- """Works exactly like :meth:`generate` but returns a
- :class:`TemplateStream`.
- """
- return TemplateStream(self.generate(*args, **kwargs))
-
- def generate(self, *args, **kwargs):
- """For very large templates it can be useful to not render the whole
- template at once but evaluate each statement after another and yield
- piece for piece. This method basically does exactly that and returns
- a generator that yields one item after another as unicode strings.
-
- It accepts the same arguments as :meth:`render`.
- """
- vars = dict(*args, **kwargs)
- try:
- for event in self.root_render_func(self.new_context(vars)):
- yield event
- except Exception:
- exc_info = sys.exc_info()
- else:
- return
- yield self.environment.handle_exception(exc_info, True)
-
- def generate_async(self, *args, **kwargs):
- """An async version of :meth:`generate`. Works very similarly but
- returns an async iterator instead.
- """
- # see asyncsupport for the actual implementation
- raise NotImplementedError('This feature is not available for this '
- 'version of Python')
-
- def new_context(self, vars=None, shared=False, locals=None):
- """Create a new :class:`Context` for this template. The vars
- provided will be passed to the template. Per default the globals
- are added to the context. If shared is set to `True` the data
- is passed as it to the context without adding the globals.
-
- `locals` can be a dict of local variables for internal usage.
- """
- return new_context(self.environment, self.name, self.blocks,
- vars, shared, self.globals, locals)
-
- def make_module(self, vars=None, shared=False, locals=None):
- """This method works like the :attr:`module` attribute when called
- without arguments but it will evaluate the template on every call
- rather than caching it. It's also possible to provide
- a dict which is then used as context. The arguments are the same
- as for the :meth:`new_context` method.
- """
- return TemplateModule(self, self.new_context(vars, shared, locals))
-
- def make_module_async(self, vars=None, shared=False, locals=None):
- """As template module creation can invoke template code for
- asynchronous exections this method must be used instead of the
- normal :meth:`make_module` one. Likewise the module attribute
- becomes unavailable in async mode.
- """
- # see asyncsupport for the actual implementation
- raise NotImplementedError('This feature is not available for this '
- 'version of Python')
-
- @internalcode
- def _get_default_module(self):
- if self._module is not None:
- return self._module
- self._module = rv = self.make_module()
- return rv
-
- @property
- def module(self):
- """The template as module. This is used for imports in the
- template runtime but is also useful if one wants to access
- exported template variables from the Python layer:
-
- >>> t = Template('{% macro foo() %}42{% endmacro %}23')
- >>> str(t.module)
- '23'
- >>> t.module.foo() == u'42'
- True
-
- This attribute is not available if async mode is enabled.
- """
- return self._get_default_module()
-
- def get_corresponding_lineno(self, lineno):
- """Return the source line number of a line number in the
- generated bytecode as they are not in sync.
- """
- for template_line, code_line in reversed(self.debug_info):
- if code_line <= lineno:
- return template_line
- return 1
-
- @property
- def is_up_to_date(self):
- """If this variable is `False` there is a newer version available."""
- if self._uptodate is None:
- return True
- return self._uptodate()
-
- @property
- def debug_info(self):
- """The debug info mapping."""
- return [tuple(imap(int, x.split('='))) for x in
- self._debug_info.split('&')]
-
- def __repr__(self):
- if self.name is None:
- name = 'memory:%x' % id(self)
- else:
- name = repr(self.name)
- return '<%s %s>' % (self.__class__.__name__, name)
-
-
-@implements_to_string
-class TemplateModule(object):
- """Represents an imported template. All the exported names of the
- template are available as attributes on this object. Additionally
- converting it into an unicode- or bytestrings renders the contents.
- """
-
- def __init__(self, template, context, body_stream=None):
- if body_stream is None:
- if context.environment.is_async:
- raise RuntimeError('Async mode requires a body stream '
- 'to be passed to a template module. Use '
- 'the async methods of the API you are '
- 'using.')
- body_stream = list(template.root_render_func(context))
- self._body_stream = body_stream
- self.__dict__.update(context.get_exported())
- self.__name__ = template.name
-
- def __html__(self):
- return Markup(concat(self._body_stream))
-
- def __str__(self):
- return concat(self._body_stream)
-
- def __repr__(self):
- if self.__name__ is None:
- name = 'memory:%x' % id(self)
- else:
- name = repr(self.__name__)
- return '<%s %s>' % (self.__class__.__name__, name)
-
-
-class TemplateExpression(object):
- """The :meth:`jinja2.Environment.compile_expression` method returns an
- instance of this object. It encapsulates the expression-like access
- to the template with an expression it wraps.
- """
-
- def __init__(self, template, undefined_to_none):
- self._template = template
- self._undefined_to_none = undefined_to_none
-
- def __call__(self, *args, **kwargs):
- context = self._template.new_context(dict(*args, **kwargs))
- consume(self._template.root_render_func(context))
- rv = context.vars['result']
- if self._undefined_to_none and isinstance(rv, Undefined):
- rv = None
- return rv
-
-
-@implements_iterator
-class TemplateStream(object):
- """A template stream works pretty much like an ordinary python generator
- but it can buffer multiple items to reduce the number of total iterations.
- Per default the output is unbuffered which means that for every unbuffered
- instruction in the template one unicode string is yielded.
-
- If buffering is enabled with a buffer size of 5, five items are combined
- into a new unicode string. This is mainly useful if you are streaming
- big templates to a client via WSGI which flushes after each iteration.
- """
-
- def __init__(self, gen):
- self._gen = gen
- self.disable_buffering()
-
- def dump(self, fp, encoding=None, errors='strict'):
- """Dump the complete stream into a file or file-like object.
- Per default unicode strings are written, if you want to encode
- before writing specify an `encoding`.
-
- Example usage::
-
- Template('Hello {{ name }}!').stream(name='foo').dump('hello.html')
- """
- close = False
- if isinstance(fp, string_types):
- if encoding is None:
- encoding = 'utf-8'
- fp = open(fp, 'wb')
- close = True
- try:
- if encoding is not None:
- iterable = (x.encode(encoding, errors) for x in self)
- else:
- iterable = self
- if hasattr(fp, 'writelines'):
- fp.writelines(iterable)
- else:
- for item in iterable:
- fp.write(item)
- finally:
- if close:
- fp.close()
-
- def disable_buffering(self):
- """Disable the output buffering."""
- self._next = partial(next, self._gen)
- self.buffered = False
-
- def _buffered_generator(self, size):
- buf = []
- c_size = 0
- push = buf.append
-
- while 1:
- try:
- while c_size < size:
- c = next(self._gen)
- push(c)
- if c:
- c_size += 1
- except StopIteration:
- if not c_size:
- return
- yield concat(buf)
- del buf[:]
- c_size = 0
-
- def enable_buffering(self, size=5):
- """Enable buffering. Buffer `size` items before yielding them."""
- if size <= 1:
- raise ValueError('buffer size too small')
-
- self.buffered = True
- self._next = partial(next, self._buffered_generator(size))
-
- def __iter__(self):
- return self
-
- def __next__(self):
- return self._next()
-
-
-# hook in default template class. if anyone reads this comment: ignore that
-# it's possible to use custom templates ;-)
-Environment.template_class = Template
diff --git a/python/jinja2/exceptions.py b/python/jinja2/exceptions.py
deleted file mode 100644
index c018a33..0000000
--- a/python/jinja2/exceptions.py
+++ /dev/null
@@ -1,146 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.exceptions
- ~~~~~~~~~~~~~~~~~
-
- Jinja exceptions.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-from jinja2._compat import imap, text_type, PY2, implements_to_string
-
-
-class TemplateError(Exception):
- """Baseclass for all template errors."""
-
- if PY2:
- def __init__(self, message=None):
- if message is not None:
- message = text_type(message).encode('utf-8')
- Exception.__init__(self, message)
-
- @property
- def message(self):
- if self.args:
- message = self.args[0]
- if message is not None:
- return message.decode('utf-8', 'replace')
-
- def __unicode__(self):
- return self.message or u''
- else:
- def __init__(self, message=None):
- Exception.__init__(self, message)
-
- @property
- def message(self):
- if self.args:
- message = self.args[0]
- if message is not None:
- return message
-
-
-@implements_to_string
-class TemplateNotFound(IOError, LookupError, TemplateError):
- """Raised if a template does not exist."""
-
- # looks weird, but removes the warning descriptor that just
- # bogusly warns us about message being deprecated
- message = None
-
- def __init__(self, name, message=None):
- IOError.__init__(self)
- if message is None:
- message = name
- self.message = message
- self.name = name
- self.templates = [name]
-
- def __str__(self):
- return self.message
-
-
-class TemplatesNotFound(TemplateNotFound):
- """Like :class:`TemplateNotFound` but raised if multiple templates
- are selected. This is a subclass of :class:`TemplateNotFound`
- exception, so just catching the base exception will catch both.
-
- .. versionadded:: 2.2
- """
-
- def __init__(self, names=(), message=None):
- if message is None:
- message = u'none of the templates given were found: ' + \
- u', '.join(imap(text_type, names))
- TemplateNotFound.__init__(self, names and names[-1] or None, message)
- self.templates = list(names)
-
-
-@implements_to_string
-class TemplateSyntaxError(TemplateError):
- """Raised to tell the user that there is a problem with the template."""
-
- def __init__(self, message, lineno, name=None, filename=None):
- TemplateError.__init__(self, message)
- self.lineno = lineno
- self.name = name
- self.filename = filename
- self.source = None
-
- # this is set to True if the debug.translate_syntax_error
- # function translated the syntax error into a new traceback
- self.translated = False
-
- def __str__(self):
- # for translated errors we only return the message
- if self.translated:
- return self.message
-
- # otherwise attach some stuff
- location = 'line %d' % self.lineno
- name = self.filename or self.name
- if name:
- location = 'File "%s", %s' % (name, location)
- lines = [self.message, ' ' + location]
-
- # if the source is set, add the line to the output
- if self.source is not None:
- try:
- line = self.source.splitlines()[self.lineno - 1]
- except IndexError:
- line = None
- if line:
- lines.append(' ' + line.strip())
-
- return u'\n'.join(lines)
-
-
-class TemplateAssertionError(TemplateSyntaxError):
- """Like a template syntax error, but covers cases where something in the
- template caused an error at compile time that wasn't necessarily caused
- by a syntax error. However it's a direct subclass of
- :exc:`TemplateSyntaxError` and has the same attributes.
- """
-
-
-class TemplateRuntimeError(TemplateError):
- """A generic runtime error in the template engine. Under some situations
- Jinja may raise this exception.
- """
-
-
-class UndefinedError(TemplateRuntimeError):
- """Raised if a template tries to operate on :class:`Undefined`."""
-
-
-class SecurityError(TemplateRuntimeError):
- """Raised if a template tries to do something insecure if the
- sandbox is enabled.
- """
-
-
-class FilterArgumentError(TemplateRuntimeError):
- """This error is raised if a filter was called with inappropriate
- arguments
- """
diff --git a/python/jinja2/ext.py b/python/jinja2/ext.py
deleted file mode 100644
index 0734a84..0000000
--- a/python/jinja2/ext.py
+++ /dev/null
@@ -1,627 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.ext
- ~~~~~~~~~~
-
- Jinja extensions allow to add custom tags similar to the way django custom
- tags work. By default two example extensions exist: an i18n and a cache
- extension.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-import re
-
-from jinja2 import nodes
-from jinja2.defaults import BLOCK_START_STRING, \
- BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \
- COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \
- LINE_COMMENT_PREFIX, TRIM_BLOCKS, NEWLINE_SEQUENCE, \
- KEEP_TRAILING_NEWLINE, LSTRIP_BLOCKS
-from jinja2.environment import Environment
-from jinja2.runtime import concat
-from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError
-from jinja2.utils import contextfunction, import_string, Markup
-from jinja2._compat import with_metaclass, string_types, iteritems
-
-
-# the only real useful gettext functions for a Jinja template. Note
-# that ugettext must be assigned to gettext as Jinja doesn't support
-# non unicode strings.
-GETTEXT_FUNCTIONS = ('_', 'gettext', 'ngettext')
-
-
-class ExtensionRegistry(type):
- """Gives the extension an unique identifier."""
-
- def __new__(cls, name, bases, d):
- rv = type.__new__(cls, name, bases, d)
- rv.identifier = rv.__module__ + '.' + rv.__name__
- return rv
-
-
-class Extension(with_metaclass(ExtensionRegistry, object)):
- """Extensions can be used to add extra functionality to the Jinja template
- system at the parser level. Custom extensions are bound to an environment
- but may not store environment specific data on `self`. The reason for
- this is that an extension can be bound to another environment (for
- overlays) by creating a copy and reassigning the `environment` attribute.
-
- As extensions are created by the environment they cannot accept any
- arguments for configuration. One may want to work around that by using
- a factory function, but that is not possible as extensions are identified
- by their import name. The correct way to configure the extension is
- storing the configuration values on the environment. Because this way the
- environment ends up acting as central configuration storage the
- attributes may clash which is why extensions have to ensure that the names
- they choose for configuration are not too generic. ``prefix`` for example
- is a terrible name, ``fragment_cache_prefix`` on the other hand is a good
- name as includes the name of the extension (fragment cache).
- """
-
- #: if this extension parses this is the list of tags it's listening to.
- tags = set()
-
- #: the priority of that extension. This is especially useful for
- #: extensions that preprocess values. A lower value means higher
- #: priority.
- #:
- #: .. versionadded:: 2.4
- priority = 100
-
- def __init__(self, environment):
- self.environment = environment
-
- def bind(self, environment):
- """Create a copy of this extension bound to another environment."""
- rv = object.__new__(self.__class__)
- rv.__dict__.update(self.__dict__)
- rv.environment = environment
- return rv
-
- def preprocess(self, source, name, filename=None):
- """This method is called before the actual lexing and can be used to
- preprocess the source. The `filename` is optional. The return value
- must be the preprocessed source.
- """
- return source
-
- def filter_stream(self, stream):
- """It's passed a :class:`~jinja2.lexer.TokenStream` that can be used
- to filter tokens returned. This method has to return an iterable of
- :class:`~jinja2.lexer.Token`\\s, but it doesn't have to return a
- :class:`~jinja2.lexer.TokenStream`.
-
- In the `ext` folder of the Jinja2 source distribution there is a file
- called `inlinegettext.py` which implements a filter that utilizes this
- method.
- """
- return stream
-
- def parse(self, parser):
- """If any of the :attr:`tags` matched this method is called with the
- parser as first argument. The token the parser stream is pointing at
- is the name token that matched. This method has to return one or a
- list of multiple nodes.
- """
- raise NotImplementedError()
-
- def attr(self, name, lineno=None):
- """Return an attribute node for the current extension. This is useful
- to pass constants on extensions to generated template code.
-
- ::
-
- self.attr('_my_attribute', lineno=lineno)
- """
- return nodes.ExtensionAttribute(self.identifier, name, lineno=lineno)
-
- def call_method(self, name, args=None, kwargs=None, dyn_args=None,
- dyn_kwargs=None, lineno=None):
- """Call a method of the extension. This is a shortcut for
- :meth:`attr` + :class:`jinja2.nodes.Call`.
- """
- if args is None:
- args = []
- if kwargs is None:
- kwargs = []
- return nodes.Call(self.attr(name, lineno=lineno), args, kwargs,
- dyn_args, dyn_kwargs, lineno=lineno)
-
-
-@contextfunction
-def _gettext_alias(__context, *args, **kwargs):
- return __context.call(__context.resolve('gettext'), *args, **kwargs)
-
-
-def _make_new_gettext(func):
- @contextfunction
- def gettext(__context, __string, **variables):
- rv = __context.call(func, __string)
- if __context.eval_ctx.autoescape:
- rv = Markup(rv)
- return rv % variables
- return gettext
-
-
-def _make_new_ngettext(func):
- @contextfunction
- def ngettext(__context, __singular, __plural, __num, **variables):
- variables.setdefault('num', __num)
- rv = __context.call(func, __singular, __plural, __num)
- if __context.eval_ctx.autoescape:
- rv = Markup(rv)
- return rv % variables
- return ngettext
-
-
-class InternationalizationExtension(Extension):
- """This extension adds gettext support to Jinja2."""
- tags = set(['trans'])
-
- # TODO: the i18n extension is currently reevaluating values in a few
- # situations. Take this example:
- # {% trans count=something() %}{{ count }} foo{% pluralize
- # %}{{ count }} fooss{% endtrans %}
- # something is called twice here. One time for the gettext value and
- # the other time for the n-parameter of the ngettext function.
-
- def __init__(self, environment):
- Extension.__init__(self, environment)
- environment.globals['_'] = _gettext_alias
- environment.extend(
- install_gettext_translations=self._install,
- install_null_translations=self._install_null,
- install_gettext_callables=self._install_callables,
- uninstall_gettext_translations=self._uninstall,
- extract_translations=self._extract,
- newstyle_gettext=False
- )
-
- def _install(self, translations, newstyle=None):
- gettext = getattr(translations, 'ugettext', None)
- if gettext is None:
- gettext = translations.gettext
- ngettext = getattr(translations, 'ungettext', None)
- if ngettext is None:
- ngettext = translations.ngettext
- self._install_callables(gettext, ngettext, newstyle)
-
- def _install_null(self, newstyle=None):
- self._install_callables(
- lambda x: x,
- lambda s, p, n: (n != 1 and (p,) or (s,))[0],
- newstyle
- )
-
- def _install_callables(self, gettext, ngettext, newstyle=None):
- if newstyle is not None:
- self.environment.newstyle_gettext = newstyle
- if self.environment.newstyle_gettext:
- gettext = _make_new_gettext(gettext)
- ngettext = _make_new_ngettext(ngettext)
- self.environment.globals.update(
- gettext=gettext,
- ngettext=ngettext
- )
-
- def _uninstall(self, translations):
- for key in 'gettext', 'ngettext':
- self.environment.globals.pop(key, None)
-
- def _extract(self, source, gettext_functions=GETTEXT_FUNCTIONS):
- if isinstance(source, string_types):
- source = self.environment.parse(source)
- return extract_from_ast(source, gettext_functions)
-
- def parse(self, parser):
- """Parse a translatable tag."""
- lineno = next(parser.stream).lineno
- num_called_num = False
-
- # find all the variables referenced. Additionally a variable can be
- # defined in the body of the trans block too, but this is checked at
- # a later state.
- plural_expr = None
- plural_expr_assignment = None
- variables = {}
- trimmed = None
- while parser.stream.current.type != 'block_end':
- if variables:
- parser.stream.expect('comma')
-
- # skip colon for python compatibility
- if parser.stream.skip_if('colon'):
- break
-
- name = parser.stream.expect('name')
- if name.value in variables:
- parser.fail('translatable variable %r defined twice.' %
- name.value, name.lineno,
- exc=TemplateAssertionError)
-
- # expressions
- if parser.stream.current.type == 'assign':
- next(parser.stream)
- variables[name.value] = var = parser.parse_expression()
- elif trimmed is None and name.value in ('trimmed', 'notrimmed'):
- trimmed = name.value == 'trimmed'
- continue
- else:
- variables[name.value] = var = nodes.Name(name.value, 'load')
-
- if plural_expr is None:
- if isinstance(var, nodes.Call):
- plural_expr = nodes.Name('_trans', 'load')
- variables[name.value] = plural_expr
- plural_expr_assignment = nodes.Assign(
- nodes.Name('_trans', 'store'), var)
- else:
- plural_expr = var
- num_called_num = name.value == 'num'
-
- parser.stream.expect('block_end')
-
- plural = None
- have_plural = False
- referenced = set()
-
- # now parse until endtrans or pluralize
- singular_names, singular = self._parse_block(parser, True)
- if singular_names:
- referenced.update(singular_names)
- if plural_expr is None:
- plural_expr = nodes.Name(singular_names[0], 'load')
- num_called_num = singular_names[0] == 'num'
-
- # if we have a pluralize block, we parse that too
- if parser.stream.current.test('name:pluralize'):
- have_plural = True
- next(parser.stream)
- if parser.stream.current.type != 'block_end':
- name = parser.stream.expect('name')
- if name.value not in variables:
- parser.fail('unknown variable %r for pluralization' %
- name.value, name.lineno,
- exc=TemplateAssertionError)
- plural_expr = variables[name.value]
- num_called_num = name.value == 'num'
- parser.stream.expect('block_end')
- plural_names, plural = self._parse_block(parser, False)
- next(parser.stream)
- referenced.update(plural_names)
- else:
- next(parser.stream)
-
- # register free names as simple name expressions
- for var in referenced:
- if var not in variables:
- variables[var] = nodes.Name(var, 'load')
-
- if not have_plural:
- plural_expr = None
- elif plural_expr is None:
- parser.fail('pluralize without variables', lineno)
-
- if trimmed is None:
- trimmed = self.environment.policies['ext.i18n.trimmed']
- if trimmed:
- singular = self._trim_whitespace(singular)
- if plural:
- plural = self._trim_whitespace(plural)
-
- node = self._make_node(singular, plural, variables, plural_expr,
- bool(referenced),
- num_called_num and have_plural)
- node.set_lineno(lineno)
- if plural_expr_assignment is not None:
- return [plural_expr_assignment, node]
- else:
- return node
-
- def _trim_whitespace(self, string, _ws_re=re.compile(r'\s*\n\s*')):
- return _ws_re.sub(' ', string.strip())
-
- def _parse_block(self, parser, allow_pluralize):
- """Parse until the next block tag with a given name."""
- referenced = []
- buf = []
- while 1:
- if parser.stream.current.type == 'data':
- buf.append(parser.stream.current.value.replace('%', '%%'))
- next(parser.stream)
- elif parser.stream.current.type == 'variable_begin':
- next(parser.stream)
- name = parser.stream.expect('name').value
- referenced.append(name)
- buf.append('%%(%s)s' % name)
- parser.stream.expect('variable_end')
- elif parser.stream.current.type == 'block_begin':
- next(parser.stream)
- if parser.stream.current.test('name:endtrans'):
- break
- elif parser.stream.current.test('name:pluralize'):
- if allow_pluralize:
- break
- parser.fail('a translatable section can have only one '
- 'pluralize section')
- parser.fail('control structures in translatable sections are '
- 'not allowed')
- elif parser.stream.eos:
- parser.fail('unclosed translation block')
- else:
- assert False, 'internal parser error'
-
- return referenced, concat(buf)
-
- def _make_node(self, singular, plural, variables, plural_expr,
- vars_referenced, num_called_num):
- """Generates a useful node from the data provided."""
- # no variables referenced? no need to escape for old style
- # gettext invocations only if there are vars.
- if not vars_referenced and not self.environment.newstyle_gettext:
- singular = singular.replace('%%', '%')
- if plural:
- plural = plural.replace('%%', '%')
-
- # singular only:
- if plural_expr is None:
- gettext = nodes.Name('gettext', 'load')
- node = nodes.Call(gettext, [nodes.Const(singular)],
- [], None, None)
-
- # singular and plural
- else:
- ngettext = nodes.Name('ngettext', 'load')
- node = nodes.Call(ngettext, [
- nodes.Const(singular),
- nodes.Const(plural),
- plural_expr
- ], [], None, None)
-
- # in case newstyle gettext is used, the method is powerful
- # enough to handle the variable expansion and autoescape
- # handling itself
- if self.environment.newstyle_gettext:
- for key, value in iteritems(variables):
- # the function adds that later anyways in case num was
- # called num, so just skip it.
- if num_called_num and key == 'num':
- continue
- node.kwargs.append(nodes.Keyword(key, value))
-
- # otherwise do that here
- else:
- # mark the return value as safe if we are in an
- # environment with autoescaping turned on
- node = nodes.MarkSafeIfAutoescape(node)
- if variables:
- node = nodes.Mod(node, nodes.Dict([
- nodes.Pair(nodes.Const(key), value)
- for key, value in variables.items()
- ]))
- return nodes.Output([node])
-
-
-class ExprStmtExtension(Extension):
- """Adds a `do` tag to Jinja2 that works like the print statement just
- that it doesn't print the return value.
- """
- tags = set(['do'])
-
- def parse(self, parser):
- node = nodes.ExprStmt(lineno=next(parser.stream).lineno)
- node.node = parser.parse_tuple()
- return node
-
-
-class LoopControlExtension(Extension):
- """Adds break and continue to the template engine."""
- tags = set(['break', 'continue'])
-
- def parse(self, parser):
- token = next(parser.stream)
- if token.value == 'break':
- return nodes.Break(lineno=token.lineno)
- return nodes.Continue(lineno=token.lineno)
-
-
-class WithExtension(Extension):
- pass
-
-
-class AutoEscapeExtension(Extension):
- pass
-
-
-def extract_from_ast(node, gettext_functions=GETTEXT_FUNCTIONS,
- babel_style=True):
- """Extract localizable strings from the given template node. Per
- default this function returns matches in babel style that means non string
- parameters as well as keyword arguments are returned as `None`. This
- allows Babel to figure out what you really meant if you are using
- gettext functions that allow keyword arguments for placeholder expansion.
- If you don't want that behavior set the `babel_style` parameter to `False`
- which causes only strings to be returned and parameters are always stored
- in tuples. As a consequence invalid gettext calls (calls without a single
- string parameter or string parameters after non-string parameters) are
- skipped.
-
- This example explains the behavior:
-
- >>> from jinja2 import Environment
- >>> env = Environment()
- >>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}')
- >>> list(extract_from_ast(node))
- [(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))]
- >>> list(extract_from_ast(node, babel_style=False))
- [(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))]
-
- For every string found this function yields a ``(lineno, function,
- message)`` tuple, where:
-
- * ``lineno`` is the number of the line on which the string was found,
- * ``function`` is the name of the ``gettext`` function used (if the
- string was extracted from embedded Python code), and
- * ``message`` is the string itself (a ``unicode`` object, or a tuple
- of ``unicode`` objects for functions with multiple string arguments).
-
- This extraction function operates on the AST and is because of that unable
- to extract any comments. For comment support you have to use the babel
- extraction interface or extract comments yourself.
- """
- for node in node.find_all(nodes.Call):
- if not isinstance(node.node, nodes.Name) or \
- node.node.name not in gettext_functions:
- continue
-
- strings = []
- for arg in node.args:
- if isinstance(arg, nodes.Const) and \
- isinstance(arg.value, string_types):
- strings.append(arg.value)
- else:
- strings.append(None)
-
- for arg in node.kwargs:
- strings.append(None)
- if node.dyn_args is not None:
- strings.append(None)
- if node.dyn_kwargs is not None:
- strings.append(None)
-
- if not babel_style:
- strings = tuple(x for x in strings if x is not None)
- if not strings:
- continue
- else:
- if len(strings) == 1:
- strings = strings[0]
- else:
- strings = tuple(strings)
- yield node.lineno, node.node.name, strings
-
-
-class _CommentFinder(object):
- """Helper class to find comments in a token stream. Can only
- find comments for gettext calls forwards. Once the comment
- from line 4 is found, a comment for line 1 will not return a
- usable value.
- """
-
- def __init__(self, tokens, comment_tags):
- self.tokens = tokens
- self.comment_tags = comment_tags
- self.offset = 0
- self.last_lineno = 0
-
- def find_backwards(self, offset):
- try:
- for _, token_type, token_value in \
- reversed(self.tokens[self.offset:offset]):
- if token_type in ('comment', 'linecomment'):
- try:
- prefix, comment = token_value.split(None, 1)
- except ValueError:
- continue
- if prefix in self.comment_tags:
- return [comment.rstrip()]
- return []
- finally:
- self.offset = offset
-
- def find_comments(self, lineno):
- if not self.comment_tags or self.last_lineno > lineno:
- return []
- for idx, (token_lineno, _, _) in enumerate(self.tokens[self.offset:]):
- if token_lineno > lineno:
- return self.find_backwards(self.offset + idx)
- return self.find_backwards(len(self.tokens))
-
-
-def babel_extract(fileobj, keywords, comment_tags, options):
- """Babel extraction method for Jinja templates.
-
- .. versionchanged:: 2.3
- Basic support for translation comments was added. If `comment_tags`
- is now set to a list of keywords for extraction, the extractor will
- try to find the best preceeding comment that begins with one of the
- keywords. For best results, make sure to not have more than one
- gettext call in one line of code and the matching comment in the
- same line or the line before.
-
- .. versionchanged:: 2.5.1
- The `newstyle_gettext` flag can be set to `True` to enable newstyle
- gettext calls.
-
- .. versionchanged:: 2.7
- A `silent` option can now be provided. If set to `False` template
- syntax errors are propagated instead of being ignored.
-
- :param fileobj: the file-like object the messages should be extracted from
- :param keywords: a list of keywords (i.e. function names) that should be
- recognized as translation functions
- :param comment_tags: a list of translator tags to search for and include
- in the results.
- :param options: a dictionary of additional options (optional)
- :return: an iterator over ``(lineno, funcname, message, comments)`` tuples.
- (comments will be empty currently)
- """
- extensions = set()
- for extension in options.get('extensions', '').split(','):
- extension = extension.strip()
- if not extension:
- continue
- extensions.add(import_string(extension))
- if InternationalizationExtension not in extensions:
- extensions.add(InternationalizationExtension)
-
- def getbool(options, key, default=False):
- return options.get(key, str(default)).lower() in \
- ('1', 'on', 'yes', 'true')
-
- silent = getbool(options, 'silent', True)
- environment = Environment(
- options.get('block_start_string', BLOCK_START_STRING),
- options.get('block_end_string', BLOCK_END_STRING),
- options.get('variable_start_string', VARIABLE_START_STRING),
- options.get('variable_end_string', VARIABLE_END_STRING),
- options.get('comment_start_string', COMMENT_START_STRING),
- options.get('comment_end_string', COMMENT_END_STRING),
- options.get('line_statement_prefix') or LINE_STATEMENT_PREFIX,
- options.get('line_comment_prefix') or LINE_COMMENT_PREFIX,
- getbool(options, 'trim_blocks', TRIM_BLOCKS),
- getbool(options, 'lstrip_blocks', LSTRIP_BLOCKS),
- NEWLINE_SEQUENCE,
- getbool(options, 'keep_trailing_newline', KEEP_TRAILING_NEWLINE),
- frozenset(extensions),
- cache_size=0,
- auto_reload=False
- )
-
- if getbool(options, 'trimmed'):
- environment.policies['ext.i18n.trimmed'] = True
- if getbool(options, 'newstyle_gettext'):
- environment.newstyle_gettext = True
-
- source = fileobj.read().decode(options.get('encoding', 'utf-8'))
- try:
- node = environment.parse(source)
- tokens = list(environment.lex(environment.preprocess(source)))
- except TemplateSyntaxError as e:
- if not silent:
- raise
- # skip templates with syntax errors
- return
-
- finder = _CommentFinder(tokens, comment_tags)
- for lineno, func, message in extract_from_ast(node, keywords):
- yield lineno, func, message, finder.find_comments(lineno)
-
-
-#: nicer import names
-i18n = InternationalizationExtension
-do = ExprStmtExtension
-loopcontrols = LoopControlExtension
-with_ = WithExtension
-autoescape = AutoEscapeExtension
diff --git a/python/jinja2/filters.py b/python/jinja2/filters.py
deleted file mode 100644
index 267dddd..0000000
--- a/python/jinja2/filters.py
+++ /dev/null
@@ -1,1190 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.filters
- ~~~~~~~~~~~~~~
-
- Bundled jinja filters.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import re
-import math
-import random
-import warnings
-
-from itertools import groupby, chain
-from collections import namedtuple
-from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode, \
- unicode_urlencode, htmlsafe_json_dumps
-from jinja2.runtime import Undefined
-from jinja2.exceptions import FilterArgumentError
-from jinja2._compat import imap, string_types, text_type, iteritems, PY2
-
-
-_word_re = re.compile(r'\w+', re.UNICODE)
-_word_beginning_split_re = re.compile(r'([-\s\(\{\[\<]+)', re.UNICODE)
-
-
-def contextfilter(f):
- """Decorator for marking context dependent filters. The current
- :class:`Context` will be passed as first argument.
- """
- f.contextfilter = True
- return f
-
-
-def evalcontextfilter(f):
- """Decorator for marking eval-context dependent filters. An eval
- context object is passed as first argument. For more information
- about the eval context, see :ref:`eval-context`.
-
- .. versionadded:: 2.4
- """
- f.evalcontextfilter = True
- return f
-
-
-def environmentfilter(f):
- """Decorator for marking environment dependent filters. The current
- :class:`Environment` is passed to the filter as first argument.
- """
- f.environmentfilter = True
- return f
-
-
-def ignore_case(value):
- """For use as a postprocessor for :func:`make_attrgetter`. Converts strings
- to lowercase and returns other types as-is."""
- return value.lower() if isinstance(value, string_types) else value
-
-
-def make_attrgetter(environment, attribute, postprocess=None):
- """Returns a callable that looks up the given attribute from a
- passed object with the rules of the environment. Dots are allowed
- to access attributes of attributes. Integer parts in paths are
- looked up as integers.
- """
- if attribute is None:
- attribute = []
- elif isinstance(attribute, string_types):
- attribute = [int(x) if x.isdigit() else x for x in attribute.split('.')]
- else:
- attribute = [attribute]
-
- def attrgetter(item):
- for part in attribute:
- item = environment.getitem(item, part)
-
- if postprocess is not None:
- item = postprocess(item)
-
- return item
-
- return attrgetter
-
-
-def do_forceescape(value):
- """Enforce HTML escaping. This will probably double escape variables."""
- if hasattr(value, '__html__'):
- value = value.__html__()
- return escape(text_type(value))
-
-
-def do_urlencode(value):
- """Escape strings for use in URLs (uses UTF-8 encoding). It accepts both
- dictionaries and regular strings as well as pairwise iterables.
-
- .. versionadded:: 2.7
- """
- itemiter = None
- if isinstance(value, dict):
- itemiter = iteritems(value)
- elif not isinstance(value, string_types):
- try:
- itemiter = iter(value)
- except TypeError:
- pass
- if itemiter is None:
- return unicode_urlencode(value)
- return u'&'.join(unicode_urlencode(k) + '=' +
- unicode_urlencode(v, for_qs=True)
- for k, v in itemiter)
-
-
-@evalcontextfilter
-def do_replace(eval_ctx, s, old, new, count=None):
- """Return a copy of the value with all occurrences of a substring
- replaced with a new one. The first argument is the substring
- that should be replaced, the second is the replacement string.
- If the optional third argument ``count`` is given, only the first
- ``count`` occurrences are replaced:
-
- .. sourcecode:: jinja
-
- {{ "Hello World"|replace("Hello", "Goodbye") }}
- -> Goodbye World
-
- {{ "aaaaargh"|replace("a", "d'oh, ", 2) }}
- -> d'oh, d'oh, aaargh
- """
- if count is None:
- count = -1
- if not eval_ctx.autoescape:
- return text_type(s).replace(text_type(old), text_type(new), count)
- if hasattr(old, '__html__') or hasattr(new, '__html__') and \
- not hasattr(s, '__html__'):
- s = escape(s)
- else:
- s = soft_unicode(s)
- return s.replace(soft_unicode(old), soft_unicode(new), count)
-
-
-def do_upper(s):
- """Convert a value to uppercase."""
- return soft_unicode(s).upper()
-
-
-def do_lower(s):
- """Convert a value to lowercase."""
- return soft_unicode(s).lower()
-
-
-@evalcontextfilter
-def do_xmlattr(_eval_ctx, d, autospace=True):
- """Create an SGML/XML attribute string based on the items in a dict.
- All values that are neither `none` nor `undefined` are automatically
- escaped:
-
- .. sourcecode:: html+jinja
-
- <ul{{ {'class': 'my_list', 'missing': none,
- 'id': 'list-%d'|format(variable)}|xmlattr }}>
- ...
- </ul>
-
- Results in something like this:
-
- .. sourcecode:: html
-
- <ul class="my_list" id="list-42">
- ...
- </ul>
-
- As you can see it automatically prepends a space in front of the item
- if the filter returned something unless the second parameter is false.
- """
- rv = u' '.join(
- u'%s="%s"' % (escape(key), escape(value))
- for key, value in iteritems(d)
- if value is not None and not isinstance(value, Undefined)
- )
- if autospace and rv:
- rv = u' ' + rv
- if _eval_ctx.autoescape:
- rv = Markup(rv)
- return rv
-
-
-def do_capitalize(s):
- """Capitalize a value. The first character will be uppercase, all others
- lowercase.
- """
- return soft_unicode(s).capitalize()
-
-
-def do_title(s):
- """Return a titlecased version of the value. I.e. words will start with
- uppercase letters, all remaining characters are lowercase.
- """
- return ''.join(
- [item[0].upper() + item[1:].lower()
- for item in _word_beginning_split_re.split(soft_unicode(s))
- if item])
-
-
-def do_dictsort(value, case_sensitive=False, by='key', reverse=False):
- """Sort a dict and yield (key, value) pairs. Because python dicts are
- unsorted you may want to use this function to order them by either
- key or value:
-
- .. sourcecode:: jinja
-
- {% for item in mydict|dictsort %}
- sort the dict by key, case insensitive
-
- {% for item in mydict|dictsort(reverse=true) %}
- sort the dict by key, case insensitive, reverse order
-
- {% for item in mydict|dictsort(true) %}
- sort the dict by key, case sensitive
-
- {% for item in mydict|dictsort(false, 'value') %}
- sort the dict by value, case insensitive
- """
- if by == 'key':
- pos = 0
- elif by == 'value':
- pos = 1
- else:
- raise FilterArgumentError(
- 'You can only sort by either "key" or "value"'
- )
-
- def sort_func(item):
- value = item[pos]
-
- if not case_sensitive:
- value = ignore_case(value)
-
- return value
-
- return sorted(value.items(), key=sort_func, reverse=reverse)
-
-
-@environmentfilter
-def do_sort(
- environment, value, reverse=False, case_sensitive=False, attribute=None
-):
- """Sort an iterable. Per default it sorts ascending, if you pass it
- true as first argument it will reverse the sorting.
-
- If the iterable is made of strings the third parameter can be used to
- control the case sensitiveness of the comparison which is disabled by
- default.
-
- .. sourcecode:: jinja
-
- {% for item in iterable|sort %}
- ...
- {% endfor %}
-
- It is also possible to sort by an attribute (for example to sort
- by the date of an object) by specifying the `attribute` parameter:
-
- .. sourcecode:: jinja
-
- {% for item in iterable|sort(attribute='date') %}
- ...
- {% endfor %}
-
- .. versionchanged:: 2.6
- The `attribute` parameter was added.
- """
- key_func = make_attrgetter(
- environment, attribute,
- postprocess=ignore_case if not case_sensitive else None
- )
- return sorted(value, key=key_func, reverse=reverse)
-
-
-@environmentfilter
-def do_unique(environment, value, case_sensitive=False, attribute=None):
- """Returns a list of unique items from the the given iterable.
-
- .. sourcecode:: jinja
-
- {{ ['foo', 'bar', 'foobar', 'FooBar']|unique }}
- -> ['foo', 'bar', 'foobar']
-
- The unique items are yielded in the same order as their first occurrence in
- the iterable passed to the filter.
-
- :param case_sensitive: Treat upper and lower case strings as distinct.
- :param attribute: Filter objects with unique values for this attribute.
- """
- getter = make_attrgetter(
- environment, attribute,
- postprocess=ignore_case if not case_sensitive else None
- )
- seen = set()
-
- for item in value:
- key = getter(item)
-
- if key not in seen:
- seen.add(key)
- yield item
-
-
-def _min_or_max(environment, value, func, case_sensitive, attribute):
- it = iter(value)
-
- try:
- first = next(it)
- except StopIteration:
- return environment.undefined('No aggregated item, sequence was empty.')
-
- key_func = make_attrgetter(
- environment, attribute,
- ignore_case if not case_sensitive else None
- )
- return func(chain([first], it), key=key_func)
-
-
-@environmentfilter
-def do_min(environment, value, case_sensitive=False, attribute=None):
- """Return the smallest item from the sequence.
-
- .. sourcecode:: jinja
-
- {{ [1, 2, 3]|min }}
- -> 1
-
- :param case_sensitive: Treat upper and lower case strings as distinct.
- :param attribute: Get the object with the max value of this attribute.
- """
- return _min_or_max(environment, value, min, case_sensitive, attribute)
-
-
-@environmentfilter
-def do_max(environment, value, case_sensitive=False, attribute=None):
- """Return the largest item from the sequence.
-
- .. sourcecode:: jinja
-
- {{ [1, 2, 3]|max }}
- -> 3
-
- :param case_sensitive: Treat upper and lower case strings as distinct.
- :param attribute: Get the object with the max value of this attribute.
- """
- return _min_or_max(environment, value, max, case_sensitive, attribute)
-
-
-def do_default(value, default_value=u'', boolean=False):
- """If the value is undefined it will return the passed default value,
- otherwise the value of the variable:
-
- .. sourcecode:: jinja
-
- {{ my_variable|default('my_variable is not defined') }}
-
- This will output the value of ``my_variable`` if the variable was
- defined, otherwise ``'my_variable is not defined'``. If you want
- to use default with variables that evaluate to false you have to
- set the second parameter to `true`:
-
- .. sourcecode:: jinja
-
- {{ ''|default('the string was empty', true) }}
- """
- if isinstance(value, Undefined) or (boolean and not value):
- return default_value
- return value
-
-
-@evalcontextfilter
-def do_join(eval_ctx, value, d=u'', attribute=None):
- """Return a string which is the concatenation of the strings in the
- sequence. The separator between elements is an empty string per
- default, you can define it with the optional parameter:
-
- .. sourcecode:: jinja
-
- {{ [1, 2, 3]|join('|') }}
- -> 1|2|3
-
- {{ [1, 2, 3]|join }}
- -> 123
-
- It is also possible to join certain attributes of an object:
-
- .. sourcecode:: jinja
-
- {{ users|join(', ', attribute='username') }}
-
- .. versionadded:: 2.6
- The `attribute` parameter was added.
- """
- if attribute is not None:
- value = imap(make_attrgetter(eval_ctx.environment, attribute), value)
-
- # no automatic escaping? joining is a lot eaiser then
- if not eval_ctx.autoescape:
- return text_type(d).join(imap(text_type, value))
-
- # if the delimiter doesn't have an html representation we check
- # if any of the items has. If yes we do a coercion to Markup
- if not hasattr(d, '__html__'):
- value = list(value)
- do_escape = False
- for idx, item in enumerate(value):
- if hasattr(item, '__html__'):
- do_escape = True
- else:
- value[idx] = text_type(item)
- if do_escape:
- d = escape(d)
- else:
- d = text_type(d)
- return d.join(value)
-
- # no html involved, to normal joining
- return soft_unicode(d).join(imap(soft_unicode, value))
-
-
-def do_center(value, width=80):
- """Centers the value in a field of a given width."""
- return text_type(value).center(width)
-
-
-@environmentfilter
-def do_first(environment, seq):
- """Return the first item of a sequence."""
- try:
- return next(iter(seq))
- except StopIteration:
- return environment.undefined('No first item, sequence was empty.')
-
-
-@environmentfilter
-def do_last(environment, seq):
- """Return the last item of a sequence."""
- try:
- return next(iter(reversed(seq)))
- except StopIteration:
- return environment.undefined('No last item, sequence was empty.')
-
-
-@contextfilter
-def do_random(context, seq):
- """Return a random item from the sequence."""
- try:
- return random.choice(seq)
- except IndexError:
- return context.environment.undefined('No random item, sequence was empty.')
-
-
-def do_filesizeformat(value, binary=False):
- """Format the value like a 'human-readable' file size (i.e. 13 kB,
- 4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega,
- Giga, etc.), if the second parameter is set to `True` the binary
- prefixes are used (Mebi, Gibi).
- """
- bytes = float(value)
- base = binary and 1024 or 1000
- prefixes = [
- (binary and 'KiB' or 'kB'),
- (binary and 'MiB' or 'MB'),
- (binary and 'GiB' or 'GB'),
- (binary and 'TiB' or 'TB'),
- (binary and 'PiB' or 'PB'),
- (binary and 'EiB' or 'EB'),
- (binary and 'ZiB' or 'ZB'),
- (binary and 'YiB' or 'YB')
- ]
- if bytes == 1:
- return '1 Byte'
- elif bytes < base:
- return '%d Bytes' % bytes
- else:
- for i, prefix in enumerate(prefixes):
- unit = base ** (i + 2)
- if bytes < unit:
- return '%.1f %s' % ((base * bytes / unit), prefix)
- return '%.1f %s' % ((base * bytes / unit), prefix)
-
-
-def do_pprint(value, verbose=False):
- """Pretty print a variable. Useful for debugging.
-
- With Jinja 1.2 onwards you can pass it a parameter. If this parameter
- is truthy the output will be more verbose (this requires `pretty`)
- """
- return pformat(value, verbose=verbose)
-
-
-@evalcontextfilter
-def do_urlize(eval_ctx, value, trim_url_limit=None, nofollow=False,
- target=None, rel=None):
- """Converts URLs in plain text into clickable links.
-
- If you pass the filter an additional integer it will shorten the urls
- to that number. Also a third argument exists that makes the urls
- "nofollow":
-
- .. sourcecode:: jinja
-
- {{ mytext|urlize(40, true) }}
- links are shortened to 40 chars and defined with rel="nofollow"
-
- If *target* is specified, the ``target`` attribute will be added to the
- ``<a>`` tag:
-
- .. sourcecode:: jinja
-
- {{ mytext|urlize(40, target='_blank') }}
-
- .. versionchanged:: 2.8+
- The *target* parameter was added.
- """
- policies = eval_ctx.environment.policies
- rel = set((rel or '').split() or [])
- if nofollow:
- rel.add('nofollow')
- rel.update((policies['urlize.rel'] or '').split())
- if target is None:
- target = policies['urlize.target']
- rel = ' '.join(sorted(rel)) or None
- rv = urlize(value, trim_url_limit, rel=rel, target=target)
- if eval_ctx.autoescape:
- rv = Markup(rv)
- return rv
-
-
-def do_indent(
- s, width=4, first=False, blank=False, indentfirst=None
-):
- """Return a copy of the string with each line indented by 4 spaces. The
- first line and blank lines are not indented by default.
-
- :param width: Number of spaces to indent by.
- :param first: Don't skip indenting the first line.
- :param blank: Don't skip indenting empty lines.
-
- .. versionchanged:: 2.10
- Blank lines are not indented by default.
-
- Rename the ``indentfirst`` argument to ``first``.
- """
- if indentfirst is not None:
- warnings.warn(DeprecationWarning(
- 'The "indentfirst" argument is renamed to "first".'
- ), stacklevel=2)
- first = indentfirst
-
- s += u'\n' # this quirk is necessary for splitlines method
- indention = u' ' * width
-
- if blank:
- rv = (u'\n' + indention).join(s.splitlines())
- else:
- lines = s.splitlines()
- rv = lines.pop(0)
-
- if lines:
- rv += u'\n' + u'\n'.join(
- indention + line if line else line for line in lines
- )
-
- if first:
- rv = indention + rv
-
- return rv
-
-
-@environmentfilter
-def do_truncate(env, s, length=255, killwords=False, end='...', leeway=None):
- """Return a truncated copy of the string. The length is specified
- with the first parameter which defaults to ``255``. If the second
- parameter is ``true`` the filter will cut the text at length. Otherwise
- it will discard the last word. If the text was in fact
- truncated it will append an ellipsis sign (``"..."``). If you want a
- different ellipsis sign than ``"..."`` you can specify it using the
- third parameter. Strings that only exceed the length by the tolerance
- margin given in the fourth parameter will not be truncated.
-
- .. sourcecode:: jinja
-
- {{ "foo bar baz qux"|truncate(9) }}
- -> "foo..."
- {{ "foo bar baz qux"|truncate(9, True) }}
- -> "foo ba..."
- {{ "foo bar baz qux"|truncate(11) }}
- -> "foo bar baz qux"
- {{ "foo bar baz qux"|truncate(11, False, '...', 0) }}
- -> "foo bar..."
-
- The default leeway on newer Jinja2 versions is 5 and was 0 before but
- can be reconfigured globally.
- """
- if leeway is None:
- leeway = env.policies['truncate.leeway']
- assert length >= len(end), 'expected length >= %s, got %s' % (len(end), length)
- assert leeway >= 0, 'expected leeway >= 0, got %s' % leeway
- if len(s) <= length + leeway:
- return s
- if killwords:
- return s[:length - len(end)] + end
- result = s[:length - len(end)].rsplit(' ', 1)[0]
- return result + end
-
-
-@environmentfilter
-def do_wordwrap(environment, s, width=79, break_long_words=True,
- wrapstring=None):
- """
- Return a copy of the string passed to the filter wrapped after
- ``79`` characters. You can override this default using the first
- parameter. If you set the second parameter to `false` Jinja will not
- split words apart if they are longer than `width`. By default, the newlines
- will be the default newlines for the environment, but this can be changed
- using the wrapstring keyword argument.
-
- .. versionadded:: 2.7
- Added support for the `wrapstring` parameter.
- """
- if not wrapstring:
- wrapstring = environment.newline_sequence
- import textwrap
- return wrapstring.join(textwrap.wrap(s, width=width, expand_tabs=False,
- replace_whitespace=False,
- break_long_words=break_long_words))
-
-
-def do_wordcount(s):
- """Count the words in that string."""
- return len(_word_re.findall(s))
-
-
-def do_int(value, default=0, base=10):
- """Convert the value into an integer. If the
- conversion doesn't work it will return ``0``. You can
- override this default using the first parameter. You
- can also override the default base (10) in the second
- parameter, which handles input with prefixes such as
- 0b, 0o and 0x for bases 2, 8 and 16 respectively.
- The base is ignored for decimal numbers and non-string values.
- """
- try:
- if isinstance(value, string_types):
- return int(value, base)
- return int(value)
- except (TypeError, ValueError):
- # this quirk is necessary so that "42.23"|int gives 42.
- try:
- return int(float(value))
- except (TypeError, ValueError):
- return default
-
-
-def do_float(value, default=0.0):
- """Convert the value into a floating point number. If the
- conversion doesn't work it will return ``0.0``. You can
- override this default using the first parameter.
- """
- try:
- return float(value)
- except (TypeError, ValueError):
- return default
-
-
-def do_format(value, *args, **kwargs):
- """
- Apply python string formatting on an object:
-
- .. sourcecode:: jinja
-
- {{ "%s - %s"|format("Hello?", "Foo!") }}
- -> Hello? - Foo!
- """
- if args and kwargs:
- raise FilterArgumentError('can\'t handle positional and keyword '
- 'arguments at the same time')
- return soft_unicode(value) % (kwargs or args)
-
-
-def do_trim(value):
- """Strip leading and trailing whitespace."""
- return soft_unicode(value).strip()
-
-
-def do_striptags(value):
- """Strip SGML/XML tags and replace adjacent whitespace by one space.
- """
- if hasattr(value, '__html__'):
- value = value.__html__()
- return Markup(text_type(value)).striptags()
-
-
-def do_slice(value, slices, fill_with=None):
- """Slice an iterator and return a list of lists containing
- those items. Useful if you want to create a div containing
- three ul tags that represent columns:
-
- .. sourcecode:: html+jinja
-
- <div class="columwrapper">
- {%- for column in items|slice(3) %}
- <ul class="column-{{ loop.index }}">
- {%- for item in column %}
- <li>{{ item }}</li>
- {%- endfor %}
- </ul>
- {%- endfor %}
- </div>
-
- If you pass it a second argument it's used to fill missing
- values on the last iteration.
- """
- seq = list(value)
- length = len(seq)
- items_per_slice = length // slices
- slices_with_extra = length % slices
- offset = 0
- for slice_number in range(slices):
- start = offset + slice_number * items_per_slice
- if slice_number < slices_with_extra:
- offset += 1
- end = offset + (slice_number + 1) * items_per_slice
- tmp = seq[start:end]
- if fill_with is not None and slice_number >= slices_with_extra:
- tmp.append(fill_with)
- yield tmp
-
-
-def do_batch(value, linecount, fill_with=None):
- """
- A filter that batches items. It works pretty much like `slice`
- just the other way round. It returns a list of lists with the
- given number of items. If you provide a second parameter this
- is used to fill up missing items. See this example:
-
- .. sourcecode:: html+jinja
-
- <table>
- {%- for row in items|batch(3, '&nbsp;') %}
- <tr>
- {%- for column in row %}
- <td>{{ column }}</td>
- {%- endfor %}
- </tr>
- {%- endfor %}
- </table>
- """
- tmp = []
- for item in value:
- if len(tmp) == linecount:
- yield tmp
- tmp = []
- tmp.append(item)
- if tmp:
- if fill_with is not None and len(tmp) < linecount:
- tmp += [fill_with] * (linecount - len(tmp))
- yield tmp
-
-
-def do_round(value, precision=0, method='common'):
- """Round the number to a given precision. The first
- parameter specifies the precision (default is ``0``), the
- second the rounding method:
-
- - ``'common'`` rounds either up or down
- - ``'ceil'`` always rounds up
- - ``'floor'`` always rounds down
-
- If you don't specify a method ``'common'`` is used.
-
- .. sourcecode:: jinja
-
- {{ 42.55|round }}
- -> 43.0
- {{ 42.55|round(1, 'floor') }}
- -> 42.5
-
- Note that even if rounded to 0 precision, a float is returned. If
- you need a real integer, pipe it through `int`:
-
- .. sourcecode:: jinja
-
- {{ 42.55|round|int }}
- -> 43
- """
- if not method in ('common', 'ceil', 'floor'):
- raise FilterArgumentError('method must be common, ceil or floor')
- if method == 'common':
- return round(value, precision)
- func = getattr(math, method)
- return func(value * (10 ** precision)) / (10 ** precision)
-
-
-# Use a regular tuple repr here. This is what we did in the past and we
-# really want to hide this custom type as much as possible. In particular
-# we do not want to accidentally expose an auto generated repr in case
-# people start to print this out in comments or something similar for
-# debugging.
-_GroupTuple = namedtuple('_GroupTuple', ['grouper', 'list'])
-_GroupTuple.__repr__ = tuple.__repr__
-_GroupTuple.__str__ = tuple.__str__
-
-@environmentfilter
-def do_groupby(environment, value, attribute):
- """Group a sequence of objects by a common attribute.
-
- If you for example have a list of dicts or objects that represent persons
- with `gender`, `first_name` and `last_name` attributes and you want to
- group all users by genders you can do something like the following
- snippet:
-
- .. sourcecode:: html+jinja
-
- <ul>
- {% for group in persons|groupby('gender') %}
- <li>{{ group.grouper }}<ul>
- {% for person in group.list %}
- <li>{{ person.first_name }} {{ person.last_name }}</li>
- {% endfor %}</ul></li>
- {% endfor %}
- </ul>
-
- Additionally it's possible to use tuple unpacking for the grouper and
- list:
-
- .. sourcecode:: html+jinja
-
- <ul>
- {% for grouper, list in persons|groupby('gender') %}
- ...
- {% endfor %}
- </ul>
-
- As you can see the item we're grouping by is stored in the `grouper`
- attribute and the `list` contains all the objects that have this grouper
- in common.
-
- .. versionchanged:: 2.6
- It's now possible to use dotted notation to group by the child
- attribute of another attribute.
- """
- expr = make_attrgetter(environment, attribute)
- return [_GroupTuple(key, list(values)) for key, values
- in groupby(sorted(value, key=expr), expr)]
-
-
-@environmentfilter
-def do_sum(environment, iterable, attribute=None, start=0):
- """Returns the sum of a sequence of numbers plus the value of parameter
- 'start' (which defaults to 0). When the sequence is empty it returns
- start.
-
- It is also possible to sum up only certain attributes:
-
- .. sourcecode:: jinja
-
- Total: {{ items|sum(attribute='price') }}
-
- .. versionchanged:: 2.6
- The `attribute` parameter was added to allow suming up over
- attributes. Also the `start` parameter was moved on to the right.
- """
- if attribute is not None:
- iterable = imap(make_attrgetter(environment, attribute), iterable)
- return sum(iterable, start)
-
-
-def do_list(value):
- """Convert the value into a list. If it was a string the returned list
- will be a list of characters.
- """
- return list(value)
-
-
-def do_mark_safe(value):
- """Mark the value as safe which means that in an environment with automatic
- escaping enabled this variable will not be escaped.
- """
- return Markup(value)
-
-
-def do_mark_unsafe(value):
- """Mark a value as unsafe. This is the reverse operation for :func:`safe`."""
- return text_type(value)
-
-
-def do_reverse(value):
- """Reverse the object or return an iterator that iterates over it the other
- way round.
- """
- if isinstance(value, string_types):
- return value[::-1]
- try:
- return reversed(value)
- except TypeError:
- try:
- rv = list(value)
- rv.reverse()
- return rv
- except TypeError:
- raise FilterArgumentError('argument must be iterable')
-
-
-@environmentfilter
-def do_attr(environment, obj, name):
- """Get an attribute of an object. ``foo|attr("bar")`` works like
- ``foo.bar`` just that always an attribute is returned and items are not
- looked up.
-
- See :ref:`Notes on subscriptions <notes-on-subscriptions>` for more details.
- """
- try:
- name = str(name)
- except UnicodeError:
- pass
- else:
- try:
- value = getattr(obj, name)
- except AttributeError:
- pass
- else:
- if environment.sandboxed and not \
- environment.is_safe_attribute(obj, name, value):
- return environment.unsafe_undefined(obj, name)
- return value
- return environment.undefined(obj=obj, name=name)
-
-
-@contextfilter
-def do_map(*args, **kwargs):
- """Applies a filter on a sequence of objects or looks up an attribute.
- This is useful when dealing with lists of objects but you are really
- only interested in a certain value of it.
-
- The basic usage is mapping on an attribute. Imagine you have a list
- of users but you are only interested in a list of usernames:
-
- .. sourcecode:: jinja
-
- Users on this page: {{ users|map(attribute='username')|join(', ') }}
-
- Alternatively you can let it invoke a filter by passing the name of the
- filter and the arguments afterwards. A good example would be applying a
- text conversion filter on a sequence:
-
- .. sourcecode:: jinja
-
- Users on this page: {{ titles|map('lower')|join(', ') }}
-
- .. versionadded:: 2.7
- """
- seq, func = prepare_map(args, kwargs)
- if seq:
- for item in seq:
- yield func(item)
-
-
-@contextfilter
-def do_select(*args, **kwargs):
- """Filters a sequence of objects by applying a test to each object,
- and only selecting the objects with the test succeeding.
-
- If no test is specified, each object will be evaluated as a boolean.
-
- Example usage:
-
- .. sourcecode:: jinja
-
- {{ numbers|select("odd") }}
- {{ numbers|select("odd") }}
- {{ numbers|select("divisibleby", 3) }}
- {{ numbers|select("lessthan", 42) }}
- {{ strings|select("equalto", "mystring") }}
-
- .. versionadded:: 2.7
- """
- return select_or_reject(args, kwargs, lambda x: x, False)
-
-
-@contextfilter
-def do_reject(*args, **kwargs):
- """Filters a sequence of objects by applying a test to each object,
- and rejecting the objects with the test succeeding.
-
- If no test is specified, each object will be evaluated as a boolean.
-
- Example usage:
-
- .. sourcecode:: jinja
-
- {{ numbers|reject("odd") }}
-
- .. versionadded:: 2.7
- """
- return select_or_reject(args, kwargs, lambda x: not x, False)
-
-
-@contextfilter
-def do_selectattr(*args, **kwargs):
- """Filters a sequence of objects by applying a test to the specified
- attribute of each object, and only selecting the objects with the
- test succeeding.
-
- If no test is specified, the attribute's value will be evaluated as
- a boolean.
-
- Example usage:
-
- .. sourcecode:: jinja
-
- {{ users|selectattr("is_active") }}
- {{ users|selectattr("email", "none") }}
-
- .. versionadded:: 2.7
- """
- return select_or_reject(args, kwargs, lambda x: x, True)
-
-
-@contextfilter
-def do_rejectattr(*args, **kwargs):
- """Filters a sequence of objects by applying a test to the specified
- attribute of each object, and rejecting the objects with the test
- succeeding.
-
- If no test is specified, the attribute's value will be evaluated as
- a boolean.
-
- .. sourcecode:: jinja
-
- {{ users|rejectattr("is_active") }}
- {{ users|rejectattr("email", "none") }}
-
- .. versionadded:: 2.7
- """
- return select_or_reject(args, kwargs, lambda x: not x, True)
-
-
-@evalcontextfilter
-def do_tojson(eval_ctx, value, indent=None):
- """Dumps a structure to JSON so that it's safe to use in ``<script>``
- tags. It accepts the same arguments and returns a JSON string. Note that
- this is available in templates through the ``|tojson`` filter which will
- also mark the result as safe. Due to how this function escapes certain
- characters this is safe even if used outside of ``<script>`` tags.
-
- The following characters are escaped in strings:
-
- - ``<``
- - ``>``
- - ``&``
- - ``'``
-
- This makes it safe to embed such strings in any place in HTML with the
- notable exception of double quoted attributes. In that case single
- quote your attributes or HTML escape it in addition.
-
- The indent parameter can be used to enable pretty printing. Set it to
- the number of spaces that the structures should be indented with.
-
- Note that this filter is for use in HTML contexts only.
-
- .. versionadded:: 2.9
- """
- policies = eval_ctx.environment.policies
- dumper = policies['json.dumps_function']
- options = policies['json.dumps_kwargs']
- if indent is not None:
- options = dict(options)
- options['indent'] = indent
- return htmlsafe_json_dumps(value, dumper=dumper, **options)
-
-
-def prepare_map(args, kwargs):
- context = args[0]
- seq = args[1]
-
- if len(args) == 2 and 'attribute' in kwargs:
- attribute = kwargs.pop('attribute')
- if kwargs:
- raise FilterArgumentError('Unexpected keyword argument %r' %
- next(iter(kwargs)))
- func = make_attrgetter(context.environment, attribute)
- else:
- try:
- name = args[2]
- args = args[3:]
- except LookupError:
- raise FilterArgumentError('map requires a filter argument')
- func = lambda item: context.environment.call_filter(
- name, item, args, kwargs, context=context)
-
- return seq, func
-
-
-def prepare_select_or_reject(args, kwargs, modfunc, lookup_attr):
- context = args[0]
- seq = args[1]
- if lookup_attr:
- try:
- attr = args[2]
- except LookupError:
- raise FilterArgumentError('Missing parameter for attribute name')
- transfunc = make_attrgetter(context.environment, attr)
- off = 1
- else:
- off = 0
- transfunc = lambda x: x
-
- try:
- name = args[2 + off]
- args = args[3 + off:]
- func = lambda item: context.environment.call_test(
- name, item, args, kwargs)
- except LookupError:
- func = bool
-
- return seq, lambda item: modfunc(func(transfunc(item)))
-
-
-def select_or_reject(args, kwargs, modfunc, lookup_attr):
- seq, func = prepare_select_or_reject(args, kwargs, modfunc, lookup_attr)
- if seq:
- for item in seq:
- if func(item):
- yield item
-
-
-FILTERS = {
- 'abs': abs,
- 'attr': do_attr,
- 'batch': do_batch,
- 'capitalize': do_capitalize,
- 'center': do_center,
- 'count': len,
- 'd': do_default,
- 'default': do_default,
- 'dictsort': do_dictsort,
- 'e': escape,
- 'escape': escape,
- 'filesizeformat': do_filesizeformat,
- 'first': do_first,
- 'float': do_float,
- 'forceescape': do_forceescape,
- 'format': do_format,
- 'groupby': do_groupby,
- 'indent': do_indent,
- 'int': do_int,
- 'join': do_join,
- 'last': do_last,
- 'length': len,
- 'list': do_list,
- 'lower': do_lower,
- 'map': do_map,
- 'min': do_min,
- 'max': do_max,
- 'pprint': do_pprint,
- 'random': do_random,
- 'reject': do_reject,
- 'rejectattr': do_rejectattr,
- 'replace': do_replace,
- 'reverse': do_reverse,
- 'round': do_round,
- 'safe': do_mark_safe,
- 'select': do_select,
- 'selectattr': do_selectattr,
- 'slice': do_slice,
- 'sort': do_sort,
- 'string': soft_unicode,
- 'striptags': do_striptags,
- 'sum': do_sum,
- 'title': do_title,
- 'trim': do_trim,
- 'truncate': do_truncate,
- 'unique': do_unique,
- 'upper': do_upper,
- 'urlencode': do_urlencode,
- 'urlize': do_urlize,
- 'wordcount': do_wordcount,
- 'wordwrap': do_wordwrap,
- 'xmlattr': do_xmlattr,
- 'tojson': do_tojson,
-}
diff --git a/python/jinja2/idtracking.py b/python/jinja2/idtracking.py
deleted file mode 100644
index 491bfe0..0000000
--- a/python/jinja2/idtracking.py
+++ /dev/null
@@ -1,286 +0,0 @@
-from jinja2.visitor import NodeVisitor
-from jinja2._compat import iteritems
-
-
-VAR_LOAD_PARAMETER = 'param'
-VAR_LOAD_RESOLVE = 'resolve'
-VAR_LOAD_ALIAS = 'alias'
-VAR_LOAD_UNDEFINED = 'undefined'
-
-
-def find_symbols(nodes, parent_symbols=None):
- sym = Symbols(parent=parent_symbols)
- visitor = FrameSymbolVisitor(sym)
- for node in nodes:
- visitor.visit(node)
- return sym
-
-
-def symbols_for_node(node, parent_symbols=None):
- sym = Symbols(parent=parent_symbols)
- sym.analyze_node(node)
- return sym
-
-
-class Symbols(object):
-
- def __init__(self, parent=None, level=None):
- if level is None:
- if parent is None:
- level = 0
- else:
- level = parent.level + 1
- self.level = level
- self.parent = parent
- self.refs = {}
- self.loads = {}
- self.stores = set()
-
- def analyze_node(self, node, **kwargs):
- visitor = RootVisitor(self)
- visitor.visit(node, **kwargs)
-
- def _define_ref(self, name, load=None):
- ident = 'l_%d_%s' % (self.level, name)
- self.refs[name] = ident
- if load is not None:
- self.loads[ident] = load
- return ident
-
- def find_load(self, target):
- if target in self.loads:
- return self.loads[target]
- if self.parent is not None:
- return self.parent.find_load(target)
-
- def find_ref(self, name):
- if name in self.refs:
- return self.refs[name]
- if self.parent is not None:
- return self.parent.find_ref(name)
-
- def ref(self, name):
- rv = self.find_ref(name)
- if rv is None:
- raise AssertionError('Tried to resolve a name to a reference that '
- 'was unknown to the frame (%r)' % name)
- return rv
-
- def copy(self):
- rv = object.__new__(self.__class__)
- rv.__dict__.update(self.__dict__)
- rv.refs = self.refs.copy()
- rv.loads = self.loads.copy()
- rv.stores = self.stores.copy()
- return rv
-
- def store(self, name):
- self.stores.add(name)
-
- # If we have not see the name referenced yet, we need to figure
- # out what to set it to.
- if name not in self.refs:
- # If there is a parent scope we check if the name has a
- # reference there. If it does it means we might have to alias
- # to a variable there.
- if self.parent is not None:
- outer_ref = self.parent.find_ref(name)
- if outer_ref is not None:
- self._define_ref(name, load=(VAR_LOAD_ALIAS, outer_ref))
- return
-
- # Otherwise we can just set it to undefined.
- self._define_ref(name, load=(VAR_LOAD_UNDEFINED, None))
-
- def declare_parameter(self, name):
- self.stores.add(name)
- return self._define_ref(name, load=(VAR_LOAD_PARAMETER, None))
-
- def load(self, name):
- target = self.find_ref(name)
- if target is None:
- self._define_ref(name, load=(VAR_LOAD_RESOLVE, name))
-
- def branch_update(self, branch_symbols):
- stores = {}
- for branch in branch_symbols:
- for target in branch.stores:
- if target in self.stores:
- continue
- stores[target] = stores.get(target, 0) + 1
-
- for sym in branch_symbols:
- self.refs.update(sym.refs)
- self.loads.update(sym.loads)
- self.stores.update(sym.stores)
-
- for name, branch_count in iteritems(stores):
- if branch_count == len(branch_symbols):
- continue
- target = self.find_ref(name)
- assert target is not None, 'should not happen'
-
- if self.parent is not None:
- outer_target = self.parent.find_ref(name)
- if outer_target is not None:
- self.loads[target] = (VAR_LOAD_ALIAS, outer_target)
- continue
- self.loads[target] = (VAR_LOAD_RESOLVE, name)
-
- def dump_stores(self):
- rv = {}
- node = self
- while node is not None:
- for name in node.stores:
- if name not in rv:
- rv[name] = self.find_ref(name)
- node = node.parent
- return rv
-
- def dump_param_targets(self):
- rv = set()
- node = self
- while node is not None:
- for target, (instr, _) in iteritems(self.loads):
- if instr == VAR_LOAD_PARAMETER:
- rv.add(target)
- node = node.parent
- return rv
-
-
-class RootVisitor(NodeVisitor):
-
- def __init__(self, symbols):
- self.sym_visitor = FrameSymbolVisitor(symbols)
-
- def _simple_visit(self, node, **kwargs):
- for child in node.iter_child_nodes():
- self.sym_visitor.visit(child)
-
- visit_Template = visit_Block = visit_Macro = visit_FilterBlock = \
- visit_Scope = visit_If = visit_ScopedEvalContextModifier = \
- _simple_visit
-
- def visit_AssignBlock(self, node, **kwargs):
- for child in node.body:
- self.sym_visitor.visit(child)
-
- def visit_CallBlock(self, node, **kwargs):
- for child in node.iter_child_nodes(exclude=('call',)):
- self.sym_visitor.visit(child)
-
- def visit_OverlayScope(self, node, **kwargs):
- for child in node.body:
- self.sym_visitor.visit(child)
-
- def visit_For(self, node, for_branch='body', **kwargs):
- if for_branch == 'body':
- self.sym_visitor.visit(node.target, store_as_param=True)
- branch = node.body
- elif for_branch == 'else':
- branch = node.else_
- elif for_branch == 'test':
- self.sym_visitor.visit(node.target, store_as_param=True)
- if node.test is not None:
- self.sym_visitor.visit(node.test)
- return
- else:
- raise RuntimeError('Unknown for branch')
- for item in branch or ():
- self.sym_visitor.visit(item)
-
- def visit_With(self, node, **kwargs):
- for target in node.targets:
- self.sym_visitor.visit(target)
- for child in node.body:
- self.sym_visitor.visit(child)
-
- def generic_visit(self, node, *args, **kwargs):
- raise NotImplementedError('Cannot find symbols for %r' %
- node.__class__.__name__)
-
-
-class FrameSymbolVisitor(NodeVisitor):
- """A visitor for `Frame.inspect`."""
-
- def __init__(self, symbols):
- self.symbols = symbols
-
- def visit_Name(self, node, store_as_param=False, **kwargs):
- """All assignments to names go through this function."""
- if store_as_param or node.ctx == 'param':
- self.symbols.declare_parameter(node.name)
- elif node.ctx == 'store':
- self.symbols.store(node.name)
- elif node.ctx == 'load':
- self.symbols.load(node.name)
-
- def visit_NSRef(self, node, **kwargs):
- self.symbols.load(node.name)
-
- def visit_If(self, node, **kwargs):
- self.visit(node.test, **kwargs)
-
- original_symbols = self.symbols
-
- def inner_visit(nodes):
- self.symbols = rv = original_symbols.copy()
- for subnode in nodes:
- self.visit(subnode, **kwargs)
- self.symbols = original_symbols
- return rv
-
- body_symbols = inner_visit(node.body)
- elif_symbols = inner_visit(node.elif_)
- else_symbols = inner_visit(node.else_ or ())
-
- self.symbols.branch_update([body_symbols, elif_symbols, else_symbols])
-
- def visit_Macro(self, node, **kwargs):
- self.symbols.store(node.name)
-
- def visit_Import(self, node, **kwargs):
- self.generic_visit(node, **kwargs)
- self.symbols.store(node.target)
-
- def visit_FromImport(self, node, **kwargs):
- self.generic_visit(node, **kwargs)
- for name in node.names:
- if isinstance(name, tuple):
- self.symbols.store(name[1])
- else:
- self.symbols.store(name)
-
- def visit_Assign(self, node, **kwargs):
- """Visit assignments in the correct order."""
- self.visit(node.node, **kwargs)
- self.visit(node.target, **kwargs)
-
- def visit_For(self, node, **kwargs):
- """Visiting stops at for blocks. However the block sequence
- is visited as part of the outer scope.
- """
- self.visit(node.iter, **kwargs)
-
- def visit_CallBlock(self, node, **kwargs):
- self.visit(node.call, **kwargs)
-
- def visit_FilterBlock(self, node, **kwargs):
- self.visit(node.filter, **kwargs)
-
- def visit_With(self, node, **kwargs):
- for target in node.values:
- self.visit(target)
-
- def visit_AssignBlock(self, node, **kwargs):
- """Stop visiting at block assigns."""
- self.visit(node.target, **kwargs)
-
- def visit_Scope(self, node, **kwargs):
- """Stop visiting at scopes."""
-
- def visit_Block(self, node, **kwargs):
- """Stop visiting at blocks."""
-
- def visit_OverlayScope(self, node, **kwargs):
- """Do not visit into overlay scopes."""
diff --git a/python/jinja2/lexer.py b/python/jinja2/lexer.py
deleted file mode 100644
index 6fd135d..0000000
--- a/python/jinja2/lexer.py
+++ /dev/null
@@ -1,739 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.lexer
- ~~~~~~~~~~~~
-
- This module implements a Jinja / Python combination lexer. The
- `Lexer` class provided by this module is used to do some preprocessing
- for Jinja.
-
- On the one hand it filters out invalid operators like the bitshift
- operators we don't allow in templates. On the other hand it separates
- template code and python code in expressions.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import re
-from collections import deque
-from operator import itemgetter
-
-from jinja2._compat import implements_iterator, intern, iteritems, text_type
-from jinja2.exceptions import TemplateSyntaxError
-from jinja2.utils import LRUCache
-
-# cache for the lexers. Exists in order to be able to have multiple
-# environments with the same lexer
-_lexer_cache = LRUCache(50)
-
-# static regular expressions
-whitespace_re = re.compile(r'\s+', re.U)
-string_re = re.compile(r"('([^'\\]*(?:\\.[^'\\]*)*)'"
- r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.S)
-integer_re = re.compile(r'\d+')
-
-try:
- # check if this Python supports Unicode identifiers
- compile('föö', '<unknown>', 'eval')
-except SyntaxError:
- # no Unicode support, use ASCII identifiers
- name_re = re.compile(r'[a-zA-Z_][a-zA-Z0-9_]*')
- check_ident = False
-else:
- # Unicode support, build a pattern to match valid characters, and set flag
- # to use str.isidentifier to validate during lexing
- from jinja2 import _identifier
- name_re = re.compile(r'[\w{0}]+'.format(_identifier.pattern))
- check_ident = True
- # remove the pattern from memory after building the regex
- import sys
- del sys.modules['jinja2._identifier']
- import jinja2
- del jinja2._identifier
- del _identifier
-
-float_re = re.compile(r'(?<!\.)\d+\.\d+')
-newline_re = re.compile(r'(\r\n|\r|\n)')
-
-# internal the tokens and keep references to them
-TOKEN_ADD = intern('add')
-TOKEN_ASSIGN = intern('assign')
-TOKEN_COLON = intern('colon')
-TOKEN_COMMA = intern('comma')
-TOKEN_DIV = intern('div')
-TOKEN_DOT = intern('dot')
-TOKEN_EQ = intern('eq')
-TOKEN_FLOORDIV = intern('floordiv')
-TOKEN_GT = intern('gt')
-TOKEN_GTEQ = intern('gteq')
-TOKEN_LBRACE = intern('lbrace')
-TOKEN_LBRACKET = intern('lbracket')
-TOKEN_LPAREN = intern('lparen')
-TOKEN_LT = intern('lt')
-TOKEN_LTEQ = intern('lteq')
-TOKEN_MOD = intern('mod')
-TOKEN_MUL = intern('mul')
-TOKEN_NE = intern('ne')
-TOKEN_PIPE = intern('pipe')
-TOKEN_POW = intern('pow')
-TOKEN_RBRACE = intern('rbrace')
-TOKEN_RBRACKET = intern('rbracket')
-TOKEN_RPAREN = intern('rparen')
-TOKEN_SEMICOLON = intern('semicolon')
-TOKEN_SUB = intern('sub')
-TOKEN_TILDE = intern('tilde')
-TOKEN_WHITESPACE = intern('whitespace')
-TOKEN_FLOAT = intern('float')
-TOKEN_INTEGER = intern('integer')
-TOKEN_NAME = intern('name')
-TOKEN_STRING = intern('string')
-TOKEN_OPERATOR = intern('operator')
-TOKEN_BLOCK_BEGIN = intern('block_begin')
-TOKEN_BLOCK_END = intern('block_end')
-TOKEN_VARIABLE_BEGIN = intern('variable_begin')
-TOKEN_VARIABLE_END = intern('variable_end')
-TOKEN_RAW_BEGIN = intern('raw_begin')
-TOKEN_RAW_END = intern('raw_end')
-TOKEN_COMMENT_BEGIN = intern('comment_begin')
-TOKEN_COMMENT_END = intern('comment_end')
-TOKEN_COMMENT = intern('comment')
-TOKEN_LINESTATEMENT_BEGIN = intern('linestatement_begin')
-TOKEN_LINESTATEMENT_END = intern('linestatement_end')
-TOKEN_LINECOMMENT_BEGIN = intern('linecomment_begin')
-TOKEN_LINECOMMENT_END = intern('linecomment_end')
-TOKEN_LINECOMMENT = intern('linecomment')
-TOKEN_DATA = intern('data')
-TOKEN_INITIAL = intern('initial')
-TOKEN_EOF = intern('eof')
-
-# bind operators to token types
-operators = {
- '+': TOKEN_ADD,
- '-': TOKEN_SUB,
- '/': TOKEN_DIV,
- '//': TOKEN_FLOORDIV,
- '*': TOKEN_MUL,
- '%': TOKEN_MOD,
- '**': TOKEN_POW,
- '~': TOKEN_TILDE,
- '[': TOKEN_LBRACKET,
- ']': TOKEN_RBRACKET,
- '(': TOKEN_LPAREN,
- ')': TOKEN_RPAREN,
- '{': TOKEN_LBRACE,
- '}': TOKEN_RBRACE,
- '==': TOKEN_EQ,
- '!=': TOKEN_NE,
- '>': TOKEN_GT,
- '>=': TOKEN_GTEQ,
- '<': TOKEN_LT,
- '<=': TOKEN_LTEQ,
- '=': TOKEN_ASSIGN,
- '.': TOKEN_DOT,
- ':': TOKEN_COLON,
- '|': TOKEN_PIPE,
- ',': TOKEN_COMMA,
- ';': TOKEN_SEMICOLON
-}
-
-reverse_operators = dict([(v, k) for k, v in iteritems(operators)])
-assert len(operators) == len(reverse_operators), 'operators dropped'
-operator_re = re.compile('(%s)' % '|'.join(re.escape(x) for x in
- sorted(operators, key=lambda x: -len(x))))
-
-ignored_tokens = frozenset([TOKEN_COMMENT_BEGIN, TOKEN_COMMENT,
- TOKEN_COMMENT_END, TOKEN_WHITESPACE,
- TOKEN_LINECOMMENT_BEGIN, TOKEN_LINECOMMENT_END,
- TOKEN_LINECOMMENT])
-ignore_if_empty = frozenset([TOKEN_WHITESPACE, TOKEN_DATA,
- TOKEN_COMMENT, TOKEN_LINECOMMENT])
-
-
-def _describe_token_type(token_type):
- if token_type in reverse_operators:
- return reverse_operators[token_type]
- return {
- TOKEN_COMMENT_BEGIN: 'begin of comment',
- TOKEN_COMMENT_END: 'end of comment',
- TOKEN_COMMENT: 'comment',
- TOKEN_LINECOMMENT: 'comment',
- TOKEN_BLOCK_BEGIN: 'begin of statement block',
- TOKEN_BLOCK_END: 'end of statement block',
- TOKEN_VARIABLE_BEGIN: 'begin of print statement',
- TOKEN_VARIABLE_END: 'end of print statement',
- TOKEN_LINESTATEMENT_BEGIN: 'begin of line statement',
- TOKEN_LINESTATEMENT_END: 'end of line statement',
- TOKEN_DATA: 'template data / text',
- TOKEN_EOF: 'end of template'
- }.get(token_type, token_type)
-
-
-def describe_token(token):
- """Returns a description of the token."""
- if token.type == 'name':
- return token.value
- return _describe_token_type(token.type)
-
-
-def describe_token_expr(expr):
- """Like `describe_token` but for token expressions."""
- if ':' in expr:
- type, value = expr.split(':', 1)
- if type == 'name':
- return value
- else:
- type = expr
- return _describe_token_type(type)
-
-
-def count_newlines(value):
- """Count the number of newline characters in the string. This is
- useful for extensions that filter a stream.
- """
- return len(newline_re.findall(value))
-
-
-def compile_rules(environment):
- """Compiles all the rules from the environment into a list of rules."""
- e = re.escape
- rules = [
- (len(environment.comment_start_string), 'comment',
- e(environment.comment_start_string)),
- (len(environment.block_start_string), 'block',
- e(environment.block_start_string)),
- (len(environment.variable_start_string), 'variable',
- e(environment.variable_start_string))
- ]
-
- if environment.line_statement_prefix is not None:
- rules.append((len(environment.line_statement_prefix), 'linestatement',
- r'^[ \t\v]*' + e(environment.line_statement_prefix)))
- if environment.line_comment_prefix is not None:
- rules.append((len(environment.line_comment_prefix), 'linecomment',
- r'(?:^|(?<=\S))[^\S\r\n]*' +
- e(environment.line_comment_prefix)))
-
- return [x[1:] for x in sorted(rules, reverse=True)]
-
-
-class Failure(object):
- """Class that raises a `TemplateSyntaxError` if called.
- Used by the `Lexer` to specify known errors.
- """
-
- def __init__(self, message, cls=TemplateSyntaxError):
- self.message = message
- self.error_class = cls
-
- def __call__(self, lineno, filename):
- raise self.error_class(self.message, lineno, filename)
-
-
-class Token(tuple):
- """Token class."""
- __slots__ = ()
- lineno, type, value = (property(itemgetter(x)) for x in range(3))
-
- def __new__(cls, lineno, type, value):
- return tuple.__new__(cls, (lineno, intern(str(type)), value))
-
- def __str__(self):
- if self.type in reverse_operators:
- return reverse_operators[self.type]
- elif self.type == 'name':
- return self.value
- return self.type
-
- def test(self, expr):
- """Test a token against a token expression. This can either be a
- token type or ``'token_type:token_value'``. This can only test
- against string values and types.
- """
- # here we do a regular string equality check as test_any is usually
- # passed an iterable of not interned strings.
- if self.type == expr:
- return True
- elif ':' in expr:
- return expr.split(':', 1) == [self.type, self.value]
- return False
-
- def test_any(self, *iterable):
- """Test against multiple token expressions."""
- for expr in iterable:
- if self.test(expr):
- return True
- return False
-
- def __repr__(self):
- return 'Token(%r, %r, %r)' % (
- self.lineno,
- self.type,
- self.value
- )
-
-
-@implements_iterator
-class TokenStreamIterator(object):
- """The iterator for tokenstreams. Iterate over the stream
- until the eof token is reached.
- """
-
- def __init__(self, stream):
- self.stream = stream
-
- def __iter__(self):
- return self
-
- def __next__(self):
- token = self.stream.current
- if token.type is TOKEN_EOF:
- self.stream.close()
- raise StopIteration()
- next(self.stream)
- return token
-
-
-@implements_iterator
-class TokenStream(object):
- """A token stream is an iterable that yields :class:`Token`\\s. The
- parser however does not iterate over it but calls :meth:`next` to go
- one token ahead. The current active token is stored as :attr:`current`.
- """
-
- def __init__(self, generator, name, filename):
- self._iter = iter(generator)
- self._pushed = deque()
- self.name = name
- self.filename = filename
- self.closed = False
- self.current = Token(1, TOKEN_INITIAL, '')
- next(self)
-
- def __iter__(self):
- return TokenStreamIterator(self)
-
- def __bool__(self):
- return bool(self._pushed) or self.current.type is not TOKEN_EOF
- __nonzero__ = __bool__ # py2
-
- eos = property(lambda x: not x, doc="Are we at the end of the stream?")
-
- def push(self, token):
- """Push a token back to the stream."""
- self._pushed.append(token)
-
- def look(self):
- """Look at the next token."""
- old_token = next(self)
- result = self.current
- self.push(result)
- self.current = old_token
- return result
-
- def skip(self, n=1):
- """Got n tokens ahead."""
- for x in range(n):
- next(self)
-
- def next_if(self, expr):
- """Perform the token test and return the token if it matched.
- Otherwise the return value is `None`.
- """
- if self.current.test(expr):
- return next(self)
-
- def skip_if(self, expr):
- """Like :meth:`next_if` but only returns `True` or `False`."""
- return self.next_if(expr) is not None
-
- def __next__(self):
- """Go one token ahead and return the old one.
-
- Use the built-in :func:`next` instead of calling this directly.
- """
- rv = self.current
- if self._pushed:
- self.current = self._pushed.popleft()
- elif self.current.type is not TOKEN_EOF:
- try:
- self.current = next(self._iter)
- except StopIteration:
- self.close()
- return rv
-
- def close(self):
- """Close the stream."""
- self.current = Token(self.current.lineno, TOKEN_EOF, '')
- self._iter = None
- self.closed = True
-
- def expect(self, expr):
- """Expect a given token type and return it. This accepts the same
- argument as :meth:`jinja2.lexer.Token.test`.
- """
- if not self.current.test(expr):
- expr = describe_token_expr(expr)
- if self.current.type is TOKEN_EOF:
- raise TemplateSyntaxError('unexpected end of template, '
- 'expected %r.' % expr,
- self.current.lineno,
- self.name, self.filename)
- raise TemplateSyntaxError("expected token %r, got %r" %
- (expr, describe_token(self.current)),
- self.current.lineno,
- self.name, self.filename)
- try:
- return self.current
- finally:
- next(self)
-
-
-def get_lexer(environment):
- """Return a lexer which is probably cached."""
- key = (environment.block_start_string,
- environment.block_end_string,
- environment.variable_start_string,
- environment.variable_end_string,
- environment.comment_start_string,
- environment.comment_end_string,
- environment.line_statement_prefix,
- environment.line_comment_prefix,
- environment.trim_blocks,
- environment.lstrip_blocks,
- environment.newline_sequence,
- environment.keep_trailing_newline)
- lexer = _lexer_cache.get(key)
- if lexer is None:
- lexer = Lexer(environment)
- _lexer_cache[key] = lexer
- return lexer
-
-
-class Lexer(object):
- """Class that implements a lexer for a given environment. Automatically
- created by the environment class, usually you don't have to do that.
-
- Note that the lexer is not automatically bound to an environment.
- Multiple environments can share the same lexer.
- """
-
- def __init__(self, environment):
- # shortcuts
- c = lambda x: re.compile(x, re.M | re.S)
- e = re.escape
-
- # lexing rules for tags
- tag_rules = [
- (whitespace_re, TOKEN_WHITESPACE, None),
- (float_re, TOKEN_FLOAT, None),
- (integer_re, TOKEN_INTEGER, None),
- (name_re, TOKEN_NAME, None),
- (string_re, TOKEN_STRING, None),
- (operator_re, TOKEN_OPERATOR, None)
- ]
-
- # assemble the root lexing rule. because "|" is ungreedy
- # we have to sort by length so that the lexer continues working
- # as expected when we have parsing rules like <% for block and
- # <%= for variables. (if someone wants asp like syntax)
- # variables are just part of the rules if variable processing
- # is required.
- root_tag_rules = compile_rules(environment)
-
- # block suffix if trimming is enabled
- block_suffix_re = environment.trim_blocks and '\\n?' or ''
-
- # strip leading spaces if lstrip_blocks is enabled
- prefix_re = {}
- if environment.lstrip_blocks:
- # use '{%+' to manually disable lstrip_blocks behavior
- no_lstrip_re = e('+')
- # detect overlap between block and variable or comment strings
- block_diff = c(r'^%s(.*)' % e(environment.block_start_string))
- # make sure we don't mistake a block for a variable or a comment
- m = block_diff.match(environment.comment_start_string)
- no_lstrip_re += m and r'|%s' % e(m.group(1)) or ''
- m = block_diff.match(environment.variable_start_string)
- no_lstrip_re += m and r'|%s' % e(m.group(1)) or ''
-
- # detect overlap between comment and variable strings
- comment_diff = c(r'^%s(.*)' % e(environment.comment_start_string))
- m = comment_diff.match(environment.variable_start_string)
- no_variable_re = m and r'(?!%s)' % e(m.group(1)) or ''
-
- lstrip_re = r'^[ \t]*'
- block_prefix_re = r'%s%s(?!%s)|%s\+?' % (
- lstrip_re,
- e(environment.block_start_string),
- no_lstrip_re,
- e(environment.block_start_string),
- )
- comment_prefix_re = r'%s%s%s|%s\+?' % (
- lstrip_re,
- e(environment.comment_start_string),
- no_variable_re,
- e(environment.comment_start_string),
- )
- prefix_re['block'] = block_prefix_re
- prefix_re['comment'] = comment_prefix_re
- else:
- block_prefix_re = '%s' % e(environment.block_start_string)
-
- self.newline_sequence = environment.newline_sequence
- self.keep_trailing_newline = environment.keep_trailing_newline
-
- # global lexing rules
- self.rules = {
- 'root': [
- # directives
- (c('(.*?)(?:%s)' % '|'.join(
- [r'(?P<raw_begin>(?:\s*%s\-|%s)\s*raw\s*(?:\-%s\s*|%s))' % (
- e(environment.block_start_string),
- block_prefix_re,
- e(environment.block_end_string),
- e(environment.block_end_string)
- )] + [
- r'(?P<%s_begin>\s*%s\-|%s)' % (n, r, prefix_re.get(n,r))
- for n, r in root_tag_rules
- ])), (TOKEN_DATA, '#bygroup'), '#bygroup'),
- # data
- (c('.+'), TOKEN_DATA, None)
- ],
- # comments
- TOKEN_COMMENT_BEGIN: [
- (c(r'(.*?)((?:\-%s\s*|%s)%s)' % (
- e(environment.comment_end_string),
- e(environment.comment_end_string),
- block_suffix_re
- )), (TOKEN_COMMENT, TOKEN_COMMENT_END), '#pop'),
- (c('(.)'), (Failure('Missing end of comment tag'),), None)
- ],
- # blocks
- TOKEN_BLOCK_BEGIN: [
- (c(r'(?:\-%s\s*|%s)%s' % (
- e(environment.block_end_string),
- e(environment.block_end_string),
- block_suffix_re
- )), TOKEN_BLOCK_END, '#pop'),
- ] + tag_rules,
- # variables
- TOKEN_VARIABLE_BEGIN: [
- (c(r'\-%s\s*|%s' % (
- e(environment.variable_end_string),
- e(environment.variable_end_string)
- )), TOKEN_VARIABLE_END, '#pop')
- ] + tag_rules,
- # raw block
- TOKEN_RAW_BEGIN: [
- (c(r'(.*?)((?:\s*%s\-|%s)\s*endraw\s*(?:\-%s\s*|%s%s))' % (
- e(environment.block_start_string),
- block_prefix_re,
- e(environment.block_end_string),
- e(environment.block_end_string),
- block_suffix_re
- )), (TOKEN_DATA, TOKEN_RAW_END), '#pop'),
- (c('(.)'), (Failure('Missing end of raw directive'),), None)
- ],
- # line statements
- TOKEN_LINESTATEMENT_BEGIN: [
- (c(r'\s*(\n|$)'), TOKEN_LINESTATEMENT_END, '#pop')
- ] + tag_rules,
- # line comments
- TOKEN_LINECOMMENT_BEGIN: [
- (c(r'(.*?)()(?=\n|$)'), (TOKEN_LINECOMMENT,
- TOKEN_LINECOMMENT_END), '#pop')
- ]
- }
-
- def _normalize_newlines(self, value):
- """Called for strings and template data to normalize it to unicode."""
- return newline_re.sub(self.newline_sequence, value)
-
- def tokenize(self, source, name=None, filename=None, state=None):
- """Calls tokeniter + tokenize and wraps it in a token stream.
- """
- stream = self.tokeniter(source, name, filename, state)
- return TokenStream(self.wrap(stream, name, filename), name, filename)
-
- def wrap(self, stream, name=None, filename=None):
- """This is called with the stream as returned by `tokenize` and wraps
- every token in a :class:`Token` and converts the value.
- """
- for lineno, token, value in stream:
- if token in ignored_tokens:
- continue
- elif token == 'linestatement_begin':
- token = 'block_begin'
- elif token == 'linestatement_end':
- token = 'block_end'
- # we are not interested in those tokens in the parser
- elif token in ('raw_begin', 'raw_end'):
- continue
- elif token == 'data':
- value = self._normalize_newlines(value)
- elif token == 'keyword':
- token = value
- elif token == 'name':
- value = str(value)
- if check_ident and not value.isidentifier():
- raise TemplateSyntaxError(
- 'Invalid character in identifier',
- lineno, name, filename)
- elif token == 'string':
- # try to unescape string
- try:
- value = self._normalize_newlines(value[1:-1]) \
- .encode('ascii', 'backslashreplace') \
- .decode('unicode-escape')
- except Exception as e:
- msg = str(e).split(':')[-1].strip()
- raise TemplateSyntaxError(msg, lineno, name, filename)
- elif token == 'integer':
- value = int(value)
- elif token == 'float':
- value = float(value)
- elif token == 'operator':
- token = operators[value]
- yield Token(lineno, token, value)
-
- def tokeniter(self, source, name, filename=None, state=None):
- """This method tokenizes the text and returns the tokens in a
- generator. Use this method if you just want to tokenize a template.
- """
- source = text_type(source)
- lines = source.splitlines()
- if self.keep_trailing_newline and source:
- for newline in ('\r\n', '\r', '\n'):
- if source.endswith(newline):
- lines.append('')
- break
- source = '\n'.join(lines)
- pos = 0
- lineno = 1
- stack = ['root']
- if state is not None and state != 'root':
- assert state in ('variable', 'block'), 'invalid state'
- stack.append(state + '_begin')
- else:
- state = 'root'
- statetokens = self.rules[stack[-1]]
- source_length = len(source)
-
- balancing_stack = []
-
- while 1:
- # tokenizer loop
- for regex, tokens, new_state in statetokens:
- m = regex.match(source, pos)
- # if no match we try again with the next rule
- if m is None:
- continue
-
- # we only match blocks and variables if braces / parentheses
- # are balanced. continue parsing with the lower rule which
- # is the operator rule. do this only if the end tags look
- # like operators
- if balancing_stack and \
- tokens in ('variable_end', 'block_end',
- 'linestatement_end'):
- continue
-
- # tuples support more options
- if isinstance(tokens, tuple):
- for idx, token in enumerate(tokens):
- # failure group
- if token.__class__ is Failure:
- raise token(lineno, filename)
- # bygroup is a bit more complex, in that case we
- # yield for the current token the first named
- # group that matched
- elif token == '#bygroup':
- for key, value in iteritems(m.groupdict()):
- if value is not None:
- yield lineno, key, value
- lineno += value.count('\n')
- break
- else:
- raise RuntimeError('%r wanted to resolve '
- 'the token dynamically'
- ' but no group matched'
- % regex)
- # normal group
- else:
- data = m.group(idx + 1)
- if data or token not in ignore_if_empty:
- yield lineno, token, data
- lineno += data.count('\n')
-
- # strings as token just are yielded as it.
- else:
- data = m.group()
- # update brace/parentheses balance
- if tokens == 'operator':
- if data == '{':
- balancing_stack.append('}')
- elif data == '(':
- balancing_stack.append(')')
- elif data == '[':
- balancing_stack.append(']')
- elif data in ('}', ')', ']'):
- if not balancing_stack:
- raise TemplateSyntaxError('unexpected \'%s\'' %
- data, lineno, name,
- filename)
- expected_op = balancing_stack.pop()
- if expected_op != data:
- raise TemplateSyntaxError('unexpected \'%s\', '
- 'expected \'%s\'' %
- (data, expected_op),
- lineno, name,
- filename)
- # yield items
- if data or tokens not in ignore_if_empty:
- yield lineno, tokens, data
- lineno += data.count('\n')
-
- # fetch new position into new variable so that we can check
- # if there is a internal parsing error which would result
- # in an infinite loop
- pos2 = m.end()
-
- # handle state changes
- if new_state is not None:
- # remove the uppermost state
- if new_state == '#pop':
- stack.pop()
- # resolve the new state by group checking
- elif new_state == '#bygroup':
- for key, value in iteritems(m.groupdict()):
- if value is not None:
- stack.append(key)
- break
- else:
- raise RuntimeError('%r wanted to resolve the '
- 'new state dynamically but'
- ' no group matched' %
- regex)
- # direct state name given
- else:
- stack.append(new_state)
- statetokens = self.rules[stack[-1]]
- # we are still at the same position and no stack change.
- # this means a loop without break condition, avoid that and
- # raise error
- elif pos2 == pos:
- raise RuntimeError('%r yielded empty string without '
- 'stack change' % regex)
- # publish new function and start again
- pos = pos2
- break
- # if loop terminated without break we haven't found a single match
- # either we are at the end of the file or we have a problem
- else:
- # end of text
- if pos >= source_length:
- return
- # something went wrong
- raise TemplateSyntaxError('unexpected char %r at %d' %
- (source[pos], pos), lineno,
- name, filename)
diff --git a/python/jinja2/loaders.py b/python/jinja2/loaders.py
deleted file mode 100644
index 4c79793..0000000
--- a/python/jinja2/loaders.py
+++ /dev/null
@@ -1,481 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.loaders
- ~~~~~~~~~~~~~~
-
- Jinja loader classes.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import os
-import sys
-import weakref
-from types import ModuleType
-from os import path
-from hashlib import sha1
-from jinja2.exceptions import TemplateNotFound
-from jinja2.utils import open_if_exists, internalcode
-from jinja2._compat import string_types, iteritems
-
-
-def split_template_path(template):
- """Split a path into segments and perform a sanity check. If it detects
- '..' in the path it will raise a `TemplateNotFound` error.
- """
- pieces = []
- for piece in template.split('/'):
- if path.sep in piece \
- or (path.altsep and path.altsep in piece) or \
- piece == path.pardir:
- raise TemplateNotFound(template)
- elif piece and piece != '.':
- pieces.append(piece)
- return pieces
-
-
-class BaseLoader(object):
- """Baseclass for all loaders. Subclass this and override `get_source` to
- implement a custom loading mechanism. The environment provides a
- `get_template` method that calls the loader's `load` method to get the
- :class:`Template` object.
-
- A very basic example for a loader that looks up templates on the file
- system could look like this::
-
- from jinja2 import BaseLoader, TemplateNotFound
- from os.path import join, exists, getmtime
-
- class MyLoader(BaseLoader):
-
- def __init__(self, path):
- self.path = path
-
- def get_source(self, environment, template):
- path = join(self.path, template)
- if not exists(path):
- raise TemplateNotFound(template)
- mtime = getmtime(path)
- with file(path) as f:
- source = f.read().decode('utf-8')
- return source, path, lambda: mtime == getmtime(path)
- """
-
- #: if set to `False` it indicates that the loader cannot provide access
- #: to the source of templates.
- #:
- #: .. versionadded:: 2.4
- has_source_access = True
-
- def get_source(self, environment, template):
- """Get the template source, filename and reload helper for a template.
- It's passed the environment and template name and has to return a
- tuple in the form ``(source, filename, uptodate)`` or raise a
- `TemplateNotFound` error if it can't locate the template.
-
- The source part of the returned tuple must be the source of the
- template as unicode string or a ASCII bytestring. The filename should
- be the name of the file on the filesystem if it was loaded from there,
- otherwise `None`. The filename is used by python for the tracebacks
- if no loader extension is used.
-
- The last item in the tuple is the `uptodate` function. If auto
- reloading is enabled it's always called to check if the template
- changed. No arguments are passed so the function must store the
- old state somewhere (for example in a closure). If it returns `False`
- the template will be reloaded.
- """
- if not self.has_source_access:
- raise RuntimeError('%s cannot provide access to the source' %
- self.__class__.__name__)
- raise TemplateNotFound(template)
-
- def list_templates(self):
- """Iterates over all templates. If the loader does not support that
- it should raise a :exc:`TypeError` which is the default behavior.
- """
- raise TypeError('this loader cannot iterate over all templates')
-
- @internalcode
- def load(self, environment, name, globals=None):
- """Loads a template. This method looks up the template in the cache
- or loads one by calling :meth:`get_source`. Subclasses should not
- override this method as loaders working on collections of other
- loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
- will not call this method but `get_source` directly.
- """
- code = None
- if globals is None:
- globals = {}
-
- # first we try to get the source for this template together
- # with the filename and the uptodate function.
- source, filename, uptodate = self.get_source(environment, name)
-
- # try to load the code from the bytecode cache if there is a
- # bytecode cache configured.
- bcc = environment.bytecode_cache
- if bcc is not None:
- bucket = bcc.get_bucket(environment, name, filename, source)
- code = bucket.code
-
- # if we don't have code so far (not cached, no longer up to
- # date) etc. we compile the template
- if code is None:
- code = environment.compile(source, name, filename)
-
- # if the bytecode cache is available and the bucket doesn't
- # have a code so far, we give the bucket the new code and put
- # it back to the bytecode cache.
- if bcc is not None and bucket.code is None:
- bucket.code = code
- bcc.set_bucket(bucket)
-
- return environment.template_class.from_code(environment, code,
- globals, uptodate)
-
-
-class FileSystemLoader(BaseLoader):
- """Loads templates from the file system. This loader can find templates
- in folders on the file system and is the preferred way to load them.
-
- The loader takes the path to the templates as string, or if multiple
- locations are wanted a list of them which is then looked up in the
- given order::
-
- >>> loader = FileSystemLoader('/path/to/templates')
- >>> loader = FileSystemLoader(['/path/to/templates', '/other/path'])
-
- Per default the template encoding is ``'utf-8'`` which can be changed
- by setting the `encoding` parameter to something else.
-
- To follow symbolic links, set the *followlinks* parameter to ``True``::
-
- >>> loader = FileSystemLoader('/path/to/templates', followlinks=True)
-
- .. versionchanged:: 2.8+
- The *followlinks* parameter was added.
- """
-
- def __init__(self, searchpath, encoding='utf-8', followlinks=False):
- if isinstance(searchpath, string_types):
- searchpath = [searchpath]
- self.searchpath = list(searchpath)
- self.encoding = encoding
- self.followlinks = followlinks
-
- def get_source(self, environment, template):
- pieces = split_template_path(template)
- for searchpath in self.searchpath:
- filename = path.join(searchpath, *pieces)
- f = open_if_exists(filename)
- if f is None:
- continue
- try:
- contents = f.read().decode(self.encoding)
- finally:
- f.close()
-
- mtime = path.getmtime(filename)
-
- def uptodate():
- try:
- return path.getmtime(filename) == mtime
- except OSError:
- return False
- return contents, filename, uptodate
- raise TemplateNotFound(template)
-
- def list_templates(self):
- found = set()
- for searchpath in self.searchpath:
- walk_dir = os.walk(searchpath, followlinks=self.followlinks)
- for dirpath, dirnames, filenames in walk_dir:
- for filename in filenames:
- template = os.path.join(dirpath, filename) \
- [len(searchpath):].strip(os.path.sep) \
- .replace(os.path.sep, '/')
- if template[:2] == './':
- template = template[2:]
- if template not in found:
- found.add(template)
- return sorted(found)
-
-
-class PackageLoader(BaseLoader):
- """Load templates from python eggs or packages. It is constructed with
- the name of the python package and the path to the templates in that
- package::
-
- loader = PackageLoader('mypackage', 'views')
-
- If the package path is not given, ``'templates'`` is assumed.
-
- Per default the template encoding is ``'utf-8'`` which can be changed
- by setting the `encoding` parameter to something else. Due to the nature
- of eggs it's only possible to reload templates if the package was loaded
- from the file system and not a zip file.
- """
-
- def __init__(self, package_name, package_path='templates',
- encoding='utf-8'):
- from pkg_resources import DefaultProvider, ResourceManager, \
- get_provider
- provider = get_provider(package_name)
- self.encoding = encoding
- self.manager = ResourceManager()
- self.filesystem_bound = isinstance(provider, DefaultProvider)
- self.provider = provider
- self.package_path = package_path
-
- def get_source(self, environment, template):
- pieces = split_template_path(template)
- p = '/'.join((self.package_path,) + tuple(pieces))
- if not self.provider.has_resource(p):
- raise TemplateNotFound(template)
-
- filename = uptodate = None
- if self.filesystem_bound:
- filename = self.provider.get_resource_filename(self.manager, p)
- mtime = path.getmtime(filename)
- def uptodate():
- try:
- return path.getmtime(filename) == mtime
- except OSError:
- return False
-
- source = self.provider.get_resource_string(self.manager, p)
- return source.decode(self.encoding), filename, uptodate
-
- def list_templates(self):
- path = self.package_path
- if path[:2] == './':
- path = path[2:]
- elif path == '.':
- path = ''
- offset = len(path)
- results = []
- def _walk(path):
- for filename in self.provider.resource_listdir(path):
- fullname = path + '/' + filename
- if self.provider.resource_isdir(fullname):
- _walk(fullname)
- else:
- results.append(fullname[offset:].lstrip('/'))
- _walk(path)
- results.sort()
- return results
-
-
-class DictLoader(BaseLoader):
- """Loads a template from a python dict. It's passed a dict of unicode
- strings bound to template names. This loader is useful for unittesting:
-
- >>> loader = DictLoader({'index.html': 'source here'})
-
- Because auto reloading is rarely useful this is disabled per default.
- """
-
- def __init__(self, mapping):
- self.mapping = mapping
-
- def get_source(self, environment, template):
- if template in self.mapping:
- source = self.mapping[template]
- return source, None, lambda: source == self.mapping.get(template)
- raise TemplateNotFound(template)
-
- def list_templates(self):
- return sorted(self.mapping)
-
-
-class FunctionLoader(BaseLoader):
- """A loader that is passed a function which does the loading. The
- function receives the name of the template and has to return either
- an unicode string with the template source, a tuple in the form ``(source,
- filename, uptodatefunc)`` or `None` if the template does not exist.
-
- >>> def load_template(name):
- ... if name == 'index.html':
- ... return '...'
- ...
- >>> loader = FunctionLoader(load_template)
-
- The `uptodatefunc` is a function that is called if autoreload is enabled
- and has to return `True` if the template is still up to date. For more
- details have a look at :meth:`BaseLoader.get_source` which has the same
- return value.
- """
-
- def __init__(self, load_func):
- self.load_func = load_func
-
- def get_source(self, environment, template):
- rv = self.load_func(template)
- if rv is None:
- raise TemplateNotFound(template)
- elif isinstance(rv, string_types):
- return rv, None, None
- return rv
-
-
-class PrefixLoader(BaseLoader):
- """A loader that is passed a dict of loaders where each loader is bound
- to a prefix. The prefix is delimited from the template by a slash per
- default, which can be changed by setting the `delimiter` argument to
- something else::
-
- loader = PrefixLoader({
- 'app1': PackageLoader('mypackage.app1'),
- 'app2': PackageLoader('mypackage.app2')
- })
-
- By loading ``'app1/index.html'`` the file from the app1 package is loaded,
- by loading ``'app2/index.html'`` the file from the second.
- """
-
- def __init__(self, mapping, delimiter='/'):
- self.mapping = mapping
- self.delimiter = delimiter
-
- def get_loader(self, template):
- try:
- prefix, name = template.split(self.delimiter, 1)
- loader = self.mapping[prefix]
- except (ValueError, KeyError):
- raise TemplateNotFound(template)
- return loader, name
-
- def get_source(self, environment, template):
- loader, name = self.get_loader(template)
- try:
- return loader.get_source(environment, name)
- except TemplateNotFound:
- # re-raise the exception with the correct filename here.
- # (the one that includes the prefix)
- raise TemplateNotFound(template)
-
- @internalcode
- def load(self, environment, name, globals=None):
- loader, local_name = self.get_loader(name)
- try:
- return loader.load(environment, local_name, globals)
- except TemplateNotFound:
- # re-raise the exception with the correct filename here.
- # (the one that includes the prefix)
- raise TemplateNotFound(name)
-
- def list_templates(self):
- result = []
- for prefix, loader in iteritems(self.mapping):
- for template in loader.list_templates():
- result.append(prefix + self.delimiter + template)
- return result
-
-
-class ChoiceLoader(BaseLoader):
- """This loader works like the `PrefixLoader` just that no prefix is
- specified. If a template could not be found by one loader the next one
- is tried.
-
- >>> loader = ChoiceLoader([
- ... FileSystemLoader('/path/to/user/templates'),
- ... FileSystemLoader('/path/to/system/templates')
- ... ])
-
- This is useful if you want to allow users to override builtin templates
- from a different location.
- """
-
- def __init__(self, loaders):
- self.loaders = loaders
-
- def get_source(self, environment, template):
- for loader in self.loaders:
- try:
- return loader.get_source(environment, template)
- except TemplateNotFound:
- pass
- raise TemplateNotFound(template)
-
- @internalcode
- def load(self, environment, name, globals=None):
- for loader in self.loaders:
- try:
- return loader.load(environment, name, globals)
- except TemplateNotFound:
- pass
- raise TemplateNotFound(name)
-
- def list_templates(self):
- found = set()
- for loader in self.loaders:
- found.update(loader.list_templates())
- return sorted(found)
-
-
-class _TemplateModule(ModuleType):
- """Like a normal module but with support for weak references"""
-
-
-class ModuleLoader(BaseLoader):
- """This loader loads templates from precompiled templates.
-
- Example usage:
-
- >>> loader = ChoiceLoader([
- ... ModuleLoader('/path/to/compiled/templates'),
- ... FileSystemLoader('/path/to/templates')
- ... ])
-
- Templates can be precompiled with :meth:`Environment.compile_templates`.
- """
-
- has_source_access = False
-
- def __init__(self, path):
- package_name = '_jinja2_module_templates_%x' % id(self)
-
- # create a fake module that looks for the templates in the
- # path given.
- mod = _TemplateModule(package_name)
- if isinstance(path, string_types):
- path = [path]
- else:
- path = list(path)
- mod.__path__ = path
-
- sys.modules[package_name] = weakref.proxy(mod,
- lambda x: sys.modules.pop(package_name, None))
-
- # the only strong reference, the sys.modules entry is weak
- # so that the garbage collector can remove it once the
- # loader that created it goes out of business.
- self.module = mod
- self.package_name = package_name
-
- @staticmethod
- def get_template_key(name):
- return 'tmpl_' + sha1(name.encode('utf-8')).hexdigest()
-
- @staticmethod
- def get_module_filename(name):
- return ModuleLoader.get_template_key(name) + '.py'
-
- @internalcode
- def load(self, environment, name, globals=None):
- key = self.get_template_key(name)
- module = '%s.%s' % (self.package_name, key)
- mod = getattr(self.module, module, None)
- if mod is None:
- try:
- mod = __import__(module, None, None, ['root'])
- except ImportError:
- raise TemplateNotFound(name)
-
- # remove the entry from sys.modules, we only want the attribute
- # on the module object we have stored on the loader.
- sys.modules.pop(module, None)
-
- return environment.template_class.from_module_dict(
- environment, mod.__dict__, globals)
diff --git a/python/jinja2/meta.py b/python/jinja2/meta.py
deleted file mode 100644
index 7421914..0000000
--- a/python/jinja2/meta.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.meta
- ~~~~~~~~~~~
-
- This module implements various functions that exposes information about
- templates that might be interesting for various kinds of applications.
-
- :copyright: (c) 2017 by the Jinja Team, see AUTHORS for more details.
- :license: BSD, see LICENSE for more details.
-"""
-from jinja2 import nodes
-from jinja2.compiler import CodeGenerator
-from jinja2._compat import string_types, iteritems
-
-
-class TrackingCodeGenerator(CodeGenerator):
- """We abuse the code generator for introspection."""
-
- def __init__(self, environment):
- CodeGenerator.__init__(self, environment, '<introspection>',
- '<introspection>')
- self.undeclared_identifiers = set()
-
- def write(self, x):
- """Don't write."""
-
- def enter_frame(self, frame):
- """Remember all undeclared identifiers."""
- CodeGenerator.enter_frame(self, frame)
- for _, (action, param) in iteritems(frame.symbols.loads):
- if action == 'resolve':
- self.undeclared_identifiers.add(param)
-
-
-def find_undeclared_variables(ast):
- """Returns a set of all variables in the AST that will be looked up from
- the context at runtime. Because at compile time it's not known which
- variables will be used depending on the path the execution takes at
- runtime, all variables are returned.
-
- >>> from jinja2 import Environment, meta
- >>> env = Environment()
- >>> ast = env.parse('{% set foo = 42 %}{{ bar + foo }}')
- >>> meta.find_undeclared_variables(ast) == set(['bar'])
- True
-
- .. admonition:: Implementation
-
- Internally the code generator is used for finding undeclared variables.
- This is good to know because the code generator might raise a
- :exc:`TemplateAssertionError` during compilation and as a matter of
- fact this function can currently raise that exception as well.
- """
- codegen = TrackingCodeGenerator(ast.environment)
- codegen.visit(ast)
- return codegen.undeclared_identifiers
-
-
-def find_referenced_templates(ast):
- """Finds all the referenced templates from the AST. This will return an
- iterator over all the hardcoded template extensions, inclusions and
- imports. If dynamic inheritance or inclusion is used, `None` will be
- yielded.
-
- >>> from jinja2 import Environment, meta
- >>> env = Environment()
- >>> ast = env.parse('{% extends "layout.html" %}{% include helper %}')
- >>> list(meta.find_referenced_templates(ast))
- ['layout.html', None]
-
- This function is useful for dependency tracking. For example if you want
- to rebuild parts of the website after a layout template has changed.
- """
- for node in ast.find_all((nodes.Extends, nodes.FromImport, nodes.Import,
- nodes.Include)):
- if not isinstance(node.template, nodes.Const):
- # a tuple with some non consts in there
- if isinstance(node.template, (nodes.Tuple, nodes.List)):
- for template_name in node.template.items:
- # something const, only yield the strings and ignore
- # non-string consts that really just make no sense
- if isinstance(template_name, nodes.Const):
- if isinstance(template_name.value, string_types):
- yield template_name.value
- # something dynamic in there
- else:
- yield None
- # something dynamic we don't know about here
- else:
- yield None
- continue
- # constant is a basestring, direct template name
- if isinstance(node.template.value, string_types):
- yield node.template.value
- # a tuple or list (latter *should* not happen) made of consts,
- # yield the consts that are strings. We could warn here for
- # non string values
- elif isinstance(node, nodes.Include) and \
- isinstance(node.template.value, (tuple, list)):
- for template_name in node.template.value:
- if isinstance(template_name, string_types):
- yield template_name
- # something else we don't care about, we could warn here
- else:
- yield None
diff --git a/python/jinja2/nativetypes.py b/python/jinja2/nativetypes.py
deleted file mode 100644
index fe17e41..0000000
--- a/python/jinja2/nativetypes.py
+++ /dev/null
@@ -1,220 +0,0 @@
-import sys
-from ast import literal_eval
-from itertools import islice, chain
-from jinja2 import nodes
-from jinja2._compat import text_type
-from jinja2.compiler import CodeGenerator, has_safe_repr
-from jinja2.environment import Environment, Template
-from jinja2.utils import concat, escape
-
-
-def native_concat(nodes):
- """Return a native Python type from the list of compiled nodes. If the
- result is a single node, its value is returned. Otherwise, the nodes are
- concatenated as strings. If the result can be parsed with
- :func:`ast.literal_eval`, the parsed value is returned. Otherwise, the
- string is returned.
- """
- head = list(islice(nodes, 2))
-
- if not head:
- return None
-
- if len(head) == 1:
- out = head[0]
- else:
- out = u''.join([text_type(v) for v in chain(head, nodes)])
-
- try:
- return literal_eval(out)
- except (ValueError, SyntaxError, MemoryError):
- return out
-
-
-class NativeCodeGenerator(CodeGenerator):
- """A code generator which avoids injecting ``to_string()`` calls around the
- internal code Jinja uses to render templates.
- """
-
- def visit_Output(self, node, frame):
- """Same as :meth:`CodeGenerator.visit_Output`, but do not call
- ``to_string`` on output nodes in generated code.
- """
- if self.has_known_extends and frame.require_output_check:
- return
-
- finalize = self.environment.finalize
- finalize_context = getattr(finalize, 'contextfunction', False)
- finalize_eval = getattr(finalize, 'evalcontextfunction', False)
- finalize_env = getattr(finalize, 'environmentfunction', False)
-
- if finalize is not None:
- if finalize_context or finalize_eval:
- const_finalize = None
- elif finalize_env:
- def const_finalize(x):
- return finalize(self.environment, x)
- else:
- const_finalize = finalize
- else:
- def const_finalize(x):
- return x
-
- # If we are inside a frame that requires output checking, we do so.
- outdent_later = False
-
- if frame.require_output_check:
- self.writeline('if parent_template is None:')
- self.indent()
- outdent_later = True
-
- # Try to evaluate as many chunks as possible into a static string at
- # compile time.
- body = []
-
- for child in node.nodes:
- try:
- if const_finalize is None:
- raise nodes.Impossible()
-
- const = child.as_const(frame.eval_ctx)
- if not has_safe_repr(const):
- raise nodes.Impossible()
- except nodes.Impossible:
- body.append(child)
- continue
-
- # the frame can't be volatile here, because otherwise the as_const
- # function would raise an Impossible exception at that point
- try:
- if frame.eval_ctx.autoescape:
- if hasattr(const, '__html__'):
- const = const.__html__()
- else:
- const = escape(const)
-
- const = const_finalize(const)
- except Exception:
- # if something goes wrong here we evaluate the node at runtime
- # for easier debugging
- body.append(child)
- continue
-
- if body and isinstance(body[-1], list):
- body[-1].append(const)
- else:
- body.append([const])
-
- # if we have less than 3 nodes or a buffer we yield or extend/append
- if len(body) < 3 or frame.buffer is not None:
- if frame.buffer is not None:
- # for one item we append, for more we extend
- if len(body) == 1:
- self.writeline('%s.append(' % frame.buffer)
- else:
- self.writeline('%s.extend((' % frame.buffer)
-
- self.indent()
-
- for item in body:
- if isinstance(item, list):
- val = repr(native_concat(item))
-
- if frame.buffer is None:
- self.writeline('yield ' + val)
- else:
- self.writeline(val + ',')
- else:
- if frame.buffer is None:
- self.writeline('yield ', item)
- else:
- self.newline(item)
-
- close = 0
-
- if finalize is not None:
- self.write('environment.finalize(')
-
- if finalize_context:
- self.write('context, ')
-
- close += 1
-
- self.visit(item, frame)
-
- if close > 0:
- self.write(')' * close)
-
- if frame.buffer is not None:
- self.write(',')
-
- if frame.buffer is not None:
- # close the open parentheses
- self.outdent()
- self.writeline(len(body) == 1 and ')' or '))')
-
- # otherwise we create a format string as this is faster in that case
- else:
- format = []
- arguments = []
-
- for item in body:
- if isinstance(item, list):
- format.append(native_concat(item).replace('%', '%%'))
- else:
- format.append('%s')
- arguments.append(item)
-
- self.writeline('yield ')
- self.write(repr(concat(format)) + ' % (')
- self.indent()
-
- for argument in arguments:
- self.newline(argument)
- close = 0
-
- if finalize is not None:
- self.write('environment.finalize(')
-
- if finalize_context:
- self.write('context, ')
- elif finalize_eval:
- self.write('context.eval_ctx, ')
- elif finalize_env:
- self.write('environment, ')
-
- close += 1
-
- self.visit(argument, frame)
- self.write(')' * close + ', ')
-
- self.outdent()
- self.writeline(')')
-
- if outdent_later:
- self.outdent()
-
-
-class NativeTemplate(Template):
- def render(self, *args, **kwargs):
- """Render the template to produce a native Python type. If the result
- is a single node, its value is returned. Otherwise, the nodes are
- concatenated as strings. If the result can be parsed with
- :func:`ast.literal_eval`, the parsed value is returned. Otherwise, the
- string is returned.
- """
- vars = dict(*args, **kwargs)
-
- try:
- return native_concat(self.root_render_func(self.new_context(vars)))
- except Exception:
- exc_info = sys.exc_info()
-
- return self.environment.handle_exception(exc_info, True)
-
-
-class NativeEnvironment(Environment):
- """An environment that renders templates to native Python types."""
-
- code_generator_class = NativeCodeGenerator
- template_class = NativeTemplate
diff --git a/python/jinja2/nodes.py b/python/jinja2/nodes.py
deleted file mode 100644
index 4d9a01a..0000000
--- a/python/jinja2/nodes.py
+++ /dev/null
@@ -1,999 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.nodes
- ~~~~~~~~~~~~
-
- This module implements additional nodes derived from the ast base node.
-
- It also provides some node tree helper functions like `in_lineno` and
- `get_nodes` used by the parser and translator in order to normalize
- python and jinja nodes.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import types
-import operator
-
-from collections import deque
-from jinja2.utils import Markup
-from jinja2._compat import izip, with_metaclass, text_type, PY2
-
-
-#: the types we support for context functions
-_context_function_types = (types.FunctionType, types.MethodType)
-
-
-_binop_to_func = {
- '*': operator.mul,
- '/': operator.truediv,
- '//': operator.floordiv,
- '**': operator.pow,
- '%': operator.mod,
- '+': operator.add,
- '-': operator.sub
-}
-
-_uaop_to_func = {
- 'not': operator.not_,
- '+': operator.pos,
- '-': operator.neg
-}
-
-_cmpop_to_func = {
- 'eq': operator.eq,
- 'ne': operator.ne,
- 'gt': operator.gt,
- 'gteq': operator.ge,
- 'lt': operator.lt,
- 'lteq': operator.le,
- 'in': lambda a, b: a in b,
- 'notin': lambda a, b: a not in b
-}
-
-
-class Impossible(Exception):
- """Raised if the node could not perform a requested action."""
-
-
-class NodeType(type):
- """A metaclass for nodes that handles the field and attribute
- inheritance. fields and attributes from the parent class are
- automatically forwarded to the child."""
-
- def __new__(cls, name, bases, d):
- for attr in 'fields', 'attributes':
- storage = []
- storage.extend(getattr(bases[0], attr, ()))
- storage.extend(d.get(attr, ()))
- assert len(bases) == 1, 'multiple inheritance not allowed'
- assert len(storage) == len(set(storage)), 'layout conflict'
- d[attr] = tuple(storage)
- d.setdefault('abstract', False)
- return type.__new__(cls, name, bases, d)
-
-
-class EvalContext(object):
- """Holds evaluation time information. Custom attributes can be attached
- to it in extensions.
- """
-
- def __init__(self, environment, template_name=None):
- self.environment = environment
- if callable(environment.autoescape):
- self.autoescape = environment.autoescape(template_name)
- else:
- self.autoescape = environment.autoescape
- self.volatile = False
-
- def save(self):
- return self.__dict__.copy()
-
- def revert(self, old):
- self.__dict__.clear()
- self.__dict__.update(old)
-
-
-def get_eval_context(node, ctx):
- if ctx is None:
- if node.environment is None:
- raise RuntimeError('if no eval context is passed, the '
- 'node must have an attached '
- 'environment.')
- return EvalContext(node.environment)
- return ctx
-
-
-class Node(with_metaclass(NodeType, object)):
- """Baseclass for all Jinja2 nodes. There are a number of nodes available
- of different types. There are four major types:
-
- - :class:`Stmt`: statements
- - :class:`Expr`: expressions
- - :class:`Helper`: helper nodes
- - :class:`Template`: the outermost wrapper node
-
- All nodes have fields and attributes. Fields may be other nodes, lists,
- or arbitrary values. Fields are passed to the constructor as regular
- positional arguments, attributes as keyword arguments. Each node has
- two attributes: `lineno` (the line number of the node) and `environment`.
- The `environment` attribute is set at the end of the parsing process for
- all nodes automatically.
- """
- fields = ()
- attributes = ('lineno', 'environment')
- abstract = True
-
- def __init__(self, *fields, **attributes):
- if self.abstract:
- raise TypeError('abstract nodes are not instanciable')
- if fields:
- if len(fields) != len(self.fields):
- if not self.fields:
- raise TypeError('%r takes 0 arguments' %
- self.__class__.__name__)
- raise TypeError('%r takes 0 or %d argument%s' % (
- self.__class__.__name__,
- len(self.fields),
- len(self.fields) != 1 and 's' or ''
- ))
- for name, arg in izip(self.fields, fields):
- setattr(self, name, arg)
- for attr in self.attributes:
- setattr(self, attr, attributes.pop(attr, None))
- if attributes:
- raise TypeError('unknown attribute %r' %
- next(iter(attributes)))
-
- def iter_fields(self, exclude=None, only=None):
- """This method iterates over all fields that are defined and yields
- ``(key, value)`` tuples. Per default all fields are returned, but
- it's possible to limit that to some fields by providing the `only`
- parameter or to exclude some using the `exclude` parameter. Both
- should be sets or tuples of field names.
- """
- for name in self.fields:
- if (exclude is only is None) or \
- (exclude is not None and name not in exclude) or \
- (only is not None and name in only):
- try:
- yield name, getattr(self, name)
- except AttributeError:
- pass
-
- def iter_child_nodes(self, exclude=None, only=None):
- """Iterates over all direct child nodes of the node. This iterates
- over all fields and yields the values of they are nodes. If the value
- of a field is a list all the nodes in that list are returned.
- """
- for field, item in self.iter_fields(exclude, only):
- if isinstance(item, list):
- for n in item:
- if isinstance(n, Node):
- yield n
- elif isinstance(item, Node):
- yield item
-
- def find(self, node_type):
- """Find the first node of a given type. If no such node exists the
- return value is `None`.
- """
- for result in self.find_all(node_type):
- return result
-
- def find_all(self, node_type):
- """Find all the nodes of a given type. If the type is a tuple,
- the check is performed for any of the tuple items.
- """
- for child in self.iter_child_nodes():
- if isinstance(child, node_type):
- yield child
- for result in child.find_all(node_type):
- yield result
-
- def set_ctx(self, ctx):
- """Reset the context of a node and all child nodes. Per default the
- parser will all generate nodes that have a 'load' context as it's the
- most common one. This method is used in the parser to set assignment
- targets and other nodes to a store context.
- """
- todo = deque([self])
- while todo:
- node = todo.popleft()
- if 'ctx' in node.fields:
- node.ctx = ctx
- todo.extend(node.iter_child_nodes())
- return self
-
- def set_lineno(self, lineno, override=False):
- """Set the line numbers of the node and children."""
- todo = deque([self])
- while todo:
- node = todo.popleft()
- if 'lineno' in node.attributes:
- if node.lineno is None or override:
- node.lineno = lineno
- todo.extend(node.iter_child_nodes())
- return self
-
- def set_environment(self, environment):
- """Set the environment for all nodes."""
- todo = deque([self])
- while todo:
- node = todo.popleft()
- node.environment = environment
- todo.extend(node.iter_child_nodes())
- return self
-
- def __eq__(self, other):
- return type(self) is type(other) and \
- tuple(self.iter_fields()) == tuple(other.iter_fields())
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- # Restore Python 2 hashing behavior on Python 3
- __hash__ = object.__hash__
-
- def __repr__(self):
- return '%s(%s)' % (
- self.__class__.__name__,
- ', '.join('%s=%r' % (arg, getattr(self, arg, None)) for
- arg in self.fields)
- )
-
- def dump(self):
- def _dump(node):
- if not isinstance(node, Node):
- buf.append(repr(node))
- return
-
- buf.append('nodes.%s(' % node.__class__.__name__)
- if not node.fields:
- buf.append(')')
- return
- for idx, field in enumerate(node.fields):
- if idx:
- buf.append(', ')
- value = getattr(node, field)
- if isinstance(value, list):
- buf.append('[')
- for idx, item in enumerate(value):
- if idx:
- buf.append(', ')
- _dump(item)
- buf.append(']')
- else:
- _dump(value)
- buf.append(')')
- buf = []
- _dump(self)
- return ''.join(buf)
-
-
-
-class Stmt(Node):
- """Base node for all statements."""
- abstract = True
-
-
-class Helper(Node):
- """Nodes that exist in a specific context only."""
- abstract = True
-
-
-class Template(Node):
- """Node that represents a template. This must be the outermost node that
- is passed to the compiler.
- """
- fields = ('body',)
-
-
-class Output(Stmt):
- """A node that holds multiple expressions which are then printed out.
- This is used both for the `print` statement and the regular template data.
- """
- fields = ('nodes',)
-
-
-class Extends(Stmt):
- """Represents an extends statement."""
- fields = ('template',)
-
-
-class For(Stmt):
- """The for loop. `target` is the target for the iteration (usually a
- :class:`Name` or :class:`Tuple`), `iter` the iterable. `body` is a list
- of nodes that are used as loop-body, and `else_` a list of nodes for the
- `else` block. If no else node exists it has to be an empty list.
-
- For filtered nodes an expression can be stored as `test`, otherwise `None`.
- """
- fields = ('target', 'iter', 'body', 'else_', 'test', 'recursive')
-
-
-class If(Stmt):
- """If `test` is true, `body` is rendered, else `else_`."""
- fields = ('test', 'body', 'elif_', 'else_')
-
-
-class Macro(Stmt):
- """A macro definition. `name` is the name of the macro, `args` a list of
- arguments and `defaults` a list of defaults if there are any. `body` is
- a list of nodes for the macro body.
- """
- fields = ('name', 'args', 'defaults', 'body')
-
-
-class CallBlock(Stmt):
- """Like a macro without a name but a call instead. `call` is called with
- the unnamed macro as `caller` argument this node holds.
- """
- fields = ('call', 'args', 'defaults', 'body')
-
-
-class FilterBlock(Stmt):
- """Node for filter sections."""
- fields = ('body', 'filter')
-
-
-class With(Stmt):
- """Specific node for with statements. In older versions of Jinja the
- with statement was implemented on the base of the `Scope` node instead.
-
- .. versionadded:: 2.9.3
- """
- fields = ('targets', 'values', 'body')
-
-
-class Block(Stmt):
- """A node that represents a block."""
- fields = ('name', 'body', 'scoped')
-
-
-class Include(Stmt):
- """A node that represents the include tag."""
- fields = ('template', 'with_context', 'ignore_missing')
-
-
-class Import(Stmt):
- """A node that represents the import tag."""
- fields = ('template', 'target', 'with_context')
-
-
-class FromImport(Stmt):
- """A node that represents the from import tag. It's important to not
- pass unsafe names to the name attribute. The compiler translates the
- attribute lookups directly into getattr calls and does *not* use the
- subscript callback of the interface. As exported variables may not
- start with double underscores (which the parser asserts) this is not a
- problem for regular Jinja code, but if this node is used in an extension
- extra care must be taken.
-
- The list of names may contain tuples if aliases are wanted.
- """
- fields = ('template', 'names', 'with_context')
-
-
-class ExprStmt(Stmt):
- """A statement that evaluates an expression and discards the result."""
- fields = ('node',)
-
-
-class Assign(Stmt):
- """Assigns an expression to a target."""
- fields = ('target', 'node')
-
-
-class AssignBlock(Stmt):
- """Assigns a block to a target."""
- fields = ('target', 'filter', 'body')
-
-
-class Expr(Node):
- """Baseclass for all expressions."""
- abstract = True
-
- def as_const(self, eval_ctx=None):
- """Return the value of the expression as constant or raise
- :exc:`Impossible` if this was not possible.
-
- An :class:`EvalContext` can be provided, if none is given
- a default context is created which requires the nodes to have
- an attached environment.
-
- .. versionchanged:: 2.4
- the `eval_ctx` parameter was added.
- """
- raise Impossible()
-
- def can_assign(self):
- """Check if it's possible to assign something to this node."""
- return False
-
-
-class BinExpr(Expr):
- """Baseclass for all binary expressions."""
- fields = ('left', 'right')
- operator = None
- abstract = True
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- # intercepted operators cannot be folded at compile time
- if self.environment.sandboxed and \
- self.operator in self.environment.intercepted_binops:
- raise Impossible()
- f = _binop_to_func[self.operator]
- try:
- return f(self.left.as_const(eval_ctx), self.right.as_const(eval_ctx))
- except Exception:
- raise Impossible()
-
-
-class UnaryExpr(Expr):
- """Baseclass for all unary expressions."""
- fields = ('node',)
- operator = None
- abstract = True
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- # intercepted operators cannot be folded at compile time
- if self.environment.sandboxed and \
- self.operator in self.environment.intercepted_unops:
- raise Impossible()
- f = _uaop_to_func[self.operator]
- try:
- return f(self.node.as_const(eval_ctx))
- except Exception:
- raise Impossible()
-
-
-class Name(Expr):
- """Looks up a name or stores a value in a name.
- The `ctx` of the node can be one of the following values:
-
- - `store`: store a value in the name
- - `load`: load that name
- - `param`: like `store` but if the name was defined as function parameter.
- """
- fields = ('name', 'ctx')
-
- def can_assign(self):
- return self.name not in ('true', 'false', 'none',
- 'True', 'False', 'None')
-
-
-class NSRef(Expr):
- """Reference to a namespace value assignment"""
- fields = ('name', 'attr')
-
- def can_assign(self):
- # We don't need any special checks here; NSRef assignments have a
- # runtime check to ensure the target is a namespace object which will
- # have been checked already as it is created using a normal assignment
- # which goes through a `Name` node.
- return True
-
-
-class Literal(Expr):
- """Baseclass for literals."""
- abstract = True
-
-
-class Const(Literal):
- """All constant values. The parser will return this node for simple
- constants such as ``42`` or ``"foo"`` but it can be used to store more
- complex values such as lists too. Only constants with a safe
- representation (objects where ``eval(repr(x)) == x`` is true).
- """
- fields = ('value',)
-
- def as_const(self, eval_ctx=None):
- rv = self.value
- if PY2 and type(rv) is text_type and \
- self.environment.policies['compiler.ascii_str']:
- try:
- rv = rv.encode('ascii')
- except UnicodeError:
- pass
- return rv
-
- @classmethod
- def from_untrusted(cls, value, lineno=None, environment=None):
- """Return a const object if the value is representable as
- constant value in the generated code, otherwise it will raise
- an `Impossible` exception.
- """
- from .compiler import has_safe_repr
- if not has_safe_repr(value):
- raise Impossible()
- return cls(value, lineno=lineno, environment=environment)
-
-
-class TemplateData(Literal):
- """A constant template string."""
- fields = ('data',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- if eval_ctx.volatile:
- raise Impossible()
- if eval_ctx.autoescape:
- return Markup(self.data)
- return self.data
-
-
-class Tuple(Literal):
- """For loop unpacking and some other things like multiple arguments
- for subscripts. Like for :class:`Name` `ctx` specifies if the tuple
- is used for loading the names or storing.
- """
- fields = ('items', 'ctx')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return tuple(x.as_const(eval_ctx) for x in self.items)
-
- def can_assign(self):
- for item in self.items:
- if not item.can_assign():
- return False
- return True
-
-
-class List(Literal):
- """Any list literal such as ``[1, 2, 3]``"""
- fields = ('items',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return [x.as_const(eval_ctx) for x in self.items]
-
-
-class Dict(Literal):
- """Any dict literal such as ``{1: 2, 3: 4}``. The items must be a list of
- :class:`Pair` nodes.
- """
- fields = ('items',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return dict(x.as_const(eval_ctx) for x in self.items)
-
-
-class Pair(Helper):
- """A key, value pair for dicts."""
- fields = ('key', 'value')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return self.key.as_const(eval_ctx), self.value.as_const(eval_ctx)
-
-
-class Keyword(Helper):
- """A key, value pair for keyword arguments where key is a string."""
- fields = ('key', 'value')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return self.key, self.value.as_const(eval_ctx)
-
-
-class CondExpr(Expr):
- """A conditional expression (inline if expression). (``{{
- foo if bar else baz }}``)
- """
- fields = ('test', 'expr1', 'expr2')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- if self.test.as_const(eval_ctx):
- return self.expr1.as_const(eval_ctx)
-
- # if we evaluate to an undefined object, we better do that at runtime
- if self.expr2 is None:
- raise Impossible()
-
- return self.expr2.as_const(eval_ctx)
-
-
-def args_as_const(node, eval_ctx):
- args = [x.as_const(eval_ctx) for x in node.args]
- kwargs = dict(x.as_const(eval_ctx) for x in node.kwargs)
-
- if node.dyn_args is not None:
- try:
- args.extend(node.dyn_args.as_const(eval_ctx))
- except Exception:
- raise Impossible()
-
- if node.dyn_kwargs is not None:
- try:
- kwargs.update(node.dyn_kwargs.as_const(eval_ctx))
- except Exception:
- raise Impossible()
-
- return args, kwargs
-
-
-class Filter(Expr):
- """This node applies a filter on an expression. `name` is the name of
- the filter, the rest of the fields are the same as for :class:`Call`.
-
- If the `node` of a filter is `None` the contents of the last buffer are
- filtered. Buffers are created by macros and filter blocks.
- """
-
- fields = ('node', 'name', 'args', 'kwargs', 'dyn_args', 'dyn_kwargs')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
-
- if eval_ctx.volatile or self.node is None:
- raise Impossible()
-
- # we have to be careful here because we call filter_ below.
- # if this variable would be called filter, 2to3 would wrap the
- # call in a list beause it is assuming we are talking about the
- # builtin filter function here which no longer returns a list in
- # python 3. because of that, do not rename filter_ to filter!
- filter_ = self.environment.filters.get(self.name)
-
- if filter_ is None or getattr(filter_, 'contextfilter', False):
- raise Impossible()
-
- # We cannot constant handle async filters, so we need to make sure
- # to not go down this path.
- if (
- eval_ctx.environment.is_async
- and getattr(filter_, 'asyncfiltervariant', False)
- ):
- raise Impossible()
-
- args, kwargs = args_as_const(self, eval_ctx)
- args.insert(0, self.node.as_const(eval_ctx))
-
- if getattr(filter_, 'evalcontextfilter', False):
- args.insert(0, eval_ctx)
- elif getattr(filter_, 'environmentfilter', False):
- args.insert(0, self.environment)
-
- try:
- return filter_(*args, **kwargs)
- except Exception:
- raise Impossible()
-
-
-class Test(Expr):
- """Applies a test on an expression. `name` is the name of the test, the
- rest of the fields are the same as for :class:`Call`.
- """
-
- fields = ('node', 'name', 'args', 'kwargs', 'dyn_args', 'dyn_kwargs')
-
- def as_const(self, eval_ctx=None):
- test = self.environment.tests.get(self.name)
-
- if test is None:
- raise Impossible()
-
- eval_ctx = get_eval_context(self, eval_ctx)
- args, kwargs = args_as_const(self, eval_ctx)
- args.insert(0, self.node.as_const(eval_ctx))
-
- try:
- return test(*args, **kwargs)
- except Exception:
- raise Impossible()
-
-
-class Call(Expr):
- """Calls an expression. `args` is a list of arguments, `kwargs` a list
- of keyword arguments (list of :class:`Keyword` nodes), and `dyn_args`
- and `dyn_kwargs` has to be either `None` or a node that is used as
- node for dynamic positional (``*args``) or keyword (``**kwargs``)
- arguments.
- """
- fields = ('node', 'args', 'kwargs', 'dyn_args', 'dyn_kwargs')
-
-
-class Getitem(Expr):
- """Get an attribute or item from an expression and prefer the item."""
- fields = ('node', 'arg', 'ctx')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- if self.ctx != 'load':
- raise Impossible()
- try:
- return self.environment.getitem(self.node.as_const(eval_ctx),
- self.arg.as_const(eval_ctx))
- except Exception:
- raise Impossible()
-
- def can_assign(self):
- return False
-
-
-class Getattr(Expr):
- """Get an attribute or item from an expression that is a ascii-only
- bytestring and prefer the attribute.
- """
- fields = ('node', 'attr', 'ctx')
-
- def as_const(self, eval_ctx=None):
- if self.ctx != 'load':
- raise Impossible()
- try:
- eval_ctx = get_eval_context(self, eval_ctx)
- return self.environment.getattr(self.node.as_const(eval_ctx),
- self.attr)
- except Exception:
- raise Impossible()
-
- def can_assign(self):
- return False
-
-
-class Slice(Expr):
- """Represents a slice object. This must only be used as argument for
- :class:`Subscript`.
- """
- fields = ('start', 'stop', 'step')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- def const(obj):
- if obj is None:
- return None
- return obj.as_const(eval_ctx)
- return slice(const(self.start), const(self.stop), const(self.step))
-
-
-class Concat(Expr):
- """Concatenates the list of expressions provided after converting them to
- unicode.
- """
- fields = ('nodes',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return ''.join(text_type(x.as_const(eval_ctx)) for x in self.nodes)
-
-
-class Compare(Expr):
- """Compares an expression with some other expressions. `ops` must be a
- list of :class:`Operand`\\s.
- """
- fields = ('expr', 'ops')
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- result = value = self.expr.as_const(eval_ctx)
- try:
- for op in self.ops:
- new_value = op.expr.as_const(eval_ctx)
- result = _cmpop_to_func[op.op](value, new_value)
- value = new_value
- except Exception:
- raise Impossible()
- return result
-
-
-class Operand(Helper):
- """Holds an operator and an expression."""
- fields = ('op', 'expr')
-
-if __debug__:
- Operand.__doc__ += '\nThe following operators are available: ' + \
- ', '.join(sorted('``%s``' % x for x in set(_binop_to_func) |
- set(_uaop_to_func) | set(_cmpop_to_func)))
-
-
-class Mul(BinExpr):
- """Multiplies the left with the right node."""
- operator = '*'
-
-
-class Div(BinExpr):
- """Divides the left by the right node."""
- operator = '/'
-
-
-class FloorDiv(BinExpr):
- """Divides the left by the right node and truncates conver the
- result into an integer by truncating.
- """
- operator = '//'
-
-
-class Add(BinExpr):
- """Add the left to the right node."""
- operator = '+'
-
-
-class Sub(BinExpr):
- """Subtract the right from the left node."""
- operator = '-'
-
-
-class Mod(BinExpr):
- """Left modulo right."""
- operator = '%'
-
-
-class Pow(BinExpr):
- """Left to the power of right."""
- operator = '**'
-
-
-class And(BinExpr):
- """Short circuited AND."""
- operator = 'and'
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return self.left.as_const(eval_ctx) and self.right.as_const(eval_ctx)
-
-
-class Or(BinExpr):
- """Short circuited OR."""
- operator = 'or'
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return self.left.as_const(eval_ctx) or self.right.as_const(eval_ctx)
-
-
-class Not(UnaryExpr):
- """Negate the expression."""
- operator = 'not'
-
-
-class Neg(UnaryExpr):
- """Make the expression negative."""
- operator = '-'
-
-
-class Pos(UnaryExpr):
- """Make the expression positive (noop for most expressions)"""
- operator = '+'
-
-
-# Helpers for extensions
-
-
-class EnvironmentAttribute(Expr):
- """Loads an attribute from the environment object. This is useful for
- extensions that want to call a callback stored on the environment.
- """
- fields = ('name',)
-
-
-class ExtensionAttribute(Expr):
- """Returns the attribute of an extension bound to the environment.
- The identifier is the identifier of the :class:`Extension`.
-
- This node is usually constructed by calling the
- :meth:`~jinja2.ext.Extension.attr` method on an extension.
- """
- fields = ('identifier', 'name')
-
-
-class ImportedName(Expr):
- """If created with an import name the import name is returned on node
- access. For example ``ImportedName('cgi.escape')`` returns the `escape`
- function from the cgi module on evaluation. Imports are optimized by the
- compiler so there is no need to assign them to local variables.
- """
- fields = ('importname',)
-
-
-class InternalName(Expr):
- """An internal name in the compiler. You cannot create these nodes
- yourself but the parser provides a
- :meth:`~jinja2.parser.Parser.free_identifier` method that creates
- a new identifier for you. This identifier is not available from the
- template and is not threated specially by the compiler.
- """
- fields = ('name',)
-
- def __init__(self):
- raise TypeError('Can\'t create internal names. Use the '
- '`free_identifier` method on a parser.')
-
-
-class MarkSafe(Expr):
- """Mark the wrapped expression as safe (wrap it as `Markup`)."""
- fields = ('expr',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- return Markup(self.expr.as_const(eval_ctx))
-
-
-class MarkSafeIfAutoescape(Expr):
- """Mark the wrapped expression as safe (wrap it as `Markup`) but
- only if autoescaping is active.
-
- .. versionadded:: 2.5
- """
- fields = ('expr',)
-
- def as_const(self, eval_ctx=None):
- eval_ctx = get_eval_context(self, eval_ctx)
- if eval_ctx.volatile:
- raise Impossible()
- expr = self.expr.as_const(eval_ctx)
- if eval_ctx.autoescape:
- return Markup(expr)
- return expr
-
-
-class ContextReference(Expr):
- """Returns the current template context. It can be used like a
- :class:`Name` node, with a ``'load'`` ctx and will return the
- current :class:`~jinja2.runtime.Context` object.
-
- Here an example that assigns the current template name to a
- variable named `foo`::
-
- Assign(Name('foo', ctx='store'),
- Getattr(ContextReference(), 'name'))
- """
-
-
-class Continue(Stmt):
- """Continue a loop."""
-
-
-class Break(Stmt):
- """Break a loop."""
-
-
-class Scope(Stmt):
- """An artificial scope."""
- fields = ('body',)
-
-
-class OverlayScope(Stmt):
- """An overlay scope for extensions. This is a largely unoptimized scope
- that however can be used to introduce completely arbitrary variables into
- a sub scope from a dictionary or dictionary like object. The `context`
- field has to evaluate to a dictionary object.
-
- Example usage::
-
- OverlayScope(context=self.call_method('get_context'),
- body=[...])
-
- .. versionadded:: 2.10
- """
- fields = ('context', 'body')
-
-
-class EvalContextModifier(Stmt):
- """Modifies the eval context. For each option that should be modified,
- a :class:`Keyword` has to be added to the :attr:`options` list.
-
- Example to change the `autoescape` setting::
-
- EvalContextModifier(options=[Keyword('autoescape', Const(True))])
- """
- fields = ('options',)
-
-
-class ScopedEvalContextModifier(EvalContextModifier):
- """Modifies the eval context and reverts it later. Works exactly like
- :class:`EvalContextModifier` but will only modify the
- :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`.
- """
- fields = ('body',)
-
-
-# make sure nobody creates custom nodes
-def _failing_new(*args, **kwargs):
- raise TypeError('can\'t create custom node types')
-NodeType.__new__ = staticmethod(_failing_new); del _failing_new
diff --git a/python/jinja2/optimizer.py b/python/jinja2/optimizer.py
deleted file mode 100644
index 65ab3ce..0000000
--- a/python/jinja2/optimizer.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.optimizer
- ~~~~~~~~~~~~~~~~
-
- The jinja optimizer is currently trying to constant fold a few expressions
- and modify the AST in place so that it should be easier to evaluate it.
-
- Because the AST does not contain all the scoping information and the
- compiler has to find that out, we cannot do all the optimizations we
- want. For example loop unrolling doesn't work because unrolled loops would
- have a different scoping.
-
- The solution would be a second syntax tree that has the scoping rules stored.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-from jinja2 import nodes
-from jinja2.visitor import NodeTransformer
-
-
-def optimize(node, environment):
- """The context hint can be used to perform an static optimization
- based on the context given."""
- optimizer = Optimizer(environment)
- return optimizer.visit(node)
-
-
-class Optimizer(NodeTransformer):
-
- def __init__(self, environment):
- self.environment = environment
-
- def fold(self, node, eval_ctx=None):
- """Do constant folding."""
- node = self.generic_visit(node)
- try:
- return nodes.Const.from_untrusted(node.as_const(eval_ctx),
- lineno=node.lineno,
- environment=self.environment)
- except nodes.Impossible:
- return node
-
- visit_Add = visit_Sub = visit_Mul = visit_Div = visit_FloorDiv = \
- visit_Pow = visit_Mod = visit_And = visit_Or = visit_Pos = visit_Neg = \
- visit_Not = visit_Compare = visit_Getitem = visit_Getattr = visit_Call = \
- visit_Filter = visit_Test = visit_CondExpr = fold
- del fold
diff --git a/python/jinja2/parser.py b/python/jinja2/parser.py
deleted file mode 100644
index ed00d97..0000000
--- a/python/jinja2/parser.py
+++ /dev/null
@@ -1,903 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.parser
- ~~~~~~~~~~~~~
-
- Implements the template parser.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-from jinja2 import nodes
-from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError
-from jinja2.lexer import describe_token, describe_token_expr
-from jinja2._compat import imap
-
-
-_statement_keywords = frozenset(['for', 'if', 'block', 'extends', 'print',
- 'macro', 'include', 'from', 'import',
- 'set', 'with', 'autoescape'])
-_compare_operators = frozenset(['eq', 'ne', 'lt', 'lteq', 'gt', 'gteq'])
-
-_math_nodes = {
- 'add': nodes.Add,
- 'sub': nodes.Sub,
- 'mul': nodes.Mul,
- 'div': nodes.Div,
- 'floordiv': nodes.FloorDiv,
- 'mod': nodes.Mod,
-}
-
-
-class Parser(object):
- """This is the central parsing class Jinja2 uses. It's passed to
- extensions and can be used to parse expressions or statements.
- """
-
- def __init__(self, environment, source, name=None, filename=None,
- state=None):
- self.environment = environment
- self.stream = environment._tokenize(source, name, filename, state)
- self.name = name
- self.filename = filename
- self.closed = False
- self.extensions = {}
- for extension in environment.iter_extensions():
- for tag in extension.tags:
- self.extensions[tag] = extension.parse
- self._last_identifier = 0
- self._tag_stack = []
- self._end_token_stack = []
-
- def fail(self, msg, lineno=None, exc=TemplateSyntaxError):
- """Convenience method that raises `exc` with the message, passed
- line number or last line number as well as the current name and
- filename.
- """
- if lineno is None:
- lineno = self.stream.current.lineno
- raise exc(msg, lineno, self.name, self.filename)
-
- def _fail_ut_eof(self, name, end_token_stack, lineno):
- expected = []
- for exprs in end_token_stack:
- expected.extend(imap(describe_token_expr, exprs))
- if end_token_stack:
- currently_looking = ' or '.join(
- "'%s'" % describe_token_expr(expr)
- for expr in end_token_stack[-1])
- else:
- currently_looking = None
-
- if name is None:
- message = ['Unexpected end of template.']
- else:
- message = ['Encountered unknown tag \'%s\'.' % name]
-
- if currently_looking:
- if name is not None and name in expected:
- message.append('You probably made a nesting mistake. Jinja '
- 'is expecting this tag, but currently looking '
- 'for %s.' % currently_looking)
- else:
- message.append('Jinja was looking for the following tags: '
- '%s.' % currently_looking)
-
- if self._tag_stack:
- message.append('The innermost block that needs to be '
- 'closed is \'%s\'.' % self._tag_stack[-1])
-
- self.fail(' '.join(message), lineno)
-
- def fail_unknown_tag(self, name, lineno=None):
- """Called if the parser encounters an unknown tag. Tries to fail
- with a human readable error message that could help to identify
- the problem.
- """
- return self._fail_ut_eof(name, self._end_token_stack, lineno)
-
- def fail_eof(self, end_tokens=None, lineno=None):
- """Like fail_unknown_tag but for end of template situations."""
- stack = list(self._end_token_stack)
- if end_tokens is not None:
- stack.append(end_tokens)
- return self._fail_ut_eof(None, stack, lineno)
-
- def is_tuple_end(self, extra_end_rules=None):
- """Are we at the end of a tuple?"""
- if self.stream.current.type in ('variable_end', 'block_end', 'rparen'):
- return True
- elif extra_end_rules is not None:
- return self.stream.current.test_any(extra_end_rules)
- return False
-
- def free_identifier(self, lineno=None):
- """Return a new free identifier as :class:`~jinja2.nodes.InternalName`."""
- self._last_identifier += 1
- rv = object.__new__(nodes.InternalName)
- nodes.Node.__init__(rv, 'fi%d' % self._last_identifier, lineno=lineno)
- return rv
-
- def parse_statement(self):
- """Parse a single statement."""
- token = self.stream.current
- if token.type != 'name':
- self.fail('tag name expected', token.lineno)
- self._tag_stack.append(token.value)
- pop_tag = True
- try:
- if token.value in _statement_keywords:
- return getattr(self, 'parse_' + self.stream.current.value)()
- if token.value == 'call':
- return self.parse_call_block()
- if token.value == 'filter':
- return self.parse_filter_block()
- ext = self.extensions.get(token.value)
- if ext is not None:
- return ext(self)
-
- # did not work out, remove the token we pushed by accident
- # from the stack so that the unknown tag fail function can
- # produce a proper error message.
- self._tag_stack.pop()
- pop_tag = False
- self.fail_unknown_tag(token.value, token.lineno)
- finally:
- if pop_tag:
- self._tag_stack.pop()
-
- def parse_statements(self, end_tokens, drop_needle=False):
- """Parse multiple statements into a list until one of the end tokens
- is reached. This is used to parse the body of statements as it also
- parses template data if appropriate. The parser checks first if the
- current token is a colon and skips it if there is one. Then it checks
- for the block end and parses until if one of the `end_tokens` is
- reached. Per default the active token in the stream at the end of
- the call is the matched end token. If this is not wanted `drop_needle`
- can be set to `True` and the end token is removed.
- """
- # the first token may be a colon for python compatibility
- self.stream.skip_if('colon')
-
- # in the future it would be possible to add whole code sections
- # by adding some sort of end of statement token and parsing those here.
- self.stream.expect('block_end')
- result = self.subparse(end_tokens)
-
- # we reached the end of the template too early, the subparser
- # does not check for this, so we do that now
- if self.stream.current.type == 'eof':
- self.fail_eof(end_tokens)
-
- if drop_needle:
- next(self.stream)
- return result
-
- def parse_set(self):
- """Parse an assign statement."""
- lineno = next(self.stream).lineno
- target = self.parse_assign_target(with_namespace=True)
- if self.stream.skip_if('assign'):
- expr = self.parse_tuple()
- return nodes.Assign(target, expr, lineno=lineno)
- filter_node = self.parse_filter(None)
- body = self.parse_statements(('name:endset',),
- drop_needle=True)
- return nodes.AssignBlock(target, filter_node, body, lineno=lineno)
-
- def parse_for(self):
- """Parse a for loop."""
- lineno = self.stream.expect('name:for').lineno
- target = self.parse_assign_target(extra_end_rules=('name:in',))
- self.stream.expect('name:in')
- iter = self.parse_tuple(with_condexpr=False,
- extra_end_rules=('name:recursive',))
- test = None
- if self.stream.skip_if('name:if'):
- test = self.parse_expression()
- recursive = self.stream.skip_if('name:recursive')
- body = self.parse_statements(('name:endfor', 'name:else'))
- if next(self.stream).value == 'endfor':
- else_ = []
- else:
- else_ = self.parse_statements(('name:endfor',), drop_needle=True)
- return nodes.For(target, iter, body, else_, test,
- recursive, lineno=lineno)
-
- def parse_if(self):
- """Parse an if construct."""
- node = result = nodes.If(lineno=self.stream.expect('name:if').lineno)
- while 1:
- node.test = self.parse_tuple(with_condexpr=False)
- node.body = self.parse_statements(('name:elif', 'name:else',
- 'name:endif'))
- node.elif_ = []
- node.else_ = []
- token = next(self.stream)
- if token.test('name:elif'):
- node = nodes.If(lineno=self.stream.current.lineno)
- result.elif_.append(node)
- continue
- elif token.test('name:else'):
- result.else_ = self.parse_statements(('name:endif',),
- drop_needle=True)
- break
- return result
-
- def parse_with(self):
- node = nodes.With(lineno=next(self.stream).lineno)
- targets = []
- values = []
- while self.stream.current.type != 'block_end':
- lineno = self.stream.current.lineno
- if targets:
- self.stream.expect('comma')
- target = self.parse_assign_target()
- target.set_ctx('param')
- targets.append(target)
- self.stream.expect('assign')
- values.append(self.parse_expression())
- node.targets = targets
- node.values = values
- node.body = self.parse_statements(('name:endwith',),
- drop_needle=True)
- return node
-
- def parse_autoescape(self):
- node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
- node.options = [
- nodes.Keyword('autoescape', self.parse_expression())
- ]
- node.body = self.parse_statements(('name:endautoescape',),
- drop_needle=True)
- return nodes.Scope([node])
-
- def parse_block(self):
- node = nodes.Block(lineno=next(self.stream).lineno)
- node.name = self.stream.expect('name').value
- node.scoped = self.stream.skip_if('name:scoped')
-
- # common problem people encounter when switching from django
- # to jinja. we do not support hyphens in block names, so let's
- # raise a nicer error message in that case.
- if self.stream.current.type == 'sub':
- self.fail('Block names in Jinja have to be valid Python '
- 'identifiers and may not contain hyphens, use an '
- 'underscore instead.')
-
- node.body = self.parse_statements(('name:endblock',), drop_needle=True)
- self.stream.skip_if('name:' + node.name)
- return node
-
- def parse_extends(self):
- node = nodes.Extends(lineno=next(self.stream).lineno)
- node.template = self.parse_expression()
- return node
-
- def parse_import_context(self, node, default):
- if self.stream.current.test_any('name:with', 'name:without') and \
- self.stream.look().test('name:context'):
- node.with_context = next(self.stream).value == 'with'
- self.stream.skip()
- else:
- node.with_context = default
- return node
-
- def parse_include(self):
- node = nodes.Include(lineno=next(self.stream).lineno)
- node.template = self.parse_expression()
- if self.stream.current.test('name:ignore') and \
- self.stream.look().test('name:missing'):
- node.ignore_missing = True
- self.stream.skip(2)
- else:
- node.ignore_missing = False
- return self.parse_import_context(node, True)
-
- def parse_import(self):
- node = nodes.Import(lineno=next(self.stream).lineno)
- node.template = self.parse_expression()
- self.stream.expect('name:as')
- node.target = self.parse_assign_target(name_only=True).name
- return self.parse_import_context(node, False)
-
- def parse_from(self):
- node = nodes.FromImport(lineno=next(self.stream).lineno)
- node.template = self.parse_expression()
- self.stream.expect('name:import')
- node.names = []
-
- def parse_context():
- if self.stream.current.value in ('with', 'without') and \
- self.stream.look().test('name:context'):
- node.with_context = next(self.stream).value == 'with'
- self.stream.skip()
- return True
- return False
-
- while 1:
- if node.names:
- self.stream.expect('comma')
- if self.stream.current.type == 'name':
- if parse_context():
- break
- target = self.parse_assign_target(name_only=True)
- if target.name.startswith('_'):
- self.fail('names starting with an underline can not '
- 'be imported', target.lineno,
- exc=TemplateAssertionError)
- if self.stream.skip_if('name:as'):
- alias = self.parse_assign_target(name_only=True)
- node.names.append((target.name, alias.name))
- else:
- node.names.append(target.name)
- if parse_context() or self.stream.current.type != 'comma':
- break
- else:
- self.stream.expect('name')
- if not hasattr(node, 'with_context'):
- node.with_context = False
- return node
-
- def parse_signature(self, node):
- node.args = args = []
- node.defaults = defaults = []
- self.stream.expect('lparen')
- while self.stream.current.type != 'rparen':
- if args:
- self.stream.expect('comma')
- arg = self.parse_assign_target(name_only=True)
- arg.set_ctx('param')
- if self.stream.skip_if('assign'):
- defaults.append(self.parse_expression())
- elif defaults:
- self.fail('non-default argument follows default argument')
- args.append(arg)
- self.stream.expect('rparen')
-
- def parse_call_block(self):
- node = nodes.CallBlock(lineno=next(self.stream).lineno)
- if self.stream.current.type == 'lparen':
- self.parse_signature(node)
- else:
- node.args = []
- node.defaults = []
-
- node.call = self.parse_expression()
- if not isinstance(node.call, nodes.Call):
- self.fail('expected call', node.lineno)
- node.body = self.parse_statements(('name:endcall',), drop_needle=True)
- return node
-
- def parse_filter_block(self):
- node = nodes.FilterBlock(lineno=next(self.stream).lineno)
- node.filter = self.parse_filter(None, start_inline=True)
- node.body = self.parse_statements(('name:endfilter',),
- drop_needle=True)
- return node
-
- def parse_macro(self):
- node = nodes.Macro(lineno=next(self.stream).lineno)
- node.name = self.parse_assign_target(name_only=True).name
- self.parse_signature(node)
- node.body = self.parse_statements(('name:endmacro',),
- drop_needle=True)
- return node
-
- def parse_print(self):
- node = nodes.Output(lineno=next(self.stream).lineno)
- node.nodes = []
- while self.stream.current.type != 'block_end':
- if node.nodes:
- self.stream.expect('comma')
- node.nodes.append(self.parse_expression())
- return node
-
- def parse_assign_target(self, with_tuple=True, name_only=False,
- extra_end_rules=None, with_namespace=False):
- """Parse an assignment target. As Jinja2 allows assignments to
- tuples, this function can parse all allowed assignment targets. Per
- default assignments to tuples are parsed, that can be disable however
- by setting `with_tuple` to `False`. If only assignments to names are
- wanted `name_only` can be set to `True`. The `extra_end_rules`
- parameter is forwarded to the tuple parsing function. If
- `with_namespace` is enabled, a namespace assignment may be parsed.
- """
- if with_namespace and self.stream.look().type == 'dot':
- token = self.stream.expect('name')
- next(self.stream) # dot
- attr = self.stream.expect('name')
- target = nodes.NSRef(token.value, attr.value, lineno=token.lineno)
- elif name_only:
- token = self.stream.expect('name')
- target = nodes.Name(token.value, 'store', lineno=token.lineno)
- else:
- if with_tuple:
- target = self.parse_tuple(simplified=True,
- extra_end_rules=extra_end_rules)
- else:
- target = self.parse_primary()
- target.set_ctx('store')
- if not target.can_assign():
- self.fail('can\'t assign to %r' % target.__class__.
- __name__.lower(), target.lineno)
- return target
-
- def parse_expression(self, with_condexpr=True):
- """Parse an expression. Per default all expressions are parsed, if
- the optional `with_condexpr` parameter is set to `False` conditional
- expressions are not parsed.
- """
- if with_condexpr:
- return self.parse_condexpr()
- return self.parse_or()
-
- def parse_condexpr(self):
- lineno = self.stream.current.lineno
- expr1 = self.parse_or()
- while self.stream.skip_if('name:if'):
- expr2 = self.parse_or()
- if self.stream.skip_if('name:else'):
- expr3 = self.parse_condexpr()
- else:
- expr3 = None
- expr1 = nodes.CondExpr(expr2, expr1, expr3, lineno=lineno)
- lineno = self.stream.current.lineno
- return expr1
-
- def parse_or(self):
- lineno = self.stream.current.lineno
- left = self.parse_and()
- while self.stream.skip_if('name:or'):
- right = self.parse_and()
- left = nodes.Or(left, right, lineno=lineno)
- lineno = self.stream.current.lineno
- return left
-
- def parse_and(self):
- lineno = self.stream.current.lineno
- left = self.parse_not()
- while self.stream.skip_if('name:and'):
- right = self.parse_not()
- left = nodes.And(left, right, lineno=lineno)
- lineno = self.stream.current.lineno
- return left
-
- def parse_not(self):
- if self.stream.current.test('name:not'):
- lineno = next(self.stream).lineno
- return nodes.Not(self.parse_not(), lineno=lineno)
- return self.parse_compare()
-
- def parse_compare(self):
- lineno = self.stream.current.lineno
- expr = self.parse_math1()
- ops = []
- while 1:
- token_type = self.stream.current.type
- if token_type in _compare_operators:
- next(self.stream)
- ops.append(nodes.Operand(token_type, self.parse_math1()))
- elif self.stream.skip_if('name:in'):
- ops.append(nodes.Operand('in', self.parse_math1()))
- elif (self.stream.current.test('name:not') and
- self.stream.look().test('name:in')):
- self.stream.skip(2)
- ops.append(nodes.Operand('notin', self.parse_math1()))
- else:
- break
- lineno = self.stream.current.lineno
- if not ops:
- return expr
- return nodes.Compare(expr, ops, lineno=lineno)
-
- def parse_math1(self):
- lineno = self.stream.current.lineno
- left = self.parse_concat()
- while self.stream.current.type in ('add', 'sub'):
- cls = _math_nodes[self.stream.current.type]
- next(self.stream)
- right = self.parse_concat()
- left = cls(left, right, lineno=lineno)
- lineno = self.stream.current.lineno
- return left
-
- def parse_concat(self):
- lineno = self.stream.current.lineno
- args = [self.parse_math2()]
- while self.stream.current.type == 'tilde':
- next(self.stream)
- args.append(self.parse_math2())
- if len(args) == 1:
- return args[0]
- return nodes.Concat(args, lineno=lineno)
-
- def parse_math2(self):
- lineno = self.stream.current.lineno
- left = self.parse_pow()
- while self.stream.current.type in ('mul', 'div', 'floordiv', 'mod'):
- cls = _math_nodes[self.stream.current.type]
- next(self.stream)
- right = self.parse_pow()
- left = cls(left, right, lineno=lineno)
- lineno = self.stream.current.lineno
- return left
-
- def parse_pow(self):
- lineno = self.stream.current.lineno
- left = self.parse_unary()
- while self.stream.current.type == 'pow':
- next(self.stream)
- right = self.parse_unary()
- left = nodes.Pow(left, right, lineno=lineno)
- lineno = self.stream.current.lineno
- return left
-
- def parse_unary(self, with_filter=True):
- token_type = self.stream.current.type
- lineno = self.stream.current.lineno
- if token_type == 'sub':
- next(self.stream)
- node = nodes.Neg(self.parse_unary(False), lineno=lineno)
- elif token_type == 'add':
- next(self.stream)
- node = nodes.Pos(self.parse_unary(False), lineno=lineno)
- else:
- node = self.parse_primary()
- node = self.parse_postfix(node)
- if with_filter:
- node = self.parse_filter_expr(node)
- return node
-
- def parse_primary(self):
- token = self.stream.current
- if token.type == 'name':
- if token.value in ('true', 'false', 'True', 'False'):
- node = nodes.Const(token.value in ('true', 'True'),
- lineno=token.lineno)
- elif token.value in ('none', 'None'):
- node = nodes.Const(None, lineno=token.lineno)
- else:
- node = nodes.Name(token.value, 'load', lineno=token.lineno)
- next(self.stream)
- elif token.type == 'string':
- next(self.stream)
- buf = [token.value]
- lineno = token.lineno
- while self.stream.current.type == 'string':
- buf.append(self.stream.current.value)
- next(self.stream)
- node = nodes.Const(''.join(buf), lineno=lineno)
- elif token.type in ('integer', 'float'):
- next(self.stream)
- node = nodes.Const(token.value, lineno=token.lineno)
- elif token.type == 'lparen':
- next(self.stream)
- node = self.parse_tuple(explicit_parentheses=True)
- self.stream.expect('rparen')
- elif token.type == 'lbracket':
- node = self.parse_list()
- elif token.type == 'lbrace':
- node = self.parse_dict()
- else:
- self.fail("unexpected '%s'" % describe_token(token), token.lineno)
- return node
-
- def parse_tuple(self, simplified=False, with_condexpr=True,
- extra_end_rules=None, explicit_parentheses=False):
- """Works like `parse_expression` but if multiple expressions are
- delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
- This method could also return a regular expression instead of a tuple
- if no commas where found.
-
- The default parsing mode is a full tuple. If `simplified` is `True`
- only names and literals are parsed. The `no_condexpr` parameter is
- forwarded to :meth:`parse_expression`.
-
- Because tuples do not require delimiters and may end in a bogus comma
- an extra hint is needed that marks the end of a tuple. For example
- for loops support tuples between `for` and `in`. In that case the
- `extra_end_rules` is set to ``['name:in']``.
-
- `explicit_parentheses` is true if the parsing was triggered by an
- expression in parentheses. This is used to figure out if an empty
- tuple is a valid expression or not.
- """
- lineno = self.stream.current.lineno
- if simplified:
- parse = self.parse_primary
- elif with_condexpr:
- parse = self.parse_expression
- else:
- parse = lambda: self.parse_expression(with_condexpr=False)
- args = []
- is_tuple = False
- while 1:
- if args:
- self.stream.expect('comma')
- if self.is_tuple_end(extra_end_rules):
- break
- args.append(parse())
- if self.stream.current.type == 'comma':
- is_tuple = True
- else:
- break
- lineno = self.stream.current.lineno
-
- if not is_tuple:
- if args:
- return args[0]
-
- # if we don't have explicit parentheses, an empty tuple is
- # not a valid expression. This would mean nothing (literally
- # nothing) in the spot of an expression would be an empty
- # tuple.
- if not explicit_parentheses:
- self.fail('Expected an expression, got \'%s\'' %
- describe_token(self.stream.current))
-
- return nodes.Tuple(args, 'load', lineno=lineno)
-
- def parse_list(self):
- token = self.stream.expect('lbracket')
- items = []
- while self.stream.current.type != 'rbracket':
- if items:
- self.stream.expect('comma')
- if self.stream.current.type == 'rbracket':
- break
- items.append(self.parse_expression())
- self.stream.expect('rbracket')
- return nodes.List(items, lineno=token.lineno)
-
- def parse_dict(self):
- token = self.stream.expect('lbrace')
- items = []
- while self.stream.current.type != 'rbrace':
- if items:
- self.stream.expect('comma')
- if self.stream.current.type == 'rbrace':
- break
- key = self.parse_expression()
- self.stream.expect('colon')
- value = self.parse_expression()
- items.append(nodes.Pair(key, value, lineno=key.lineno))
- self.stream.expect('rbrace')
- return nodes.Dict(items, lineno=token.lineno)
-
- def parse_postfix(self, node):
- while 1:
- token_type = self.stream.current.type
- if token_type == 'dot' or token_type == 'lbracket':
- node = self.parse_subscript(node)
- # calls are valid both after postfix expressions (getattr
- # and getitem) as well as filters and tests
- elif token_type == 'lparen':
- node = self.parse_call(node)
- else:
- break
- return node
-
- def parse_filter_expr(self, node):
- while 1:
- token_type = self.stream.current.type
- if token_type == 'pipe':
- node = self.parse_filter(node)
- elif token_type == 'name' and self.stream.current.value == 'is':
- node = self.parse_test(node)
- # calls are valid both after postfix expressions (getattr
- # and getitem) as well as filters and tests
- elif token_type == 'lparen':
- node = self.parse_call(node)
- else:
- break
- return node
-
- def parse_subscript(self, node):
- token = next(self.stream)
- if token.type == 'dot':
- attr_token = self.stream.current
- next(self.stream)
- if attr_token.type == 'name':
- return nodes.Getattr(node, attr_token.value, 'load',
- lineno=token.lineno)
- elif attr_token.type != 'integer':
- self.fail('expected name or number', attr_token.lineno)
- arg = nodes.Const(attr_token.value, lineno=attr_token.lineno)
- return nodes.Getitem(node, arg, 'load', lineno=token.lineno)
- if token.type == 'lbracket':
- args = []
- while self.stream.current.type != 'rbracket':
- if args:
- self.stream.expect('comma')
- args.append(self.parse_subscribed())
- self.stream.expect('rbracket')
- if len(args) == 1:
- arg = args[0]
- else:
- arg = nodes.Tuple(args, 'load', lineno=token.lineno)
- return nodes.Getitem(node, arg, 'load', lineno=token.lineno)
- self.fail('expected subscript expression', self.lineno)
-
- def parse_subscribed(self):
- lineno = self.stream.current.lineno
-
- if self.stream.current.type == 'colon':
- next(self.stream)
- args = [None]
- else:
- node = self.parse_expression()
- if self.stream.current.type != 'colon':
- return node
- next(self.stream)
- args = [node]
-
- if self.stream.current.type == 'colon':
- args.append(None)
- elif self.stream.current.type not in ('rbracket', 'comma'):
- args.append(self.parse_expression())
- else:
- args.append(None)
-
- if self.stream.current.type == 'colon':
- next(self.stream)
- if self.stream.current.type not in ('rbracket', 'comma'):
- args.append(self.parse_expression())
- else:
- args.append(None)
- else:
- args.append(None)
-
- return nodes.Slice(lineno=lineno, *args)
-
- def parse_call(self, node):
- token = self.stream.expect('lparen')
- args = []
- kwargs = []
- dyn_args = dyn_kwargs = None
- require_comma = False
-
- def ensure(expr):
- if not expr:
- self.fail('invalid syntax for function call expression',
- token.lineno)
-
- while self.stream.current.type != 'rparen':
- if require_comma:
- self.stream.expect('comma')
- # support for trailing comma
- if self.stream.current.type == 'rparen':
- break
- if self.stream.current.type == 'mul':
- ensure(dyn_args is None and dyn_kwargs is None)
- next(self.stream)
- dyn_args = self.parse_expression()
- elif self.stream.current.type == 'pow':
- ensure(dyn_kwargs is None)
- next(self.stream)
- dyn_kwargs = self.parse_expression()
- else:
- ensure(dyn_args is None and dyn_kwargs is None)
- if self.stream.current.type == 'name' and \
- self.stream.look().type == 'assign':
- key = self.stream.current.value
- self.stream.skip(2)
- value = self.parse_expression()
- kwargs.append(nodes.Keyword(key, value,
- lineno=value.lineno))
- else:
- ensure(not kwargs)
- args.append(self.parse_expression())
-
- require_comma = True
- self.stream.expect('rparen')
-
- if node is None:
- return args, kwargs, dyn_args, dyn_kwargs
- return nodes.Call(node, args, kwargs, dyn_args, dyn_kwargs,
- lineno=token.lineno)
-
- def parse_filter(self, node, start_inline=False):
- while self.stream.current.type == 'pipe' or start_inline:
- if not start_inline:
- next(self.stream)
- token = self.stream.expect('name')
- name = token.value
- while self.stream.current.type == 'dot':
- next(self.stream)
- name += '.' + self.stream.expect('name').value
- if self.stream.current.type == 'lparen':
- args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
- else:
- args = []
- kwargs = []
- dyn_args = dyn_kwargs = None
- node = nodes.Filter(node, name, args, kwargs, dyn_args,
- dyn_kwargs, lineno=token.lineno)
- start_inline = False
- return node
-
- def parse_test(self, node):
- token = next(self.stream)
- if self.stream.current.test('name:not'):
- next(self.stream)
- negated = True
- else:
- negated = False
- name = self.stream.expect('name').value
- while self.stream.current.type == 'dot':
- next(self.stream)
- name += '.' + self.stream.expect('name').value
- dyn_args = dyn_kwargs = None
- kwargs = []
- if self.stream.current.type == 'lparen':
- args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
- elif (self.stream.current.type in ('name', 'string', 'integer',
- 'float', 'lparen', 'lbracket',
- 'lbrace') and not
- self.stream.current.test_any('name:else', 'name:or',
- 'name:and')):
- if self.stream.current.test('name:is'):
- self.fail('You cannot chain multiple tests with is')
- args = [self.parse_primary()]
- else:
- args = []
- node = nodes.Test(node, name, args, kwargs, dyn_args,
- dyn_kwargs, lineno=token.lineno)
- if negated:
- node = nodes.Not(node, lineno=token.lineno)
- return node
-
- def subparse(self, end_tokens=None):
- body = []
- data_buffer = []
- add_data = data_buffer.append
-
- if end_tokens is not None:
- self._end_token_stack.append(end_tokens)
-
- def flush_data():
- if data_buffer:
- lineno = data_buffer[0].lineno
- body.append(nodes.Output(data_buffer[:], lineno=lineno))
- del data_buffer[:]
-
- try:
- while self.stream:
- token = self.stream.current
- if token.type == 'data':
- if token.value:
- add_data(nodes.TemplateData(token.value,
- lineno=token.lineno))
- next(self.stream)
- elif token.type == 'variable_begin':
- next(self.stream)
- add_data(self.parse_tuple(with_condexpr=True))
- self.stream.expect('variable_end')
- elif token.type == 'block_begin':
- flush_data()
- next(self.stream)
- if end_tokens is not None and \
- self.stream.current.test_any(*end_tokens):
- return body
- rv = self.parse_statement()
- if isinstance(rv, list):
- body.extend(rv)
- else:
- body.append(rv)
- self.stream.expect('block_end')
- else:
- raise AssertionError('internal parsing error')
-
- flush_data()
- finally:
- if end_tokens is not None:
- self._end_token_stack.pop()
-
- return body
-
- def parse(self):
- """Parse the whole template into a `Template` node."""
- result = nodes.Template(self.subparse(), lineno=1)
- result.set_environment(self.environment)
- return result
diff --git a/python/jinja2/runtime.py b/python/jinja2/runtime.py
deleted file mode 100644
index f9d7a68..0000000
--- a/python/jinja2/runtime.py
+++ /dev/null
@@ -1,813 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.runtime
- ~~~~~~~~~~~~~~
-
- Runtime helpers.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-import sys
-
-from itertools import chain
-from types import MethodType
-
-from jinja2.nodes import EvalContext, _context_function_types
-from jinja2.utils import Markup, soft_unicode, escape, missing, concat, \
- internalcode, object_type_repr, evalcontextfunction, Namespace
-from jinja2.exceptions import UndefinedError, TemplateRuntimeError, \
- TemplateNotFound
-from jinja2._compat import imap, text_type, iteritems, \
- implements_iterator, implements_to_string, string_types, PY2, \
- with_metaclass
-
-
-# these variables are exported to the template runtime
-__all__ = ['LoopContext', 'TemplateReference', 'Macro', 'Markup',
- 'TemplateRuntimeError', 'missing', 'concat', 'escape',
- 'markup_join', 'unicode_join', 'to_string', 'identity',
- 'TemplateNotFound', 'Namespace']
-
-#: the name of the function that is used to convert something into
-#: a string. We can just use the text type here.
-to_string = text_type
-
-#: the identity function. Useful for certain things in the environment
-identity = lambda x: x
-
-_first_iteration = object()
-_last_iteration = object()
-
-
-def markup_join(seq):
- """Concatenation that escapes if necessary and converts to unicode."""
- buf = []
- iterator = imap(soft_unicode, seq)
- for arg in iterator:
- buf.append(arg)
- if hasattr(arg, '__html__'):
- return Markup(u'').join(chain(buf, iterator))
- return concat(buf)
-
-
-def unicode_join(seq):
- """Simple args to unicode conversion and concatenation."""
- return concat(imap(text_type, seq))
-
-
-def new_context(environment, template_name, blocks, vars=None,
- shared=None, globals=None, locals=None):
- """Internal helper to for context creation."""
- if vars is None:
- vars = {}
- if shared:
- parent = vars
- else:
- parent = dict(globals or (), **vars)
- if locals:
- # if the parent is shared a copy should be created because
- # we don't want to modify the dict passed
- if shared:
- parent = dict(parent)
- for key, value in iteritems(locals):
- if value is not missing:
- parent[key] = value
- return environment.context_class(environment, parent, template_name,
- blocks)
-
-
-class TemplateReference(object):
- """The `self` in templates."""
-
- def __init__(self, context):
- self.__context = context
-
- def __getitem__(self, name):
- blocks = self.__context.blocks[name]
- return BlockReference(name, self.__context, blocks, 0)
-
- def __repr__(self):
- return '<%s %r>' % (
- self.__class__.__name__,
- self.__context.name
- )
-
-
-def _get_func(x):
- return getattr(x, '__func__', x)
-
-
-class ContextMeta(type):
-
- def __new__(cls, name, bases, d):
- rv = type.__new__(cls, name, bases, d)
- if bases == ():
- return rv
-
- resolve = _get_func(rv.resolve)
- default_resolve = _get_func(Context.resolve)
- resolve_or_missing = _get_func(rv.resolve_or_missing)
- default_resolve_or_missing = _get_func(Context.resolve_or_missing)
-
- # If we have a changed resolve but no changed default or missing
- # resolve we invert the call logic.
- if resolve is not default_resolve and \
- resolve_or_missing is default_resolve_or_missing:
- rv._legacy_resolve_mode = True
- elif resolve is default_resolve and \
- resolve_or_missing is default_resolve_or_missing:
- rv._fast_resolve_mode = True
-
- return rv
-
-
-def resolve_or_missing(context, key, missing=missing):
- if key in context.vars:
- return context.vars[key]
- if key in context.parent:
- return context.parent[key]
- return missing
-
-
-class Context(with_metaclass(ContextMeta)):
- """The template context holds the variables of a template. It stores the
- values passed to the template and also the names the template exports.
- Creating instances is neither supported nor useful as it's created
- automatically at various stages of the template evaluation and should not
- be created by hand.
-
- The context is immutable. Modifications on :attr:`parent` **must not**
- happen and modifications on :attr:`vars` are allowed from generated
- template code only. Template filters and global functions marked as
- :func:`contextfunction`\\s get the active context passed as first argument
- and are allowed to access the context read-only.
-
- The template context supports read only dict operations (`get`,
- `keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`,
- `__getitem__`, `__contains__`). Additionally there is a :meth:`resolve`
- method that doesn't fail with a `KeyError` but returns an
- :class:`Undefined` object for missing variables.
- """
- # XXX: we want to eventually make this be a deprecation warning and
- # remove it.
- _legacy_resolve_mode = False
- _fast_resolve_mode = False
-
- def __init__(self, environment, parent, name, blocks):
- self.parent = parent
- self.vars = {}
- self.environment = environment
- self.eval_ctx = EvalContext(self.environment, name)
- self.exported_vars = set()
- self.name = name
-
- # create the initial mapping of blocks. Whenever template inheritance
- # takes place the runtime will update this mapping with the new blocks
- # from the template.
- self.blocks = dict((k, [v]) for k, v in iteritems(blocks))
-
- # In case we detect the fast resolve mode we can set up an alias
- # here that bypasses the legacy code logic.
- if self._fast_resolve_mode:
- self.resolve_or_missing = MethodType(resolve_or_missing, self)
-
- def super(self, name, current):
- """Render a parent block."""
- try:
- blocks = self.blocks[name]
- index = blocks.index(current) + 1
- blocks[index]
- except LookupError:
- return self.environment.undefined('there is no parent block '
- 'called %r.' % name,
- name='super')
- return BlockReference(name, self, blocks, index)
-
- def get(self, key, default=None):
- """Returns an item from the template context, if it doesn't exist
- `default` is returned.
- """
- try:
- return self[key]
- except KeyError:
- return default
-
- def resolve(self, key):
- """Looks up a variable like `__getitem__` or `get` but returns an
- :class:`Undefined` object with the name of the name looked up.
- """
- if self._legacy_resolve_mode:
- rv = resolve_or_missing(self, key)
- else:
- rv = self.resolve_or_missing(key)
- if rv is missing:
- return self.environment.undefined(name=key)
- return rv
-
- def resolve_or_missing(self, key):
- """Resolves a variable like :meth:`resolve` but returns the
- special `missing` value if it cannot be found.
- """
- if self._legacy_resolve_mode:
- rv = self.resolve(key)
- if isinstance(rv, Undefined):
- rv = missing
- return rv
- return resolve_or_missing(self, key)
-
- def get_exported(self):
- """Get a new dict with the exported variables."""
- return dict((k, self.vars[k]) for k in self.exported_vars)
-
- def get_all(self):
- """Return the complete context as dict including the exported
- variables. For optimizations reasons this might not return an
- actual copy so be careful with using it.
- """
- if not self.vars:
- return self.parent
- if not self.parent:
- return self.vars
- return dict(self.parent, **self.vars)
-
- @internalcode
- def call(__self, __obj, *args, **kwargs):
- """Call the callable with the arguments and keyword arguments
- provided but inject the active context or environment as first
- argument if the callable is a :func:`contextfunction` or
- :func:`environmentfunction`.
- """
- if __debug__:
- __traceback_hide__ = True # noqa
-
- # Allow callable classes to take a context
- if hasattr(__obj, '__call__'):
- fn = __obj.__call__
- for fn_type in ('contextfunction',
- 'evalcontextfunction',
- 'environmentfunction'):
- if hasattr(fn, fn_type):
- __obj = fn
- break
-
- if isinstance(__obj, _context_function_types):
- if getattr(__obj, 'contextfunction', 0):
- args = (__self,) + args
- elif getattr(__obj, 'evalcontextfunction', 0):
- args = (__self.eval_ctx,) + args
- elif getattr(__obj, 'environmentfunction', 0):
- args = (__self.environment,) + args
- try:
- return __obj(*args, **kwargs)
- except StopIteration:
- return __self.environment.undefined('value was undefined because '
- 'a callable raised a '
- 'StopIteration exception')
-
- def derived(self, locals=None):
- """Internal helper function to create a derived context. This is
- used in situations where the system needs a new context in the same
- template that is independent.
- """
- context = new_context(self.environment, self.name, {},
- self.get_all(), True, None, locals)
- context.eval_ctx = self.eval_ctx
- context.blocks.update((k, list(v)) for k, v in iteritems(self.blocks))
- return context
-
- def _all(meth):
- proxy = lambda self: getattr(self.get_all(), meth)()
- proxy.__doc__ = getattr(dict, meth).__doc__
- proxy.__name__ = meth
- return proxy
-
- keys = _all('keys')
- values = _all('values')
- items = _all('items')
-
- # not available on python 3
- if PY2:
- iterkeys = _all('iterkeys')
- itervalues = _all('itervalues')
- iteritems = _all('iteritems')
- del _all
-
- def __contains__(self, name):
- return name in self.vars or name in self.parent
-
- def __getitem__(self, key):
- """Lookup a variable or raise `KeyError` if the variable is
- undefined.
- """
- item = self.resolve_or_missing(key)
- if item is missing:
- raise KeyError(key)
- return item
-
- def __repr__(self):
- return '<%s %s of %r>' % (
- self.__class__.__name__,
- repr(self.get_all()),
- self.name
- )
-
-
-# register the context as mapping if possible
-try:
- from collections import Mapping
- Mapping.register(Context)
-except ImportError:
- pass
-
-
-class BlockReference(object):
- """One block on a template reference."""
-
- def __init__(self, name, context, stack, depth):
- self.name = name
- self._context = context
- self._stack = stack
- self._depth = depth
-
- @property
- def super(self):
- """Super the block."""
- if self._depth + 1 >= len(self._stack):
- return self._context.environment. \
- undefined('there is no parent block called %r.' %
- self.name, name='super')
- return BlockReference(self.name, self._context, self._stack,
- self._depth + 1)
-
- @internalcode
- def __call__(self):
- rv = concat(self._stack[self._depth](self._context))
- if self._context.eval_ctx.autoescape:
- rv = Markup(rv)
- return rv
-
-
-class LoopContextBase(object):
- """A loop context for dynamic iteration."""
-
- _before = _first_iteration
- _current = _first_iteration
- _after = _last_iteration
- _length = None
-
- def __init__(self, undefined, recurse=None, depth0=0):
- self._undefined = undefined
- self._recurse = recurse
- self.index0 = -1
- self.depth0 = depth0
- self._last_checked_value = missing
-
- def cycle(self, *args):
- """Cycles among the arguments with the current loop index."""
- if not args:
- raise TypeError('no items for cycling given')
- return args[self.index0 % len(args)]
-
- def changed(self, *value):
- """Checks whether the value has changed since the last call."""
- if self._last_checked_value != value:
- self._last_checked_value = value
- return True
- return False
-
- first = property(lambda x: x.index0 == 0)
- last = property(lambda x: x._after is _last_iteration)
- index = property(lambda x: x.index0 + 1)
- revindex = property(lambda x: x.length - x.index0)
- revindex0 = property(lambda x: x.length - x.index)
- depth = property(lambda x: x.depth0 + 1)
-
- @property
- def previtem(self):
- if self._before is _first_iteration:
- return self._undefined('there is no previous item')
- return self._before
-
- @property
- def nextitem(self):
- if self._after is _last_iteration:
- return self._undefined('there is no next item')
- return self._after
-
- def __len__(self):
- return self.length
-
- @internalcode
- def loop(self, iterable):
- if self._recurse is None:
- raise TypeError('Tried to call non recursive loop. Maybe you '
- "forgot the 'recursive' modifier.")
- return self._recurse(iterable, self._recurse, self.depth0 + 1)
-
- # a nifty trick to enhance the error message if someone tried to call
- # the the loop without or with too many arguments.
- __call__ = loop
- del loop
-
- def __repr__(self):
- return '<%s %r/%r>' % (
- self.__class__.__name__,
- self.index,
- self.length
- )
-
-
-class LoopContext(LoopContextBase):
-
- def __init__(self, iterable, undefined, recurse=None, depth0=0):
- LoopContextBase.__init__(self, undefined, recurse, depth0)
- self._iterator = iter(iterable)
-
- # try to get the length of the iterable early. This must be done
- # here because there are some broken iterators around where there
- # __len__ is the number of iterations left (i'm looking at your
- # listreverseiterator!).
- try:
- self._length = len(iterable)
- except (TypeError, AttributeError):
- self._length = None
- self._after = self._safe_next()
-
- @property
- def length(self):
- if self._length is None:
- # if was not possible to get the length of the iterator when
- # the loop context was created (ie: iterating over a generator)
- # we have to convert the iterable into a sequence and use the
- # length of that + the number of iterations so far.
- iterable = tuple(self._iterator)
- self._iterator = iter(iterable)
- iterations_done = self.index0 + 2
- self._length = len(iterable) + iterations_done
- return self._length
-
- def __iter__(self):
- return LoopContextIterator(self)
-
- def _safe_next(self):
- try:
- return next(self._iterator)
- except StopIteration:
- return _last_iteration
-
-
-@implements_iterator
-class LoopContextIterator(object):
- """The iterator for a loop context."""
- __slots__ = ('context',)
-
- def __init__(self, context):
- self.context = context
-
- def __iter__(self):
- return self
-
- def __next__(self):
- ctx = self.context
- ctx.index0 += 1
- if ctx._after is _last_iteration:
- raise StopIteration()
- ctx._before = ctx._current
- ctx._current = ctx._after
- ctx._after = ctx._safe_next()
- return ctx._current, ctx
-
-
-class Macro(object):
- """Wraps a macro function."""
-
- def __init__(self, environment, func, name, arguments,
- catch_kwargs, catch_varargs, caller,
- default_autoescape=None):
- self._environment = environment
- self._func = func
- self._argument_count = len(arguments)
- self.name = name
- self.arguments = arguments
- self.catch_kwargs = catch_kwargs
- self.catch_varargs = catch_varargs
- self.caller = caller
- self.explicit_caller = 'caller' in arguments
- if default_autoescape is None:
- default_autoescape = environment.autoescape
- self._default_autoescape = default_autoescape
-
- @internalcode
- @evalcontextfunction
- def __call__(self, *args, **kwargs):
- # This requires a bit of explanation, In the past we used to
- # decide largely based on compile-time information if a macro is
- # safe or unsafe. While there was a volatile mode it was largely
- # unused for deciding on escaping. This turns out to be
- # problemtic for macros because if a macro is safe or not not so
- # much depends on the escape mode when it was defined but when it
- # was used.
- #
- # Because however we export macros from the module system and
- # there are historic callers that do not pass an eval context (and
- # will continue to not pass one), we need to perform an instance
- # check here.
- #
- # This is considered safe because an eval context is not a valid
- # argument to callables otherwise anwyays. Worst case here is
- # that if no eval context is passed we fall back to the compile
- # time autoescape flag.
- if args and isinstance(args[0], EvalContext):
- autoescape = args[0].autoescape
- args = args[1:]
- else:
- autoescape = self._default_autoescape
-
- # try to consume the positional arguments
- arguments = list(args[:self._argument_count])
- off = len(arguments)
-
- # For information why this is necessary refer to the handling
- # of caller in the `macro_body` handler in the compiler.
- found_caller = False
-
- # if the number of arguments consumed is not the number of
- # arguments expected we start filling in keyword arguments
- # and defaults.
- if off != self._argument_count:
- for idx, name in enumerate(self.arguments[len(arguments):]):
- try:
- value = kwargs.pop(name)
- except KeyError:
- value = missing
- if name == 'caller':
- found_caller = True
- arguments.append(value)
- else:
- found_caller = self.explicit_caller
-
- # it's important that the order of these arguments does not change
- # if not also changed in the compiler's `function_scoping` method.
- # the order is caller, keyword arguments, positional arguments!
- if self.caller and not found_caller:
- caller = kwargs.pop('caller', None)
- if caller is None:
- caller = self._environment.undefined('No caller defined',
- name='caller')
- arguments.append(caller)
-
- if self.catch_kwargs:
- arguments.append(kwargs)
- elif kwargs:
- if 'caller' in kwargs:
- raise TypeError('macro %r was invoked with two values for '
- 'the special caller argument. This is '
- 'most likely a bug.' % self.name)
- raise TypeError('macro %r takes no keyword argument %r' %
- (self.name, next(iter(kwargs))))
- if self.catch_varargs:
- arguments.append(args[self._argument_count:])
- elif len(args) > self._argument_count:
- raise TypeError('macro %r takes not more than %d argument(s)' %
- (self.name, len(self.arguments)))
-
- return self._invoke(arguments, autoescape)
-
- def _invoke(self, arguments, autoescape):
- """This method is being swapped out by the async implementation."""
- rv = self._func(*arguments)
- if autoescape:
- rv = Markup(rv)
- return rv
-
- def __repr__(self):
- return '<%s %s>' % (
- self.__class__.__name__,
- self.name is None and 'anonymous' or repr(self.name)
- )
-
-
-@implements_to_string
-class Undefined(object):
- """The default undefined type. This undefined type can be printed and
- iterated over, but every other access will raise an :exc:`jinja2.exceptions.UndefinedError`:
-
- >>> foo = Undefined(name='foo')
- >>> str(foo)
- ''
- >>> not foo
- True
- >>> foo + 42
- Traceback (most recent call last):
- ...
- jinja2.exceptions.UndefinedError: 'foo' is undefined
- """
- __slots__ = ('_undefined_hint', '_undefined_obj', '_undefined_name',
- '_undefined_exception')
-
- def __init__(self, hint=None, obj=missing, name=None, exc=UndefinedError):
- self._undefined_hint = hint
- self._undefined_obj = obj
- self._undefined_name = name
- self._undefined_exception = exc
-
- @internalcode
- def _fail_with_undefined_error(self, *args, **kwargs):
- """Regular callback function for undefined objects that raises an
- `jinja2.exceptions.UndefinedError` on call.
- """
- if self._undefined_hint is None:
- if self._undefined_obj is missing:
- hint = '%r is undefined' % self._undefined_name
- elif not isinstance(self._undefined_name, string_types):
- hint = '%s has no element %r' % (
- object_type_repr(self._undefined_obj),
- self._undefined_name
- )
- else:
- hint = '%r has no attribute %r' % (
- object_type_repr(self._undefined_obj),
- self._undefined_name
- )
- else:
- hint = self._undefined_hint
- raise self._undefined_exception(hint)
-
- @internalcode
- def __getattr__(self, name):
- if name[:2] == '__':
- raise AttributeError(name)
- return self._fail_with_undefined_error()
-
- __add__ = __radd__ = __mul__ = __rmul__ = __div__ = __rdiv__ = \
- __truediv__ = __rtruediv__ = __floordiv__ = __rfloordiv__ = \
- __mod__ = __rmod__ = __pos__ = __neg__ = __call__ = \
- __getitem__ = __lt__ = __le__ = __gt__ = __ge__ = __int__ = \
- __float__ = __complex__ = __pow__ = __rpow__ = __sub__ = \
- __rsub__ = _fail_with_undefined_error
-
- def __eq__(self, other):
- return type(self) is type(other)
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __hash__(self):
- return id(type(self))
-
- def __str__(self):
- return u''
-
- def __len__(self):
- return 0
-
- def __iter__(self):
- if 0:
- yield None
-
- def __nonzero__(self):
- return False
- __bool__ = __nonzero__
-
- def __repr__(self):
- return 'Undefined'
-
-
-def make_logging_undefined(logger=None, base=None):
- """Given a logger object this returns a new undefined class that will
- log certain failures. It will log iterations and printing. If no
- logger is given a default logger is created.
-
- Example::
-
- logger = logging.getLogger(__name__)
- LoggingUndefined = make_logging_undefined(
- logger=logger,
- base=Undefined
- )
-
- .. versionadded:: 2.8
-
- :param logger: the logger to use. If not provided, a default logger
- is created.
- :param base: the base class to add logging functionality to. This
- defaults to :class:`Undefined`.
- """
- if logger is None:
- import logging
- logger = logging.getLogger(__name__)
- logger.addHandler(logging.StreamHandler(sys.stderr))
- if base is None:
- base = Undefined
-
- def _log_message(undef):
- if undef._undefined_hint is None:
- if undef._undefined_obj is missing:
- hint = '%s is undefined' % undef._undefined_name
- elif not isinstance(undef._undefined_name, string_types):
- hint = '%s has no element %s' % (
- object_type_repr(undef._undefined_obj),
- undef._undefined_name)
- else:
- hint = '%s has no attribute %s' % (
- object_type_repr(undef._undefined_obj),
- undef._undefined_name)
- else:
- hint = undef._undefined_hint
- logger.warning('Template variable warning: %s', hint)
-
- class LoggingUndefined(base):
-
- def _fail_with_undefined_error(self, *args, **kwargs):
- try:
- return base._fail_with_undefined_error(self, *args, **kwargs)
- except self._undefined_exception as e:
- logger.error('Template variable error: %s', str(e))
- raise e
-
- def __str__(self):
- rv = base.__str__(self)
- _log_message(self)
- return rv
-
- def __iter__(self):
- rv = base.__iter__(self)
- _log_message(self)
- return rv
-
- if PY2:
- def __nonzero__(self):
- rv = base.__nonzero__(self)
- _log_message(self)
- return rv
-
- def __unicode__(self):
- rv = base.__unicode__(self)
- _log_message(self)
- return rv
- else:
- def __bool__(self):
- rv = base.__bool__(self)
- _log_message(self)
- return rv
-
- return LoggingUndefined
-
-
-@implements_to_string
-class DebugUndefined(Undefined):
- """An undefined that returns the debug info when printed.
-
- >>> foo = DebugUndefined(name='foo')
- >>> str(foo)
- '{{ foo }}'
- >>> not foo
- True
- >>> foo + 42
- Traceback (most recent call last):
- ...
- jinja2.exceptions.UndefinedError: 'foo' is undefined
- """
- __slots__ = ()
-
- def __str__(self):
- if self._undefined_hint is None:
- if self._undefined_obj is missing:
- return u'{{ %s }}' % self._undefined_name
- return '{{ no such element: %s[%r] }}' % (
- object_type_repr(self._undefined_obj),
- self._undefined_name
- )
- return u'{{ undefined value printed: %s }}' % self._undefined_hint
-
-
-@implements_to_string
-class StrictUndefined(Undefined):
- """An undefined that barks on print and iteration as well as boolean
- tests and all kinds of comparisons. In other words: you can do nothing
- with it except checking if it's defined using the `defined` test.
-
- >>> foo = StrictUndefined(name='foo')
- >>> str(foo)
- Traceback (most recent call last):
- ...
- jinja2.exceptions.UndefinedError: 'foo' is undefined
- >>> not foo
- Traceback (most recent call last):
- ...
- jinja2.exceptions.UndefinedError: 'foo' is undefined
- >>> foo + 42
- Traceback (most recent call last):
- ...
- jinja2.exceptions.UndefinedError: 'foo' is undefined
- """
- __slots__ = ()
- __iter__ = __str__ = __len__ = __nonzero__ = __eq__ = \
- __ne__ = __bool__ = __hash__ = \
- Undefined._fail_with_undefined_error
-
-
-# remove remaining slots attributes, after the metaclass did the magic they
-# are unneeded and irritating as they contain wrong data for the subclasses.
-del Undefined.__slots__, DebugUndefined.__slots__, StrictUndefined.__slots__
diff --git a/python/jinja2/sandbox.py b/python/jinja2/sandbox.py
deleted file mode 100644
index 752e812..0000000
--- a/python/jinja2/sandbox.py
+++ /dev/null
@@ -1,486 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.sandbox
- ~~~~~~~~~~~~~~
-
- Adds a sandbox layer to Jinja as it was the default behavior in the old
- Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the
- default behavior is easier to use.
-
- The behavior can be changed by subclassing the environment.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-import types
-import operator
-from collections import Mapping
-from jinja2.environment import Environment
-from jinja2.exceptions import SecurityError
-from jinja2._compat import string_types, PY2
-from jinja2.utils import Markup
-
-from markupsafe import EscapeFormatter
-from string import Formatter
-
-
-#: maximum number of items a range may produce
-MAX_RANGE = 100000
-
-#: attributes of function objects that are considered unsafe.
-if PY2:
- UNSAFE_FUNCTION_ATTRIBUTES = set(['func_closure', 'func_code', 'func_dict',
- 'func_defaults', 'func_globals'])
-else:
- # On versions > python 2 the special attributes on functions are gone,
- # but they remain on methods and generators for whatever reason.
- UNSAFE_FUNCTION_ATTRIBUTES = set()
-
-
-#: unsafe method attributes. function attributes are unsafe for methods too
-UNSAFE_METHOD_ATTRIBUTES = set(['im_class', 'im_func', 'im_self'])
-
-#: unsafe generator attirbutes.
-UNSAFE_GENERATOR_ATTRIBUTES = set(['gi_frame', 'gi_code'])
-
-#: unsafe attributes on coroutines
-UNSAFE_COROUTINE_ATTRIBUTES = set(['cr_frame', 'cr_code'])
-
-#: unsafe attributes on async generators
-UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = set(['ag_code', 'ag_frame'])
-
-import warnings
-
-# make sure we don't warn in python 2.6 about stuff we don't care about
-warnings.filterwarnings('ignore', 'the sets module', DeprecationWarning,
- module='jinja2.sandbox')
-
-from collections import deque
-
-_mutable_set_types = (set,)
-_mutable_mapping_types = (dict,)
-_mutable_sequence_types = (list,)
-
-
-# on python 2.x we can register the user collection types
-try:
- from UserDict import UserDict, DictMixin
- from UserList import UserList
- _mutable_mapping_types += (UserDict, DictMixin)
- _mutable_set_types += (UserList,)
-except ImportError:
- pass
-
-# if sets is still available, register the mutable set from there as well
-try:
- from sets import Set
- _mutable_set_types += (Set,)
-except ImportError:
- pass
-
-#: register Python 2.6 abstract base classes
-from collections import MutableSet, MutableMapping, MutableSequence
-_mutable_set_types += (MutableSet,)
-_mutable_mapping_types += (MutableMapping,)
-_mutable_sequence_types += (MutableSequence,)
-
-
-_mutable_spec = (
- (_mutable_set_types, frozenset([
- 'add', 'clear', 'difference_update', 'discard', 'pop', 'remove',
- 'symmetric_difference_update', 'update'
- ])),
- (_mutable_mapping_types, frozenset([
- 'clear', 'pop', 'popitem', 'setdefault', 'update'
- ])),
- (_mutable_sequence_types, frozenset([
- 'append', 'reverse', 'insert', 'sort', 'extend', 'remove'
- ])),
- (deque, frozenset([
- 'append', 'appendleft', 'clear', 'extend', 'extendleft', 'pop',
- 'popleft', 'remove', 'rotate'
- ]))
-)
-
-
-class _MagicFormatMapping(Mapping):
- """This class implements a dummy wrapper to fix a bug in the Python
- standard library for string formatting.
-
- See https://bugs.python.org/issue13598 for information about why
- this is necessary.
- """
-
- def __init__(self, args, kwargs):
- self._args = args
- self._kwargs = kwargs
- self._last_index = 0
-
- def __getitem__(self, key):
- if key == '':
- idx = self._last_index
- self._last_index += 1
- try:
- return self._args[idx]
- except LookupError:
- pass
- key = str(idx)
- return self._kwargs[key]
-
- def __iter__(self):
- return iter(self._kwargs)
-
- def __len__(self):
- return len(self._kwargs)
-
-
-def inspect_format_method(callable):
- if not isinstance(callable, (types.MethodType,
- types.BuiltinMethodType)) or \
- callable.__name__ not in ('format', 'format_map'):
- return None
- obj = callable.__self__
- if isinstance(obj, string_types):
- return obj
-
-
-def safe_range(*args):
- """A range that can't generate ranges with a length of more than
- MAX_RANGE items.
- """
- rng = range(*args)
- if len(rng) > MAX_RANGE:
- raise OverflowError('range too big, maximum size for range is %d' %
- MAX_RANGE)
- return rng
-
-
-def unsafe(f):
- """Marks a function or method as unsafe.
-
- ::
-
- @unsafe
- def delete(self):
- pass
- """
- f.unsafe_callable = True
- return f
-
-
-def is_internal_attribute(obj, attr):
- """Test if the attribute given is an internal python attribute. For
- example this function returns `True` for the `func_code` attribute of
- python objects. This is useful if the environment method
- :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.
-
- >>> from jinja2.sandbox import is_internal_attribute
- >>> is_internal_attribute(str, "mro")
- True
- >>> is_internal_attribute(str, "upper")
- False
- """
- if isinstance(obj, types.FunctionType):
- if attr in UNSAFE_FUNCTION_ATTRIBUTES:
- return True
- elif isinstance(obj, types.MethodType):
- if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
- attr in UNSAFE_METHOD_ATTRIBUTES:
- return True
- elif isinstance(obj, type):
- if attr == 'mro':
- return True
- elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
- return True
- elif isinstance(obj, types.GeneratorType):
- if attr in UNSAFE_GENERATOR_ATTRIBUTES:
- return True
- elif hasattr(types, 'CoroutineType') and isinstance(obj, types.CoroutineType):
- if attr in UNSAFE_COROUTINE_ATTRIBUTES:
- return True
- elif hasattr(types, 'AsyncGeneratorType') and isinstance(obj, types.AsyncGeneratorType):
- if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
- return True
- return attr.startswith('__')
-
-
-def modifies_known_mutable(obj, attr):
- """This function checks if an attribute on a builtin mutable object
- (list, dict, set or deque) would modify it if called. It also supports
- the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and
- with Python 2.6 onwards the abstract base classes `MutableSet`,
- `MutableMapping`, and `MutableSequence`.
-
- >>> modifies_known_mutable({}, "clear")
- True
- >>> modifies_known_mutable({}, "keys")
- False
- >>> modifies_known_mutable([], "append")
- True
- >>> modifies_known_mutable([], "index")
- False
-
- If called with an unsupported object (such as unicode) `False` is
- returned.
-
- >>> modifies_known_mutable("foo", "upper")
- False
- """
- for typespec, unsafe in _mutable_spec:
- if isinstance(obj, typespec):
- return attr in unsafe
- return False
-
-
-class SandboxedEnvironment(Environment):
- """The sandboxed environment. It works like the regular environment but
- tells the compiler to generate sandboxed code. Additionally subclasses of
- this environment may override the methods that tell the runtime what
- attributes or functions are safe to access.
-
- If the template tries to access insecure code a :exc:`SecurityError` is
- raised. However also other exceptions may occur during the rendering so
- the caller has to ensure that all exceptions are caught.
- """
- sandboxed = True
-
- #: default callback table for the binary operators. A copy of this is
- #: available on each instance of a sandboxed environment as
- #: :attr:`binop_table`
- default_binop_table = {
- '+': operator.add,
- '-': operator.sub,
- '*': operator.mul,
- '/': operator.truediv,
- '//': operator.floordiv,
- '**': operator.pow,
- '%': operator.mod
- }
-
- #: default callback table for the unary operators. A copy of this is
- #: available on each instance of a sandboxed environment as
- #: :attr:`unop_table`
- default_unop_table = {
- '+': operator.pos,
- '-': operator.neg
- }
-
- #: a set of binary operators that should be intercepted. Each operator
- #: that is added to this set (empty by default) is delegated to the
- #: :meth:`call_binop` method that will perform the operator. The default
- #: operator callback is specified by :attr:`binop_table`.
- #:
- #: The following binary operators are interceptable:
- #: ``//``, ``%``, ``+``, ``*``, ``-``, ``/``, and ``**``
- #:
- #: The default operation form the operator table corresponds to the
- #: builtin function. Intercepted calls are always slower than the native
- #: operator call, so make sure only to intercept the ones you are
- #: interested in.
- #:
- #: .. versionadded:: 2.6
- intercepted_binops = frozenset()
-
- #: a set of unary operators that should be intercepted. Each operator
- #: that is added to this set (empty by default) is delegated to the
- #: :meth:`call_unop` method that will perform the operator. The default
- #: operator callback is specified by :attr:`unop_table`.
- #:
- #: The following unary operators are interceptable: ``+``, ``-``
- #:
- #: The default operation form the operator table corresponds to the
- #: builtin function. Intercepted calls are always slower than the native
- #: operator call, so make sure only to intercept the ones you are
- #: interested in.
- #:
- #: .. versionadded:: 2.6
- intercepted_unops = frozenset()
-
- def intercept_unop(self, operator):
- """Called during template compilation with the name of a unary
- operator to check if it should be intercepted at runtime. If this
- method returns `True`, :meth:`call_unop` is excuted for this unary
- operator. The default implementation of :meth:`call_unop` will use
- the :attr:`unop_table` dictionary to perform the operator with the
- same logic as the builtin one.
-
- The following unary operators are interceptable: ``+`` and ``-``
-
- Intercepted calls are always slower than the native operator call,
- so make sure only to intercept the ones you are interested in.
-
- .. versionadded:: 2.6
- """
- return False
-
-
- def __init__(self, *args, **kwargs):
- Environment.__init__(self, *args, **kwargs)
- self.globals['range'] = safe_range
- self.binop_table = self.default_binop_table.copy()
- self.unop_table = self.default_unop_table.copy()
-
- def is_safe_attribute(self, obj, attr, value):
- """The sandboxed environment will call this method to check if the
- attribute of an object is safe to access. Per default all attributes
- starting with an underscore are considered private as well as the
- special attributes of internal python objects as returned by the
- :func:`is_internal_attribute` function.
- """
- return not (attr.startswith('_') or is_internal_attribute(obj, attr))
-
- def is_safe_callable(self, obj):
- """Check if an object is safely callable. Per default a function is
- considered safe unless the `unsafe_callable` attribute exists and is
- True. Override this method to alter the behavior, but this won't
- affect the `unsafe` decorator from this module.
- """
- return not (getattr(obj, 'unsafe_callable', False) or
- getattr(obj, 'alters_data', False))
-
- def call_binop(self, context, operator, left, right):
- """For intercepted binary operator calls (:meth:`intercepted_binops`)
- this function is executed instead of the builtin operator. This can
- be used to fine tune the behavior of certain operators.
-
- .. versionadded:: 2.6
- """
- return self.binop_table[operator](left, right)
-
- def call_unop(self, context, operator, arg):
- """For intercepted unary operator calls (:meth:`intercepted_unops`)
- this function is executed instead of the builtin operator. This can
- be used to fine tune the behavior of certain operators.
-
- .. versionadded:: 2.6
- """
- return self.unop_table[operator](arg)
-
- def getitem(self, obj, argument):
- """Subscribe an object from sandboxed code."""
- try:
- return obj[argument]
- except (TypeError, LookupError):
- if isinstance(argument, string_types):
- try:
- attr = str(argument)
- except Exception:
- pass
- else:
- try:
- value = getattr(obj, attr)
- except AttributeError:
- pass
- else:
- if self.is_safe_attribute(obj, argument, value):
- return value
- return self.unsafe_undefined(obj, argument)
- return self.undefined(obj=obj, name=argument)
-
- def getattr(self, obj, attribute):
- """Subscribe an object from sandboxed code and prefer the
- attribute. The attribute passed *must* be a bytestring.
- """
- try:
- value = getattr(obj, attribute)
- except AttributeError:
- try:
- return obj[attribute]
- except (TypeError, LookupError):
- pass
- else:
- if self.is_safe_attribute(obj, attribute, value):
- return value
- return self.unsafe_undefined(obj, attribute)
- return self.undefined(obj=obj, name=attribute)
-
- def unsafe_undefined(self, obj, attribute):
- """Return an undefined object for unsafe attributes."""
- return self.undefined('access to attribute %r of %r '
- 'object is unsafe.' % (
- attribute,
- obj.__class__.__name__
- ), name=attribute, obj=obj, exc=SecurityError)
-
- def format_string(self, s, args, kwargs, format_func=None):
- """If a format call is detected, then this is routed through this
- method so that our safety sandbox can be used for it.
- """
- if isinstance(s, Markup):
- formatter = SandboxedEscapeFormatter(self, s.escape)
- else:
- formatter = SandboxedFormatter(self)
-
- if format_func is not None and format_func.__name__ == 'format_map':
- if len(args) != 1 or kwargs:
- raise TypeError(
- 'format_map() takes exactly one argument %d given'
- % (len(args) + (kwargs is not None))
- )
-
- kwargs = args[0]
- args = None
-
- kwargs = _MagicFormatMapping(args, kwargs)
- rv = formatter.vformat(s, args, kwargs)
- return type(s)(rv)
-
- def call(__self, __context, __obj, *args, **kwargs):
- """Call an object from sandboxed code."""
- fmt = inspect_format_method(__obj)
- if fmt is not None:
- return __self.format_string(fmt, args, kwargs, __obj)
-
- # the double prefixes are to avoid double keyword argument
- # errors when proxying the call.
- if not __self.is_safe_callable(__obj):
- raise SecurityError('%r is not safely callable' % (__obj,))
- return __context.call(__obj, *args, **kwargs)
-
-
-class ImmutableSandboxedEnvironment(SandboxedEnvironment):
- """Works exactly like the regular `SandboxedEnvironment` but does not
- permit modifications on the builtin mutable objects `list`, `set`, and
- `dict` by using the :func:`modifies_known_mutable` function.
- """
-
- def is_safe_attribute(self, obj, attr, value):
- if not SandboxedEnvironment.is_safe_attribute(self, obj, attr, value):
- return False
- return not modifies_known_mutable(obj, attr)
-
-
-# This really is not a public API apparenlty.
-try:
- from _string import formatter_field_name_split
-except ImportError:
- def formatter_field_name_split(field_name):
- return field_name._formatter_field_name_split()
-
-
-class SandboxedFormatterMixin(object):
-
- def __init__(self, env):
- self._env = env
-
- def get_field(self, field_name, args, kwargs):
- first, rest = formatter_field_name_split(field_name)
- obj = self.get_value(first, args, kwargs)
- for is_attr, i in rest:
- if is_attr:
- obj = self._env.getattr(obj, i)
- else:
- obj = self._env.getitem(obj, i)
- return obj, first
-
-class SandboxedFormatter(SandboxedFormatterMixin, Formatter):
-
- def __init__(self, env):
- SandboxedFormatterMixin.__init__(self, env)
- Formatter.__init__(self)
-
-class SandboxedEscapeFormatter(SandboxedFormatterMixin, EscapeFormatter):
-
- def __init__(self, env, escape):
- SandboxedFormatterMixin.__init__(self, env)
- EscapeFormatter.__init__(self, escape)
diff --git a/python/jinja2/tests.py b/python/jinja2/tests.py
deleted file mode 100644
index 0adc3d4..0000000
--- a/python/jinja2/tests.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.tests
- ~~~~~~~~~~~~
-
- Jinja test functions. Used with the "is" operator.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import operator
-import re
-from collections import Mapping
-from jinja2.runtime import Undefined
-from jinja2._compat import text_type, string_types, integer_types
-import decimal
-
-number_re = re.compile(r'^-?\d+(\.\d+)?$')
-regex_type = type(number_re)
-
-
-test_callable = callable
-
-
-def test_odd(value):
- """Return true if the variable is odd."""
- return value % 2 == 1
-
-
-def test_even(value):
- """Return true if the variable is even."""
- return value % 2 == 0
-
-
-def test_divisibleby(value, num):
- """Check if a variable is divisible by a number."""
- return value % num == 0
-
-
-def test_defined(value):
- """Return true if the variable is defined:
-
- .. sourcecode:: jinja
-
- {% if variable is defined %}
- value of variable: {{ variable }}
- {% else %}
- variable is not defined
- {% endif %}
-
- See the :func:`default` filter for a simple way to set undefined
- variables.
- """
- return not isinstance(value, Undefined)
-
-
-def test_undefined(value):
- """Like :func:`defined` but the other way round."""
- return isinstance(value, Undefined)
-
-
-def test_none(value):
- """Return true if the variable is none."""
- return value is None
-
-
-def test_lower(value):
- """Return true if the variable is lowercased."""
- return text_type(value).islower()
-
-
-def test_upper(value):
- """Return true if the variable is uppercased."""
- return text_type(value).isupper()
-
-
-def test_string(value):
- """Return true if the object is a string."""
- return isinstance(value, string_types)
-
-
-def test_mapping(value):
- """Return true if the object is a mapping (dict etc.).
-
- .. versionadded:: 2.6
- """
- return isinstance(value, Mapping)
-
-
-def test_number(value):
- """Return true if the variable is a number."""
- return isinstance(value, integer_types + (float, complex, decimal.Decimal))
-
-
-def test_sequence(value):
- """Return true if the variable is a sequence. Sequences are variables
- that are iterable.
- """
- try:
- len(value)
- value.__getitem__
- except:
- return False
- return True
-
-
-def test_sameas(value, other):
- """Check if an object points to the same memory address than another
- object:
-
- .. sourcecode:: jinja
-
- {% if foo.attribute is sameas false %}
- the foo attribute really is the `False` singleton
- {% endif %}
- """
- return value is other
-
-
-def test_iterable(value):
- """Check if it's possible to iterate over an object."""
- try:
- iter(value)
- except TypeError:
- return False
- return True
-
-
-def test_escaped(value):
- """Check if the value is escaped."""
- return hasattr(value, '__html__')
-
-
-def test_in(value, seq):
- """Check if value is in seq.
-
- .. versionadded:: 2.10
- """
- return value in seq
-
-
-TESTS = {
- 'odd': test_odd,
- 'even': test_even,
- 'divisibleby': test_divisibleby,
- 'defined': test_defined,
- 'undefined': test_undefined,
- 'none': test_none,
- 'lower': test_lower,
- 'upper': test_upper,
- 'string': test_string,
- 'mapping': test_mapping,
- 'number': test_number,
- 'sequence': test_sequence,
- 'iterable': test_iterable,
- 'callable': test_callable,
- 'sameas': test_sameas,
- 'escaped': test_escaped,
- 'in': test_in,
- '==': operator.eq,
- 'eq': operator.eq,
- 'equalto': operator.eq,
- '!=': operator.ne,
- 'ne': operator.ne,
- '>': operator.gt,
- 'gt': operator.gt,
- 'greaterthan': operator.gt,
- 'ge': operator.ge,
- '>=': operator.ge,
- '<': operator.lt,
- 'lt': operator.lt,
- 'lessthan': operator.lt,
- '<=': operator.le,
- 'le': operator.le,
-}
diff --git a/python/jinja2/utils.py b/python/jinja2/utils.py
deleted file mode 100644
index 502a311..0000000
--- a/python/jinja2/utils.py
+++ /dev/null
@@ -1,647 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.utils
- ~~~~~~~~~~~~
-
- Utility functions.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD, see LICENSE for more details.
-"""
-import re
-import json
-import errno
-from collections import deque
-from threading import Lock
-from jinja2._compat import text_type, string_types, implements_iterator, \
- url_quote
-
-
-_word_split_re = re.compile(r'(\s+)')
-_punctuation_re = re.compile(
- '^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$' % (
- '|'.join(map(re.escape, ('(', '<', '&lt;'))),
- '|'.join(map(re.escape, ('.', ',', ')', '>', '\n', '&gt;')))
- )
-)
-_simple_email_re = re.compile(r'^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$')
-_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
-_entity_re = re.compile(r'&([^;]+);')
-_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
-_digits = '0123456789'
-
-# special singleton representing missing values for the runtime
-missing = type('MissingType', (), {'__repr__': lambda x: 'missing'})()
-
-# internal code
-internal_code = set()
-
-concat = u''.join
-
-_slash_escape = '\\/' not in json.dumps('/')
-
-
-def contextfunction(f):
- """This decorator can be used to mark a function or method context callable.
- A context callable is passed the active :class:`Context` as first argument when
- called from the template. This is useful if a function wants to get access
- to the context or functions provided on the context object. For example
- a function that returns a sorted list of template variables the current
- template exports could look like this::
-
- @contextfunction
- def get_exported_names(context):
- return sorted(context.exported_vars)
- """
- f.contextfunction = True
- return f
-
-
-def evalcontextfunction(f):
- """This decorator can be used to mark a function or method as an eval
- context callable. This is similar to the :func:`contextfunction`
- but instead of passing the context, an evaluation context object is
- passed. For more information about the eval context, see
- :ref:`eval-context`.
-
- .. versionadded:: 2.4
- """
- f.evalcontextfunction = True
- return f
-
-
-def environmentfunction(f):
- """This decorator can be used to mark a function or method as environment
- callable. This decorator works exactly like the :func:`contextfunction`
- decorator just that the first argument is the active :class:`Environment`
- and not context.
- """
- f.environmentfunction = True
- return f
-
-
-def internalcode(f):
- """Marks the function as internally used"""
- internal_code.add(f.__code__)
- return f
-
-
-def is_undefined(obj):
- """Check if the object passed is undefined. This does nothing more than
- performing an instance check against :class:`Undefined` but looks nicer.
- This can be used for custom filters or tests that want to react to
- undefined variables. For example a custom default filter can look like
- this::
-
- def default(var, default=''):
- if is_undefined(var):
- return default
- return var
- """
- from jinja2.runtime import Undefined
- return isinstance(obj, Undefined)
-
-
-def consume(iterable):
- """Consumes an iterable without doing anything with it."""
- for event in iterable:
- pass
-
-
-def clear_caches():
- """Jinja2 keeps internal caches for environments and lexers. These are
- used so that Jinja2 doesn't have to recreate environments and lexers all
- the time. Normally you don't have to care about that but if you are
- measuring memory consumption you may want to clean the caches.
- """
- from jinja2.environment import _spontaneous_environments
- from jinja2.lexer import _lexer_cache
- _spontaneous_environments.clear()
- _lexer_cache.clear()
-
-
-def import_string(import_name, silent=False):
- """Imports an object based on a string. This is useful if you want to
- use import paths as endpoints or something similar. An import path can
- be specified either in dotted notation (``xml.sax.saxutils.escape``)
- or with a colon as object delimiter (``xml.sax.saxutils:escape``).
-
- If the `silent` is True the return value will be `None` if the import
- fails.
-
- :return: imported object
- """
- try:
- if ':' in import_name:
- module, obj = import_name.split(':', 1)
- elif '.' in import_name:
- items = import_name.split('.')
- module = '.'.join(items[:-1])
- obj = items[-1]
- else:
- return __import__(import_name)
- return getattr(__import__(module, None, None, [obj]), obj)
- except (ImportError, AttributeError):
- if not silent:
- raise
-
-
-def open_if_exists(filename, mode='rb'):
- """Returns a file descriptor for the filename if that file exists,
- otherwise `None`.
- """
- try:
- return open(filename, mode)
- except IOError as e:
- if e.errno not in (errno.ENOENT, errno.EISDIR, errno.EINVAL):
- raise
-
-
-def object_type_repr(obj):
- """Returns the name of the object's type. For some recognized
- singletons the name of the object is returned instead. (For
- example for `None` and `Ellipsis`).
- """
- if obj is None:
- return 'None'
- elif obj is Ellipsis:
- return 'Ellipsis'
- # __builtin__ in 2.x, builtins in 3.x
- if obj.__class__.__module__ in ('__builtin__', 'builtins'):
- name = obj.__class__.__name__
- else:
- name = obj.__class__.__module__ + '.' + obj.__class__.__name__
- return '%s object' % name
-
-
-def pformat(obj, verbose=False):
- """Prettyprint an object. Either use the `pretty` library or the
- builtin `pprint`.
- """
- try:
- from pretty import pretty
- return pretty(obj, verbose=verbose)
- except ImportError:
- from pprint import pformat
- return pformat(obj)
-
-
-def urlize(text, trim_url_limit=None, rel=None, target=None):
- """Converts any URLs in text into clickable links. Works on http://,
- https:// and www. links. Links can have trailing punctuation (periods,
- commas, close-parens) and leading punctuation (opening parens) and
- it'll still do the right thing.
-
- If trim_url_limit is not None, the URLs in link text will be limited
- to trim_url_limit characters.
-
- If nofollow is True, the URLs in link text will get a rel="nofollow"
- attribute.
-
- If target is not None, a target attribute will be added to the link.
- """
- trim_url = lambda x, limit=trim_url_limit: limit is not None \
- and (x[:limit] + (len(x) >=limit and '...'
- or '')) or x
- words = _word_split_re.split(text_type(escape(text)))
- rel_attr = rel and ' rel="%s"' % text_type(escape(rel)) or ''
- target_attr = target and ' target="%s"' % escape(target) or ''
-
- for i, word in enumerate(words):
- match = _punctuation_re.match(word)
- if match:
- lead, middle, trail = match.groups()
- if middle.startswith('www.') or (
- '@' not in middle and
- not middle.startswith('http://') and
- not middle.startswith('https://') and
- len(middle) > 0 and
- middle[0] in _letters + _digits and (
- middle.endswith('.org') or
- middle.endswith('.net') or
- middle.endswith('.com')
- )):
- middle = '<a href="http://%s"%s%s>%s</a>' % (middle,
- rel_attr, target_attr, trim_url(middle))
- if middle.startswith('http://') or \
- middle.startswith('https://'):
- middle = '<a href="%s"%s%s>%s</a>' % (middle,
- rel_attr, target_attr, trim_url(middle))
- if '@' in middle and not middle.startswith('www.') and \
- not ':' in middle and _simple_email_re.match(middle):
- middle = '<a href="mailto:%s">%s</a>' % (middle, middle)
- if lead + middle + trail != word:
- words[i] = lead + middle + trail
- return u''.join(words)
-
-
-def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
- """Generate some lorem ipsum for the template."""
- from jinja2.constants import LOREM_IPSUM_WORDS
- from random import choice, randrange
- words = LOREM_IPSUM_WORDS.split()
- result = []
-
- for _ in range(n):
- next_capitalized = True
- last_comma = last_fullstop = 0
- word = None
- last = None
- p = []
-
- # each paragraph contains out of 20 to 100 words.
- for idx, _ in enumerate(range(randrange(min, max))):
- while True:
- word = choice(words)
- if word != last:
- last = word
- break
- if next_capitalized:
- word = word.capitalize()
- next_capitalized = False
- # add commas
- if idx - randrange(3, 8) > last_comma:
- last_comma = idx
- last_fullstop += 2
- word += ','
- # add end of sentences
- if idx - randrange(10, 20) > last_fullstop:
- last_comma = last_fullstop = idx
- word += '.'
- next_capitalized = True
- p.append(word)
-
- # ensure that the paragraph ends with a dot.
- p = u' '.join(p)
- if p.endswith(','):
- p = p[:-1] + '.'
- elif not p.endswith('.'):
- p += '.'
- result.append(p)
-
- if not html:
- return u'\n\n'.join(result)
- return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
-
-
-def unicode_urlencode(obj, charset='utf-8', for_qs=False):
- """URL escapes a single bytestring or unicode string with the
- given charset if applicable to URL safe quoting under all rules
- that need to be considered under all supported Python versions.
-
- If non strings are provided they are converted to their unicode
- representation first.
- """
- if not isinstance(obj, string_types):
- obj = text_type(obj)
- if isinstance(obj, text_type):
- obj = obj.encode(charset)
- safe = not for_qs and b'/' or b''
- rv = text_type(url_quote(obj, safe))
- if for_qs:
- rv = rv.replace('%20', '+')
- return rv
-
-
-class LRUCache(object):
- """A simple LRU Cache implementation."""
-
- # this is fast for small capacities (something below 1000) but doesn't
- # scale. But as long as it's only used as storage for templates this
- # won't do any harm.
-
- def __init__(self, capacity):
- self.capacity = capacity
- self._mapping = {}
- self._queue = deque()
- self._postinit()
-
- def _postinit(self):
- # alias all queue methods for faster lookup
- self._popleft = self._queue.popleft
- self._pop = self._queue.pop
- self._remove = self._queue.remove
- self._wlock = Lock()
- self._append = self._queue.append
-
- def __getstate__(self):
- return {
- 'capacity': self.capacity,
- '_mapping': self._mapping,
- '_queue': self._queue
- }
-
- def __setstate__(self, d):
- self.__dict__.update(d)
- self._postinit()
-
- def __getnewargs__(self):
- return (self.capacity,)
-
- def copy(self):
- """Return a shallow copy of the instance."""
- rv = self.__class__(self.capacity)
- rv._mapping.update(self._mapping)
- rv._queue = deque(self._queue)
- return rv
-
- def get(self, key, default=None):
- """Return an item from the cache dict or `default`"""
- try:
- return self[key]
- except KeyError:
- return default
-
- def setdefault(self, key, default=None):
- """Set `default` if the key is not in the cache otherwise
- leave unchanged. Return the value of this key.
- """
- self._wlock.acquire()
- try:
- try:
- return self[key]
- except KeyError:
- self[key] = default
- return default
- finally:
- self._wlock.release()
-
- def clear(self):
- """Clear the cache."""
- self._wlock.acquire()
- try:
- self._mapping.clear()
- self._queue.clear()
- finally:
- self._wlock.release()
-
- def __contains__(self, key):
- """Check if a key exists in this cache."""
- return key in self._mapping
-
- def __len__(self):
- """Return the current size of the cache."""
- return len(self._mapping)
-
- def __repr__(self):
- return '<%s %r>' % (
- self.__class__.__name__,
- self._mapping
- )
-
- def __getitem__(self, key):
- """Get an item from the cache. Moves the item up so that it has the
- highest priority then.
-
- Raise a `KeyError` if it does not exist.
- """
- self._wlock.acquire()
- try:
- rv = self._mapping[key]
- if self._queue[-1] != key:
- try:
- self._remove(key)
- except ValueError:
- # if something removed the key from the container
- # when we read, ignore the ValueError that we would
- # get otherwise.
- pass
- self._append(key)
- return rv
- finally:
- self._wlock.release()
-
- def __setitem__(self, key, value):
- """Sets the value for an item. Moves the item up so that it
- has the highest priority then.
- """
- self._wlock.acquire()
- try:
- if key in self._mapping:
- self._remove(key)
- elif len(self._mapping) == self.capacity:
- del self._mapping[self._popleft()]
- self._append(key)
- self._mapping[key] = value
- finally:
- self._wlock.release()
-
- def __delitem__(self, key):
- """Remove an item from the cache dict.
- Raise a `KeyError` if it does not exist.
- """
- self._wlock.acquire()
- try:
- del self._mapping[key]
- try:
- self._remove(key)
- except ValueError:
- # __getitem__ is not locked, it might happen
- pass
- finally:
- self._wlock.release()
-
- def items(self):
- """Return a list of items."""
- result = [(key, self._mapping[key]) for key in list(self._queue)]
- result.reverse()
- return result
-
- def iteritems(self):
- """Iterate over all items."""
- return iter(self.items())
-
- def values(self):
- """Return a list of all values."""
- return [x[1] for x in self.items()]
-
- def itervalue(self):
- """Iterate over all values."""
- return iter(self.values())
-
- def keys(self):
- """Return a list of all keys ordered by most recent usage."""
- return list(self)
-
- def iterkeys(self):
- """Iterate over all keys in the cache dict, ordered by
- the most recent usage.
- """
- return reversed(tuple(self._queue))
-
- __iter__ = iterkeys
-
- def __reversed__(self):
- """Iterate over the values in the cache dict, oldest items
- coming first.
- """
- return iter(tuple(self._queue))
-
- __copy__ = copy
-
-
-# register the LRU cache as mutable mapping if possible
-try:
- from collections import MutableMapping
- MutableMapping.register(LRUCache)
-except ImportError:
- pass
-
-
-def select_autoescape(enabled_extensions=('html', 'htm', 'xml'),
- disabled_extensions=(),
- default_for_string=True,
- default=False):
- """Intelligently sets the initial value of autoescaping based on the
- filename of the template. This is the recommended way to configure
- autoescaping if you do not want to write a custom function yourself.
-
- If you want to enable it for all templates created from strings or
- for all templates with `.html` and `.xml` extensions::
-
- from jinja2 import Environment, select_autoescape
- env = Environment(autoescape=select_autoescape(
- enabled_extensions=('html', 'xml'),
- default_for_string=True,
- ))
-
- Example configuration to turn it on at all times except if the template
- ends with `.txt`::
-
- from jinja2 import Environment, select_autoescape
- env = Environment(autoescape=select_autoescape(
- disabled_extensions=('txt',),
- default_for_string=True,
- default=True,
- ))
-
- The `enabled_extensions` is an iterable of all the extensions that
- autoescaping should be enabled for. Likewise `disabled_extensions` is
- a list of all templates it should be disabled for. If a template is
- loaded from a string then the default from `default_for_string` is used.
- If nothing matches then the initial value of autoescaping is set to the
- value of `default`.
-
- For security reasons this function operates case insensitive.
-
- .. versionadded:: 2.9
- """
- enabled_patterns = tuple('.' + x.lstrip('.').lower()
- for x in enabled_extensions)
- disabled_patterns = tuple('.' + x.lstrip('.').lower()
- for x in disabled_extensions)
- def autoescape(template_name):
- if template_name is None:
- return default_for_string
- template_name = template_name.lower()
- if template_name.endswith(enabled_patterns):
- return True
- if template_name.endswith(disabled_patterns):
- return False
- return default
- return autoescape
-
-
-def htmlsafe_json_dumps(obj, dumper=None, **kwargs):
- """Works exactly like :func:`dumps` but is safe for use in ``<script>``
- tags. It accepts the same arguments and returns a JSON string. Note that
- this is available in templates through the ``|tojson`` filter which will
- also mark the result as safe. Due to how this function escapes certain
- characters this is safe even if used outside of ``<script>`` tags.
-
- The following characters are escaped in strings:
-
- - ``<``
- - ``>``
- - ``&``
- - ``'``
-
- This makes it safe to embed such strings in any place in HTML with the
- notable exception of double quoted attributes. In that case single
- quote your attributes or HTML escape it in addition.
- """
- if dumper is None:
- dumper = json.dumps
- rv = dumper(obj, **kwargs) \
- .replace(u'<', u'\\u003c') \
- .replace(u'>', u'\\u003e') \
- .replace(u'&', u'\\u0026') \
- .replace(u"'", u'\\u0027')
- return Markup(rv)
-
-
-@implements_iterator
-class Cycler(object):
- """A cycle helper for templates."""
-
- def __init__(self, *items):
- if not items:
- raise RuntimeError('at least one item has to be provided')
- self.items = items
- self.reset()
-
- def reset(self):
- """Resets the cycle."""
- self.pos = 0
-
- @property
- def current(self):
- """Returns the current item."""
- return self.items[self.pos]
-
- def next(self):
- """Goes one item ahead and returns it."""
- rv = self.current
- self.pos = (self.pos + 1) % len(self.items)
- return rv
-
- __next__ = next
-
-
-class Joiner(object):
- """A joining helper for templates."""
-
- def __init__(self, sep=u', '):
- self.sep = sep
- self.used = False
-
- def __call__(self):
- if not self.used:
- self.used = True
- return u''
- return self.sep
-
-
-class Namespace(object):
- """A namespace object that can hold arbitrary attributes. It may be
- initialized from a dictionary or with keyword argments."""
-
- def __init__(*args, **kwargs):
- self, args = args[0], args[1:]
- self.__attrs = dict(*args, **kwargs)
-
- def __getattribute__(self, name):
- if name == '_Namespace__attrs':
- return object.__getattribute__(self, name)
- try:
- return self.__attrs[name]
- except KeyError:
- raise AttributeError(name)
-
- def __setitem__(self, name, value):
- self.__attrs[name] = value
-
- def __repr__(self):
- return '<Namespace %r>' % self.__attrs
-
-
-# does this python version support async for in and async generators?
-try:
- exec('async def _():\n async for _ in ():\n yield _')
- have_async_gen = True
-except SyntaxError:
- have_async_gen = False
-
-
-# Imported here because that's where it was in the past
-from markupsafe import Markup, escape, soft_unicode
diff --git a/python/jinja2/visitor.py b/python/jinja2/visitor.py
deleted file mode 100644
index ba526df..0000000
--- a/python/jinja2/visitor.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- jinja2.visitor
- ~~~~~~~~~~~~~~
-
- This module implements a visitor for the nodes.
-
- :copyright: (c) 2017 by the Jinja Team.
- :license: BSD.
-"""
-from jinja2.nodes import Node
-
-
-class NodeVisitor(object):
- """Walks the abstract syntax tree and call visitor functions for every
- node found. The visitor functions may return values which will be
- forwarded by the `visit` method.
-
- Per default the visitor functions for the nodes are ``'visit_'`` +
- class name of the node. So a `TryFinally` node visit function would
- be `visit_TryFinally`. This behavior can be changed by overriding
- the `get_visitor` function. If no visitor function exists for a node
- (return value `None`) the `generic_visit` visitor is used instead.
- """
-
- def get_visitor(self, node):
- """Return the visitor function for this node or `None` if no visitor
- exists for this node. In that case the generic visit function is
- used instead.
- """
- method = 'visit_' + node.__class__.__name__
- return getattr(self, method, None)
-
- def visit(self, node, *args, **kwargs):
- """Visit a node."""
- f = self.get_visitor(node)
- if f is not None:
- return f(node, *args, **kwargs)
- return self.generic_visit(node, *args, **kwargs)
-
- def generic_visit(self, node, *args, **kwargs):
- """Called if no explicit visitor function exists for a node."""
- for node in node.iter_child_nodes():
- self.visit(node, *args, **kwargs)
-
-
-class NodeTransformer(NodeVisitor):
- """Walks the abstract syntax tree and allows modifications of nodes.
-
- The `NodeTransformer` will walk the AST and use the return value of the
- visitor functions to replace or remove the old node. If the return
- value of the visitor function is `None` the node will be removed
- from the previous location otherwise it's replaced with the return
- value. The return value may be the original node in which case no
- replacement takes place.
- """
-
- def generic_visit(self, node, *args, **kwargs):
- for field, old_value in node.iter_fields():
- if isinstance(old_value, list):
- new_values = []
- for value in old_value:
- if isinstance(value, Node):
- value = self.visit(value, *args, **kwargs)
- if value is None:
- continue
- elif not isinstance(value, Node):
- new_values.extend(value)
- continue
- new_values.append(value)
- old_value[:] = new_values
- elif isinstance(old_value, Node):
- new_node = self.visit(old_value, *args, **kwargs)
- if new_node is None:
- delattr(node, field)
- else:
- setattr(node, field, new_node)
- return node
-
- def visit_list(self, node, *args, **kwargs):
- """As transformers may return lists in some places this method
- can be used to enforce a list as return value.
- """
- rv = self.visit(node, *args, **kwargs)
- if not isinstance(rv, list):
- rv = [rv]
- return rv
diff --git a/python/markupsafe/__init__.py b/python/markupsafe/__init__.py
deleted file mode 100644
index 68dc85f..0000000
--- a/python/markupsafe/__init__.py
+++ /dev/null
@@ -1,305 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- markupsafe
- ~~~~~~~~~~
-
- Implements a Markup string.
-
- :copyright: (c) 2010 by Armin Ronacher.
- :license: BSD, see LICENSE for more details.
-"""
-import re
-import string
-from collections import Mapping
-from markupsafe._compat import text_type, string_types, int_types, \
- unichr, iteritems, PY2
-
-__version__ = "1.0"
-
-__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
-
-
-_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
-_entity_re = re.compile(r'&([^& ;]+);')
-
-
-class Markup(text_type):
- r"""Marks a string as being safe for inclusion in HTML/XML output without
- needing to be escaped. This implements the `__html__` interface a couple
- of frameworks and web applications use. :class:`Markup` is a direct
- subclass of `unicode` and provides all the methods of `unicode` just that
- it escapes arguments passed and always returns `Markup`.
-
- The `escape` function returns markup objects so that double escaping can't
- happen.
-
- The constructor of the :class:`Markup` class can be used for three
- different things: When passed an unicode object it's assumed to be safe,
- when passed an object with an HTML representation (has an `__html__`
- method) that representation is used, otherwise the object passed is
- converted into a unicode string and then assumed to be safe:
-
- >>> Markup("Hello <em>World</em>!")
- Markup(u'Hello <em>World</em>!')
- >>> class Foo(object):
- ... def __html__(self):
- ... return '<a href="#">foo</a>'
- ...
- >>> Markup(Foo())
- Markup(u'<a href="#">foo</a>')
-
- If you want object passed being always treated as unsafe you can use the
- :meth:`escape` classmethod to create a :class:`Markup` object:
-
- >>> Markup.escape("Hello <em>World</em>!")
- Markup(u'Hello &lt;em&gt;World&lt;/em&gt;!')
-
- Operations on a markup string are markup aware which means that all
- arguments are passed through the :func:`escape` function:
-
- >>> em = Markup("<em>%s</em>")
- >>> em % "foo & bar"
- Markup(u'<em>foo &amp; bar</em>')
- >>> strong = Markup("<strong>%(text)s</strong>")
- >>> strong % {'text': '<blink>hacker here</blink>'}
- Markup(u'<strong>&lt;blink&gt;hacker here&lt;/blink&gt;</strong>')
- >>> Markup("<em>Hello</em> ") + "<foo>"
- Markup(u'<em>Hello</em> &lt;foo&gt;')
- """
- __slots__ = ()
-
- def __new__(cls, base=u'', encoding=None, errors='strict'):
- if hasattr(base, '__html__'):
- base = base.__html__()
- if encoding is None:
- return text_type.__new__(cls, base)
- return text_type.__new__(cls, base, encoding, errors)
-
- def __html__(self):
- return self
-
- def __add__(self, other):
- if isinstance(other, string_types) or hasattr(other, '__html__'):
- return self.__class__(super(Markup, self).__add__(self.escape(other)))
- return NotImplemented
-
- def __radd__(self, other):
- if hasattr(other, '__html__') or isinstance(other, string_types):
- return self.escape(other).__add__(self)
- return NotImplemented
-
- def __mul__(self, num):
- if isinstance(num, int_types):
- return self.__class__(text_type.__mul__(self, num))
- return NotImplemented
- __rmul__ = __mul__
-
- def __mod__(self, arg):
- if isinstance(arg, tuple):
- arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg)
- else:
- arg = _MarkupEscapeHelper(arg, self.escape)
- return self.__class__(text_type.__mod__(self, arg))
-
- def __repr__(self):
- return '%s(%s)' % (
- self.__class__.__name__,
- text_type.__repr__(self)
- )
-
- def join(self, seq):
- return self.__class__(text_type.join(self, map(self.escape, seq)))
- join.__doc__ = text_type.join.__doc__
-
- def split(self, *args, **kwargs):
- return list(map(self.__class__, text_type.split(self, *args, **kwargs)))
- split.__doc__ = text_type.split.__doc__
-
- def rsplit(self, *args, **kwargs):
- return list(map(self.__class__, text_type.rsplit(self, *args, **kwargs)))
- rsplit.__doc__ = text_type.rsplit.__doc__
-
- def splitlines(self, *args, **kwargs):
- return list(map(self.__class__, text_type.splitlines(
- self, *args, **kwargs)))
- splitlines.__doc__ = text_type.splitlines.__doc__
-
- def unescape(self):
- r"""Unescape markup again into an text_type string. This also resolves
- known HTML4 and XHTML entities:
-
- >>> Markup("Main &raquo; <em>About</em>").unescape()
- u'Main \xbb <em>About</em>'
- """
- from markupsafe._constants import HTML_ENTITIES
- def handle_match(m):
- name = m.group(1)
- if name in HTML_ENTITIES:
- return unichr(HTML_ENTITIES[name])
- try:
- if name[:2] in ('#x', '#X'):
- return unichr(int(name[2:], 16))
- elif name.startswith('#'):
- return unichr(int(name[1:]))
- except ValueError:
- pass
- # Don't modify unexpected input.
- return m.group()
- return _entity_re.sub(handle_match, text_type(self))
-
- def striptags(self):
- r"""Unescape markup into an text_type string and strip all tags. This
- also resolves known HTML4 and XHTML entities. Whitespace is
- normalized to one:
-
- >>> Markup("Main &raquo; <em>About</em>").striptags()
- u'Main \xbb About'
- """
- stripped = u' '.join(_striptags_re.sub('', self).split())
- return Markup(stripped).unescape()
-
- @classmethod
- def escape(cls, s):
- """Escape the string. Works like :func:`escape` with the difference
- that for subclasses of :class:`Markup` this function would return the
- correct subclass.
- """
- rv = escape(s)
- if rv.__class__ is not cls:
- return cls(rv)
- return rv
-
- def make_simple_escaping_wrapper(name):
- orig = getattr(text_type, name)
- def func(self, *args, **kwargs):
- args = _escape_argspec(list(args), enumerate(args), self.escape)
- _escape_argspec(kwargs, iteritems(kwargs), self.escape)
- return self.__class__(orig(self, *args, **kwargs))
- func.__name__ = orig.__name__
- func.__doc__ = orig.__doc__
- return func
-
- for method in '__getitem__', 'capitalize', \
- 'title', 'lower', 'upper', 'replace', 'ljust', \
- 'rjust', 'lstrip', 'rstrip', 'center', 'strip', \
- 'translate', 'expandtabs', 'swapcase', 'zfill':
- locals()[method] = make_simple_escaping_wrapper(method)
-
- # new in python 2.5
- if hasattr(text_type, 'partition'):
- def partition(self, sep):
- return tuple(map(self.__class__,
- text_type.partition(self, self.escape(sep))))
- def rpartition(self, sep):
- return tuple(map(self.__class__,
- text_type.rpartition(self, self.escape(sep))))
-
- # new in python 2.6
- if hasattr(text_type, 'format'):
- def format(*args, **kwargs):
- self, args = args[0], args[1:]
- formatter = EscapeFormatter(self.escape)
- kwargs = _MagicFormatMapping(args, kwargs)
- return self.__class__(formatter.vformat(self, args, kwargs))
-
- def __html_format__(self, format_spec):
- if format_spec:
- raise ValueError('Unsupported format specification '
- 'for Markup.')
- return self
-
- # not in python 3
- if hasattr(text_type, '__getslice__'):
- __getslice__ = make_simple_escaping_wrapper('__getslice__')
-
- del method, make_simple_escaping_wrapper
-
-
-class _MagicFormatMapping(Mapping):
- """This class implements a dummy wrapper to fix a bug in the Python
- standard library for string formatting.
-
- See http://bugs.python.org/issue13598 for information about why
- this is necessary.
- """
-
- def __init__(self, args, kwargs):
- self._args = args
- self._kwargs = kwargs
- self._last_index = 0
-
- def __getitem__(self, key):
- if key == '':
- idx = self._last_index
- self._last_index += 1
- try:
- return self._args[idx]
- except LookupError:
- pass
- key = str(idx)
- return self._kwargs[key]
-
- def __iter__(self):
- return iter(self._kwargs)
-
- def __len__(self):
- return len(self._kwargs)
-
-
-if hasattr(text_type, 'format'):
- class EscapeFormatter(string.Formatter):
-
- def __init__(self, escape):
- self.escape = escape
-
- def format_field(self, value, format_spec):
- if hasattr(value, '__html_format__'):
- rv = value.__html_format__(format_spec)
- elif hasattr(value, '__html__'):
- if format_spec:
- raise ValueError('No format specification allowed '
- 'when formatting an object with '
- 'its __html__ method.')
- rv = value.__html__()
- else:
- # We need to make sure the format spec is unicode here as
- # otherwise the wrong callback methods are invoked. For
- # instance a byte string there would invoke __str__ and
- # not __unicode__.
- rv = string.Formatter.format_field(
- self, value, text_type(format_spec))
- return text_type(self.escape(rv))
-
-
-def _escape_argspec(obj, iterable, escape):
- """Helper for various string-wrapped functions."""
- for key, value in iterable:
- if hasattr(value, '__html__') or isinstance(value, string_types):
- obj[key] = escape(value)
- return obj
-
-
-class _MarkupEscapeHelper(object):
- """Helper for Markup.__mod__"""
-
- def __init__(self, obj, escape):
- self.obj = obj
- self.escape = escape
-
- __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x], s.escape)
- __unicode__ = __str__ = lambda s: text_type(s.escape(s.obj))
- __repr__ = lambda s: str(s.escape(repr(s.obj)))
- __int__ = lambda s: int(s.obj)
- __float__ = lambda s: float(s.obj)
-
-
-# we have to import it down here as the speedups and native
-# modules imports the markup type which is define above.
-try:
- from markupsafe._speedups import escape, escape_silent, soft_unicode
-except ImportError:
- from markupsafe._native import escape, escape_silent, soft_unicode
-
-if not PY2:
- soft_str = soft_unicode
- __all__.append('soft_str')
diff --git a/python/markupsafe/_compat.py b/python/markupsafe/_compat.py
deleted file mode 100644
index 62e5632..0000000
--- a/python/markupsafe/_compat.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- markupsafe._compat
- ~~~~~~~~~~~~~~~~~~
-
- Compatibility module for different Python versions.
-
- :copyright: (c) 2013 by Armin Ronacher.
- :license: BSD, see LICENSE for more details.
-"""
-import sys
-
-PY2 = sys.version_info[0] == 2
-
-if not PY2:
- text_type = str
- string_types = (str,)
- unichr = chr
- int_types = (int,)
- iteritems = lambda x: iter(x.items())
-else:
- text_type = unicode
- string_types = (str, unicode)
- unichr = unichr
- int_types = (int, long)
- iteritems = lambda x: x.iteritems()
diff --git a/python/markupsafe/_constants.py b/python/markupsafe/_constants.py
deleted file mode 100644
index 919bf03..0000000
--- a/python/markupsafe/_constants.py
+++ /dev/null
@@ -1,267 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- markupsafe._constants
- ~~~~~~~~~~~~~~~~~~~~~
-
- Highlevel implementation of the Markup string.
-
- :copyright: (c) 2010 by Armin Ronacher.
- :license: BSD, see LICENSE for more details.
-"""
-
-
-HTML_ENTITIES = {
- 'AElig': 198,
- 'Aacute': 193,
- 'Acirc': 194,
- 'Agrave': 192,
- 'Alpha': 913,
- 'Aring': 197,
- 'Atilde': 195,
- 'Auml': 196,
- 'Beta': 914,
- 'Ccedil': 199,
- 'Chi': 935,
- 'Dagger': 8225,
- 'Delta': 916,
- 'ETH': 208,
- 'Eacute': 201,
- 'Ecirc': 202,
- 'Egrave': 200,
- 'Epsilon': 917,
- 'Eta': 919,
- 'Euml': 203,
- 'Gamma': 915,
- 'Iacute': 205,
- 'Icirc': 206,
- 'Igrave': 204,
- 'Iota': 921,
- 'Iuml': 207,
- 'Kappa': 922,
- 'Lambda': 923,
- 'Mu': 924,
- 'Ntilde': 209,
- 'Nu': 925,
- 'OElig': 338,
- 'Oacute': 211,
- 'Ocirc': 212,
- 'Ograve': 210,
- 'Omega': 937,
- 'Omicron': 927,
- 'Oslash': 216,
- 'Otilde': 213,
- 'Ouml': 214,
- 'Phi': 934,
- 'Pi': 928,
- 'Prime': 8243,
- 'Psi': 936,
- 'Rho': 929,
- 'Scaron': 352,
- 'Sigma': 931,
- 'THORN': 222,
- 'Tau': 932,
- 'Theta': 920,
- 'Uacute': 218,
- 'Ucirc': 219,
- 'Ugrave': 217,
- 'Upsilon': 933,
- 'Uuml': 220,
- 'Xi': 926,
- 'Yacute': 221,
- 'Yuml': 376,
- 'Zeta': 918,
- 'aacute': 225,
- 'acirc': 226,
- 'acute': 180,
- 'aelig': 230,
- 'agrave': 224,
- 'alefsym': 8501,
- 'alpha': 945,
- 'amp': 38,
- 'and': 8743,
- 'ang': 8736,
- 'apos': 39,
- 'aring': 229,
- 'asymp': 8776,
- 'atilde': 227,
- 'auml': 228,
- 'bdquo': 8222,
- 'beta': 946,
- 'brvbar': 166,
- 'bull': 8226,
- 'cap': 8745,
- 'ccedil': 231,
- 'cedil': 184,
- 'cent': 162,
- 'chi': 967,
- 'circ': 710,
- 'clubs': 9827,
- 'cong': 8773,
- 'copy': 169,
- 'crarr': 8629,
- 'cup': 8746,
- 'curren': 164,
- 'dArr': 8659,
- 'dagger': 8224,
- 'darr': 8595,
- 'deg': 176,
- 'delta': 948,
- 'diams': 9830,
- 'divide': 247,
- 'eacute': 233,
- 'ecirc': 234,
- 'egrave': 232,
- 'empty': 8709,
- 'emsp': 8195,
- 'ensp': 8194,
- 'epsilon': 949,
- 'equiv': 8801,
- 'eta': 951,
- 'eth': 240,
- 'euml': 235,
- 'euro': 8364,
- 'exist': 8707,
- 'fnof': 402,
- 'forall': 8704,
- 'frac12': 189,
- 'frac14': 188,
- 'frac34': 190,
- 'frasl': 8260,
- 'gamma': 947,
- 'ge': 8805,
- 'gt': 62,
- 'hArr': 8660,
- 'harr': 8596,
- 'hearts': 9829,
- 'hellip': 8230,
- 'iacute': 237,
- 'icirc': 238,
- 'iexcl': 161,
- 'igrave': 236,
- 'image': 8465,
- 'infin': 8734,
- 'int': 8747,
- 'iota': 953,
- 'iquest': 191,
- 'isin': 8712,
- 'iuml': 239,
- 'kappa': 954,
- 'lArr': 8656,
- 'lambda': 955,
- 'lang': 9001,
- 'laquo': 171,
- 'larr': 8592,
- 'lceil': 8968,
- 'ldquo': 8220,
- 'le': 8804,
- 'lfloor': 8970,
- 'lowast': 8727,
- 'loz': 9674,
- 'lrm': 8206,
- 'lsaquo': 8249,
- 'lsquo': 8216,
- 'lt': 60,
- 'macr': 175,
- 'mdash': 8212,
- 'micro': 181,
- 'middot': 183,
- 'minus': 8722,
- 'mu': 956,
- 'nabla': 8711,
- 'nbsp': 160,
- 'ndash': 8211,
- 'ne': 8800,
- 'ni': 8715,
- 'not': 172,
- 'notin': 8713,
- 'nsub': 8836,
- 'ntilde': 241,
- 'nu': 957,
- 'oacute': 243,
- 'ocirc': 244,
- 'oelig': 339,
- 'ograve': 242,
- 'oline': 8254,
- 'omega': 969,
- 'omicron': 959,
- 'oplus': 8853,
- 'or': 8744,
- 'ordf': 170,
- 'ordm': 186,
- 'oslash': 248,
- 'otilde': 245,
- 'otimes': 8855,
- 'ouml': 246,
- 'para': 182,
- 'part': 8706,
- 'permil': 8240,
- 'perp': 8869,
- 'phi': 966,
- 'pi': 960,
- 'piv': 982,
- 'plusmn': 177,
- 'pound': 163,
- 'prime': 8242,
- 'prod': 8719,
- 'prop': 8733,
- 'psi': 968,
- 'quot': 34,
- 'rArr': 8658,
- 'radic': 8730,
- 'rang': 9002,
- 'raquo': 187,
- 'rarr': 8594,
- 'rceil': 8969,
- 'rdquo': 8221,
- 'real': 8476,
- 'reg': 174,
- 'rfloor': 8971,
- 'rho': 961,
- 'rlm': 8207,
- 'rsaquo': 8250,
- 'rsquo': 8217,
- 'sbquo': 8218,
- 'scaron': 353,
- 'sdot': 8901,
- 'sect': 167,
- 'shy': 173,
- 'sigma': 963,
- 'sigmaf': 962,
- 'sim': 8764,
- 'spades': 9824,
- 'sub': 8834,
- 'sube': 8838,
- 'sum': 8721,
- 'sup': 8835,
- 'sup1': 185,
- 'sup2': 178,
- 'sup3': 179,
- 'supe': 8839,
- 'szlig': 223,
- 'tau': 964,
- 'there4': 8756,
- 'theta': 952,
- 'thetasym': 977,
- 'thinsp': 8201,
- 'thorn': 254,
- 'tilde': 732,
- 'times': 215,
- 'trade': 8482,
- 'uArr': 8657,
- 'uacute': 250,
- 'uarr': 8593,
- 'ucirc': 251,
- 'ugrave': 249,
- 'uml': 168,
- 'upsih': 978,
- 'upsilon': 965,
- 'uuml': 252,
- 'weierp': 8472,
- 'xi': 958,
- 'yacute': 253,
- 'yen': 165,
- 'yuml': 255,
- 'zeta': 950,
- 'zwj': 8205,
- 'zwnj': 8204
-}
diff --git a/python/markupsafe/_native.py b/python/markupsafe/_native.py
deleted file mode 100644
index 5e83f10..0000000
--- a/python/markupsafe/_native.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- markupsafe._native
- ~~~~~~~~~~~~~~~~~~
-
- Native Python implementation the C module is not compiled.
-
- :copyright: (c) 2010 by Armin Ronacher.
- :license: BSD, see LICENSE for more details.
-"""
-from markupsafe import Markup
-from markupsafe._compat import text_type
-
-
-def escape(s):
- """Convert the characters &, <, >, ' and " in string s to HTML-safe
- sequences. Use this if you need to display text that might contain
- such characters in HTML. Marks return value as markup string.
- """
- if hasattr(s, '__html__'):
- return s.__html__()
- return Markup(text_type(s)
- .replace('&', '&amp;')
- .replace('>', '&gt;')
- .replace('<', '&lt;')
- .replace("'", '&#39;')
- .replace('"', '&#34;')
- )
-
-
-def escape_silent(s):
- """Like :func:`escape` but converts `None` into an empty
- markup string.
- """
- if s is None:
- return Markup()
- return escape(s)
-
-
-def soft_unicode(s):
- """Make a string unicode if it isn't already. That way a markup
- string is not converted back to unicode.
- """
- if not isinstance(s, text_type):
- s = text_type(s)
- return s
diff --git a/python/markupsafe/_speedups.c b/python/markupsafe/_speedups.c
deleted file mode 100644
index d779a68..0000000
--- a/python/markupsafe/_speedups.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * markupsafe._speedups
- * ~~~~~~~~~~~~~~~~~~~~
- *
- * This module implements functions for automatic escaping in C for better
- * performance.
- *
- * :copyright: (c) 2010 by Armin Ronacher.
- * :license: BSD.
- */
-
-#include <Python.h>
-
-#define ESCAPED_CHARS_TABLE_SIZE 63
-#define UNICHR(x) (PyUnicode_AS_UNICODE((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL)));
-
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-#define PY_SSIZE_T_MAX INT_MAX
-#define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-
-static PyObject* markup;
-static Py_ssize_t escaped_chars_delta_len[ESCAPED_CHARS_TABLE_SIZE];
-static Py_UNICODE *escaped_chars_repl[ESCAPED_CHARS_TABLE_SIZE];
-
-static int
-init_constants(void)
-{
- PyObject *module;
- /* mapping of characters to replace */
- escaped_chars_repl['"'] = UNICHR("&#34;");
- escaped_chars_repl['\''] = UNICHR("&#39;");
- escaped_chars_repl['&'] = UNICHR("&amp;");
- escaped_chars_repl['<'] = UNICHR("&lt;");
- escaped_chars_repl['>'] = UNICHR("&gt;");
-
- /* lengths of those characters when replaced - 1 */
- memset(escaped_chars_delta_len, 0, sizeof (escaped_chars_delta_len));
- escaped_chars_delta_len['"'] = escaped_chars_delta_len['\''] = \
- escaped_chars_delta_len['&'] = 4;
- escaped_chars_delta_len['<'] = escaped_chars_delta_len['>'] = 3;
-
- /* import markup type so that we can mark the return value */
- module = PyImport_ImportModule("markupsafe");
- if (!module)
- return 0;
- markup = PyObject_GetAttrString(module, "Markup");
- Py_DECREF(module);
-
- return 1;
-}
-
-static PyObject*
-escape_unicode(PyUnicodeObject *in)
-{
- PyUnicodeObject *out;
- Py_UNICODE *inp = PyUnicode_AS_UNICODE(in);
- const Py_UNICODE *inp_end = PyUnicode_AS_UNICODE(in) + PyUnicode_GET_SIZE(in);
- Py_UNICODE *next_escp;
- Py_UNICODE *outp;
- Py_ssize_t delta=0, erepl=0, delta_len=0;
-
- /* First we need to figure out how long the escaped string will be */
- while (*(inp) || inp < inp_end) {
- if (*inp < ESCAPED_CHARS_TABLE_SIZE) {
- delta += escaped_chars_delta_len[*inp];
- erepl += !!escaped_chars_delta_len[*inp];
- }
- ++inp;
- }
-
- /* Do we need to escape anything at all? */
- if (!erepl) {
- Py_INCREF(in);
- return (PyObject*)in;
- }
-
- out = (PyUnicodeObject*)PyUnicode_FromUnicode(NULL, PyUnicode_GET_SIZE(in) + delta);
- if (!out)
- return NULL;
-
- outp = PyUnicode_AS_UNICODE(out);
- inp = PyUnicode_AS_UNICODE(in);
- while (erepl-- > 0) {
- /* look for the next substitution */
- next_escp = inp;
- while (next_escp < inp_end) {
- if (*next_escp < ESCAPED_CHARS_TABLE_SIZE &&
- (delta_len = escaped_chars_delta_len[*next_escp])) {
- ++delta_len;
- break;
- }
- ++next_escp;
- }
-
- if (next_escp > inp) {
- /* copy unescaped chars between inp and next_escp */
- Py_UNICODE_COPY(outp, inp, next_escp-inp);
- outp += next_escp - inp;
- }
-
- /* escape 'next_escp' */
- Py_UNICODE_COPY(outp, escaped_chars_repl[*next_escp], delta_len);
- outp += delta_len;
-
- inp = next_escp + 1;
- }
- if (inp < inp_end)
- Py_UNICODE_COPY(outp, inp, PyUnicode_GET_SIZE(in) - (inp - PyUnicode_AS_UNICODE(in)));
-
- return (PyObject*)out;
-}
-
-
-static PyObject*
-escape(PyObject *self, PyObject *text)
-{
- PyObject *s = NULL, *rv = NULL, *html;
-
- /* we don't have to escape integers, bools or floats */
- if (PyLong_CheckExact(text) ||
-#if PY_MAJOR_VERSION < 3
- PyInt_CheckExact(text) ||
-#endif
- PyFloat_CheckExact(text) || PyBool_Check(text) ||
- text == Py_None)
- return PyObject_CallFunctionObjArgs(markup, text, NULL);
-
- /* if the object has an __html__ method that performs the escaping */
- html = PyObject_GetAttrString(text, "__html__");
- if (html) {
- rv = PyObject_CallObject(html, NULL);
- Py_DECREF(html);
- return rv;
- }
-
- /* otherwise make the object unicode if it isn't, then escape */
- PyErr_Clear();
- if (!PyUnicode_Check(text)) {
-#if PY_MAJOR_VERSION < 3
- PyObject *unicode = PyObject_Unicode(text);
-#else
- PyObject *unicode = PyObject_Str(text);
-#endif
- if (!unicode)
- return NULL;
- s = escape_unicode((PyUnicodeObject*)unicode);
- Py_DECREF(unicode);
- }
- else
- s = escape_unicode((PyUnicodeObject*)text);
-
- /* convert the unicode string into a markup object. */
- rv = PyObject_CallFunctionObjArgs(markup, (PyObject*)s, NULL);
- Py_DECREF(s);
- return rv;
-}
-
-
-static PyObject*
-escape_silent(PyObject *self, PyObject *text)
-{
- if (text != Py_None)
- return escape(self, text);
- return PyObject_CallFunctionObjArgs(markup, NULL);
-}
-
-
-static PyObject*
-soft_unicode(PyObject *self, PyObject *s)
-{
- if (!PyUnicode_Check(s))
-#if PY_MAJOR_VERSION < 3
- return PyObject_Unicode(s);
-#else
- return PyObject_Str(s);
-#endif
- Py_INCREF(s);
- return s;
-}
-
-
-static PyMethodDef module_methods[] = {
- {"escape", (PyCFunction)escape, METH_O,
- "escape(s) -> markup\n\n"
- "Convert the characters &, <, >, ', and \" in string s to HTML-safe\n"
- "sequences. Use this if you need to display text that might contain\n"
- "such characters in HTML. Marks return value as markup string."},
- {"escape_silent", (PyCFunction)escape_silent, METH_O,
- "escape_silent(s) -> markup\n\n"
- "Like escape but converts None to an empty string."},
- {"soft_unicode", (PyCFunction)soft_unicode, METH_O,
- "soft_unicode(object) -> string\n\n"
- "Make a string unicode if it isn't already. That way a markup\n"
- "string is not converted back to unicode."},
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-
-#if PY_MAJOR_VERSION < 3
-
-#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
-PyMODINIT_FUNC
-init_speedups(void)
-{
- if (!init_constants())
- return;
-
- Py_InitModule3("markupsafe._speedups", module_methods, "");
-}
-
-#else /* Python 3.x module initialization */
-
-static struct PyModuleDef module_definition = {
- PyModuleDef_HEAD_INIT,
- "markupsafe._speedups",
- NULL,
- -1,
- module_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-PyMODINIT_FUNC
-PyInit__speedups(void)
-{
- if (!init_constants())
- return NULL;
-
- return PyModule_Create(&module_definition);
-}
-
-#endif
diff --git a/python/msvcp140.dll b/python/msvcp140.dll
deleted file mode 100644
index 0a2b9b7..0000000
--- a/python/msvcp140.dll
+++ /dev/null
Binary files differ
diff --git a/python/pyexpat.pyd b/python/pyexpat.pyd
deleted file mode 100644
index 9010832..0000000
--- a/python/pyexpat.pyd
+++ /dev/null
Binary files differ
diff --git a/python/python.exe b/python/python.exe
deleted file mode 100644
index da57b2a..0000000
--- a/python/python.exe
+++ /dev/null
Binary files differ
diff --git a/python/python3.dll b/python/python3.dll
deleted file mode 100644
index e802959..0000000
--- a/python/python3.dll
+++ /dev/null
Binary files differ
diff --git a/python/python36._pth b/python/python36._pth
deleted file mode 100644
index 901a723..0000000
--- a/python/python36._pth
+++ /dev/null
@@ -1,6 +0,0 @@
-python36.zip
-.
-..
-
-# Uncomment to run site.main() automatically
-#import site
diff --git a/python/python36.dll b/python/python36.dll
deleted file mode 100644
index b7d0518..0000000
--- a/python/python36.dll
+++ /dev/null
Binary files differ
diff --git a/python/python36.zip b/python/python36.zip
deleted file mode 100644
index 9f0b983..0000000
--- a/python/python36.zip
+++ /dev/null
Binary files differ
diff --git a/python/pythonw.exe b/python/pythonw.exe
deleted file mode 100644
index e966a7e..0000000
--- a/python/pythonw.exe
+++ /dev/null
Binary files differ
diff --git a/python/select.pyd b/python/select.pyd
deleted file mode 100644
index 9c9c87d..0000000
--- a/python/select.pyd
+++ /dev/null
Binary files differ
diff --git a/python/six.py b/python/six.py
deleted file mode 100644
index 6bf4fd3..0000000
--- a/python/six.py
+++ /dev/null
@@ -1,891 +0,0 @@
-# Copyright (c) 2010-2017 Benjamin Peterson
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-"""Utilities for writing code that runs on Python 2 and 3"""
-
-from __future__ import absolute_import
-
-import functools
-import itertools
-import operator
-import sys
-import types
-
-__author__ = "Benjamin Peterson <benjamin@python.org>"
-__version__ = "1.11.0"
-
-
-# Useful for very coarse version differentiation.
-PY2 = sys.version_info[0] == 2
-PY3 = sys.version_info[0] == 3
-PY34 = sys.version_info[0:2] >= (3, 4)
-
-if PY3:
- string_types = str,
- integer_types = int,
- class_types = type,
- text_type = str
- binary_type = bytes
-
- MAXSIZE = sys.maxsize
-else:
- string_types = basestring,
- integer_types = (int, long)
- class_types = (type, types.ClassType)
- text_type = unicode
- binary_type = str
-
- if sys.platform.startswith("java"):
- # Jython always uses 32 bits.
- MAXSIZE = int((1 << 31) - 1)
- else:
- # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
- class X(object):
-
- def __len__(self):
- return 1 << 31
- try:
- len(X())
- except OverflowError:
- # 32-bit
- MAXSIZE = int((1 << 31) - 1)
- else:
- # 64-bit
- MAXSIZE = int((1 << 63) - 1)
- del X
-
-
-def _add_doc(func, doc):
- """Add documentation to a function."""
- func.__doc__ = doc
-
-
-def _import_module(name):
- """Import module, returning the module after the last dot."""
- __import__(name)
- return sys.modules[name]
-
-
-class _LazyDescr(object):
-
- def __init__(self, name):
- self.name = name
-
- def __get__(self, obj, tp):
- result = self._resolve()
- setattr(obj, self.name, result) # Invokes __set__.
- try:
- # This is a bit ugly, but it avoids running this again by
- # removing this descriptor.
- delattr(obj.__class__, self.name)
- except AttributeError:
- pass
- return result
-
-
-class MovedModule(_LazyDescr):
-
- def __init__(self, name, old, new=None):
- super(MovedModule, self).__init__(name)
- if PY3:
- if new is None:
- new = name
- self.mod = new
- else:
- self.mod = old
-
- def _resolve(self):
- return _import_module(self.mod)
-
- def __getattr__(self, attr):
- _module = self._resolve()
- value = getattr(_module, attr)
- setattr(self, attr, value)
- return value
-
-
-class _LazyModule(types.ModuleType):
-
- def __init__(self, name):
- super(_LazyModule, self).__init__(name)
- self.__doc__ = self.__class__.__doc__
-
- def __dir__(self):
- attrs = ["__doc__", "__name__"]
- attrs += [attr.name for attr in self._moved_attributes]
- return attrs
-
- # Subclasses should override this
- _moved_attributes = []
-
-
-class MovedAttribute(_LazyDescr):
-
- def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
- super(MovedAttribute, self).__init__(name)
- if PY3:
- if new_mod is None:
- new_mod = name
- self.mod = new_mod
- if new_attr is None:
- if old_attr is None:
- new_attr = name
- else:
- new_attr = old_attr
- self.attr = new_attr
- else:
- self.mod = old_mod
- if old_attr is None:
- old_attr = name
- self.attr = old_attr
-
- def _resolve(self):
- module = _import_module(self.mod)
- return getattr(module, self.attr)
-
-
-class _SixMetaPathImporter(object):
-
- """
- A meta path importer to import six.moves and its submodules.
-
- This class implements a PEP302 finder and loader. It should be compatible
- with Python 2.5 and all existing versions of Python3
- """
-
- def __init__(self, six_module_name):
- self.name = six_module_name
- self.known_modules = {}
-
- def _add_module(self, mod, *fullnames):
- for fullname in fullnames:
- self.known_modules[self.name + "." + fullname] = mod
-
- def _get_module(self, fullname):
- return self.known_modules[self.name + "." + fullname]
-
- def find_module(self, fullname, path=None):
- if fullname in self.known_modules:
- return self
- return None
-
- def __get_module(self, fullname):
- try:
- return self.known_modules[fullname]
- except KeyError:
- raise ImportError("This loader does not know module " + fullname)
-
- def load_module(self, fullname):
- try:
- # in case of a reload
- return sys.modules[fullname]
- except KeyError:
- pass
- mod = self.__get_module(fullname)
- if isinstance(mod, MovedModule):
- mod = mod._resolve()
- else:
- mod.__loader__ = self
- sys.modules[fullname] = mod
- return mod
-
- def is_package(self, fullname):
- """
- Return true, if the named module is a package.
-
- We need this method to get correct spec objects with
- Python 3.4 (see PEP451)
- """
- return hasattr(self.__get_module(fullname), "__path__")
-
- def get_code(self, fullname):
- """Return None
-
- Required, if is_package is implemented"""
- self.__get_module(fullname) # eventually raises ImportError
- return None
- get_source = get_code # same as get_code
-
-_importer = _SixMetaPathImporter(__name__)
-
-
-class _MovedItems(_LazyModule):
-
- """Lazy loading of moved objects"""
- __path__ = [] # mark as package
-
-
-_moved_attributes = [
- MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
- MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
- MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
- MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
- MovedAttribute("intern", "__builtin__", "sys"),
- MovedAttribute("map", "itertools", "builtins", "imap", "map"),
- MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
- MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
- MovedAttribute("getoutput", "commands", "subprocess"),
- MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
- MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
- MovedAttribute("reduce", "__builtin__", "functools"),
- MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
- MovedAttribute("StringIO", "StringIO", "io"),
- MovedAttribute("UserDict", "UserDict", "collections"),
- MovedAttribute("UserList", "UserList", "collections"),
- MovedAttribute("UserString", "UserString", "collections"),
- MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
- MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
- MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
- MovedModule("builtins", "__builtin__"),
- MovedModule("configparser", "ConfigParser"),
- MovedModule("copyreg", "copy_reg"),
- MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
- MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
- MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
- MovedModule("http_cookies", "Cookie", "http.cookies"),
- MovedModule("html_entities", "htmlentitydefs", "html.entities"),
- MovedModule("html_parser", "HTMLParser", "html.parser"),
- MovedModule("http_client", "httplib", "http.client"),
- MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
- MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"),
- MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
- MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
- MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
- MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
- MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
- MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
- MovedModule("cPickle", "cPickle", "pickle"),
- MovedModule("queue", "Queue"),
- MovedModule("reprlib", "repr"),
- MovedModule("socketserver", "SocketServer"),
- MovedModule("_thread", "thread", "_thread"),
- MovedModule("tkinter", "Tkinter"),
- MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
- MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
- MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
- MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
- MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
- MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
- MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
- MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
- MovedModule("tkinter_colorchooser", "tkColorChooser",
- "tkinter.colorchooser"),
- MovedModule("tkinter_commondialog", "tkCommonDialog",
- "tkinter.commondialog"),
- MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
- MovedModule("tkinter_font", "tkFont", "tkinter.font"),
- MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
- MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
- "tkinter.simpledialog"),
- MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
- MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
- MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
- MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
- MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
- MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
-]
-# Add windows specific modules.
-if sys.platform == "win32":
- _moved_attributes += [
- MovedModule("winreg", "_winreg"),
- ]
-
-for attr in _moved_attributes:
- setattr(_MovedItems, attr.name, attr)
- if isinstance(attr, MovedModule):
- _importer._add_module(attr, "moves." + attr.name)
-del attr
-
-_MovedItems._moved_attributes = _moved_attributes
-
-moves = _MovedItems(__name__ + ".moves")
-_importer._add_module(moves, "moves")
-
-
-class Module_six_moves_urllib_parse(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_parse"""
-
-
-_urllib_parse_moved_attributes = [
- MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
- MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
- MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
- MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
- MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
- MovedAttribute("urljoin", "urlparse", "urllib.parse"),
- MovedAttribute("urlparse", "urlparse", "urllib.parse"),
- MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
- MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
- MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
- MovedAttribute("quote", "urllib", "urllib.parse"),
- MovedAttribute("quote_plus", "urllib", "urllib.parse"),
- MovedAttribute("unquote", "urllib", "urllib.parse"),
- MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
- MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"),
- MovedAttribute("urlencode", "urllib", "urllib.parse"),
- MovedAttribute("splitquery", "urllib", "urllib.parse"),
- MovedAttribute("splittag", "urllib", "urllib.parse"),
- MovedAttribute("splituser", "urllib", "urllib.parse"),
- MovedAttribute("splitvalue", "urllib", "urllib.parse"),
- MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
- MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
- MovedAttribute("uses_params", "urlparse", "urllib.parse"),
- MovedAttribute("uses_query", "urlparse", "urllib.parse"),
- MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
-]
-for attr in _urllib_parse_moved_attributes:
- setattr(Module_six_moves_urllib_parse, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
- "moves.urllib_parse", "moves.urllib.parse")
-
-
-class Module_six_moves_urllib_error(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_error"""
-
-
-_urllib_error_moved_attributes = [
- MovedAttribute("URLError", "urllib2", "urllib.error"),
- MovedAttribute("HTTPError", "urllib2", "urllib.error"),
- MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
-]
-for attr in _urllib_error_moved_attributes:
- setattr(Module_six_moves_urllib_error, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
- "moves.urllib_error", "moves.urllib.error")
-
-
-class Module_six_moves_urllib_request(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_request"""
-
-
-_urllib_request_moved_attributes = [
- MovedAttribute("urlopen", "urllib2", "urllib.request"),
- MovedAttribute("install_opener", "urllib2", "urllib.request"),
- MovedAttribute("build_opener", "urllib2", "urllib.request"),
- MovedAttribute("pathname2url", "urllib", "urllib.request"),
- MovedAttribute("url2pathname", "urllib", "urllib.request"),
- MovedAttribute("getproxies", "urllib", "urllib.request"),
- MovedAttribute("Request", "urllib2", "urllib.request"),
- MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
- MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
- MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
- MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
- MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
- MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
- MovedAttribute("FileHandler", "urllib2", "urllib.request"),
- MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
- MovedAttribute("urlretrieve", "urllib", "urllib.request"),
- MovedAttribute("urlcleanup", "urllib", "urllib.request"),
- MovedAttribute("URLopener", "urllib", "urllib.request"),
- MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
- MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
- MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
- MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
-]
-for attr in _urllib_request_moved_attributes:
- setattr(Module_six_moves_urllib_request, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
- "moves.urllib_request", "moves.urllib.request")
-
-
-class Module_six_moves_urllib_response(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_response"""
-
-
-_urllib_response_moved_attributes = [
- MovedAttribute("addbase", "urllib", "urllib.response"),
- MovedAttribute("addclosehook", "urllib", "urllib.response"),
- MovedAttribute("addinfo", "urllib", "urllib.response"),
- MovedAttribute("addinfourl", "urllib", "urllib.response"),
-]
-for attr in _urllib_response_moved_attributes:
- setattr(Module_six_moves_urllib_response, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
- "moves.urllib_response", "moves.urllib.response")
-
-
-class Module_six_moves_urllib_robotparser(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_robotparser"""
-
-
-_urllib_robotparser_moved_attributes = [
- MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
-]
-for attr in _urllib_robotparser_moved_attributes:
- setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
- "moves.urllib_robotparser", "moves.urllib.robotparser")
-
-
-class Module_six_moves_urllib(types.ModuleType):
-
- """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
- __path__ = [] # mark as package
- parse = _importer._get_module("moves.urllib_parse")
- error = _importer._get_module("moves.urllib_error")
- request = _importer._get_module("moves.urllib_request")
- response = _importer._get_module("moves.urllib_response")
- robotparser = _importer._get_module("moves.urllib_robotparser")
-
- def __dir__(self):
- return ['parse', 'error', 'request', 'response', 'robotparser']
-
-_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
- "moves.urllib")
-
-
-def add_move(move):
- """Add an item to six.moves."""
- setattr(_MovedItems, move.name, move)
-
-
-def remove_move(name):
- """Remove item from six.moves."""
- try:
- delattr(_MovedItems, name)
- except AttributeError:
- try:
- del moves.__dict__[name]
- except KeyError:
- raise AttributeError("no such move, %r" % (name,))
-
-
-if PY3:
- _meth_func = "__func__"
- _meth_self = "__self__"
-
- _func_closure = "__closure__"
- _func_code = "__code__"
- _func_defaults = "__defaults__"
- _func_globals = "__globals__"
-else:
- _meth_func = "im_func"
- _meth_self = "im_self"
-
- _func_closure = "func_closure"
- _func_code = "func_code"
- _func_defaults = "func_defaults"
- _func_globals = "func_globals"
-
-
-try:
- advance_iterator = next
-except NameError:
- def advance_iterator(it):
- return it.next()
-next = advance_iterator
-
-
-try:
- callable = callable
-except NameError:
- def callable(obj):
- return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
-
-
-if PY3:
- def get_unbound_function(unbound):
- return unbound
-
- create_bound_method = types.MethodType
-
- def create_unbound_method(func, cls):
- return func
-
- Iterator = object
-else:
- def get_unbound_function(unbound):
- return unbound.im_func
-
- def create_bound_method(func, obj):
- return types.MethodType(func, obj, obj.__class__)
-
- def create_unbound_method(func, cls):
- return types.MethodType(func, None, cls)
-
- class Iterator(object):
-
- def next(self):
- return type(self).__next__(self)
-
- callable = callable
-_add_doc(get_unbound_function,
- """Get the function out of a possibly unbound function""")
-
-
-get_method_function = operator.attrgetter(_meth_func)
-get_method_self = operator.attrgetter(_meth_self)
-get_function_closure = operator.attrgetter(_func_closure)
-get_function_code = operator.attrgetter(_func_code)
-get_function_defaults = operator.attrgetter(_func_defaults)
-get_function_globals = operator.attrgetter(_func_globals)
-
-
-if PY3:
- def iterkeys(d, **kw):
- return iter(d.keys(**kw))
-
- def itervalues(d, **kw):
- return iter(d.values(**kw))
-
- def iteritems(d, **kw):
- return iter(d.items(**kw))
-
- def iterlists(d, **kw):
- return iter(d.lists(**kw))
-
- viewkeys = operator.methodcaller("keys")
-
- viewvalues = operator.methodcaller("values")
-
- viewitems = operator.methodcaller("items")
-else:
- def iterkeys(d, **kw):
- return d.iterkeys(**kw)
-
- def itervalues(d, **kw):
- return d.itervalues(**kw)
-
- def iteritems(d, **kw):
- return d.iteritems(**kw)
-
- def iterlists(d, **kw):
- return d.iterlists(**kw)
-
- viewkeys = operator.methodcaller("viewkeys")
-
- viewvalues = operator.methodcaller("viewvalues")
-
- viewitems = operator.methodcaller("viewitems")
-
-_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
-_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
-_add_doc(iteritems,
- "Return an iterator over the (key, value) pairs of a dictionary.")
-_add_doc(iterlists,
- "Return an iterator over the (key, [values]) pairs of a dictionary.")
-
-
-if PY3:
- def b(s):
- return s.encode("latin-1")
-
- def u(s):
- return s
- unichr = chr
- import struct
- int2byte = struct.Struct(">B").pack
- del struct
- byte2int = operator.itemgetter(0)
- indexbytes = operator.getitem
- iterbytes = iter
- import io
- StringIO = io.StringIO
- BytesIO = io.BytesIO
- _assertCountEqual = "assertCountEqual"
- if sys.version_info[1] <= 1:
- _assertRaisesRegex = "assertRaisesRegexp"
- _assertRegex = "assertRegexpMatches"
- else:
- _assertRaisesRegex = "assertRaisesRegex"
- _assertRegex = "assertRegex"
-else:
- def b(s):
- return s
- # Workaround for standalone backslash
-
- def u(s):
- return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
- unichr = unichr
- int2byte = chr
-
- def byte2int(bs):
- return ord(bs[0])
-
- def indexbytes(buf, i):
- return ord(buf[i])
- iterbytes = functools.partial(itertools.imap, ord)
- import StringIO
- StringIO = BytesIO = StringIO.StringIO
- _assertCountEqual = "assertItemsEqual"
- _assertRaisesRegex = "assertRaisesRegexp"
- _assertRegex = "assertRegexpMatches"
-_add_doc(b, """Byte literal""")
-_add_doc(u, """Text literal""")
-
-
-def assertCountEqual(self, *args, **kwargs):
- return getattr(self, _assertCountEqual)(*args, **kwargs)
-
-
-def assertRaisesRegex(self, *args, **kwargs):
- return getattr(self, _assertRaisesRegex)(*args, **kwargs)
-
-
-def assertRegex(self, *args, **kwargs):
- return getattr(self, _assertRegex)(*args, **kwargs)
-
-
-if PY3:
- exec_ = getattr(moves.builtins, "exec")
-
- def reraise(tp, value, tb=None):
- try:
- if value is None:
- value = tp()
- if value.__traceback__ is not tb:
- raise value.with_traceback(tb)
- raise value
- finally:
- value = None
- tb = None
-
-else:
- def exec_(_code_, _globs_=None, _locs_=None):
- """Execute code in a namespace."""
- if _globs_ is None:
- frame = sys._getframe(1)
- _globs_ = frame.f_globals
- if _locs_ is None:
- _locs_ = frame.f_locals
- del frame
- elif _locs_ is None:
- _locs_ = _globs_
- exec("""exec _code_ in _globs_, _locs_""")
-
- exec_("""def reraise(tp, value, tb=None):
- try:
- raise tp, value, tb
- finally:
- tb = None
-""")
-
-
-if sys.version_info[:2] == (3, 2):
- exec_("""def raise_from(value, from_value):
- try:
- if from_value is None:
- raise value
- raise value from from_value
- finally:
- value = None
-""")
-elif sys.version_info[:2] > (3, 2):
- exec_("""def raise_from(value, from_value):
- try:
- raise value from from_value
- finally:
- value = None
-""")
-else:
- def raise_from(value, from_value):
- raise value
-
-
-print_ = getattr(moves.builtins, "print", None)
-if print_ is None:
- def print_(*args, **kwargs):
- """The new-style print function for Python 2.4 and 2.5."""
- fp = kwargs.pop("file", sys.stdout)
- if fp is None:
- return
-
- def write(data):
- if not isinstance(data, basestring):
- data = str(data)
- # If the file has an encoding, encode unicode with it.
- if (isinstance(fp, file) and
- isinstance(data, unicode) and
- fp.encoding is not None):
- errors = getattr(fp, "errors", None)
- if errors is None:
- errors = "strict"
- data = data.encode(fp.encoding, errors)
- fp.write(data)
- want_unicode = False
- sep = kwargs.pop("sep", None)
- if sep is not None:
- if isinstance(sep, unicode):
- want_unicode = True
- elif not isinstance(sep, str):
- raise TypeError("sep must be None or a string")
- end = kwargs.pop("end", None)
- if end is not None:
- if isinstance(end, unicode):
- want_unicode = True
- elif not isinstance(end, str):
- raise TypeError("end must be None or a string")
- if kwargs:
- raise TypeError("invalid keyword arguments to print()")
- if not want_unicode:
- for arg in args:
- if isinstance(arg, unicode):
- want_unicode = True
- break
- if want_unicode:
- newline = unicode("\n")
- space = unicode(" ")
- else:
- newline = "\n"
- space = " "
- if sep is None:
- sep = space
- if end is None:
- end = newline
- for i, arg in enumerate(args):
- if i:
- write(sep)
- write(arg)
- write(end)
-if sys.version_info[:2] < (3, 3):
- _print = print_
-
- def print_(*args, **kwargs):
- fp = kwargs.get("file", sys.stdout)
- flush = kwargs.pop("flush", False)
- _print(*args, **kwargs)
- if flush and fp is not None:
- fp.flush()
-
-_add_doc(reraise, """Reraise an exception.""")
-
-if sys.version_info[0:2] < (3, 4):
- def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
- updated=functools.WRAPPER_UPDATES):
- def wrapper(f):
- f = functools.wraps(wrapped, assigned, updated)(f)
- f.__wrapped__ = wrapped
- return f
- return wrapper
-else:
- wraps = functools.wraps
-
-
-def with_metaclass(meta, *bases):
- """Create a base class with a metaclass."""
- # This requires a bit of explanation: the basic idea is to make a dummy
- # metaclass for one level of class instantiation that replaces itself with
- # the actual metaclass.
- class metaclass(type):
-
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
-
- @classmethod
- def __prepare__(cls, name, this_bases):
- return meta.__prepare__(name, bases)
- return type.__new__(metaclass, 'temporary_class', (), {})
-
-
-def add_metaclass(metaclass):
- """Class decorator for creating a class with a metaclass."""
- def wrapper(cls):
- orig_vars = cls.__dict__.copy()
- slots = orig_vars.get('__slots__')
- if slots is not None:
- if isinstance(slots, str):
- slots = [slots]
- for slots_var in slots:
- orig_vars.pop(slots_var)
- orig_vars.pop('__dict__', None)
- orig_vars.pop('__weakref__', None)
- return metaclass(cls.__name__, cls.__bases__, orig_vars)
- return wrapper
-
-
-def python_2_unicode_compatible(klass):
- """
- A decorator that defines __unicode__ and __str__ methods under Python 2.
- Under Python 3 it does nothing.
-
- To support Python 2 and 3 with a single code base, define a __str__ method
- returning text and apply this decorator to the class.
- """
- if PY2:
- if '__str__' not in klass.__dict__:
- raise ValueError("@python_2_unicode_compatible cannot be applied "
- "to %s because it doesn't define __str__()." %
- klass.__name__)
- klass.__unicode__ = klass.__str__
- klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
- return klass
-
-
-# Complete the moves implementation.
-# This code is at the end of this module to speed up module loading.
-# Turn this module into a package.
-__path__ = [] # required for PEP 302 and PEP 451
-__package__ = __name__ # see PEP 366 @ReservedAssignment
-if globals().get("__spec__") is not None:
- __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
-# Remove other six meta path importers, since they cause problems. This can
-# happen if six is removed from sys.modules and then reloaded. (Setuptools does
-# this for some reason.)
-if sys.meta_path:
- for i, importer in enumerate(sys.meta_path):
- # Here's some real nastiness: Another "instance" of the six module might
- # be floating around. Therefore, we can't use isinstance() to check for
- # the six meta path importer, since the other six instance will have
- # inserted an importer with different class.
- if (type(importer).__name__ == "_SixMetaPathImporter" and
- importer.name == __name__):
- del sys.meta_path[i]
- break
- del i, importer
-# Finally, add the importer to the meta path import hook.
-sys.meta_path.append(_importer)
diff --git a/python/socks.py b/python/socks.py
deleted file mode 100644
index 7bcf590..0000000
--- a/python/socks.py
+++ /dev/null
@@ -1,870 +0,0 @@
-"""SocksiPy - Python SOCKS module.
-
-Copyright 2006 Dan-Haim. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-3. Neither the name of Dan Haim nor the names of his contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
-OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-This module provides a standard socket-like interface for Python
-for tunneling connections through SOCKS proxies.
-
-===============================================================================
-
-Minor modifications made by Christopher Gilbert (http://motomastyle.com/)
-for use in PyLoris (http://pyloris.sourceforge.net/)
-
-Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/)
-mainly to merge bug fixes found in Sourceforge
-
-Modifications made by Anorov (https://github.com/Anorov)
--Forked and renamed to PySocks
--Fixed issue with HTTP proxy failure checking (same bug that was in the
- old ___recvall() method)
--Included SocksiPyHandler (sockshandler.py), to be used as a urllib2 handler,
- courtesy of e000 (https://github.com/e000):
- https://gist.github.com/869791#file_socksipyhandler.py
--Re-styled code to make it readable
- -Aliased PROXY_TYPE_SOCKS5 -> SOCKS5 etc.
- -Improved exception handling and output
- -Removed irritating use of sequence indexes, replaced with tuple unpacked
- variables
- -Fixed up Python 3 bytestring handling - chr(0x03).encode() -> b"\x03"
- -Other general fixes
--Added clarification that the HTTP proxy connection method only supports
- CONNECT-style tunneling HTTP proxies
--Various small bug fixes
-"""
-
-from base64 import b64encode
-from collections import Callable
-from errno import EOPNOTSUPP, EINVAL, EAGAIN
-import functools
-from io import BytesIO
-import logging
-import os
-from os import SEEK_CUR
-import socket
-import struct
-import sys
-
-__version__ = "1.6.7"
-
-
-if os.name == "nt" and sys.version_info < (3, 0):
- try:
- import win_inet_pton
- except ImportError:
- raise ImportError(
- "To run PySocks on Windows you must install win_inet_pton")
-
-log = logging.getLogger(__name__)
-
-PROXY_TYPE_SOCKS4 = SOCKS4 = 1
-PROXY_TYPE_SOCKS5 = SOCKS5 = 2
-PROXY_TYPE_HTTP = HTTP = 3
-
-PROXY_TYPES = {"SOCKS4": SOCKS4, "SOCKS5": SOCKS5, "HTTP": HTTP}
-PRINTABLE_PROXY_TYPES = dict(zip(PROXY_TYPES.values(), PROXY_TYPES.keys()))
-
-_orgsocket = _orig_socket = socket.socket
-
-
-def set_self_blocking(function):
-
- @functools.wraps(function)
- def wrapper(*args, **kwargs):
- self = args[0]
- try:
- _is_blocking = self.gettimeout()
- if _is_blocking == 0:
- self.setblocking(True)
- return function(*args, **kwargs)
- except Exception as e:
- raise
- finally:
- # set orgin blocking
- if _is_blocking == 0:
- self.setblocking(False)
- return wrapper
-
-
-class ProxyError(IOError):
- """Socket_err contains original socket.error exception."""
- def __init__(self, msg, socket_err=None):
- self.msg = msg
- self.socket_err = socket_err
-
- if socket_err:
- self.msg += ": {0}".format(socket_err)
-
- def __str__(self):
- return self.msg
-
-
-class GeneralProxyError(ProxyError):
- pass
-
-
-class ProxyConnectionError(ProxyError):
- pass
-
-
-class SOCKS5AuthError(ProxyError):
- pass
-
-
-class SOCKS5Error(ProxyError):
- pass
-
-
-class SOCKS4Error(ProxyError):
- pass
-
-
-class HTTPError(ProxyError):
- pass
-
-SOCKS4_ERRORS = {
- 0x5B: "Request rejected or failed",
- 0x5C: ("Request rejected because SOCKS server cannot connect to identd on"
- " the client"),
- 0x5D: ("Request rejected because the client program and identd report"
- " different user-ids")
-}
-
-SOCKS5_ERRORS = {
- 0x01: "General SOCKS server failure",
- 0x02: "Connection not allowed by ruleset",
- 0x03: "Network unreachable",
- 0x04: "Host unreachable",
- 0x05: "Connection refused",
- 0x06: "TTL expired",
- 0x07: "Command not supported, or protocol error",
- 0x08: "Address type not supported"
-}
-
-DEFAULT_PORTS = {SOCKS4: 1080, SOCKS5: 1080, HTTP: 8080}
-
-
-def set_default_proxy(proxy_type=None, addr=None, port=None, rdns=True,
- username=None, password=None):
- """Sets a default proxy.
-
- All further socksocket objects will use the default unless explicitly
- changed. All parameters are as for socket.set_proxy()."""
- socksocket.default_proxy = (proxy_type, addr, port, rdns,
- username.encode() if username else None,
- password.encode() if password else None)
-
-
-def setdefaultproxy(*args, **kwargs):
- if "proxytype" in kwargs:
- kwargs["proxy_type"] = kwargs.pop("proxytype")
- return set_default_proxy(*args, **kwargs)
-
-
-def get_default_proxy():
- """Returns the default proxy, set by set_default_proxy."""
- return socksocket.default_proxy
-
-getdefaultproxy = get_default_proxy
-
-
-def wrap_module(module):
- """Attempts to replace a module's socket library with a SOCKS socket.
-
- Must set a default proxy using set_default_proxy(...) first. This will
- only work on modules that import socket directly into the namespace;
- most of the Python Standard Library falls into this category."""
- if socksocket.default_proxy:
- module.socket.socket = socksocket
- else:
- raise GeneralProxyError("No default proxy specified")
-
-wrapmodule = wrap_module
-
-
-def create_connection(dest_pair,
- timeout=None, source_address=None,
- proxy_type=None, proxy_addr=None,
- proxy_port=None, proxy_rdns=True,
- proxy_username=None, proxy_password=None,
- socket_options=None):
- """create_connection(dest_pair, *[, timeout], **proxy_args) -> socket object
-
- Like socket.create_connection(), but connects to proxy
- before returning the socket object.
-
- dest_pair - 2-tuple of (IP/hostname, port).
- **proxy_args - Same args passed to socksocket.set_proxy() if present.
- timeout - Optional socket timeout value, in seconds.
- source_address - tuple (host, port) for the socket to bind to as its source
- address before connecting (only for compatibility)
- """
- # Remove IPv6 brackets on the remote address and proxy address.
- remote_host, remote_port = dest_pair
- if remote_host.startswith("["):
- remote_host = remote_host.strip("[]")
- if proxy_addr and proxy_addr.startswith("["):
- proxy_addr = proxy_addr.strip("[]")
-
- err = None
-
- # Allow the SOCKS proxy to be on IPv4 or IPv6 addresses.
- for r in socket.getaddrinfo(proxy_addr, proxy_port, 0, socket.SOCK_STREAM):
- family, socket_type, proto, canonname, sa = r
- sock = None
- try:
- sock = socksocket(family, socket_type, proto)
-
- if socket_options:
- for opt in socket_options:
- sock.setsockopt(*opt)
-
- if isinstance(timeout, (int, float)):
- sock.settimeout(timeout)
-
- if proxy_type:
- sock.set_proxy(proxy_type, proxy_addr, proxy_port, proxy_rdns,
- proxy_username, proxy_password)
- if source_address:
- sock.bind(source_address)
-
- sock.connect((remote_host, remote_port))
- return sock
-
- except (socket.error, ProxyConnectionError) as e:
- err = e
- if sock:
- sock.close()
- sock = None
-
- if err:
- raise err
-
- raise socket.error("gai returned empty list.")
-
-
-class _BaseSocket(socket.socket):
- """Allows Python 2 delegated methods such as send() to be overridden."""
- def __init__(self, *pos, **kw):
- _orig_socket.__init__(self, *pos, **kw)
-
- self._savedmethods = dict()
- for name in self._savenames:
- self._savedmethods[name] = getattr(self, name)
- delattr(self, name) # Allows normal overriding mechanism to work
-
- _savenames = list()
-
-
-def _makemethod(name):
- return lambda self, *pos, **kw: self._savedmethods[name](*pos, **kw)
-for name in ("sendto", "send", "recvfrom", "recv"):
- method = getattr(_BaseSocket, name, None)
-
- # Determine if the method is not defined the usual way
- # as a function in the class.
- # Python 2 uses __slots__, so there are descriptors for each method,
- # but they are not functions.
- if not isinstance(method, Callable):
- _BaseSocket._savenames.append(name)
- setattr(_BaseSocket, name, _makemethod(name))
-
-
-class socksocket(_BaseSocket):
- """socksocket([family[, type[, proto]]]) -> socket object
-
- Open a SOCKS enabled socket. The parameters are the same as
- those of the standard socket init. In order for SOCKS to work,
- you must specify family=AF_INET and proto=0.
- The "type" argument must be either SOCK_STREAM or SOCK_DGRAM.
- """
-
- default_proxy = None
-
- def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM,
- proto=0, *args, **kwargs):
- if type not in (socket.SOCK_STREAM, socket.SOCK_DGRAM):
- msg = "Socket type must be stream or datagram, not {!r}"
- raise ValueError(msg.format(type))
-
- super(socksocket, self).__init__(family, type, proto, *args, **kwargs)
- self._proxyconn = None # TCP connection to keep UDP relay alive
-
- if self.default_proxy:
- self.proxy = self.default_proxy
- else:
- self.proxy = (None, None, None, None, None, None)
- self.proxy_sockname = None
- self.proxy_peername = None
-
- self._timeout = None
-
- def _readall(self, file, count):
- """Receive EXACTLY the number of bytes requested from the file object.
-
- Blocks until the required number of bytes have been received."""
- data = b""
- while len(data) < count:
- d = file.read(count - len(data))
- if not d:
- raise GeneralProxyError("Connection closed unexpectedly")
- data += d
- return data
-
- def settimeout(self, timeout):
- self._timeout = timeout
- try:
- # test if we're connected, if so apply timeout
- peer = self.get_proxy_peername()
- super(socksocket, self).settimeout(self._timeout)
- except socket.error:
- pass
-
- def gettimeout(self):
- return self._timeout
-
- def setblocking(self, v):
- if v:
- self.settimeout(None)
- else:
- self.settimeout(0.0)
-
- def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True,
- username=None, password=None):
- """ Sets the proxy to be used.
-
- proxy_type - The type of the proxy to be used. Three types
- are supported: PROXY_TYPE_SOCKS4 (including socks4a),
- PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
- addr - The address of the server (IP or DNS).
- port - The port of the server. Defaults to 1080 for SOCKS
- servers and 8080 for HTTP proxy servers.
- rdns - Should DNS queries be performed on the remote side
- (rather than the local side). The default is True.
- Note: This has no effect with SOCKS4 servers.
- username - Username to authenticate with to the server.
- The default is no authentication.
- password - Password to authenticate with to the server.
- Only relevant when username is also provided."""
- self.proxy = (proxy_type, addr, port, rdns,
- username.encode() if username else None,
- password.encode() if password else None)
-
- def setproxy(self, *args, **kwargs):
- if "proxytype" in kwargs:
- kwargs["proxy_type"] = kwargs.pop("proxytype")
- return self.set_proxy(*args, **kwargs)
-
- def bind(self, *pos, **kw):
- """Implements proxy connection for UDP sockets.
-
- Happens during the bind() phase."""
- (proxy_type, proxy_addr, proxy_port, rdns, username,
- password) = self.proxy
- if not proxy_type or self.type != socket.SOCK_DGRAM:
- return _orig_socket.bind(self, *pos, **kw)
-
- if self._proxyconn:
- raise socket.error(EINVAL, "Socket already bound to an address")
- if proxy_type != SOCKS5:
- msg = "UDP only supported by SOCKS5 proxy type"
- raise socket.error(EOPNOTSUPP, msg)
- super(socksocket, self).bind(*pos, **kw)
-
- # Need to specify actual local port because
- # some relays drop packets if a port of zero is specified.
- # Avoid specifying host address in case of NAT though.
- _, port = self.getsockname()
- dst = ("0", port)
-
- self._proxyconn = _orig_socket()
- proxy = self._proxy_addr()
- self._proxyconn.connect(proxy)
-
- UDP_ASSOCIATE = b"\x03"
- _, relay = self._SOCKS5_request(self._proxyconn, UDP_ASSOCIATE, dst)
-
- # The relay is most likely on the same host as the SOCKS proxy,
- # but some proxies return a private IP address (10.x.y.z)
- host, _ = proxy
- _, port = relay
- super(socksocket, self).connect((host, port))
- super(socksocket, self).settimeout(self._timeout)
- self.proxy_sockname = ("0.0.0.0", 0) # Unknown
-
- def sendto(self, bytes, *args, **kwargs):
- if self.type != socket.SOCK_DGRAM:
- return super(socksocket, self).sendto(bytes, *args, **kwargs)
- if not self._proxyconn:
- self.bind(("", 0))
-
- address = args[-1]
- flags = args[:-1]
-
- header = BytesIO()
- RSV = b"\x00\x00"
- header.write(RSV)
- STANDALONE = b"\x00"
- header.write(STANDALONE)
- self._write_SOCKS5_address(address, header)
-
- sent = super(socksocket, self).send(header.getvalue() + bytes, *flags,
- **kwargs)
- return sent - header.tell()
-
- def send(self, bytes, flags=0, **kwargs):
- if self.type == socket.SOCK_DGRAM:
- return self.sendto(bytes, flags, self.proxy_peername, **kwargs)
- else:
- return super(socksocket, self).send(bytes, flags, **kwargs)
-
- def recvfrom(self, bufsize, flags=0):
- if self.type != socket.SOCK_DGRAM:
- return super(socksocket, self).recvfrom(bufsize, flags)
- if not self._proxyconn:
- self.bind(("", 0))
-
- buf = BytesIO(super(socksocket, self).recv(bufsize + 1024, flags))
- buf.seek(2, SEEK_CUR)
- frag = buf.read(1)
- if ord(frag):
- raise NotImplementedError("Received UDP packet fragment")
- fromhost, fromport = self._read_SOCKS5_address(buf)
-
- if self.proxy_peername:
- peerhost, peerport = self.proxy_peername
- if fromhost != peerhost or peerport not in (0, fromport):
- raise socket.error(EAGAIN, "Packet filtered")
-
- return (buf.read(bufsize), (fromhost, fromport))
-
- def recv(self, *pos, **kw):
- bytes, _ = self.recvfrom(*pos, **kw)
- return bytes
-
- def close(self):
- if self._proxyconn:
- self._proxyconn.close()
- return super(socksocket, self).close()
-
- def get_proxy_sockname(self):
- """Returns the bound IP address and port number at the proxy."""
- return self.proxy_sockname
-
- getproxysockname = get_proxy_sockname
-
- def get_proxy_peername(self):
- """
- Returns the IP and port number of the proxy.
- """
- return self.getpeername()
-
- getproxypeername = get_proxy_peername
-
- def get_peername(self):
- """Returns the IP address and port number of the destination machine.
-
- Note: get_proxy_peername returns the proxy."""
- return self.proxy_peername
-
- getpeername = get_peername
-
- def _negotiate_SOCKS5(self, *dest_addr):
- """Negotiates a stream connection through a SOCKS5 server."""
- CONNECT = b"\x01"
- self.proxy_peername, self.proxy_sockname = self._SOCKS5_request(
- self, CONNECT, dest_addr)
-
- def _SOCKS5_request(self, conn, cmd, dst):
- """
- Send SOCKS5 request with given command (CMD field) and
- address (DST field). Returns resolved DST address that was used.
- """
- proxy_type, addr, port, rdns, username, password = self.proxy
-
- writer = conn.makefile("wb")
- reader = conn.makefile("rb", 0) # buffering=0 renamed in Python 3
- try:
- # First we'll send the authentication packages we support.
- if username and password:
- # The username/password details were supplied to the
- # set_proxy method so we support the USERNAME/PASSWORD
- # authentication (in addition to the standard none).
- writer.write(b"\x05\x02\x00\x02")
- else:
- # No username/password were entered, therefore we
- # only support connections with no authentication.
- writer.write(b"\x05\x01\x00")
-
- # We'll receive the server's response to determine which
- # method was selected
- writer.flush()
- chosen_auth = self._readall(reader, 2)
-
- if chosen_auth[0:1] != b"\x05":
- # Note: string[i:i+1] is used because indexing of a bytestring
- # via bytestring[i] yields an integer in Python 3
- raise GeneralProxyError(
- "SOCKS5 proxy server sent invalid data")
-
- # Check the chosen authentication method
-
- if chosen_auth[1:2] == b"\x02":
- # Okay, we need to perform a basic username/password
- # authentication.
- writer.write(b"\x01" + chr(len(username)).encode()
- + username
- + chr(len(password)).encode()
- + password)
- writer.flush()
- auth_status = self._readall(reader, 2)
- if auth_status[0:1] != b"\x01":
- # Bad response
- raise GeneralProxyError(
- "SOCKS5 proxy server sent invalid data")
- if auth_status[1:2] != b"\x00":
- # Authentication failed
- raise SOCKS5AuthError("SOCKS5 authentication failed")
-
- # Otherwise, authentication succeeded
-
- # No authentication is required if 0x00
- elif chosen_auth[1:2] != b"\x00":
- # Reaching here is always bad
- if chosen_auth[1:2] == b"\xFF":
- raise SOCKS5AuthError(
- "All offered SOCKS5 authentication methods were"
- " rejected")
- else:
- raise GeneralProxyError(
- "SOCKS5 proxy server sent invalid data")
-
- # Now we can request the actual connection
- writer.write(b"\x05" + cmd + b"\x00")
- resolved = self._write_SOCKS5_address(dst, writer)
- writer.flush()
-
- # Get the response
- resp = self._readall(reader, 3)
- if resp[0:1] != b"\x05":
- raise GeneralProxyError(
- "SOCKS5 proxy server sent invalid data")
-
- status = ord(resp[1:2])
- if status != 0x00:
- # Connection failed: server returned an error
- error = SOCKS5_ERRORS.get(status, "Unknown error")
- raise SOCKS5Error("{0:#04x}: {1}".format(status, error))
-
- # Get the bound address/port
- bnd = self._read_SOCKS5_address(reader)
-
- super(socksocket, self).settimeout(self._timeout)
- return (resolved, bnd)
- finally:
- reader.close()
- writer.close()
-
- def _write_SOCKS5_address(self, addr, file):
- """
- Return the host and port packed for the SOCKS5 protocol,
- and the resolved address as a tuple object.
- """
- host, port = addr
- proxy_type, _, _, rdns, username, password = self.proxy
- family_to_byte = {socket.AF_INET: b"\x01", socket.AF_INET6: b"\x04"}
-
- # If the given destination address is an IP address, we'll
- # use the IP address request even if remote resolving was specified.
- # Detect whether the address is IPv4/6 directly.
- for family in (socket.AF_INET, socket.AF_INET6):
- try:
- addr_bytes = socket.inet_pton(family, host)
- file.write(family_to_byte[family] + addr_bytes)
- host = socket.inet_ntop(family, addr_bytes)
- file.write(struct.pack(">H", port))
- return host, port
- except socket.error:
- continue
-
- # Well it's not an IP number, so it's probably a DNS name.
- if rdns:
- # Resolve remotely
- host_bytes = host.encode("idna")
- file.write(b"\x03" + chr(len(host_bytes)).encode() + host_bytes)
- else:
- # Resolve locally
- addresses = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
- socket.SOCK_STREAM,
- socket.IPPROTO_TCP,
- socket.AI_ADDRCONFIG)
- # We can't really work out what IP is reachable, so just pick the
- # first.
- target_addr = addresses[0]
- family = target_addr[0]
- host = target_addr[4][0]
-
- addr_bytes = socket.inet_pton(family, host)
- file.write(family_to_byte[family] + addr_bytes)
- host = socket.inet_ntop(family, addr_bytes)
- file.write(struct.pack(">H", port))
- return host, port
-
- def _read_SOCKS5_address(self, file):
- atyp = self._readall(file, 1)
- if atyp == b"\x01":
- addr = socket.inet_ntoa(self._readall(file, 4))
- elif atyp == b"\x03":
- length = self._readall(file, 1)
- addr = self._readall(file, ord(length))
- elif atyp == b"\x04":
- addr = socket.inet_ntop(socket.AF_INET6, self._readall(file, 16))
- else:
- raise GeneralProxyError("SOCKS5 proxy server sent invalid data")
-
- port = struct.unpack(">H", self._readall(file, 2))[0]
- return addr, port
-
- def _negotiate_SOCKS4(self, dest_addr, dest_port):
- """Negotiates a connection through a SOCKS4 server."""
- proxy_type, addr, port, rdns, username, password = self.proxy
-
- writer = self.makefile("wb")
- reader = self.makefile("rb", 0) # buffering=0 renamed in Python 3
- try:
- # Check if the destination address provided is an IP address
- remote_resolve = False
- try:
- addr_bytes = socket.inet_aton(dest_addr)
- except socket.error:
- # It's a DNS name. Check where it should be resolved.
- if rdns:
- addr_bytes = b"\x00\x00\x00\x01"
- remote_resolve = True
- else:
- addr_bytes = socket.inet_aton(
- socket.gethostbyname(dest_addr))
-
- # Construct the request packet
- writer.write(struct.pack(">BBH", 0x04, 0x01, dest_port))
- writer.write(addr_bytes)
-
- # The username parameter is considered userid for SOCKS4
- if username:
- writer.write(username)
- writer.write(b"\x00")
-
- # DNS name if remote resolving is required
- # NOTE: This is actually an extension to the SOCKS4 protocol
- # called SOCKS4A and may not be supported in all cases.
- if remote_resolve:
- writer.write(dest_addr.encode("idna") + b"\x00")
- writer.flush()
-
- # Get the response from the server
- resp = self._readall(reader, 8)
- if resp[0:1] != b"\x00":
- # Bad data
- raise GeneralProxyError(
- "SOCKS4 proxy server sent invalid data")
-
- status = ord(resp[1:2])
- if status != 0x5A:
- # Connection failed: server returned an error
- error = SOCKS4_ERRORS.get(status, "Unknown error")
- raise SOCKS4Error("{0:#04x}: {1}".format(status, error))
-
- # Get the bound address/port
- self.proxy_sockname = (socket.inet_ntoa(resp[4:]),
- struct.unpack(">H", resp[2:4])[0])
- if remote_resolve:
- self.proxy_peername = socket.inet_ntoa(addr_bytes), dest_port
- else:
- self.proxy_peername = dest_addr, dest_port
- finally:
- reader.close()
- writer.close()
-
- def _negotiate_HTTP(self, dest_addr, dest_port):
- """Negotiates a connection through an HTTP server.
-
- NOTE: This currently only supports HTTP CONNECT-style proxies."""
- proxy_type, addr, port, rdns, username, password = self.proxy
-
- # If we need to resolve locally, we do this now
- addr = dest_addr if rdns else socket.gethostbyname(dest_addr)
-
- http_headers = [
- (b"CONNECT " + addr.encode("idna") + b":"
- + str(dest_port).encode() + b" HTTP/1.1"),
- b"Host: " + dest_addr.encode("idna")
- ]
-
- if username and password:
- http_headers.append(b"Proxy-Authorization: basic "
- + b64encode(username + b":" + password))
-
- http_headers.append(b"\r\n")
-
- self.sendall(b"\r\n".join(http_headers))
-
- # We just need the first line to check if the connection was successful
- fobj = self.makefile()
- status_line = fobj.readline()
- fobj.close()
-
- if not status_line:
- raise GeneralProxyError("Connection closed unexpectedly")
-
- try:
- proto, status_code, status_msg = status_line.split(" ", 2)
- except ValueError:
- raise GeneralProxyError("HTTP proxy server sent invalid response")
-
- if not proto.startswith("HTTP/"):
- raise GeneralProxyError(
- "Proxy server does not appear to be an HTTP proxy")
-
- try:
- status_code = int(status_code)
- except ValueError:
- raise HTTPError(
- "HTTP proxy server did not return a valid HTTP status")
-
- if status_code != 200:
- error = "{0}: {1}".format(status_code, status_msg)
- if status_code in (400, 403, 405):
- # It's likely that the HTTP proxy server does not support the
- # CONNECT tunneling method
- error += ("\n[*] Note: The HTTP proxy server may not be"
- " supported by PySocks (must be a CONNECT tunnel"
- " proxy)")
- raise HTTPError(error)
-
- self.proxy_sockname = (b"0.0.0.0", 0)
- self.proxy_peername = addr, dest_port
-
- _proxy_negotiators = {
- SOCKS4: _negotiate_SOCKS4,
- SOCKS5: _negotiate_SOCKS5,
- HTTP: _negotiate_HTTP
- }
-
- @set_self_blocking
- def connect(self, dest_pair):
- """
- Connects to the specified destination through a proxy.
- Uses the same API as socket's connect().
- To select the proxy server, use set_proxy().
-
- dest_pair - 2-tuple of (IP/hostname, port).
- """
- if len(dest_pair) != 2 or dest_pair[0].startswith("["):
- # Probably IPv6, not supported -- raise an error, and hope
- # Happy Eyeballs (RFC6555) makes sure at least the IPv4
- # connection works...
- raise socket.error("PySocks doesn't support IPv6: %s"
- % str(dest_pair))
-
- dest_addr, dest_port = dest_pair
-
- if self.type == socket.SOCK_DGRAM:
- if not self._proxyconn:
- self.bind(("", 0))
- dest_addr = socket.gethostbyname(dest_addr)
-
- # If the host address is INADDR_ANY or similar, reset the peer
- # address so that packets are received from any peer
- if dest_addr == "0.0.0.0" and not dest_port:
- self.proxy_peername = None
- else:
- self.proxy_peername = (dest_addr, dest_port)
- return
-
- (proxy_type, proxy_addr, proxy_port, rdns, username,
- password) = self.proxy
-
- # Do a minimal input check first
- if (not isinstance(dest_pair, (list, tuple))
- or len(dest_pair) != 2
- or not dest_addr
- or not isinstance(dest_port, int)):
- # Inputs failed, raise an error
- raise GeneralProxyError(
- "Invalid destination-connection (host, port) pair")
-
- # We set the timeout here so that we don't hang in connection or during
- # negotiation.
- super(socksocket, self).settimeout(self._timeout)
-
- if proxy_type is None:
- # Treat like regular socket object
- self.proxy_peername = dest_pair
- super(socksocket, self).settimeout(self._timeout)
- super(socksocket, self).connect((dest_addr, dest_port))
- return
-
- proxy_addr = self._proxy_addr()
-
- try:
- # Initial connection to proxy server.
- super(socksocket, self).connect(proxy_addr)
-
- except socket.error as error:
- # Error while connecting to proxy
- self.close()
- proxy_addr, proxy_port = proxy_addr
- proxy_server = "{0}:{1}".format(proxy_addr, proxy_port)
- printable_type = PRINTABLE_PROXY_TYPES[proxy_type]
-
- msg = "Error connecting to {0} proxy {1}".format(printable_type,
- proxy_server)
- log.debug("%s due to: %s", msg, error)
- raise ProxyConnectionError(msg, error)
-
- else:
- # Connected to proxy server, now negotiate
- try:
- # Calls negotiate_{SOCKS4, SOCKS5, HTTP}
- negotiate = self._proxy_negotiators[proxy_type]
- negotiate(self, dest_addr, dest_port)
- except socket.error as error:
- # Wrap socket errors
- self.close()
- raise GeneralProxyError("Socket error", error)
- except ProxyError:
- # Protocol error while negotiating with proxy
- self.close()
- raise
-
- def _proxy_addr(self):
- """
- Return proxy address to connect to as tuple object
- """
- (proxy_type, proxy_addr, proxy_port, rdns, username,
- password) = self.proxy
- proxy_port = proxy_port or DEFAULT_PORTS.get(proxy_type)
- if not proxy_port:
- raise GeneralProxyError("Invalid proxy type")
- return proxy_addr, proxy_port
diff --git a/python/sockshandler.py b/python/sockshandler.py
deleted file mode 100644
index 26c8343..0000000
--- a/python/sockshandler.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-"""
-SocksiPy + urllib2 handler
-
-version: 0.3
-author: e<e@tr0ll.in>
-
-This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket...
-"""
-import ssl
-
-try:
- import urllib2
- import httplib
-except ImportError: # Python 3
- import urllib.request as urllib2
- import http.client as httplib
-
-import socks # $ pip install PySocks
-
-def merge_dict(a, b):
- d = a.copy()
- d.update(b)
- return d
-
-class SocksiPyConnection(httplib.HTTPConnection):
- def __init__(self, proxytype, proxyaddr, proxyport=None, rdns=True, username=None, password=None, *args, **kwargs):
- self.proxyargs = (proxytype, proxyaddr, proxyport, rdns, username, password)
- httplib.HTTPConnection.__init__(self, *args, **kwargs)
-
- def connect(self):
- self.sock = socks.socksocket()
- self.sock.setproxy(*self.proxyargs)
- if type(self.timeout) in (int, float):
- self.sock.settimeout(self.timeout)
- self.sock.connect((self.host, self.port))
-
-class SocksiPyConnectionS(httplib.HTTPSConnection):
- def __init__(self, proxytype, proxyaddr, proxyport=None, rdns=True, username=None, password=None, *args, **kwargs):
- self.proxyargs = (proxytype, proxyaddr, proxyport, rdns, username, password)
- httplib.HTTPSConnection.__init__(self, *args, **kwargs)
-
- def connect(self):
- sock = socks.socksocket()
- sock.setproxy(*self.proxyargs)
- if type(self.timeout) in (int, float):
- sock.settimeout(self.timeout)
- sock.connect((self.host, self.port))
- self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
-
-class SocksiPyHandler(urllib2.HTTPHandler, urllib2.HTTPSHandler):
- def __init__(self, *args, **kwargs):
- self.args = args
- self.kw = kwargs
- urllib2.HTTPHandler.__init__(self)
-
- def http_open(self, req):
- def build(host, port=None, timeout=0, **kwargs):
- kw = merge_dict(self.kw, kwargs)
- conn = SocksiPyConnection(*self.args, host=host, port=port, timeout=timeout, **kw)
- return conn
- return self.do_open(build, req)
-
- def https_open(self, req):
- def build(host, port=None, timeout=0, **kwargs):
- kw = merge_dict(self.kw, kwargs)
- conn = SocksiPyConnectionS(*self.args, host=host, port=port, timeout=timeout, **kw)
- return conn
- return self.do_open(build, req)
-
-if __name__ == "__main__":
- import sys
- try:
- port = int(sys.argv[1])
- except (ValueError, IndexError):
- port = 9050
- opener = urllib2.build_opener(SocksiPyHandler(socks.PROXY_TYPE_SOCKS5, "localhost", port))
- print("HTTP: " + opener.open("http://httpbin.org/ip").read().decode())
- print("HTTPS: " + opener.open("https://httpbin.org/ip").read().decode())
diff --git a/python/sqlite3.dll b/python/sqlite3.dll
deleted file mode 100644
index 184dace..0000000
--- a/python/sqlite3.dll
+++ /dev/null
Binary files differ
diff --git a/python/unicodedata.pyd b/python/unicodedata.pyd
deleted file mode 100644
index ac77470..0000000
--- a/python/unicodedata.pyd
+++ /dev/null
Binary files differ
diff --git a/python/urllib3/__init__.py b/python/urllib3/__init__.py
deleted file mode 100644
index 148a9c3..0000000
--- a/python/urllib3/__init__.py
+++ /dev/null
@@ -1,92 +0,0 @@
-"""
-urllib3 - Thread-safe connection pooling and re-using.
-"""
-
-from __future__ import absolute_import
-import warnings
-
-from .connectionpool import (
- HTTPConnectionPool,
- HTTPSConnectionPool,
- connection_from_url
-)
-
-from . import exceptions
-from .filepost import encode_multipart_formdata
-from .poolmanager import PoolManager, ProxyManager, proxy_from_url
-from .response import HTTPResponse
-from .util.request import make_headers
-from .util.url import get_host
-from .util.timeout import Timeout
-from .util.retry import Retry
-
-
-# Set default logging handler to avoid "No handler found" warnings.
-import logging
-from logging import NullHandler
-
-__author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'
-__license__ = 'MIT'
-__version__ = '1.24.1'
-
-__all__ = (
- 'HTTPConnectionPool',
- 'HTTPSConnectionPool',
- 'PoolManager',
- 'ProxyManager',
- 'HTTPResponse',
- 'Retry',
- 'Timeout',
- 'add_stderr_logger',
- 'connection_from_url',
- 'disable_warnings',
- 'encode_multipart_formdata',
- 'get_host',
- 'make_headers',
- 'proxy_from_url',
-)
-
-logging.getLogger(__name__).addHandler(NullHandler())
-
-
-def add_stderr_logger(level=logging.DEBUG):
- """
- Helper for quickly adding a StreamHandler to the logger. Useful for
- debugging.
-
- Returns the handler after adding it.
- """
- # This method needs to be in this __init__.py to get the __name__ correct
- # even if urllib3 is vendored within another package.
- logger = logging.getLogger(__name__)
- handler = logging.StreamHandler()
- handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
- logger.addHandler(handler)
- logger.setLevel(level)
- logger.debug('Added a stderr logging handler to logger: %s', __name__)
- return handler
-
-
-# ... Clean up.
-del NullHandler
-
-
-# All warning filters *must* be appended unless you're really certain that they
-# shouldn't be: otherwise, it's very hard for users to use most Python
-# mechanisms to silence them.
-# SecurityWarning's always go off by default.
-warnings.simplefilter('always', exceptions.SecurityWarning, append=True)
-# SubjectAltNameWarning's should go off once per host
-warnings.simplefilter('default', exceptions.SubjectAltNameWarning, append=True)
-# InsecurePlatformWarning's don't vary between requests, so we keep it default.
-warnings.simplefilter('default', exceptions.InsecurePlatformWarning,
- append=True)
-# SNIMissingWarnings should go off only once.
-warnings.simplefilter('default', exceptions.SNIMissingWarning, append=True)
-
-
-def disable_warnings(category=exceptions.HTTPWarning):
- """
- Helper for quickly disabling all urllib3 warnings.
- """
- warnings.simplefilter('ignore', category)
diff --git a/python/urllib3/_collections.py b/python/urllib3/_collections.py
deleted file mode 100644
index 34f2381..0000000
--- a/python/urllib3/_collections.py
+++ /dev/null
@@ -1,329 +0,0 @@
-from __future__ import absolute_import
-try:
- from collections.abc import Mapping, MutableMapping
-except ImportError:
- from collections import Mapping, MutableMapping
-try:
- from threading import RLock
-except ImportError: # Platform-specific: No threads available
- class RLock:
- def __enter__(self):
- pass
-
- def __exit__(self, exc_type, exc_value, traceback):
- pass
-
-
-from collections import OrderedDict
-from .exceptions import InvalidHeader
-from .packages.six import iterkeys, itervalues, PY3
-
-
-__all__ = ['RecentlyUsedContainer', 'HTTPHeaderDict']
-
-
-_Null = object()
-
-
-class RecentlyUsedContainer(MutableMapping):
- """
- Provides a thread-safe dict-like container which maintains up to
- ``maxsize`` keys while throwing away the least-recently-used keys beyond
- ``maxsize``.
-
- :param maxsize:
- Maximum number of recent elements to retain.
-
- :param dispose_func:
- Every time an item is evicted from the container,
- ``dispose_func(value)`` is called. Callback which will get called
- """
-
- ContainerCls = OrderedDict
-
- def __init__(self, maxsize=10, dispose_func=None):
- self._maxsize = maxsize
- self.dispose_func = dispose_func
-
- self._container = self.ContainerCls()
- self.lock = RLock()
-
- def __getitem__(self, key):
- # Re-insert the item, moving it to the end of the eviction line.
- with self.lock:
- item = self._container.pop(key)
- self._container[key] = item
- return item
-
- def __setitem__(self, key, value):
- evicted_value = _Null
- with self.lock:
- # Possibly evict the existing value of 'key'
- evicted_value = self._container.get(key, _Null)
- self._container[key] = value
-
- # If we didn't evict an existing value, we might have to evict the
- # least recently used item from the beginning of the container.
- if len(self._container) > self._maxsize:
- _key, evicted_value = self._container.popitem(last=False)
-
- if self.dispose_func and evicted_value is not _Null:
- self.dispose_func(evicted_value)
-
- def __delitem__(self, key):
- with self.lock:
- value = self._container.pop(key)
-
- if self.dispose_func:
- self.dispose_func(value)
-
- def __len__(self):
- with self.lock:
- return len(self._container)
-
- def __iter__(self):
- raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')
-
- def clear(self):
- with self.lock:
- # Copy pointers to all values, then wipe the mapping
- values = list(itervalues(self._container))
- self._container.clear()
-
- if self.dispose_func:
- for value in values:
- self.dispose_func(value)
-
- def keys(self):
- with self.lock:
- return list(iterkeys(self._container))
-
-
-class HTTPHeaderDict(MutableMapping):
- """
- :param headers:
- An iterable of field-value pairs. Must not contain multiple field names
- when compared case-insensitively.
-
- :param kwargs:
- Additional field-value pairs to pass in to ``dict.update``.
-
- A ``dict`` like container for storing HTTP Headers.
-
- Field names are stored and compared case-insensitively in compliance with
- RFC 7230. Iteration provides the first case-sensitive key seen for each
- case-insensitive pair.
-
- Using ``__setitem__`` syntax overwrites fields that compare equal
- case-insensitively in order to maintain ``dict``'s api. For fields that
- compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
- in a loop.
-
- If multiple fields that are equal case-insensitively are passed to the
- constructor or ``.update``, the behavior is undefined and some will be
- lost.
-
- >>> headers = HTTPHeaderDict()
- >>> headers.add('Set-Cookie', 'foo=bar')
- >>> headers.add('set-cookie', 'baz=quxx')
- >>> headers['content-length'] = '7'
- >>> headers['SET-cookie']
- 'foo=bar, baz=quxx'
- >>> headers['Content-Length']
- '7'
- """
-
- def __init__(self, headers=None, **kwargs):
- super(HTTPHeaderDict, self).__init__()
- self._container = OrderedDict()
- if headers is not None:
- if isinstance(headers, HTTPHeaderDict):
- self._copy_from(headers)
- else:
- self.extend(headers)
- if kwargs:
- self.extend(kwargs)
-
- def __setitem__(self, key, val):
- self._container[key.lower()] = [key, val]
- return self._container[key.lower()]
-
- def __getitem__(self, key):
- val = self._container[key.lower()]
- return ', '.join(val[1:])
-
- def __delitem__(self, key):
- del self._container[key.lower()]
-
- def __contains__(self, key):
- return key.lower() in self._container
-
- def __eq__(self, other):
- if not isinstance(other, Mapping) and not hasattr(other, 'keys'):
- return False
- if not isinstance(other, type(self)):
- other = type(self)(other)
- return (dict((k.lower(), v) for k, v in self.itermerged()) ==
- dict((k.lower(), v) for k, v in other.itermerged()))
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- if not PY3: # Python 2
- iterkeys = MutableMapping.iterkeys
- itervalues = MutableMapping.itervalues
-
- __marker = object()
-
- def __len__(self):
- return len(self._container)
-
- def __iter__(self):
- # Only provide the originally cased names
- for vals in self._container.values():
- yield vals[0]
-
- def pop(self, key, default=__marker):
- '''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
- If key is not found, d is returned if given, otherwise KeyError is raised.
- '''
- # Using the MutableMapping function directly fails due to the private marker.
- # Using ordinary dict.pop would expose the internal structures.
- # So let's reinvent the wheel.
- try:
- value = self[key]
- except KeyError:
- if default is self.__marker:
- raise
- return default
- else:
- del self[key]
- return value
-
- def discard(self, key):
- try:
- del self[key]
- except KeyError:
- pass
-
- def add(self, key, val):
- """Adds a (name, value) pair, doesn't overwrite the value if it already
- exists.
-
- >>> headers = HTTPHeaderDict(foo='bar')
- >>> headers.add('Foo', 'baz')
- >>> headers['foo']
- 'bar, baz'
- """
- key_lower = key.lower()
- new_vals = [key, val]
- # Keep the common case aka no item present as fast as possible
- vals = self._container.setdefault(key_lower, new_vals)
- if new_vals is not vals:
- vals.append(val)
-
- def extend(self, *args, **kwargs):
- """Generic import function for any type of header-like object.
- Adapted version of MutableMapping.update in order to insert items
- with self.add instead of self.__setitem__
- """
- if len(args) > 1:
- raise TypeError("extend() takes at most 1 positional "
- "arguments ({0} given)".format(len(args)))
- other = args[0] if len(args) >= 1 else ()
-
- if isinstance(other, HTTPHeaderDict):
- for key, val in other.iteritems():
- self.add(key, val)
- elif isinstance(other, Mapping):
- for key in other:
- self.add(key, other[key])
- elif hasattr(other, "keys"):
- for key in other.keys():
- self.add(key, other[key])
- else:
- for key, value in other:
- self.add(key, value)
-
- for key, value in kwargs.items():
- self.add(key, value)
-
- def getlist(self, key, default=__marker):
- """Returns a list of all the values for the named field. Returns an
- empty list if the key doesn't exist."""
- try:
- vals = self._container[key.lower()]
- except KeyError:
- if default is self.__marker:
- return []
- return default
- else:
- return vals[1:]
-
- # Backwards compatibility for httplib
- getheaders = getlist
- getallmatchingheaders = getlist
- iget = getlist
-
- # Backwards compatibility for http.cookiejar
- get_all = getlist
-
- def __repr__(self):
- return "%s(%s)" % (type(self).__name__, dict(self.itermerged()))
-
- def _copy_from(self, other):
- for key in other:
- val = other.getlist(key)
- if isinstance(val, list):
- # Don't need to convert tuples
- val = list(val)
- self._container[key.lower()] = [key] + val
-
- def copy(self):
- clone = type(self)()
- clone._copy_from(self)
- return clone
-
- def iteritems(self):
- """Iterate over all header lines, including duplicate ones."""
- for key in self:
- vals = self._container[key.lower()]
- for val in vals[1:]:
- yield vals[0], val
-
- def itermerged(self):
- """Iterate over all headers, merging duplicate ones together."""
- for key in self:
- val = self._container[key.lower()]
- yield val[0], ', '.join(val[1:])
-
- def items(self):
- return list(self.iteritems())
-
- @classmethod
- def from_httplib(cls, message): # Python 2
- """Read headers from a Python 2 httplib message object."""
- # python2.7 does not expose a proper API for exporting multiheaders
- # efficiently. This function re-reads raw lines from the message
- # object and extracts the multiheaders properly.
- obs_fold_continued_leaders = (' ', '\t')
- headers = []
-
- for line in message.headers:
- if line.startswith(obs_fold_continued_leaders):
- if not headers:
- # We received a header line that starts with OWS as described
- # in RFC-7230 S3.2.4. This indicates a multiline header, but
- # there exists no previous header to which we can attach it.
- raise InvalidHeader(
- 'Header continuation with no previous header: %s' % line
- )
- else:
- key, value = headers[-1]
- headers[-1] = (key, value + ' ' + line.strip())
- continue
-
- key, value = line.split(':', 1)
- headers.append((key, value.strip()))
-
- return cls(headers)
diff --git a/python/urllib3/connection.py b/python/urllib3/connection.py
deleted file mode 100644
index 02b3665..0000000
--- a/python/urllib3/connection.py
+++ /dev/null
@@ -1,391 +0,0 @@
-from __future__ import absolute_import
-import datetime
-import logging
-import os
-import socket
-from socket import error as SocketError, timeout as SocketTimeout
-import warnings
-from .packages import six
-from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection
-from .packages.six.moves.http_client import HTTPException # noqa: F401
-
-try: # Compiled with SSL?
- import ssl
- BaseSSLError = ssl.SSLError
-except (ImportError, AttributeError): # Platform-specific: No SSL.
- ssl = None
-
- class BaseSSLError(BaseException):
- pass
-
-
-try: # Python 3:
- # Not a no-op, we're adding this to the namespace so it can be imported.
- ConnectionError = ConnectionError
-except NameError: # Python 2:
- class ConnectionError(Exception):
- pass
-
-
-from .exceptions import (
- NewConnectionError,
- ConnectTimeoutError,
- SubjectAltNameWarning,
- SystemTimeWarning,
-)
-from .packages.ssl_match_hostname import match_hostname, CertificateError
-
-from .util.ssl_ import (
- resolve_cert_reqs,
- resolve_ssl_version,
- assert_fingerprint,
- create_urllib3_context,
- ssl_wrap_socket
-)
-
-
-from .util import connection
-
-from ._collections import HTTPHeaderDict
-
-log = logging.getLogger(__name__)
-
-port_by_scheme = {
- 'http': 80,
- 'https': 443,
-}
-
-# When updating RECENT_DATE, move it to within two years of the current date,
-# and not less than 6 months ago.
-# Example: if Today is 2018-01-01, then RECENT_DATE should be any date on or
-# after 2016-01-01 (today - 2 years) AND before 2017-07-01 (today - 6 months)
-RECENT_DATE = datetime.date(2017, 6, 30)
-
-
-class DummyConnection(object):
- """Used to detect a failed ConnectionCls import."""
- pass
-
-
-class HTTPConnection(_HTTPConnection, object):
- """
- Based on httplib.HTTPConnection but provides an extra constructor
- backwards-compatibility layer between older and newer Pythons.
-
- Additional keyword parameters are used to configure attributes of the connection.
- Accepted parameters include:
-
- - ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
- - ``source_address``: Set the source address for the current connection.
- - ``socket_options``: Set specific options on the underlying socket. If not specified, then
- defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
- Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
-
- For example, if you wish to enable TCP Keep Alive in addition to the defaults,
- you might pass::
-
- HTTPConnection.default_socket_options + [
- (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
- ]
-
- Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
- """
-
- default_port = port_by_scheme['http']
-
- #: Disable Nagle's algorithm by default.
- #: ``[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]``
- default_socket_options = [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]
-
- #: Whether this connection verifies the host's certificate.
- is_verified = False
-
- def __init__(self, *args, **kw):
- if six.PY3: # Python 3
- kw.pop('strict', None)
-
- # Pre-set source_address.
- self.source_address = kw.get('source_address')
-
- #: The socket options provided by the user. If no options are
- #: provided, we use the default options.
- self.socket_options = kw.pop('socket_options', self.default_socket_options)
-
- _HTTPConnection.__init__(self, *args, **kw)
-
- @property
- def host(self):
- """
- Getter method to remove any trailing dots that indicate the hostname is an FQDN.
-
- In general, SSL certificates don't include the trailing dot indicating a
- fully-qualified domain name, and thus, they don't validate properly when
- checked against a domain name that includes the dot. In addition, some
- servers may not expect to receive the trailing dot when provided.
-
- However, the hostname with trailing dot is critical to DNS resolution; doing a
- lookup with the trailing dot will properly only resolve the appropriate FQDN,
- whereas a lookup without a trailing dot will search the system's search domain
- list. Thus, it's important to keep the original host around for use only in
- those cases where it's appropriate (i.e., when doing DNS lookup to establish the
- actual TCP connection across which we're going to send HTTP requests).
- """
- return self._dns_host.rstrip('.')
-
- @host.setter
- def host(self, value):
- """
- Setter for the `host` property.
-
- We assume that only urllib3 uses the _dns_host attribute; httplib itself
- only uses `host`, and it seems reasonable that other libraries follow suit.
- """
- self._dns_host = value
-
- def _new_conn(self):
- """ Establish a socket connection and set nodelay settings on it.
-
- :return: New socket connection.
- """
- extra_kw = {}
- if self.source_address:
- extra_kw['source_address'] = self.source_address
-
- if self.socket_options:
- extra_kw['socket_options'] = self.socket_options
-
- try:
- conn = connection.create_connection(
- (self._dns_host, self.port), self.timeout, **extra_kw)
-
- except SocketTimeout as e:
- raise ConnectTimeoutError(
- self, "Connection to %s timed out. (connect timeout=%s)" %
- (self.host, self.timeout))
-
- except SocketError as e:
- raise NewConnectionError(
- self, "Failed to establish a new connection: %s" % e)
-
- return conn
-
- def _prepare_conn(self, conn):
- self.sock = conn
- if self._tunnel_host:
- # TODO: Fix tunnel so it doesn't depend on self.sock state.
- self._tunnel()
- # Mark this connection as not reusable
- self.auto_open = 0
-
- def connect(self):
- conn = self._new_conn()
- self._prepare_conn(conn)
-
- def request_chunked(self, method, url, body=None, headers=None):
- """
- Alternative to the common request method, which sends the
- body with chunked encoding and not as one block
- """
- headers = HTTPHeaderDict(headers if headers is not None else {})
- skip_accept_encoding = 'accept-encoding' in headers
- skip_host = 'host' in headers
- self.putrequest(
- method,
- url,
- skip_accept_encoding=skip_accept_encoding,
- skip_host=skip_host
- )
- for header, value in headers.items():
- self.putheader(header, value)
- if 'transfer-encoding' not in headers:
- self.putheader('Transfer-Encoding', 'chunked')
- self.endheaders()
-
- if body is not None:
- stringish_types = six.string_types + (bytes,)
- if isinstance(body, stringish_types):
- body = (body,)
- for chunk in body:
- if not chunk:
- continue
- if not isinstance(chunk, bytes):
- chunk = chunk.encode('utf8')
- len_str = hex(len(chunk))[2:]
- self.send(len_str.encode('utf-8'))
- self.send(b'\r\n')
- self.send(chunk)
- self.send(b'\r\n')
-
- # After the if clause, to always have a closed body
- self.send(b'0\r\n\r\n')
-
-
-class HTTPSConnection(HTTPConnection):
- default_port = port_by_scheme['https']
-
- ssl_version = None
-
- def __init__(self, host, port=None, key_file=None, cert_file=None,
- strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
- ssl_context=None, server_hostname=None, **kw):
-
- HTTPConnection.__init__(self, host, port, strict=strict,
- timeout=timeout, **kw)
-
- self.key_file = key_file
- self.cert_file = cert_file
- self.ssl_context = ssl_context
- self.server_hostname = server_hostname
-
- # Required property for Google AppEngine 1.9.0 which otherwise causes
- # HTTPS requests to go out as HTTP. (See Issue #356)
- self._protocol = 'https'
-
- def connect(self):
- conn = self._new_conn()
- self._prepare_conn(conn)
-
- if self.ssl_context is None:
- self.ssl_context = create_urllib3_context(
- ssl_version=resolve_ssl_version(None),
- cert_reqs=resolve_cert_reqs(None),
- )
-
- self.sock = ssl_wrap_socket(
- sock=conn,
- keyfile=self.key_file,
- certfile=self.cert_file,
- ssl_context=self.ssl_context,
- server_hostname=self.server_hostname
- )
-
-
-class VerifiedHTTPSConnection(HTTPSConnection):
- """
- Based on httplib.HTTPSConnection but wraps the socket with
- SSL certification.
- """
- cert_reqs = None
- ca_certs = None
- ca_cert_dir = None
- ssl_version = None
- assert_fingerprint = None
-
- def set_cert(self, key_file=None, cert_file=None,
- cert_reqs=None, ca_certs=None,
- assert_hostname=None, assert_fingerprint=None,
- ca_cert_dir=None):
- """
- This method should only be called once, before the connection is used.
- """
- # If cert_reqs is not provided, we can try to guess. If the user gave
- # us a cert database, we assume they want to use it: otherwise, if
- # they gave us an SSL Context object we should use whatever is set for
- # it.
- if cert_reqs is None:
- if ca_certs or ca_cert_dir:
- cert_reqs = 'CERT_REQUIRED'
- elif self.ssl_context is not None:
- cert_reqs = self.ssl_context.verify_mode
-
- self.key_file = key_file
- self.cert_file = cert_file
- self.cert_reqs = cert_reqs
- self.assert_hostname = assert_hostname
- self.assert_fingerprint = assert_fingerprint
- self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
- self.ca_cert_dir = ca_cert_dir and os.path.expanduser(ca_cert_dir)
-
- def connect(self):
- # Add certificate verification
- conn = self._new_conn()
- hostname = self.host
-
- if self._tunnel_host:
- self.sock = conn
- # Calls self._set_hostport(), so self.host is
- # self._tunnel_host below.
- self._tunnel()
- # Mark this connection as not reusable
- self.auto_open = 0
-
- # Override the host with the one we're requesting data from.
- hostname = self._tunnel_host
-
- server_hostname = hostname
- if self.server_hostname is not None:
- server_hostname = self.server_hostname
-
- is_time_off = datetime.date.today() < RECENT_DATE
- if is_time_off:
- warnings.warn((
- 'System time is way off (before {0}). This will probably '
- 'lead to SSL verification errors').format(RECENT_DATE),
- SystemTimeWarning
- )
-
- # Wrap socket using verification with the root certs in
- # trusted_root_certs
- if self.ssl_context is None:
- self.ssl_context = create_urllib3_context(
- ssl_version=resolve_ssl_version(self.ssl_version),
- cert_reqs=resolve_cert_reqs(self.cert_reqs),
- )
-
- context = self.ssl_context
- context.verify_mode = resolve_cert_reqs(self.cert_reqs)
- self.sock = ssl_wrap_socket(
- sock=conn,
- keyfile=self.key_file,
- certfile=self.cert_file,
- ca_certs=self.ca_certs,
- ca_cert_dir=self.ca_cert_dir,
- server_hostname=server_hostname,
- ssl_context=context)
-
- if self.assert_fingerprint:
- assert_fingerprint(self.sock.getpeercert(binary_form=True),
- self.assert_fingerprint)
- elif context.verify_mode != ssl.CERT_NONE \
- and not getattr(context, 'check_hostname', False) \
- and self.assert_hostname is not False:
- # While urllib3 attempts to always turn off hostname matching from
- # the TLS library, this cannot always be done. So we check whether
- # the TLS Library still thinks it's matching hostnames.
- cert = self.sock.getpeercert()
- if not cert.get('subjectAltName', ()):
- warnings.warn((
- 'Certificate for {0} has no `subjectAltName`, falling back to check for a '
- '`commonName` for now. This feature is being removed by major browsers and '
- 'deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 '
- 'for details.)'.format(hostname)),
- SubjectAltNameWarning
- )
- _match_hostname(cert, self.assert_hostname or server_hostname)
-
- self.is_verified = (
- context.verify_mode == ssl.CERT_REQUIRED or
- self.assert_fingerprint is not None
- )
-
-
-def _match_hostname(cert, asserted_hostname):
- try:
- match_hostname(cert, asserted_hostname)
- except CertificateError as e:
- log.error(
- 'Certificate did not match expected hostname: %s. '
- 'Certificate: %s', asserted_hostname, cert
- )
- # Add cert to exception and reraise so client code can inspect
- # the cert when catching the exception, if they want to
- e._peer_cert = cert
- raise
-
-
-if ssl:
- # Make a copy for testing.
- UnverifiedHTTPSConnection = HTTPSConnection
- HTTPSConnection = VerifiedHTTPSConnection
-else:
- HTTPSConnection = DummyConnection
diff --git a/python/urllib3/connectionpool.py b/python/urllib3/connectionpool.py
deleted file mode 100644
index f7a8f19..0000000
--- a/python/urllib3/connectionpool.py
+++ /dev/null
@@ -1,896 +0,0 @@
-from __future__ import absolute_import
-import errno
-import logging
-import sys
-import warnings
-
-from socket import error as SocketError, timeout as SocketTimeout
-import socket
-
-
-from .exceptions import (
- ClosedPoolError,
- ProtocolError,
- EmptyPoolError,
- HeaderParsingError,
- HostChangedError,
- LocationValueError,
- MaxRetryError,
- ProxyError,
- ReadTimeoutError,
- SSLError,
- TimeoutError,
- InsecureRequestWarning,
- NewConnectionError,
-)
-from .packages.ssl_match_hostname import CertificateError
-from .packages import six
-from .packages.six.moves import queue
-from .connection import (
- port_by_scheme,
- DummyConnection,
- HTTPConnection, HTTPSConnection, VerifiedHTTPSConnection,
- HTTPException, BaseSSLError,
-)
-from .request import RequestMethods
-from .response import HTTPResponse
-
-from .util.connection import is_connection_dropped
-from .util.request import set_file_position
-from .util.response import assert_header_parsing
-from .util.retry import Retry
-from .util.timeout import Timeout
-from .util.url import get_host, Url, NORMALIZABLE_SCHEMES
-from .util.queue import LifoQueue
-
-
-xrange = six.moves.xrange
-
-log = logging.getLogger(__name__)
-
-_Default = object()
-
-
-# Pool objects
-class ConnectionPool(object):
- """
- Base class for all connection pools, such as
- :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
- """
-
- scheme = None
- QueueCls = LifoQueue
-
- def __init__(self, host, port=None):
- if not host:
- raise LocationValueError("No host specified.")
-
- self.host = _ipv6_host(host, self.scheme)
- self._proxy_host = host.lower()
- self.port = port
-
- def __str__(self):
- return '%s(host=%r, port=%r)' % (type(self).__name__,
- self.host, self.port)
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- self.close()
- # Return False to re-raise any potential exceptions
- return False
-
- def close(self):
- """
- Close all pooled connections and disable the pool.
- """
- pass
-
-
-# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l252
-_blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
-
-
-class HTTPConnectionPool(ConnectionPool, RequestMethods):
- """
- Thread-safe connection pool for one host.
-
- :param host:
- Host used for this HTTP Connection (e.g. "localhost"), passed into
- :class:`httplib.HTTPConnection`.
-
- :param port:
- Port used for this HTTP Connection (None is equivalent to 80), passed
- into :class:`httplib.HTTPConnection`.
-
- :param strict:
- Causes BadStatusLine to be raised if the status line can't be parsed
- as a valid HTTP/1.0 or 1.1 status line, passed into
- :class:`httplib.HTTPConnection`.
-
- .. note::
- Only works in Python 2. This parameter is ignored in Python 3.
-
- :param timeout:
- Socket timeout in seconds for each individual connection. This can
- be a float or integer, which sets the timeout for the HTTP request,
- or an instance of :class:`urllib3.util.Timeout` which gives you more
- fine-grained control over request timeouts. After the constructor has
- been parsed, this is always a `urllib3.util.Timeout` object.
-
- :param maxsize:
- Number of connections to save that can be reused. More than 1 is useful
- in multithreaded situations. If ``block`` is set to False, more
- connections will be created but they will not be saved once they've
- been used.
-
- :param block:
- If set to True, no more than ``maxsize`` connections will be used at
- a time. When no free connections are available, the call will block
- until a connection has been released. This is a useful side effect for
- particular multithreaded situations where one does not want to use more
- than maxsize connections per host to prevent flooding.
-
- :param headers:
- Headers to include with all requests, unless other headers are given
- explicitly.
-
- :param retries:
- Retry configuration to use by default with requests in this pool.
-
- :param _proxy:
- Parsed proxy URL, should not be used directly, instead, see
- :class:`urllib3.connectionpool.ProxyManager`"
-
- :param _proxy_headers:
- A dictionary with proxy headers, should not be used directly,
- instead, see :class:`urllib3.connectionpool.ProxyManager`"
-
- :param \\**conn_kw:
- Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
- :class:`urllib3.connection.HTTPSConnection` instances.
- """
-
- scheme = 'http'
- ConnectionCls = HTTPConnection
- ResponseCls = HTTPResponse
-
- def __init__(self, host, port=None, strict=False,
- timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1, block=False,
- headers=None, retries=None,
- _proxy=None, _proxy_headers=None,
- **conn_kw):
- ConnectionPool.__init__(self, host, port)
- RequestMethods.__init__(self, headers)
-
- self.strict = strict
-
- if not isinstance(timeout, Timeout):
- timeout = Timeout.from_float(timeout)
-
- if retries is None:
- retries = Retry.DEFAULT
-
- self.timeout = timeout
- self.retries = retries
-
- self.pool = self.QueueCls(maxsize)
- self.block = block
-
- self.proxy = _proxy
- self.proxy_headers = _proxy_headers or {}
-
- # Fill the queue up so that doing get() on it will block properly
- for _ in xrange(maxsize):
- self.pool.put(None)
-
- # These are mostly for testing and debugging purposes.
- self.num_connections = 0
- self.num_requests = 0
- self.conn_kw = conn_kw
-
- if self.proxy:
- # Enable Nagle's algorithm for proxies, to avoid packet fragmentation.
- # We cannot know if the user has added default socket options, so we cannot replace the
- # list.
- self.conn_kw.setdefault('socket_options', [])
-
- def _new_conn(self):
- """
- Return a fresh :class:`HTTPConnection`.
- """
- self.num_connections += 1
- log.debug("Starting new HTTP connection (%d): %s:%s",
- self.num_connections, self.host, self.port or "80")
-
- conn = self.ConnectionCls(host=self.host, port=self.port,
- timeout=self.timeout.connect_timeout,
- strict=self.strict, **self.conn_kw)
- return conn
-
- def _get_conn(self, timeout=None):
- """
- Get a connection. Will return a pooled connection if one is available.
-
- If no connections are available and :prop:`.block` is ``False``, then a
- fresh connection is returned.
-
- :param timeout:
- Seconds to wait before giving up and raising
- :class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
- :prop:`.block` is ``True``.
- """
- conn = None
- try:
- conn = self.pool.get(block=self.block, timeout=timeout)
-
- except AttributeError: # self.pool is None
- raise ClosedPoolError(self, "Pool is closed.")
-
- except queue.Empty:
- if self.block:
- raise EmptyPoolError(self,
- "Pool reached maximum size and no more "
- "connections are allowed.")
- pass # Oh well, we'll create a new connection then
-
- # If this is a persistent connection, check if it got disconnected
- if conn and is_connection_dropped(conn):
- log.debug("Resetting dropped connection: %s", self.host)
- conn.close()
- if getattr(conn, 'auto_open', 1) == 0:
- # This is a proxied connection that has been mutated by
- # httplib._tunnel() and cannot be reused (since it would
- # attempt to bypass the proxy)
- conn = None
-
- return conn or self._new_conn()
-
- def _put_conn(self, conn):
- """
- Put a connection back into the pool.
-
- :param conn:
- Connection object for the current host and port as returned by
- :meth:`._new_conn` or :meth:`._get_conn`.
-
- If the pool is already full, the connection is closed and discarded
- because we exceeded maxsize. If connections are discarded frequently,
- then maxsize should be increased.
-
- If the pool is closed, then the connection will be closed and discarded.
- """
- try:
- self.pool.put(conn, block=False)
- return # Everything is dandy, done.
- except AttributeError:
- # self.pool is None.
- pass
- except queue.Full:
- # This should never happen if self.block == True
- log.warning(
- "Connection pool is full, discarding connection: %s",
- self.host)
-
- # Connection never got put back into the pool, close it.
- if conn:
- conn.close()
-
- def _validate_conn(self, conn):
- """
- Called right before a request is made, after the socket is created.
- """
- pass
-
- def _prepare_proxy(self, conn):
- # Nothing to do for HTTP connections.
- pass
-
- def _get_timeout(self, timeout):
- """ Helper that always returns a :class:`urllib3.util.Timeout` """
- if timeout is _Default:
- return self.timeout.clone()
-
- if isinstance(timeout, Timeout):
- return timeout.clone()
- else:
- # User passed us an int/float. This is for backwards compatibility,
- # can be removed later
- return Timeout.from_float(timeout)
-
- def _raise_timeout(self, err, url, timeout_value):
- """Is the error actually a timeout? Will raise a ReadTimeout or pass"""
-
- if isinstance(err, SocketTimeout):
- raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
-
- # See the above comment about EAGAIN in Python 3. In Python 2 we have
- # to specifically catch it and throw the timeout error
- if hasattr(err, 'errno') and err.errno in _blocking_errnos:
- raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
-
- # Catch possible read timeouts thrown as SSL errors. If not the
- # case, rethrow the original. We need to do this because of:
- # http://bugs.python.org/issue10272
- if 'timed out' in str(err) or 'did not complete (read)' in str(err): # Python < 2.7.4
- raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
-
- def _make_request(self, conn, method, url, timeout=_Default, chunked=False,
- **httplib_request_kw):
- """
- Perform a request on a given urllib connection object taken from our
- pool.
-
- :param conn:
- a connection from one of our connection pools
-
- :param timeout:
- Socket timeout in seconds for the request. This can be a
- float or integer, which will set the same timeout value for
- the socket connect and the socket read, or an instance of
- :class:`urllib3.util.Timeout`, which gives you more fine-grained
- control over your timeouts.
- """
- self.num_requests += 1
-
- timeout_obj = self._get_timeout(timeout)
- timeout_obj.start_connect()
- conn.timeout = timeout_obj.connect_timeout
-
- # Trigger any extra validation we need to do.
- try:
- self._validate_conn(conn)
- except (SocketTimeout, BaseSSLError) as e:
- # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
- self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
- raise
-
- # conn.request() calls httplib.*.request, not the method in
- # urllib3.request. It also calls makefile (recv) on the socket.
- if chunked:
- conn.request_chunked(method, url, **httplib_request_kw)
- else:
- conn.request(method, url, **httplib_request_kw)
-
- # Reset the timeout for the recv() on the socket
- read_timeout = timeout_obj.read_timeout
-
- # App Engine doesn't have a sock attr
- if getattr(conn, 'sock', None):
- # In Python 3 socket.py will catch EAGAIN and return None when you
- # try and read into the file pointer created by http.client, which
- # instead raises a BadStatusLine exception. Instead of catching
- # the exception and assuming all BadStatusLine exceptions are read
- # timeouts, check for a zero timeout before making the request.
- if read_timeout == 0:
- raise ReadTimeoutError(
- self, url, "Read timed out. (read timeout=%s)" % read_timeout)
- if read_timeout is Timeout.DEFAULT_TIMEOUT:
- conn.sock.settimeout(socket.getdefaulttimeout())
- else: # None or a value
- conn.sock.settimeout(read_timeout)
-
- # Receive the response from the server
- try:
- try: # Python 2.7, use buffering of HTTP responses
- httplib_response = conn.getresponse(buffering=True)
- except TypeError: # Python 3
- try:
- httplib_response = conn.getresponse()
- except Exception as e:
- # Remove the TypeError from the exception chain in Python 3;
- # otherwise it looks like a programming error was the cause.
- six.raise_from(e, None)
- except (SocketTimeout, BaseSSLError, SocketError) as e:
- self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
- raise
-
- # AppEngine doesn't have a version attr.
- http_version = getattr(conn, '_http_vsn_str', 'HTTP/?')
- log.debug("%s://%s:%s \"%s %s %s\" %s %s", self.scheme, self.host, self.port,
- method, url, http_version, httplib_response.status,
- httplib_response.length)
-
- try:
- assert_header_parsing(httplib_response.msg)
- except (HeaderParsingError, TypeError) as hpe: # Platform-specific: Python 3
- log.warning(
- 'Failed to parse headers (url=%s): %s',
- self._absolute_url(url), hpe, exc_info=True)
-
- return httplib_response
-
- def _absolute_url(self, path):
- return Url(scheme=self.scheme, host=self.host, port=self.port, path=path).url
-
- def close(self):
- """
- Close all pooled connections and disable the pool.
- """
- if self.pool is None:
- return
- # Disable access to the pool
- old_pool, self.pool = self.pool, None
-
- try:
- while True:
- conn = old_pool.get(block=False)
- if conn:
- conn.close()
-
- except queue.Empty:
- pass # Done.
-
- def is_same_host(self, url):
- """
- Check if the given ``url`` is a member of the same host as this
- connection pool.
- """
- if url.startswith('/'):
- return True
-
- # TODO: Add optional support for socket.gethostbyname checking.
- scheme, host, port = get_host(url)
-
- host = _ipv6_host(host, self.scheme)
-
- # Use explicit default port for comparison when none is given
- if self.port and not port:
- port = port_by_scheme.get(scheme)
- elif not self.port and port == port_by_scheme.get(scheme):
- port = None
-
- return (scheme, host, port) == (self.scheme, self.host, self.port)
-
- def urlopen(self, method, url, body=None, headers=None, retries=None,
- redirect=True, assert_same_host=True, timeout=_Default,
- pool_timeout=None, release_conn=None, chunked=False,
- body_pos=None, **response_kw):
- """
- Get a connection from the pool and perform an HTTP request. This is the
- lowest level call for making a request, so you'll need to specify all
- the raw details.
-
- .. note::
-
- More commonly, it's appropriate to use a convenience method provided
- by :class:`.RequestMethods`, such as :meth:`request`.
-
- .. note::
-
- `release_conn` will only behave as expected if
- `preload_content=False` because we want to make
- `preload_content=False` the default behaviour someday soon without
- breaking backwards compatibility.
-
- :param method:
- HTTP request method (such as GET, POST, PUT, etc.)
-
- :param body:
- Data to send in the request body (useful for creating
- POST requests, see HTTPConnectionPool.post_url for
- more convenience).
-
- :param headers:
- Dictionary of custom headers to send, such as User-Agent,
- If-None-Match, etc. If None, pool headers are used. If provided,
- these headers completely replace any pool-specific headers.
-
- :param retries:
- Configure the number of retries to allow before raising a
- :class:`~urllib3.exceptions.MaxRetryError` exception.
-
- Pass ``None`` to retry until you receive a response. Pass a
- :class:`~urllib3.util.retry.Retry` object for fine-grained control
- over different types of retries.
- Pass an integer number to retry connection errors that many times,
- but no other types of errors. Pass zero to never retry.
-
- If ``False``, then retries are disabled and any exception is raised
- immediately. Also, instead of raising a MaxRetryError on redirects,
- the redirect response will be returned.
-
- :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
-
- :param redirect:
- If True, automatically handle redirects (status codes 301, 302,
- 303, 307, 308). Each redirect counts as a retry. Disabling retries
- will disable redirect, too.
-
- :param assert_same_host:
- If ``True``, will make sure that the host of the pool requests is
- consistent else will raise HostChangedError. When False, you can
- use the pool on an HTTP proxy and request foreign hosts.
-
- :param timeout:
- If specified, overrides the default timeout for this one
- request. It may be a float (in seconds) or an instance of
- :class:`urllib3.util.Timeout`.
-
- :param pool_timeout:
- If set and the pool is set to block=True, then this method will
- block for ``pool_timeout`` seconds and raise EmptyPoolError if no
- connection is available within the time period.
-
- :param release_conn:
- If False, then the urlopen call will not release the connection
- back into the pool once a response is received (but will release if
- you read the entire contents of the response such as when
- `preload_content=True`). This is useful if you're not preloading
- the response's content immediately. You will need to call
- ``r.release_conn()`` on the response ``r`` to return the connection
- back into the pool. If None, it takes the value of
- ``response_kw.get('preload_content', True)``.
-
- :param chunked:
- If True, urllib3 will send the body using chunked transfer
- encoding. Otherwise, urllib3 will send the body using the standard
- content-length form. Defaults to False.
-
- :param int body_pos:
- Position to seek to in file-like body in the event of a retry or
- redirect. Typically this won't need to be set because urllib3 will
- auto-populate the value when needed.
-
- :param \\**response_kw:
- Additional parameters are passed to
- :meth:`urllib3.response.HTTPResponse.from_httplib`
- """
- if headers is None:
- headers = self.headers
-
- if not isinstance(retries, Retry):
- retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
-
- if release_conn is None:
- release_conn = response_kw.get('preload_content', True)
-
- # Check host
- if assert_same_host and not self.is_same_host(url):
- raise HostChangedError(self, url, retries)
-
- conn = None
-
- # Track whether `conn` needs to be released before
- # returning/raising/recursing. Update this variable if necessary, and
- # leave `release_conn` constant throughout the function. That way, if
- # the function recurses, the original value of `release_conn` will be
- # passed down into the recursive call, and its value will be respected.
- #
- # See issue #651 [1] for details.
- #
- # [1] <https://github.com/shazow/urllib3/issues/651>
- release_this_conn = release_conn
-
- # Merge the proxy headers. Only do this in HTTP. We have to copy the
- # headers dict so we can safely change it without those changes being
- # reflected in anyone else's copy.
- if self.scheme == 'http':
- headers = headers.copy()
- headers.update(self.proxy_headers)
-
- # Must keep the exception bound to a separate variable or else Python 3
- # complains about UnboundLocalError.
- err = None
-
- # Keep track of whether we cleanly exited the except block. This
- # ensures we do proper cleanup in finally.
- clean_exit = False
-
- # Rewind body position, if needed. Record current position
- # for future rewinds in the event of a redirect/retry.
- body_pos = set_file_position(body, body_pos)
-
- try:
- # Request a connection from the queue.
- timeout_obj = self._get_timeout(timeout)
- conn = self._get_conn(timeout=pool_timeout)
-
- conn.timeout = timeout_obj.connect_timeout
-
- is_new_proxy_conn = self.proxy is not None and not getattr(conn, 'sock', None)
- if is_new_proxy_conn:
- self._prepare_proxy(conn)
-
- # Make the request on the httplib connection object.
- httplib_response = self._make_request(conn, method, url,
- timeout=timeout_obj,
- body=body, headers=headers,
- chunked=chunked)
-
- # If we're going to release the connection in ``finally:``, then
- # the response doesn't need to know about the connection. Otherwise
- # it will also try to release it and we'll have a double-release
- # mess.
- response_conn = conn if not release_conn else None
-
- # Pass method to Response for length checking
- response_kw['request_method'] = method
-
- # Import httplib's response into our own wrapper object
- response = self.ResponseCls.from_httplib(httplib_response,
- pool=self,
- connection=response_conn,
- retries=retries,
- **response_kw)
-
- # Everything went great!
- clean_exit = True
-
- except queue.Empty:
- # Timed out by queue.
- raise EmptyPoolError(self, "No pool connections are available.")
-
- except (TimeoutError, HTTPException, SocketError, ProtocolError,
- BaseSSLError, SSLError, CertificateError) as e:
- # Discard the connection for these exceptions. It will be
- # replaced during the next _get_conn() call.
- clean_exit = False
- if isinstance(e, (BaseSSLError, CertificateError)):
- e = SSLError(e)
- elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
- e = ProxyError('Cannot connect to proxy.', e)
- elif isinstance(e, (SocketError, HTTPException)):
- e = ProtocolError('Connection aborted.', e)
-
- retries = retries.increment(method, url, error=e, _pool=self,
- _stacktrace=sys.exc_info()[2])
- retries.sleep()
-
- # Keep track of the error for the retry warning.
- err = e
-
- finally:
- if not clean_exit:
- # We hit some kind of exception, handled or otherwise. We need
- # to throw the connection away unless explicitly told not to.
- # Close the connection, set the variable to None, and make sure
- # we put the None back in the pool to avoid leaking it.
- conn = conn and conn.close()
- release_this_conn = True
-
- if release_this_conn:
- # Put the connection back to be reused. If the connection is
- # expired then it will be None, which will get replaced with a
- # fresh connection during _get_conn.
- self._put_conn(conn)
-
- if not conn:
- # Try again
- log.warning("Retrying (%r) after connection "
- "broken by '%r': %s", retries, err, url)
- return self.urlopen(method, url, body, headers, retries,
- redirect, assert_same_host,
- timeout=timeout, pool_timeout=pool_timeout,
- release_conn=release_conn, body_pos=body_pos,
- **response_kw)
-
- def drain_and_release_conn(response):
- try:
- # discard any remaining response body, the connection will be
- # released back to the pool once the entire response is read
- response.read()
- except (TimeoutError, HTTPException, SocketError, ProtocolError,
- BaseSSLError, SSLError) as e:
- pass
-
- # Handle redirect?
- redirect_location = redirect and response.get_redirect_location()
- if redirect_location:
- if response.status == 303:
- method = 'GET'
-
- try:
- retries = retries.increment(method, url, response=response, _pool=self)
- except MaxRetryError:
- if retries.raise_on_redirect:
- # Drain and release the connection for this response, since
- # we're not returning it to be released manually.
- drain_and_release_conn(response)
- raise
- return response
-
- # drain and return the connection to the pool before recursing
- drain_and_release_conn(response)
-
- retries.sleep_for_retry(response)
- log.debug("Redirecting %s -> %s", url, redirect_location)
- return self.urlopen(
- method, redirect_location, body, headers,
- retries=retries, redirect=redirect,
- assert_same_host=assert_same_host,
- timeout=timeout, pool_timeout=pool_timeout,
- release_conn=release_conn, body_pos=body_pos,
- **response_kw)
-
- # Check if we should retry the HTTP response.
- has_retry_after = bool(response.getheader('Retry-After'))
- if retries.is_retry(method, response.status, has_retry_after):
- try:
- retries = retries.increment(method, url, response=response, _pool=self)
- except MaxRetryError:
- if retries.raise_on_status:
- # Drain and release the connection for this response, since
- # we're not returning it to be released manually.
- drain_and_release_conn(response)
- raise
- return response
-
- # drain and return the connection to the pool before recursing
- drain_and_release_conn(response)
-
- retries.sleep(response)
- log.debug("Retry: %s", url)
- return self.urlopen(
- method, url, body, headers,
- retries=retries, redirect=redirect,
- assert_same_host=assert_same_host,
- timeout=timeout, pool_timeout=pool_timeout,
- release_conn=release_conn,
- body_pos=body_pos, **response_kw)
-
- return response
-
-
-class HTTPSConnectionPool(HTTPConnectionPool):
- """
- Same as :class:`.HTTPConnectionPool`, but HTTPS.
-
- When Python is compiled with the :mod:`ssl` module, then
- :class:`.VerifiedHTTPSConnection` is used, which *can* verify certificates,
- instead of :class:`.HTTPSConnection`.
-
- :class:`.VerifiedHTTPSConnection` uses one of ``assert_fingerprint``,
- ``assert_hostname`` and ``host`` in this order to verify connections.
- If ``assert_hostname`` is False, no verification is done.
-
- The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``,
- ``ca_cert_dir``, and ``ssl_version`` are only used if :mod:`ssl` is
- available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade
- the connection socket into an SSL socket.
- """
-
- scheme = 'https'
- ConnectionCls = HTTPSConnection
-
- def __init__(self, host, port=None,
- strict=False, timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1,
- block=False, headers=None, retries=None,
- _proxy=None, _proxy_headers=None,
- key_file=None, cert_file=None, cert_reqs=None,
- ca_certs=None, ssl_version=None,
- assert_hostname=None, assert_fingerprint=None,
- ca_cert_dir=None, **conn_kw):
-
- HTTPConnectionPool.__init__(self, host, port, strict, timeout, maxsize,
- block, headers, retries, _proxy, _proxy_headers,
- **conn_kw)
-
- if ca_certs and cert_reqs is None:
- cert_reqs = 'CERT_REQUIRED'
-
- self.key_file = key_file
- self.cert_file = cert_file
- self.cert_reqs = cert_reqs
- self.ca_certs = ca_certs
- self.ca_cert_dir = ca_cert_dir
- self.ssl_version = ssl_version
- self.assert_hostname = assert_hostname
- self.assert_fingerprint = assert_fingerprint
-
- def _prepare_conn(self, conn):
- """
- Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
- and establish the tunnel if proxy is used.
- """
-
- if isinstance(conn, VerifiedHTTPSConnection):
- conn.set_cert(key_file=self.key_file,
- cert_file=self.cert_file,
- cert_reqs=self.cert_reqs,
- ca_certs=self.ca_certs,
- ca_cert_dir=self.ca_cert_dir,
- assert_hostname=self.assert_hostname,
- assert_fingerprint=self.assert_fingerprint)
- conn.ssl_version = self.ssl_version
- return conn
-
- def _prepare_proxy(self, conn):
- """
- Establish tunnel connection early, because otherwise httplib
- would improperly set Host: header to proxy's IP:port.
- """
- conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
- conn.connect()
-
- def _new_conn(self):
- """
- Return a fresh :class:`httplib.HTTPSConnection`.
- """
- self.num_connections += 1
- log.debug("Starting new HTTPS connection (%d): %s:%s",
- self.num_connections, self.host, self.port or "443")
-
- if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
- raise SSLError("Can't connect to HTTPS URL because the SSL "
- "module is not available.")
-
- actual_host = self.host
- actual_port = self.port
- if self.proxy is not None:
- actual_host = self.proxy.host
- actual_port = self.proxy.port
-
- conn = self.ConnectionCls(host=actual_host, port=actual_port,
- timeout=self.timeout.connect_timeout,
- strict=self.strict, **self.conn_kw)
-
- return self._prepare_conn(conn)
-
- def _validate_conn(self, conn):
- """
- Called right before a request is made, after the socket is created.
- """
- super(HTTPSConnectionPool, self)._validate_conn(conn)
-
- # Force connect early to allow us to validate the connection.
- if not getattr(conn, 'sock', None): # AppEngine might not have `.sock`
- conn.connect()
-
- if not conn.is_verified:
- warnings.warn((
- 'Unverified HTTPS request is being made. '
- 'Adding certificate verification is strongly advised. See: '
- 'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
- '#ssl-warnings'),
- InsecureRequestWarning)
-
-
-def connection_from_url(url, **kw):
- """
- Given a url, return an :class:`.ConnectionPool` instance of its host.
-
- This is a shortcut for not having to parse out the scheme, host, and port
- of the url before creating an :class:`.ConnectionPool` instance.
-
- :param url:
- Absolute URL string that must include the scheme. Port is optional.
-
- :param \\**kw:
- Passes additional parameters to the constructor of the appropriate
- :class:`.ConnectionPool`. Useful for specifying things like
- timeout, maxsize, headers, etc.
-
- Example::
-
- >>> conn = connection_from_url('http://google.com/')
- >>> r = conn.request('GET', '/')
- """
- scheme, host, port = get_host(url)
- port = port or port_by_scheme.get(scheme, 80)
- if scheme == 'https':
- return HTTPSConnectionPool(host, port=port, **kw)
- else:
- return HTTPConnectionPool(host, port=port, **kw)
-
-
-def _ipv6_host(host, scheme):
- """
- Process IPv6 address literals
- """
-
- # httplib doesn't like it when we include brackets in IPv6 addresses
- # Specifically, if we include brackets but also pass the port then
- # httplib crazily doubles up the square brackets on the Host header.
- # Instead, we need to make sure we never pass ``None`` as the port.
- # However, for backward compatibility reasons we can't actually
- # *assert* that. See http://bugs.python.org/issue28539
- #
- # Also if an IPv6 address literal has a zone identifier, the
- # percent sign might be URIencoded, convert it back into ASCII
- if host.startswith('[') and host.endswith(']'):
- host = host.replace('%25', '%').strip('[]')
- if scheme in NORMALIZABLE_SCHEMES:
- host = host.lower()
- return host
diff --git a/python/urllib3/contrib/__init__.py b/python/urllib3/contrib/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/python/urllib3/contrib/__init__.py
+++ /dev/null
diff --git a/python/urllib3/contrib/_appengine_environ.py b/python/urllib3/contrib/_appengine_environ.py
deleted file mode 100644
index f3e0094..0000000
--- a/python/urllib3/contrib/_appengine_environ.py
+++ /dev/null
@@ -1,30 +0,0 @@
-"""
-This module provides means to detect the App Engine environment.
-"""
-
-import os
-
-
-def is_appengine():
- return (is_local_appengine() or
- is_prod_appengine() or
- is_prod_appengine_mvms())
-
-
-def is_appengine_sandbox():
- return is_appengine() and not is_prod_appengine_mvms()
-
-
-def is_local_appengine():
- return ('APPENGINE_RUNTIME' in os.environ and
- 'Development/' in os.environ['SERVER_SOFTWARE'])
-
-
-def is_prod_appengine():
- return ('APPENGINE_RUNTIME' in os.environ and
- 'Google App Engine/' in os.environ['SERVER_SOFTWARE'] and
- not is_prod_appengine_mvms())
-
-
-def is_prod_appengine_mvms():
- return os.environ.get('GAE_VM', False) == 'true'
diff --git a/python/urllib3/contrib/_securetransport/__init__.py b/python/urllib3/contrib/_securetransport/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/python/urllib3/contrib/_securetransport/__init__.py
+++ /dev/null
diff --git a/python/urllib3/contrib/_securetransport/bindings.py b/python/urllib3/contrib/_securetransport/bindings.py
deleted file mode 100644
index bcf41c0..0000000
--- a/python/urllib3/contrib/_securetransport/bindings.py
+++ /dev/null
@@ -1,593 +0,0 @@
-"""
-This module uses ctypes to bind a whole bunch of functions and constants from
-SecureTransport. The goal here is to provide the low-level API to
-SecureTransport. These are essentially the C-level functions and constants, and
-they're pretty gross to work with.
-
-This code is a bastardised version of the code found in Will Bond's oscrypto
-library. An enormous debt is owed to him for blazing this trail for us. For
-that reason, this code should be considered to be covered both by urllib3's
-license and by oscrypto's:
-
- Copyright (c) 2015-2016 Will Bond <will@wbond.net>
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-"""
-from __future__ import absolute_import
-
-import platform
-from ctypes.util import find_library
-from ctypes import (
- c_void_p, c_int32, c_char_p, c_size_t, c_byte, c_uint32, c_ulong, c_long,
- c_bool
-)
-from ctypes import CDLL, POINTER, CFUNCTYPE
-
-
-security_path = find_library('Security')
-if not security_path:
- raise ImportError('The library Security could not be found')
-
-
-core_foundation_path = find_library('CoreFoundation')
-if not core_foundation_path:
- raise ImportError('The library CoreFoundation could not be found')
-
-
-version = platform.mac_ver()[0]
-version_info = tuple(map(int, version.split('.')))
-if version_info < (10, 8):
- raise OSError(
- 'Only OS X 10.8 and newer are supported, not %s.%s' % (
- version_info[0], version_info[1]
- )
- )
-
-Security = CDLL(security_path, use_errno=True)
-CoreFoundation = CDLL(core_foundation_path, use_errno=True)
-
-Boolean = c_bool
-CFIndex = c_long
-CFStringEncoding = c_uint32
-CFData = c_void_p
-CFString = c_void_p
-CFArray = c_void_p
-CFMutableArray = c_void_p
-CFDictionary = c_void_p
-CFError = c_void_p
-CFType = c_void_p
-CFTypeID = c_ulong
-
-CFTypeRef = POINTER(CFType)
-CFAllocatorRef = c_void_p
-
-OSStatus = c_int32
-
-CFDataRef = POINTER(CFData)
-CFStringRef = POINTER(CFString)
-CFArrayRef = POINTER(CFArray)
-CFMutableArrayRef = POINTER(CFMutableArray)
-CFDictionaryRef = POINTER(CFDictionary)
-CFArrayCallBacks = c_void_p
-CFDictionaryKeyCallBacks = c_void_p
-CFDictionaryValueCallBacks = c_void_p
-
-SecCertificateRef = POINTER(c_void_p)
-SecExternalFormat = c_uint32
-SecExternalItemType = c_uint32
-SecIdentityRef = POINTER(c_void_p)
-SecItemImportExportFlags = c_uint32
-SecItemImportExportKeyParameters = c_void_p
-SecKeychainRef = POINTER(c_void_p)
-SSLProtocol = c_uint32
-SSLCipherSuite = c_uint32
-SSLContextRef = POINTER(c_void_p)
-SecTrustRef = POINTER(c_void_p)
-SSLConnectionRef = c_uint32
-SecTrustResultType = c_uint32
-SecTrustOptionFlags = c_uint32
-SSLProtocolSide = c_uint32
-SSLConnectionType = c_uint32
-SSLSessionOption = c_uint32
-
-
-try:
- Security.SecItemImport.argtypes = [
- CFDataRef,
- CFStringRef,
- POINTER(SecExternalFormat),
- POINTER(SecExternalItemType),
- SecItemImportExportFlags,
- POINTER(SecItemImportExportKeyParameters),
- SecKeychainRef,
- POINTER(CFArrayRef),
- ]
- Security.SecItemImport.restype = OSStatus
-
- Security.SecCertificateGetTypeID.argtypes = []
- Security.SecCertificateGetTypeID.restype = CFTypeID
-
- Security.SecIdentityGetTypeID.argtypes = []
- Security.SecIdentityGetTypeID.restype = CFTypeID
-
- Security.SecKeyGetTypeID.argtypes = []
- Security.SecKeyGetTypeID.restype = CFTypeID
-
- Security.SecCertificateCreateWithData.argtypes = [
- CFAllocatorRef,
- CFDataRef
- ]
- Security.SecCertificateCreateWithData.restype = SecCertificateRef
-
- Security.SecCertificateCopyData.argtypes = [
- SecCertificateRef
- ]
- Security.SecCertificateCopyData.restype = CFDataRef
-
- Security.SecCopyErrorMessageString.argtypes = [
- OSStatus,
- c_void_p
- ]
- Security.SecCopyErrorMessageString.restype = CFStringRef
-
- Security.SecIdentityCreateWithCertificate.argtypes = [
- CFTypeRef,
- SecCertificateRef,
- POINTER(SecIdentityRef)
- ]
- Security.SecIdentityCreateWithCertificate.restype = OSStatus
-
- Security.SecKeychainCreate.argtypes = [
- c_char_p,
- c_uint32,
- c_void_p,
- Boolean,
- c_void_p,
- POINTER(SecKeychainRef)
- ]
- Security.SecKeychainCreate.restype = OSStatus
-
- Security.SecKeychainDelete.argtypes = [
- SecKeychainRef
- ]
- Security.SecKeychainDelete.restype = OSStatus
-
- Security.SecPKCS12Import.argtypes = [
- CFDataRef,
- CFDictionaryRef,
- POINTER(CFArrayRef)
- ]
- Security.SecPKCS12Import.restype = OSStatus
-
- SSLReadFunc = CFUNCTYPE(OSStatus, SSLConnectionRef, c_void_p, POINTER(c_size_t))
- SSLWriteFunc = CFUNCTYPE(OSStatus, SSLConnectionRef, POINTER(c_byte), POINTER(c_size_t))
-
- Security.SSLSetIOFuncs.argtypes = [
- SSLContextRef,
- SSLReadFunc,
- SSLWriteFunc
- ]
- Security.SSLSetIOFuncs.restype = OSStatus
-
- Security.SSLSetPeerID.argtypes = [
- SSLContextRef,
- c_char_p,
- c_size_t
- ]
- Security.SSLSetPeerID.restype = OSStatus
-
- Security.SSLSetCertificate.argtypes = [
- SSLContextRef,
- CFArrayRef
- ]
- Security.SSLSetCertificate.restype = OSStatus
-
- Security.SSLSetCertificateAuthorities.argtypes = [
- SSLContextRef,
- CFTypeRef,
- Boolean
- ]
- Security.SSLSetCertificateAuthorities.restype = OSStatus
-
- Security.SSLSetConnection.argtypes = [
- SSLContextRef,
- SSLConnectionRef
- ]
- Security.SSLSetConnection.restype = OSStatus
-
- Security.SSLSetPeerDomainName.argtypes = [
- SSLContextRef,
- c_char_p,
- c_size_t
- ]
- Security.SSLSetPeerDomainName.restype = OSStatus
-
- Security.SSLHandshake.argtypes = [
- SSLContextRef
- ]
- Security.SSLHandshake.restype = OSStatus
-
- Security.SSLRead.argtypes = [
- SSLContextRef,
- c_char_p,
- c_size_t,
- POINTER(c_size_t)
- ]
- Security.SSLRead.restype = OSStatus
-
- Security.SSLWrite.argtypes = [
- SSLContextRef,
- c_char_p,
- c_size_t,
- POINTER(c_size_t)
- ]
- Security.SSLWrite.restype = OSStatus
-
- Security.SSLClose.argtypes = [
- SSLContextRef
- ]
- Security.SSLClose.restype = OSStatus
-
- Security.SSLGetNumberSupportedCiphers.argtypes = [
- SSLContextRef,
- POINTER(c_size_t)
- ]
- Security.SSLGetNumberSupportedCiphers.restype = OSStatus
-
- Security.SSLGetSupportedCiphers.argtypes = [
- SSLContextRef,
- POINTER(SSLCipherSuite),
- POINTER(c_size_t)
- ]
- Security.SSLGetSupportedCiphers.restype = OSStatus
-
- Security.SSLSetEnabledCiphers.argtypes = [
- SSLContextRef,
- POINTER(SSLCipherSuite),
- c_size_t
- ]
- Security.SSLSetEnabledCiphers.restype = OSStatus
-
- Security.SSLGetNumberEnabledCiphers.argtype = [
- SSLContextRef,
- POINTER(c_size_t)
- ]
- Security.SSLGetNumberEnabledCiphers.restype = OSStatus
-
- Security.SSLGetEnabledCiphers.argtypes = [
- SSLContextRef,
- POINTER(SSLCipherSuite),
- POINTER(c_size_t)
- ]
- Security.SSLGetEnabledCiphers.restype = OSStatus
-
- Security.SSLGetNegotiatedCipher.argtypes = [
- SSLContextRef,
- POINTER(SSLCipherSuite)
- ]
- Security.SSLGetNegotiatedCipher.restype = OSStatus
-
- Security.SSLGetNegotiatedProtocolVersion.argtypes = [
- SSLContextRef,
- POINTER(SSLProtocol)
- ]
- Security.SSLGetNegotiatedProtocolVersion.restype = OSStatus
-
- Security.SSLCopyPeerTrust.argtypes = [
- SSLContextRef,
- POINTER(SecTrustRef)
- ]
- Security.SSLCopyPeerTrust.restype = OSStatus
-
- Security.SecTrustSetAnchorCertificates.argtypes = [
- SecTrustRef,
- CFArrayRef
- ]
- Security.SecTrustSetAnchorCertificates.restype = OSStatus
-
- Security.SecTrustSetAnchorCertificatesOnly.argstypes = [
- SecTrustRef,
- Boolean
- ]
- Security.SecTrustSetAnchorCertificatesOnly.restype = OSStatus
-
- Security.SecTrustEvaluate.argtypes = [
- SecTrustRef,
- POINTER(SecTrustResultType)
- ]
- Security.SecTrustEvaluate.restype = OSStatus
-
- Security.SecTrustGetCertificateCount.argtypes = [
- SecTrustRef
- ]
- Security.SecTrustGetCertificateCount.restype = CFIndex
-
- Security.SecTrustGetCertificateAtIndex.argtypes = [
- SecTrustRef,
- CFIndex
- ]
- Security.SecTrustGetCertificateAtIndex.restype = SecCertificateRef
-
- Security.SSLCreateContext.argtypes = [
- CFAllocatorRef,
- SSLProtocolSide,
- SSLConnectionType
- ]
- Security.SSLCreateContext.restype = SSLContextRef
-
- Security.SSLSetSessionOption.argtypes = [
- SSLContextRef,
- SSLSessionOption,
- Boolean
- ]
- Security.SSLSetSessionOption.restype = OSStatus
-
- Security.SSLSetProtocolVersionMin.argtypes = [
- SSLContextRef,
- SSLProtocol
- ]
- Security.SSLSetProtocolVersionMin.restype = OSStatus
-
- Security.SSLSetProtocolVersionMax.argtypes = [
- SSLContextRef,
- SSLProtocol
- ]
- Security.SSLSetProtocolVersionMax.restype = OSStatus
-
- Security.SecCopyErrorMessageString.argtypes = [
- OSStatus,
- c_void_p
- ]
- Security.SecCopyErrorMessageString.restype = CFStringRef
-
- Security.SSLReadFunc = SSLReadFunc
- Security.SSLWriteFunc = SSLWriteFunc
- Security.SSLContextRef = SSLContextRef
- Security.SSLProtocol = SSLProtocol
- Security.SSLCipherSuite = SSLCipherSuite
- Security.SecIdentityRef = SecIdentityRef
- Security.SecKeychainRef = SecKeychainRef
- Security.SecTrustRef = SecTrustRef
- Security.SecTrustResultType = SecTrustResultType
- Security.SecExternalFormat = SecExternalFormat
- Security.OSStatus = OSStatus
-
- Security.kSecImportExportPassphrase = CFStringRef.in_dll(
- Security, 'kSecImportExportPassphrase'
- )
- Security.kSecImportItemIdentity = CFStringRef.in_dll(
- Security, 'kSecImportItemIdentity'
- )
-
- # CoreFoundation time!
- CoreFoundation.CFRetain.argtypes = [
- CFTypeRef
- ]
- CoreFoundation.CFRetain.restype = CFTypeRef
-
- CoreFoundation.CFRelease.argtypes = [
- CFTypeRef
- ]
- CoreFoundation.CFRelease.restype = None
-
- CoreFoundation.CFGetTypeID.argtypes = [
- CFTypeRef
- ]
- CoreFoundation.CFGetTypeID.restype = CFTypeID
-
- CoreFoundation.CFStringCreateWithCString.argtypes = [
- CFAllocatorRef,
- c_char_p,
- CFStringEncoding
- ]
- CoreFoundation.CFStringCreateWithCString.restype = CFStringRef
-
- CoreFoundation.CFStringGetCStringPtr.argtypes = [
- CFStringRef,
- CFStringEncoding
- ]
- CoreFoundation.CFStringGetCStringPtr.restype = c_char_p
-
- CoreFoundation.CFStringGetCString.argtypes = [
- CFStringRef,
- c_char_p,
- CFIndex,
- CFStringEncoding
- ]
- CoreFoundation.CFStringGetCString.restype = c_bool
-
- CoreFoundation.CFDataCreate.argtypes = [
- CFAllocatorRef,
- c_char_p,
- CFIndex
- ]
- CoreFoundation.CFDataCreate.restype = CFDataRef
-
- CoreFoundation.CFDataGetLength.argtypes = [
- CFDataRef
- ]
- CoreFoundation.CFDataGetLength.restype = CFIndex
-
- CoreFoundation.CFDataGetBytePtr.argtypes = [
- CFDataRef
- ]
- CoreFoundation.CFDataGetBytePtr.restype = c_void_p
-
- CoreFoundation.CFDictionaryCreate.argtypes = [
- CFAllocatorRef,
- POINTER(CFTypeRef),
- POINTER(CFTypeRef),
- CFIndex,
- CFDictionaryKeyCallBacks,
- CFDictionaryValueCallBacks
- ]
- CoreFoundation.CFDictionaryCreate.restype = CFDictionaryRef
-
- CoreFoundation.CFDictionaryGetValue.argtypes = [
- CFDictionaryRef,
- CFTypeRef
- ]
- CoreFoundation.CFDictionaryGetValue.restype = CFTypeRef
-
- CoreFoundation.CFArrayCreate.argtypes = [
- CFAllocatorRef,
- POINTER(CFTypeRef),
- CFIndex,
- CFArrayCallBacks,
- ]
- CoreFoundation.CFArrayCreate.restype = CFArrayRef
-
- CoreFoundation.CFArrayCreateMutable.argtypes = [
- CFAllocatorRef,
- CFIndex,
- CFArrayCallBacks
- ]
- CoreFoundation.CFArrayCreateMutable.restype = CFMutableArrayRef
-
- CoreFoundation.CFArrayAppendValue.argtypes = [
- CFMutableArrayRef,
- c_void_p
- ]
- CoreFoundation.CFArrayAppendValue.restype = None
-
- CoreFoundation.CFArrayGetCount.argtypes = [
- CFArrayRef
- ]
- CoreFoundation.CFArrayGetCount.restype = CFIndex
-
- CoreFoundation.CFArrayGetValueAtIndex.argtypes = [
- CFArrayRef,
- CFIndex
- ]
- CoreFoundation.CFArrayGetValueAtIndex.restype = c_void_p
-
- CoreFoundation.kCFAllocatorDefault = CFAllocatorRef.in_dll(
- CoreFoundation, 'kCFAllocatorDefault'
- )
- CoreFoundation.kCFTypeArrayCallBacks = c_void_p.in_dll(CoreFoundation, 'kCFTypeArrayCallBacks')
- CoreFoundation.kCFTypeDictionaryKeyCallBacks = c_void_p.in_dll(
- CoreFoundation, 'kCFTypeDictionaryKeyCallBacks'
- )
- CoreFoundation.kCFTypeDictionaryValueCallBacks = c_void_p.in_dll(
- CoreFoundation, 'kCFTypeDictionaryValueCallBacks'
- )
-
- CoreFoundation.CFTypeRef = CFTypeRef
- CoreFoundation.CFArrayRef = CFArrayRef
- CoreFoundation.CFStringRef = CFStringRef
- CoreFoundation.CFDictionaryRef = CFDictionaryRef
-
-except (AttributeError):
- raise ImportError('Error initializing ctypes')
-
-
-class CFConst(object):
- """
- A class object that acts as essentially a namespace for CoreFoundation
- constants.
- """
- kCFStringEncodingUTF8 = CFStringEncoding(0x08000100)
-
-
-class SecurityConst(object):
- """
- A class object that acts as essentially a namespace for Security constants.
- """
- kSSLSessionOptionBreakOnServerAuth = 0
-
- kSSLProtocol2 = 1
- kSSLProtocol3 = 2
- kTLSProtocol1 = 4
- kTLSProtocol11 = 7
- kTLSProtocol12 = 8
-
- kSSLClientSide = 1
- kSSLStreamType = 0
-
- kSecFormatPEMSequence = 10
-
- kSecTrustResultInvalid = 0
- kSecTrustResultProceed = 1
- # This gap is present on purpose: this was kSecTrustResultConfirm, which
- # is deprecated.
- kSecTrustResultDeny = 3
- kSecTrustResultUnspecified = 4
- kSecTrustResultRecoverableTrustFailure = 5
- kSecTrustResultFatalTrustFailure = 6
- kSecTrustResultOtherError = 7
-
- errSSLProtocol = -9800
- errSSLWouldBlock = -9803
- errSSLClosedGraceful = -9805
- errSSLClosedNoNotify = -9816
- errSSLClosedAbort = -9806
-
- errSSLXCertChainInvalid = -9807
- errSSLCrypto = -9809
- errSSLInternal = -9810
- errSSLCertExpired = -9814
- errSSLCertNotYetValid = -9815
- errSSLUnknownRootCert = -9812
- errSSLNoRootCert = -9813
- errSSLHostNameMismatch = -9843
- errSSLPeerHandshakeFail = -9824
- errSSLPeerUserCancelled = -9839
- errSSLWeakPeerEphemeralDHKey = -9850
- errSSLServerAuthCompleted = -9841
- errSSLRecordOverflow = -9847
-
- errSecVerifyFailed = -67808
- errSecNoTrustSettings = -25263
- errSecItemNotFound = -25300
- errSecInvalidTrustSettings = -25262
-
- # Cipher suites. We only pick the ones our default cipher string allows.
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02C
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xC030
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02B
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F
- TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = 0x00A3
- TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x009F
- TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = 0x00A2
- TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x009E
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xC024
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xC028
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014
- TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x006B
- TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x006A
- TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x0039
- TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x0038
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xC023
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xC027
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xC009
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013
- TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x0067
- TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x0040
- TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x0033
- TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x0032
- TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x009D
- TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x009C
- TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x003D
- TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x003C
- TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035
- TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F
- TLS_AES_128_GCM_SHA256 = 0x1301
- TLS_AES_256_GCM_SHA384 = 0x1302
- TLS_CHACHA20_POLY1305_SHA256 = 0x1303
diff --git a/python/urllib3/contrib/_securetransport/low_level.py b/python/urllib3/contrib/_securetransport/low_level.py
deleted file mode 100644
index b13cd9e..0000000
--- a/python/urllib3/contrib/_securetransport/low_level.py
+++ /dev/null
@@ -1,346 +0,0 @@
-"""
-Low-level helpers for the SecureTransport bindings.
-
-These are Python functions that are not directly related to the high-level APIs
-but are necessary to get them to work. They include a whole bunch of low-level
-CoreFoundation messing about and memory management. The concerns in this module
-are almost entirely about trying to avoid memory leaks and providing
-appropriate and useful assistance to the higher-level code.
-"""
-import base64
-import ctypes
-import itertools
-import re
-import os
-import ssl
-import tempfile
-
-from .bindings import Security, CoreFoundation, CFConst
-
-
-# This regular expression is used to grab PEM data out of a PEM bundle.
-_PEM_CERTS_RE = re.compile(
- b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTIFICATE-----", re.DOTALL
-)
-
-
-def _cf_data_from_bytes(bytestring):
- """
- Given a bytestring, create a CFData object from it. This CFData object must
- be CFReleased by the caller.
- """
- return CoreFoundation.CFDataCreate(
- CoreFoundation.kCFAllocatorDefault, bytestring, len(bytestring)
- )
-
-
-def _cf_dictionary_from_tuples(tuples):
- """
- Given a list of Python tuples, create an associated CFDictionary.
- """
- dictionary_size = len(tuples)
-
- # We need to get the dictionary keys and values out in the same order.
- keys = (t[0] for t in tuples)
- values = (t[1] for t in tuples)
- cf_keys = (CoreFoundation.CFTypeRef * dictionary_size)(*keys)
- cf_values = (CoreFoundation.CFTypeRef * dictionary_size)(*values)
-
- return CoreFoundation.CFDictionaryCreate(
- CoreFoundation.kCFAllocatorDefault,
- cf_keys,
- cf_values,
- dictionary_size,
- CoreFoundation.kCFTypeDictionaryKeyCallBacks,
- CoreFoundation.kCFTypeDictionaryValueCallBacks,
- )
-
-
-def _cf_string_to_unicode(value):
- """
- Creates a Unicode string from a CFString object. Used entirely for error
- reporting.
-
- Yes, it annoys me quite a lot that this function is this complex.
- """
- value_as_void_p = ctypes.cast(value, ctypes.POINTER(ctypes.c_void_p))
-
- string = CoreFoundation.CFStringGetCStringPtr(
- value_as_void_p,
- CFConst.kCFStringEncodingUTF8
- )
- if string is None:
- buffer = ctypes.create_string_buffer(1024)
- result = CoreFoundation.CFStringGetCString(
- value_as_void_p,
- buffer,
- 1024,
- CFConst.kCFStringEncodingUTF8
- )
- if not result:
- raise OSError('Error copying C string from CFStringRef')
- string = buffer.value
- if string is not None:
- string = string.decode('utf-8')
- return string
-
-
-def _assert_no_error(error, exception_class=None):
- """
- Checks the return code and throws an exception if there is an error to
- report
- """
- if error == 0:
- return
-
- cf_error_string = Security.SecCopyErrorMessageString(error, None)
- output = _cf_string_to_unicode(cf_error_string)
- CoreFoundation.CFRelease(cf_error_string)
-
- if output is None or output == u'':
- output = u'OSStatus %s' % error
-
- if exception_class is None:
- exception_class = ssl.SSLError
-
- raise exception_class(output)
-
-
-def _cert_array_from_pem(pem_bundle):
- """
- Given a bundle of certs in PEM format, turns them into a CFArray of certs
- that can be used to validate a cert chain.
- """
- # Normalize the PEM bundle's line endings.
- pem_bundle = pem_bundle.replace(b"\r\n", b"\n")
-
- der_certs = [
- base64.b64decode(match.group(1))
- for match in _PEM_CERTS_RE.finditer(pem_bundle)
- ]
- if not der_certs:
- raise ssl.SSLError("No root certificates specified")
-
- cert_array = CoreFoundation.CFArrayCreateMutable(
- CoreFoundation.kCFAllocatorDefault,
- 0,
- ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks)
- )
- if not cert_array:
- raise ssl.SSLError("Unable to allocate memory!")
-
- try:
- for der_bytes in der_certs:
- certdata = _cf_data_from_bytes(der_bytes)
- if not certdata:
- raise ssl.SSLError("Unable to allocate memory!")
- cert = Security.SecCertificateCreateWithData(
- CoreFoundation.kCFAllocatorDefault, certdata
- )
- CoreFoundation.CFRelease(certdata)
- if not cert:
- raise ssl.SSLError("Unable to build cert object!")
-
- CoreFoundation.CFArrayAppendValue(cert_array, cert)
- CoreFoundation.CFRelease(cert)
- except Exception:
- # We need to free the array before the exception bubbles further.
- # We only want to do that if an error occurs: otherwise, the caller
- # should free.
- CoreFoundation.CFRelease(cert_array)
-
- return cert_array
-
-
-def _is_cert(item):
- """
- Returns True if a given CFTypeRef is a certificate.
- """
- expected = Security.SecCertificateGetTypeID()
- return CoreFoundation.CFGetTypeID(item) == expected
-
-
-def _is_identity(item):
- """
- Returns True if a given CFTypeRef is an identity.
- """
- expected = Security.SecIdentityGetTypeID()
- return CoreFoundation.CFGetTypeID(item) == expected
-
-
-def _temporary_keychain():
- """
- This function creates a temporary Mac keychain that we can use to work with
- credentials. This keychain uses a one-time password and a temporary file to
- store the data. We expect to have one keychain per socket. The returned
- SecKeychainRef must be freed by the caller, including calling
- SecKeychainDelete.
-
- Returns a tuple of the SecKeychainRef and the path to the temporary
- directory that contains it.
- """
- # Unfortunately, SecKeychainCreate requires a path to a keychain. This
- # means we cannot use mkstemp to use a generic temporary file. Instead,
- # we're going to create a temporary directory and a filename to use there.
- # This filename will be 8 random bytes expanded into base64. We also need
- # some random bytes to password-protect the keychain we're creating, so we
- # ask for 40 random bytes.
- random_bytes = os.urandom(40)
- filename = base64.b16encode(random_bytes[:8]).decode('utf-8')
- password = base64.b16encode(random_bytes[8:]) # Must be valid UTF-8
- tempdirectory = tempfile.mkdtemp()
-
- keychain_path = os.path.join(tempdirectory, filename).encode('utf-8')
-
- # We now want to create the keychain itself.
- keychain = Security.SecKeychainRef()
- status = Security.SecKeychainCreate(
- keychain_path,
- len(password),
- password,
- False,
- None,
- ctypes.byref(keychain)
- )
- _assert_no_error(status)
-
- # Having created the keychain, we want to pass it off to the caller.
- return keychain, tempdirectory
-
-
-def _load_items_from_file(keychain, path):
- """
- Given a single file, loads all the trust objects from it into arrays and
- the keychain.
- Returns a tuple of lists: the first list is a list of identities, the
- second a list of certs.
- """
- certificates = []
- identities = []
- result_array = None
-
- with open(path, 'rb') as f:
- raw_filedata = f.read()
-
- try:
- filedata = CoreFoundation.CFDataCreate(
- CoreFoundation.kCFAllocatorDefault,
- raw_filedata,
- len(raw_filedata)
- )
- result_array = CoreFoundation.CFArrayRef()
- result = Security.SecItemImport(
- filedata, # cert data
- None, # Filename, leaving it out for now
- None, # What the type of the file is, we don't care
- None, # what's in the file, we don't care
- 0, # import flags
- None, # key params, can include passphrase in the future
- keychain, # The keychain to insert into
- ctypes.byref(result_array) # Results
- )
- _assert_no_error(result)
-
- # A CFArray is not very useful to us as an intermediary
- # representation, so we are going to extract the objects we want
- # and then free the array. We don't need to keep hold of keys: the
- # keychain already has them!
- result_count = CoreFoundation.CFArrayGetCount(result_array)
- for index in range(result_count):
- item = CoreFoundation.CFArrayGetValueAtIndex(
- result_array, index
- )
- item = ctypes.cast(item, CoreFoundation.CFTypeRef)
-
- if _is_cert(item):
- CoreFoundation.CFRetain(item)
- certificates.append(item)
- elif _is_identity(item):
- CoreFoundation.CFRetain(item)
- identities.append(item)
- finally:
- if result_array:
- CoreFoundation.CFRelease(result_array)
-
- CoreFoundation.CFRelease(filedata)
-
- return (identities, certificates)
-
-
-def _load_client_cert_chain(keychain, *paths):
- """
- Load certificates and maybe keys from a number of files. Has the end goal
- of returning a CFArray containing one SecIdentityRef, and then zero or more
- SecCertificateRef objects, suitable for use as a client certificate trust
- chain.
- """
- # Ok, the strategy.
- #
- # This relies on knowing that macOS will not give you a SecIdentityRef
- # unless you have imported a key into a keychain. This is a somewhat
- # artificial limitation of macOS (for example, it doesn't necessarily
- # affect iOS), but there is nothing inside Security.framework that lets you
- # get a SecIdentityRef without having a key in a keychain.
- #
- # So the policy here is we take all the files and iterate them in order.
- # Each one will use SecItemImport to have one or more objects loaded from
- # it. We will also point at a keychain that macOS can use to work with the
- # private key.
- #
- # Once we have all the objects, we'll check what we actually have. If we
- # already have a SecIdentityRef in hand, fab: we'll use that. Otherwise,
- # we'll take the first certificate (which we assume to be our leaf) and
- # ask the keychain to give us a SecIdentityRef with that cert's associated
- # key.
- #
- # We'll then return a CFArray containing the trust chain: one
- # SecIdentityRef and then zero-or-more SecCertificateRef objects. The
- # responsibility for freeing this CFArray will be with the caller. This
- # CFArray must remain alive for the entire connection, so in practice it
- # will be stored with a single SSLSocket, along with the reference to the
- # keychain.
- certificates = []
- identities = []
-
- # Filter out bad paths.
- paths = (path for path in paths if path)
-
- try:
- for file_path in paths:
- new_identities, new_certs = _load_items_from_file(
- keychain, file_path
- )
- identities.extend(new_identities)
- certificates.extend(new_certs)
-
- # Ok, we have everything. The question is: do we have an identity? If
- # not, we want to grab one from the first cert we have.
- if not identities:
- new_identity = Security.SecIdentityRef()
- status = Security.SecIdentityCreateWithCertificate(
- keychain,
- certificates[0],
- ctypes.byref(new_identity)
- )
- _assert_no_error(status)
- identities.append(new_identity)
-
- # We now want to release the original certificate, as we no longer
- # need it.
- CoreFoundation.CFRelease(certificates.pop(0))
-
- # We now need to build a new CFArray that holds the trust chain.
- trust_chain = CoreFoundation.CFArrayCreateMutable(
- CoreFoundation.kCFAllocatorDefault,
- 0,
- ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
- )
- for item in itertools.chain(identities, certificates):
- # ArrayAppendValue does a CFRetain on the item. That's fine,
- # because the finally block will release our other refs to them.
- CoreFoundation.CFArrayAppendValue(trust_chain, item)
-
- return trust_chain
- finally:
- for obj in itertools.chain(identities, certificates):
- CoreFoundation.CFRelease(obj)
diff --git a/python/urllib3/contrib/appengine.py b/python/urllib3/contrib/appengine.py
deleted file mode 100644
index 2952f11..0000000
--- a/python/urllib3/contrib/appengine.py
+++ /dev/null
@@ -1,289 +0,0 @@
-"""
-This module provides a pool manager that uses Google App Engine's
-`URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_.
-
-Example usage::
-
- from urllib3 import PoolManager
- from urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox
-
- if is_appengine_sandbox():
- # AppEngineManager uses AppEngine's URLFetch API behind the scenes
- http = AppEngineManager()
- else:
- # PoolManager uses a socket-level API behind the scenes
- http = PoolManager()
-
- r = http.request('GET', 'https://google.com/')
-
-There are `limitations <https://cloud.google.com/appengine/docs/python/\
-urlfetch/#Python_Quotas_and_limits>`_ to the URLFetch service and it may not be
-the best choice for your application. There are three options for using
-urllib3 on Google App Engine:
-
-1. You can use :class:`AppEngineManager` with URLFetch. URLFetch is
- cost-effective in many circumstances as long as your usage is within the
- limitations.
-2. You can use a normal :class:`~urllib3.PoolManager` by enabling sockets.
- Sockets also have `limitations and restrictions
- <https://cloud.google.com/appengine/docs/python/sockets/\
- #limitations-and-restrictions>`_ and have a lower free quota than URLFetch.
- To use sockets, be sure to specify the following in your ``app.yaml``::
-
- env_variables:
- GAE_USE_SOCKETS_HTTPLIB : 'true'
-
-3. If you are using `App Engine Flexible
-<https://cloud.google.com/appengine/docs/flexible/>`_, you can use the standard
-:class:`PoolManager` without any configuration or special environment variables.
-"""
-
-from __future__ import absolute_import
-import io
-import logging
-import warnings
-from ..packages.six.moves.urllib.parse import urljoin
-
-from ..exceptions import (
- HTTPError,
- HTTPWarning,
- MaxRetryError,
- ProtocolError,
- TimeoutError,
- SSLError
-)
-
-from ..request import RequestMethods
-from ..response import HTTPResponse
-from ..util.timeout import Timeout
-from ..util.retry import Retry
-from . import _appengine_environ
-
-try:
- from google.appengine.api import urlfetch
-except ImportError:
- urlfetch = None
-
-
-log = logging.getLogger(__name__)
-
-
-class AppEnginePlatformWarning(HTTPWarning):
- pass
-
-
-class AppEnginePlatformError(HTTPError):
- pass
-
-
-class AppEngineManager(RequestMethods):
- """
- Connection manager for Google App Engine sandbox applications.
-
- This manager uses the URLFetch service directly instead of using the
- emulated httplib, and is subject to URLFetch limitations as described in
- the App Engine documentation `here
- <https://cloud.google.com/appengine/docs/python/urlfetch>`_.
-
- Notably it will raise an :class:`AppEnginePlatformError` if:
- * URLFetch is not available.
- * If you attempt to use this on App Engine Flexible, as full socket
- support is available.
- * If a request size is more than 10 megabytes.
- * If a response size is more than 32 megabtyes.
- * If you use an unsupported request method such as OPTIONS.
-
- Beyond those cases, it will raise normal urllib3 errors.
- """
-
- def __init__(self, headers=None, retries=None, validate_certificate=True,
- urlfetch_retries=True):
- if not urlfetch:
- raise AppEnginePlatformError(
- "URLFetch is not available in this environment.")
-
- if is_prod_appengine_mvms():
- raise AppEnginePlatformError(
- "Use normal urllib3.PoolManager instead of AppEngineManager"
- "on Managed VMs, as using URLFetch is not necessary in "
- "this environment.")
-
- warnings.warn(
- "urllib3 is using URLFetch on Google App Engine sandbox instead "
- "of sockets. To use sockets directly instead of URLFetch see "
- "https://urllib3.readthedocs.io/en/latest/reference/urllib3.contrib.html.",
- AppEnginePlatformWarning)
-
- RequestMethods.__init__(self, headers)
- self.validate_certificate = validate_certificate
- self.urlfetch_retries = urlfetch_retries
-
- self.retries = retries or Retry.DEFAULT
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- # Return False to re-raise any potential exceptions
- return False
-
- def urlopen(self, method, url, body=None, headers=None,
- retries=None, redirect=True, timeout=Timeout.DEFAULT_TIMEOUT,
- **response_kw):
-
- retries = self._get_retries(retries, redirect)
-
- try:
- follow_redirects = (
- redirect and
- retries.redirect != 0 and
- retries.total)
- response = urlfetch.fetch(
- url,
- payload=body,
- method=method,
- headers=headers or {},
- allow_truncated=False,
- follow_redirects=self.urlfetch_retries and follow_redirects,
- deadline=self._get_absolute_timeout(timeout),
- validate_certificate=self.validate_certificate,
- )
- except urlfetch.DeadlineExceededError as e:
- raise TimeoutError(self, e)
-
- except urlfetch.InvalidURLError as e:
- if 'too large' in str(e):
- raise AppEnginePlatformError(
- "URLFetch request too large, URLFetch only "
- "supports requests up to 10mb in size.", e)
- raise ProtocolError(e)
-
- except urlfetch.DownloadError as e:
- if 'Too many redirects' in str(e):
- raise MaxRetryError(self, url, reason=e)
- raise ProtocolError(e)
-
- except urlfetch.ResponseTooLargeError as e:
- raise AppEnginePlatformError(
- "URLFetch response too large, URLFetch only supports"
- "responses up to 32mb in size.", e)
-
- except urlfetch.SSLCertificateError as e:
- raise SSLError(e)
-
- except urlfetch.InvalidMethodError as e:
- raise AppEnginePlatformError(
- "URLFetch does not support method: %s" % method, e)
-
- http_response = self._urlfetch_response_to_http_response(
- response, retries=retries, **response_kw)
-
- # Handle redirect?
- redirect_location = redirect and http_response.get_redirect_location()
- if redirect_location:
- # Check for redirect response
- if (self.urlfetch_retries and retries.raise_on_redirect):
- raise MaxRetryError(self, url, "too many redirects")
- else:
- if http_response.status == 303:
- method = 'GET'
-
- try:
- retries = retries.increment(method, url, response=http_response, _pool=self)
- except MaxRetryError:
- if retries.raise_on_redirect:
- raise MaxRetryError(self, url, "too many redirects")
- return http_response
-
- retries.sleep_for_retry(http_response)
- log.debug("Redirecting %s -> %s", url, redirect_location)
- redirect_url = urljoin(url, redirect_location)
- return self.urlopen(
- method, redirect_url, body, headers,
- retries=retries, redirect=redirect,
- timeout=timeout, **response_kw)
-
- # Check if we should retry the HTTP response.
- has_retry_after = bool(http_response.getheader('Retry-After'))
- if retries.is_retry(method, http_response.status, has_retry_after):
- retries = retries.increment(
- method, url, response=http_response, _pool=self)
- log.debug("Retry: %s", url)
- retries.sleep(http_response)
- return self.urlopen(
- method, url,
- body=body, headers=headers,
- retries=retries, redirect=redirect,
- timeout=timeout, **response_kw)
-
- return http_response
-
- def _urlfetch_response_to_http_response(self, urlfetch_resp, **response_kw):
-
- if is_prod_appengine():
- # Production GAE handles deflate encoding automatically, but does
- # not remove the encoding header.
- content_encoding = urlfetch_resp.headers.get('content-encoding')
-
- if content_encoding == 'deflate':
- del urlfetch_resp.headers['content-encoding']
-
- transfer_encoding = urlfetch_resp.headers.get('transfer-encoding')
- # We have a full response's content,
- # so let's make sure we don't report ourselves as chunked data.
- if transfer_encoding == 'chunked':
- encodings = transfer_encoding.split(",")
- encodings.remove('chunked')
- urlfetch_resp.headers['transfer-encoding'] = ','.join(encodings)
-
- original_response = HTTPResponse(
- # In order for decoding to work, we must present the content as
- # a file-like object.
- body=io.BytesIO(urlfetch_resp.content),
- msg=urlfetch_resp.header_msg,
- headers=urlfetch_resp.headers,
- status=urlfetch_resp.status_code,
- **response_kw
- )
-
- return HTTPResponse(
- body=io.BytesIO(urlfetch_resp.content),
- headers=urlfetch_resp.headers,
- status=urlfetch_resp.status_code,
- original_response=original_response,
- **response_kw
- )
-
- def _get_absolute_timeout(self, timeout):
- if timeout is Timeout.DEFAULT_TIMEOUT:
- return None # Defer to URLFetch's default.
- if isinstance(timeout, Timeout):
- if timeout._read is not None or timeout._connect is not None:
- warnings.warn(
- "URLFetch does not support granular timeout settings, "
- "reverting to total or default URLFetch timeout.",
- AppEnginePlatformWarning)
- return timeout.total
- return timeout
-
- def _get_retries(self, retries, redirect):
- if not isinstance(retries, Retry):
- retries = Retry.from_int(
- retries, redirect=redirect, default=self.retries)
-
- if retries.connect or retries.read or retries.redirect:
- warnings.warn(
- "URLFetch only supports total retries and does not "
- "recognize connect, read, or redirect retry parameters.",
- AppEnginePlatformWarning)
-
- return retries
-
-
-# Alias methods from _appengine_environ to maintain public API interface.
-
-is_appengine = _appengine_environ.is_appengine
-is_appengine_sandbox = _appengine_environ.is_appengine_sandbox
-is_local_appengine = _appengine_environ.is_local_appengine
-is_prod_appengine = _appengine_environ.is_prod_appengine
-is_prod_appengine_mvms = _appengine_environ.is_prod_appengine_mvms
diff --git a/python/urllib3/contrib/ntlmpool.py b/python/urllib3/contrib/ntlmpool.py
deleted file mode 100644
index 8ea127c..0000000
--- a/python/urllib3/contrib/ntlmpool.py
+++ /dev/null
@@ -1,111 +0,0 @@
-"""
-NTLM authenticating pool, contributed by erikcederstran
-
-Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
-"""
-from __future__ import absolute_import
-
-from logging import getLogger
-from ntlm import ntlm
-
-from .. import HTTPSConnectionPool
-from ..packages.six.moves.http_client import HTTPSConnection
-
-
-log = getLogger(__name__)
-
-
-class NTLMConnectionPool(HTTPSConnectionPool):
- """
- Implements an NTLM authentication version of an urllib3 connection pool
- """
-
- scheme = 'https'
-
- def __init__(self, user, pw, authurl, *args, **kwargs):
- """
- authurl is a random URL on the server that is protected by NTLM.
- user is the Windows user, probably in the DOMAIN\\username format.
- pw is the password for the user.
- """
- super(NTLMConnectionPool, self).__init__(*args, **kwargs)
- self.authurl = authurl
- self.rawuser = user
- user_parts = user.split('\\', 1)
- self.domain = user_parts[0].upper()
- self.user = user_parts[1]
- self.pw = pw
-
- def _new_conn(self):
- # Performs the NTLM handshake that secures the connection. The socket
- # must be kept open while requests are performed.
- self.num_connections += 1
- log.debug('Starting NTLM HTTPS connection no. %d: https://%s%s',
- self.num_connections, self.host, self.authurl)
-
- headers = {'Connection': 'Keep-Alive'}
- req_header = 'Authorization'
- resp_header = 'www-authenticate'
-
- conn = HTTPSConnection(host=self.host, port=self.port)
-
- # Send negotiation message
- headers[req_header] = (
- 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(self.rawuser))
- log.debug('Request headers: %s', headers)
- conn.request('GET', self.authurl, None, headers)
- res = conn.getresponse()
- reshdr = dict(res.getheaders())
- log.debug('Response status: %s %s', res.status, res.reason)
- log.debug('Response headers: %s', reshdr)
- log.debug('Response data: %s [...]', res.read(100))
-
- # Remove the reference to the socket, so that it can not be closed by
- # the response object (we want to keep the socket open)
- res.fp = None
-
- # Server should respond with a challenge message
- auth_header_values = reshdr[resp_header].split(', ')
- auth_header_value = None
- for s in auth_header_values:
- if s[:5] == 'NTLM ':
- auth_header_value = s[5:]
- if auth_header_value is None:
- raise Exception('Unexpected %s response header: %s' %
- (resp_header, reshdr[resp_header]))
-
- # Send authentication message
- ServerChallenge, NegotiateFlags = \
- ntlm.parse_NTLM_CHALLENGE_MESSAGE(auth_header_value)
- auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge,
- self.user,
- self.domain,
- self.pw,
- NegotiateFlags)
- headers[req_header] = 'NTLM %s' % auth_msg
- log.debug('Request headers: %s', headers)
- conn.request('GET', self.authurl, None, headers)
- res = conn.getresponse()
- log.debug('Response status: %s %s', res.status, res.reason)
- log.debug('Response headers: %s', dict(res.getheaders()))
- log.debug('Response data: %s [...]', res.read()[:100])
- if res.status != 200:
- if res.status == 401:
- raise Exception('Server rejected request: wrong '
- 'username or password')
- raise Exception('Wrong server response: %s %s' %
- (res.status, res.reason))
-
- res.fp = None
- log.debug('Connection established')
- return conn
-
- def urlopen(self, method, url, body=None, headers=None, retries=3,
- redirect=True, assert_same_host=True):
- if headers is None:
- headers = {}
- headers['Connection'] = 'Keep-Alive'
- return super(NTLMConnectionPool, self).urlopen(method, url, body,
- headers, retries,
- redirect,
- assert_same_host)
diff --git a/python/urllib3/contrib/pyopenssl.py b/python/urllib3/contrib/pyopenssl.py
deleted file mode 100644
index 7c0e946..0000000
--- a/python/urllib3/contrib/pyopenssl.py
+++ /dev/null
@@ -1,466 +0,0 @@
-"""
-SSL with SNI_-support for Python 2. Follow these instructions if you would
-like to verify SSL certificates in Python 2. Note, the default libraries do
-*not* do certificate checking; you need to do additional work to validate
-certificates yourself.
-
-This needs the following packages installed:
-
-* pyOpenSSL (tested with 16.0.0)
-* cryptography (minimum 1.3.4, from pyopenssl)
-* idna (minimum 2.0, from cryptography)
-
-However, pyopenssl depends on cryptography, which depends on idna, so while we
-use all three directly here we end up having relatively few packages required.
-
-You can install them with the following command:
-
- pip install pyopenssl cryptography idna
-
-To activate certificate checking, call
-:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
-before you begin making HTTP requests. This can be done in a ``sitecustomize``
-module, or at any other time before your application begins using ``urllib3``,
-like this::
-
- try:
- import urllib3.contrib.pyopenssl
- urllib3.contrib.pyopenssl.inject_into_urllib3()
- except ImportError:
- pass
-
-Now you can use :mod:`urllib3` as you normally would, and it will support SNI
-when the required modules are installed.
-
-Activating this module also has the positive side effect of disabling SSL/TLS
-compression in Python 2 (see `CRIME attack`_).
-
-If you want to configure the default list of supported cipher suites, you can
-set the ``urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST`` variable.
-
-.. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication
-.. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit)
-"""
-from __future__ import absolute_import
-
-import OpenSSL.SSL
-from cryptography import x509
-from cryptography.hazmat.backends.openssl import backend as openssl_backend
-from cryptography.hazmat.backends.openssl.x509 import _Certificate
-try:
- from cryptography.x509 import UnsupportedExtension
-except ImportError:
- # UnsupportedExtension is gone in cryptography >= 2.1.0
- class UnsupportedExtension(Exception):
- pass
-
-from socket import timeout, error as SocketError
-from io import BytesIO
-
-try: # Platform-specific: Python 2
- from socket import _fileobject
-except ImportError: # Platform-specific: Python 3
- _fileobject = None
- from ..packages.backports.makefile import backport_makefile
-
-import logging
-import ssl
-from ..packages import six
-import sys
-
-from .. import util
-
-__all__ = ['inject_into_urllib3', 'extract_from_urllib3']
-
-# SNI always works.
-HAS_SNI = True
-
-# Map from urllib3 to PyOpenSSL compatible parameter-values.
-_openssl_versions = {
- ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
- ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
-}
-
-if hasattr(ssl, 'PROTOCOL_TLSv1_1') and hasattr(OpenSSL.SSL, 'TLSv1_1_METHOD'):
- _openssl_versions[ssl.PROTOCOL_TLSv1_1] = OpenSSL.SSL.TLSv1_1_METHOD
-
-if hasattr(ssl, 'PROTOCOL_TLSv1_2') and hasattr(OpenSSL.SSL, 'TLSv1_2_METHOD'):
- _openssl_versions[ssl.PROTOCOL_TLSv1_2] = OpenSSL.SSL.TLSv1_2_METHOD
-
-try:
- _openssl_versions.update({ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD})
-except AttributeError:
- pass
-
-_stdlib_to_openssl_verify = {
- ssl.CERT_NONE: OpenSSL.SSL.VERIFY_NONE,
- ssl.CERT_OPTIONAL: OpenSSL.SSL.VERIFY_PEER,
- ssl.CERT_REQUIRED:
- OpenSSL.SSL.VERIFY_PEER + OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
-}
-_openssl_to_stdlib_verify = dict(
- (v, k) for k, v in _stdlib_to_openssl_verify.items()
-)
-
-# OpenSSL will only write 16K at a time
-SSL_WRITE_BLOCKSIZE = 16384
-
-orig_util_HAS_SNI = util.HAS_SNI
-orig_util_SSLContext = util.ssl_.SSLContext
-
-
-log = logging.getLogger(__name__)
-
-
-def inject_into_urllib3():
- 'Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.'
-
- _validate_dependencies_met()
-
- util.ssl_.SSLContext = PyOpenSSLContext
- util.HAS_SNI = HAS_SNI
- util.ssl_.HAS_SNI = HAS_SNI
- util.IS_PYOPENSSL = True
- util.ssl_.IS_PYOPENSSL = True
-
-
-def extract_from_urllib3():
- 'Undo monkey-patching by :func:`inject_into_urllib3`.'
-
- util.ssl_.SSLContext = orig_util_SSLContext
- util.HAS_SNI = orig_util_HAS_SNI
- util.ssl_.HAS_SNI = orig_util_HAS_SNI
- util.IS_PYOPENSSL = False
- util.ssl_.IS_PYOPENSSL = False
-
-
-def _validate_dependencies_met():
- """
- Verifies that PyOpenSSL's package-level dependencies have been met.
- Throws `ImportError` if they are not met.
- """
- # Method added in `cryptography==1.1`; not available in older versions
- from cryptography.x509.extensions import Extensions
- if getattr(Extensions, "get_extension_for_class", None) is None:
- raise ImportError("'cryptography' module missing required functionality. "
- "Try upgrading to v1.3.4 or newer.")
-
- # pyOpenSSL 0.14 and above use cryptography for OpenSSL bindings. The _x509
- # attribute is only present on those versions.
- from OpenSSL.crypto import X509
- x509 = X509()
- if getattr(x509, "_x509", None) is None:
- raise ImportError("'pyOpenSSL' module missing required functionality. "
- "Try upgrading to v0.14 or newer.")
-
-
-def _dnsname_to_stdlib(name):
- """
- Converts a dNSName SubjectAlternativeName field to the form used by the
- standard library on the given Python version.
-
- Cryptography produces a dNSName as a unicode string that was idna-decoded
- from ASCII bytes. We need to idna-encode that string to get it back, and
- then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
- uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).
-
- If the name cannot be idna-encoded then we return None signalling that
- the name given should be skipped.
- """
- def idna_encode(name):
- """
- Borrowed wholesale from the Python Cryptography Project. It turns out
- that we can't just safely call `idna.encode`: it can explode for
- wildcard names. This avoids that problem.
- """
- import idna
-
- try:
- for prefix in [u'*.', u'.']:
- if name.startswith(prefix):
- name = name[len(prefix):]
- return prefix.encode('ascii') + idna.encode(name)
- return idna.encode(name)
- except idna.core.IDNAError:
- return None
-
- name = idna_encode(name)
- if name is None:
- return None
- elif sys.version_info >= (3, 0):
- name = name.decode('utf-8')
- return name
-
-
-def get_subj_alt_name(peer_cert):
- """
- Given an PyOpenSSL certificate, provides all the subject alternative names.
- """
- # Pass the cert to cryptography, which has much better APIs for this.
- if hasattr(peer_cert, "to_cryptography"):
- cert = peer_cert.to_cryptography()
- else:
- # This is technically using private APIs, but should work across all
- # relevant versions before PyOpenSSL got a proper API for this.
- cert = _Certificate(openssl_backend, peer_cert._x509)
-
- # We want to find the SAN extension. Ask Cryptography to locate it (it's
- # faster than looping in Python)
- try:
- ext = cert.extensions.get_extension_for_class(
- x509.SubjectAlternativeName
- ).value
- except x509.ExtensionNotFound:
- # No such extension, return the empty list.
- return []
- except (x509.DuplicateExtension, UnsupportedExtension,
- x509.UnsupportedGeneralNameType, UnicodeError) as e:
- # A problem has been found with the quality of the certificate. Assume
- # no SAN field is present.
- log.warning(
- "A problem was encountered with the certificate that prevented "
- "urllib3 from finding the SubjectAlternativeName field. This can "
- "affect certificate validation. The error was %s",
- e,
- )
- return []
-
- # We want to return dNSName and iPAddress fields. We need to cast the IPs
- # back to strings because the match_hostname function wants them as
- # strings.
- # Sadly the DNS names need to be idna encoded and then, on Python 3, UTF-8
- # decoded. This is pretty frustrating, but that's what the standard library
- # does with certificates, and so we need to attempt to do the same.
- # We also want to skip over names which cannot be idna encoded.
- names = [
- ('DNS', name) for name in map(_dnsname_to_stdlib, ext.get_values_for_type(x509.DNSName))
- if name is not None
- ]
- names.extend(
- ('IP Address', str(name))
- for name in ext.get_values_for_type(x509.IPAddress)
- )
-
- return names
-
-
-class WrappedSocket(object):
- '''API-compatibility wrapper for Python OpenSSL's Connection-class.
-
- Note: _makefile_refs, _drop() and _reuse() are needed for the garbage
- collector of pypy.
- '''
-
- def __init__(self, connection, socket, suppress_ragged_eofs=True):
- self.connection = connection
- self.socket = socket
- self.suppress_ragged_eofs = suppress_ragged_eofs
- self._makefile_refs = 0
- self._closed = False
-
- def fileno(self):
- return self.socket.fileno()
-
- # Copy-pasted from Python 3.5 source code
- def _decref_socketios(self):
- if self._makefile_refs > 0:
- self._makefile_refs -= 1
- if self._closed:
- self.close()
-
- def recv(self, *args, **kwargs):
- try:
- data = self.connection.recv(*args, **kwargs)
- except OpenSSL.SSL.SysCallError as e:
- if self.suppress_ragged_eofs and e.args == (-1, 'Unexpected EOF'):
- return b''
- else:
- raise SocketError(str(e))
- except OpenSSL.SSL.ZeroReturnError as e:
- if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
- return b''
- else:
- raise
- except OpenSSL.SSL.WantReadError:
- if not util.wait_for_read(self.socket, self.socket.gettimeout()):
- raise timeout('The read operation timed out')
- else:
- return self.recv(*args, **kwargs)
- else:
- return data
-
- def recv_into(self, *args, **kwargs):
- try:
- return self.connection.recv_into(*args, **kwargs)
- except OpenSSL.SSL.SysCallError as e:
- if self.suppress_ragged_eofs and e.args == (-1, 'Unexpected EOF'):
- return 0
- else:
- raise SocketError(str(e))
- except OpenSSL.SSL.ZeroReturnError as e:
- if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
- return 0
- else:
- raise
- except OpenSSL.SSL.WantReadError:
- if not util.wait_for_read(self.socket, self.socket.gettimeout()):
- raise timeout('The read operation timed out')
- else:
- return self.recv_into(*args, **kwargs)
-
- def settimeout(self, timeout):
- return self.socket.settimeout(timeout)
-
- def _send_until_done(self, data):
- while True:
- try:
- return self.connection.send(data)
- except OpenSSL.SSL.WantWriteError:
- if not util.wait_for_write(self.socket, self.socket.gettimeout()):
- raise timeout()
- continue
- except OpenSSL.SSL.SysCallError as e:
- raise SocketError(str(e))
-
- def sendall(self, data):
- total_sent = 0
- while total_sent < len(data):
- sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
- total_sent += sent
-
- def shutdown(self):
- # FIXME rethrow compatible exceptions should we ever use this
- self.connection.shutdown()
-
- def close(self):
- if self._makefile_refs < 1:
- try:
- self._closed = True
- return self.connection.close()
- except OpenSSL.SSL.Error:
- return
- else:
- self._makefile_refs -= 1
-
- def getpeercert(self, binary_form=False):
- x509 = self.connection.get_peer_certificate()
-
- if not x509:
- return x509
-
- if binary_form:
- return OpenSSL.crypto.dump_certificate(
- OpenSSL.crypto.FILETYPE_ASN1,
- x509)
-
- return {
- 'subject': (
- (('commonName', x509.get_subject().CN),),
- ),
- 'subjectAltName': get_subj_alt_name(x509)
- }
-
- def _reuse(self):
- self._makefile_refs += 1
-
- def _drop(self):
- if self._makefile_refs < 1:
- self.close()
- else:
- self._makefile_refs -= 1
-
-
-if _fileobject: # Platform-specific: Python 2
- def makefile(self, mode, bufsize=-1):
- self._makefile_refs += 1
- return _fileobject(self, mode, bufsize, close=True)
-else: # Platform-specific: Python 3
- makefile = backport_makefile
-
-WrappedSocket.makefile = makefile
-
-
-class PyOpenSSLContext(object):
- """
- I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible
- for translating the interface of the standard library ``SSLContext`` object
- to calls into PyOpenSSL.
- """
- def __init__(self, protocol):
- self.protocol = _openssl_versions[protocol]
- self._ctx = OpenSSL.SSL.Context(self.protocol)
- self._options = 0
- self.check_hostname = False
-
- @property
- def options(self):
- return self._options
-
- @options.setter
- def options(self, value):
- self._options = value
- self._ctx.set_options(value)
-
- @property
- def verify_mode(self):
- return _openssl_to_stdlib_verify[self._ctx.get_verify_mode()]
-
- @verify_mode.setter
- def verify_mode(self, value):
- self._ctx.set_verify(
- _stdlib_to_openssl_verify[value],
- _verify_callback
- )
-
- def set_default_verify_paths(self):
- self._ctx.set_default_verify_paths()
-
- def set_ciphers(self, ciphers):
- if isinstance(ciphers, six.text_type):
- ciphers = ciphers.encode('utf-8')
- self._ctx.set_cipher_list(ciphers)
-
- def load_verify_locations(self, cafile=None, capath=None, cadata=None):
- if cafile is not None:
- cafile = cafile.encode('utf-8')
- if capath is not None:
- capath = capath.encode('utf-8')
- self._ctx.load_verify_locations(cafile, capath)
- if cadata is not None:
- self._ctx.load_verify_locations(BytesIO(cadata))
-
- def load_cert_chain(self, certfile, keyfile=None, password=None):
- self._ctx.use_certificate_chain_file(certfile)
- if password is not None:
- self._ctx.set_passwd_cb(lambda max_length, prompt_twice, userdata: password)
- self._ctx.use_privatekey_file(keyfile or certfile)
-
- def wrap_socket(self, sock, server_side=False,
- do_handshake_on_connect=True, suppress_ragged_eofs=True,
- server_hostname=None):
- cnx = OpenSSL.SSL.Connection(self._ctx, sock)
-
- if isinstance(server_hostname, six.text_type): # Platform-specific: Python 3
- server_hostname = server_hostname.encode('utf-8')
-
- if server_hostname is not None:
- cnx.set_tlsext_host_name(server_hostname)
-
- cnx.set_connect_state()
-
- while True:
- try:
- cnx.do_handshake()
- except OpenSSL.SSL.WantReadError:
- if not util.wait_for_read(sock, sock.gettimeout()):
- raise timeout('select timed out')
- continue
- except OpenSSL.SSL.Error as e:
- raise ssl.SSLError('bad handshake: %r' % e)
- break
-
- return WrappedSocket(cnx, sock)
-
-
-def _verify_callback(cnx, x509, err_no, err_depth, return_code):
- return err_no == 0
diff --git a/python/urllib3/contrib/securetransport.py b/python/urllib3/contrib/securetransport.py
deleted file mode 100644
index 77cb59e..0000000
--- a/python/urllib3/contrib/securetransport.py
+++ /dev/null
@@ -1,804 +0,0 @@
-"""
-SecureTranport support for urllib3 via ctypes.
-
-This makes platform-native TLS available to urllib3 users on macOS without the
-use of a compiler. This is an important feature because the Python Package
-Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL
-that ships with macOS is not capable of doing TLSv1.2. The only way to resolve
-this is to give macOS users an alternative solution to the problem, and that
-solution is to use SecureTransport.
-
-We use ctypes here because this solution must not require a compiler. That's
-because pip is not allowed to require a compiler either.
-
-This is not intended to be a seriously long-term solution to this problem.
-The hope is that PEP 543 will eventually solve this issue for us, at which
-point we can retire this contrib module. But in the short term, we need to
-solve the impending tire fire that is Python on Mac without this kind of
-contrib module. So...here we are.
-
-To use this module, simply import and inject it::
-
- import urllib3.contrib.securetransport
- urllib3.contrib.securetransport.inject_into_urllib3()
-
-Happy TLSing!
-"""
-from __future__ import absolute_import
-
-import contextlib
-import ctypes
-import errno
-import os.path
-import shutil
-import socket
-import ssl
-import threading
-import weakref
-
-from .. import util
-from ._securetransport.bindings import (
- Security, SecurityConst, CoreFoundation
-)
-from ._securetransport.low_level import (
- _assert_no_error, _cert_array_from_pem, _temporary_keychain,
- _load_client_cert_chain
-)
-
-try: # Platform-specific: Python 2
- from socket import _fileobject
-except ImportError: # Platform-specific: Python 3
- _fileobject = None
- from ..packages.backports.makefile import backport_makefile
-
-__all__ = ['inject_into_urllib3', 'extract_from_urllib3']
-
-# SNI always works
-HAS_SNI = True
-
-orig_util_HAS_SNI = util.HAS_SNI
-orig_util_SSLContext = util.ssl_.SSLContext
-
-# This dictionary is used by the read callback to obtain a handle to the
-# calling wrapped socket. This is a pretty silly approach, but for now it'll
-# do. I feel like I should be able to smuggle a handle to the wrapped socket
-# directly in the SSLConnectionRef, but for now this approach will work I
-# guess.
-#
-# We need to lock around this structure for inserts, but we don't do it for
-# reads/writes in the callbacks. The reasoning here goes as follows:
-#
-# 1. It is not possible to call into the callbacks before the dictionary is
-# populated, so once in the callback the id must be in the dictionary.
-# 2. The callbacks don't mutate the dictionary, they only read from it, and
-# so cannot conflict with any of the insertions.
-#
-# This is good: if we had to lock in the callbacks we'd drastically slow down
-# the performance of this code.
-_connection_refs = weakref.WeakValueDictionary()
-_connection_ref_lock = threading.Lock()
-
-# Limit writes to 16kB. This is OpenSSL's limit, but we'll cargo-cult it over
-# for no better reason than we need *a* limit, and this one is right there.
-SSL_WRITE_BLOCKSIZE = 16384
-
-# This is our equivalent of util.ssl_.DEFAULT_CIPHERS, but expanded out to
-# individual cipher suites. We need to do this because this is how
-# SecureTransport wants them.
-CIPHER_SUITES = [
- SecurityConst.TLS_AES_256_GCM_SHA384,
- SecurityConst.TLS_CHACHA20_POLY1305_SHA256,
- SecurityConst.TLS_AES_128_GCM_SHA256,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
- SecurityConst.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384,
- SecurityConst.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
- SecurityConst.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,
- SecurityConst.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
- SecurityConst.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
- SecurityConst.TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,
- SecurityConst.TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
- SecurityConst.TLS_DHE_DSS_WITH_AES_256_CBC_SHA,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
- SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
- SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
- SecurityConst.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
- SecurityConst.TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,
- SecurityConst.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
- SecurityConst.TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
- SecurityConst.TLS_RSA_WITH_AES_256_GCM_SHA384,
- SecurityConst.TLS_RSA_WITH_AES_128_GCM_SHA256,
- SecurityConst.TLS_RSA_WITH_AES_256_CBC_SHA256,
- SecurityConst.TLS_RSA_WITH_AES_128_CBC_SHA256,
- SecurityConst.TLS_RSA_WITH_AES_256_CBC_SHA,
- SecurityConst.TLS_RSA_WITH_AES_128_CBC_SHA,
-]
-
-# Basically this is simple: for PROTOCOL_SSLv23 we turn it into a low of
-# TLSv1 and a high of TLSv1.2. For everything else, we pin to that version.
-_protocol_to_min_max = {
- ssl.PROTOCOL_SSLv23: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12),
-}
-
-if hasattr(ssl, "PROTOCOL_SSLv2"):
- _protocol_to_min_max[ssl.PROTOCOL_SSLv2] = (
- SecurityConst.kSSLProtocol2, SecurityConst.kSSLProtocol2
- )
-if hasattr(ssl, "PROTOCOL_SSLv3"):
- _protocol_to_min_max[ssl.PROTOCOL_SSLv3] = (
- SecurityConst.kSSLProtocol3, SecurityConst.kSSLProtocol3
- )
-if hasattr(ssl, "PROTOCOL_TLSv1"):
- _protocol_to_min_max[ssl.PROTOCOL_TLSv1] = (
- SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol1
- )
-if hasattr(ssl, "PROTOCOL_TLSv1_1"):
- _protocol_to_min_max[ssl.PROTOCOL_TLSv1_1] = (
- SecurityConst.kTLSProtocol11, SecurityConst.kTLSProtocol11
- )
-if hasattr(ssl, "PROTOCOL_TLSv1_2"):
- _protocol_to_min_max[ssl.PROTOCOL_TLSv1_2] = (
- SecurityConst.kTLSProtocol12, SecurityConst.kTLSProtocol12
- )
-if hasattr(ssl, "PROTOCOL_TLS"):
- _protocol_to_min_max[ssl.PROTOCOL_TLS] = _protocol_to_min_max[ssl.PROTOCOL_SSLv23]
-
-
-def inject_into_urllib3():
- """
- Monkey-patch urllib3 with SecureTransport-backed SSL-support.
- """
- util.ssl_.SSLContext = SecureTransportContext
- util.HAS_SNI = HAS_SNI
- util.ssl_.HAS_SNI = HAS_SNI
- util.IS_SECURETRANSPORT = True
- util.ssl_.IS_SECURETRANSPORT = True
-
-
-def extract_from_urllib3():
- """
- Undo monkey-patching by :func:`inject_into_urllib3`.
- """
- util.ssl_.SSLContext = orig_util_SSLContext
- util.HAS_SNI = orig_util_HAS_SNI
- util.ssl_.HAS_SNI = orig_util_HAS_SNI
- util.IS_SECURETRANSPORT = False
- util.ssl_.IS_SECURETRANSPORT = False
-
-
-def _read_callback(connection_id, data_buffer, data_length_pointer):
- """
- SecureTransport read callback. This is called by ST to request that data
- be returned from the socket.
- """
- wrapped_socket = None
- try:
- wrapped_socket = _connection_refs.get(connection_id)
- if wrapped_socket is None:
- return SecurityConst.errSSLInternal
- base_socket = wrapped_socket.socket
-
- requested_length = data_length_pointer[0]
-
- timeout = wrapped_socket.gettimeout()
- error = None
- read_count = 0
-
- try:
- while read_count < requested_length:
- if timeout is None or timeout >= 0:
- if not util.wait_for_read(base_socket, timeout):
- raise socket.error(errno.EAGAIN, 'timed out')
-
- remaining = requested_length - read_count
- buffer = (ctypes.c_char * remaining).from_address(
- data_buffer + read_count
- )
- chunk_size = base_socket.recv_into(buffer, remaining)
- read_count += chunk_size
- if not chunk_size:
- if not read_count:
- return SecurityConst.errSSLClosedGraceful
- break
- except (socket.error) as e:
- error = e.errno
-
- if error is not None and error != errno.EAGAIN:
- data_length_pointer[0] = read_count
- if error == errno.ECONNRESET or error == errno.EPIPE:
- return SecurityConst.errSSLClosedAbort
- raise
-
- data_length_pointer[0] = read_count
-
- if read_count != requested_length:
- return SecurityConst.errSSLWouldBlock
-
- return 0
- except Exception as e:
- if wrapped_socket is not None:
- wrapped_socket._exception = e
- return SecurityConst.errSSLInternal
-
-
-def _write_callback(connection_id, data_buffer, data_length_pointer):
- """
- SecureTransport write callback. This is called by ST to request that data
- actually be sent on the network.
- """
- wrapped_socket = None
- try:
- wrapped_socket = _connection_refs.get(connection_id)
- if wrapped_socket is None:
- return SecurityConst.errSSLInternal
- base_socket = wrapped_socket.socket
-
- bytes_to_write = data_length_pointer[0]
- data = ctypes.string_at(data_buffer, bytes_to_write)
-
- timeout = wrapped_socket.gettimeout()
- error = None
- sent = 0
-
- try:
- while sent < bytes_to_write:
- if timeout is None or timeout >= 0:
- if not util.wait_for_write(base_socket, timeout):
- raise socket.error(errno.EAGAIN, 'timed out')
- chunk_sent = base_socket.send(data)
- sent += chunk_sent
-
- # This has some needless copying here, but I'm not sure there's
- # much value in optimising this data path.
- data = data[chunk_sent:]
- except (socket.error) as e:
- error = e.errno
-
- if error is not None and error != errno.EAGAIN:
- data_length_pointer[0] = sent
- if error == errno.ECONNRESET or error == errno.EPIPE:
- return SecurityConst.errSSLClosedAbort
- raise
-
- data_length_pointer[0] = sent
-
- if sent != bytes_to_write:
- return SecurityConst.errSSLWouldBlock
-
- return 0
- except Exception as e:
- if wrapped_socket is not None:
- wrapped_socket._exception = e
- return SecurityConst.errSSLInternal
-
-
-# We need to keep these two objects references alive: if they get GC'd while
-# in use then SecureTransport could attempt to call a function that is in freed
-# memory. That would be...uh...bad. Yeah, that's the word. Bad.
-_read_callback_pointer = Security.SSLReadFunc(_read_callback)
-_write_callback_pointer = Security.SSLWriteFunc(_write_callback)
-
-
-class WrappedSocket(object):
- """
- API-compatibility wrapper for Python's OpenSSL wrapped socket object.
-
- Note: _makefile_refs, _drop(), and _reuse() are needed for the garbage
- collector of PyPy.
- """
- def __init__(self, socket):
- self.socket = socket
- self.context = None
- self._makefile_refs = 0
- self._closed = False
- self._exception = None
- self._keychain = None
- self._keychain_dir = None
- self._client_cert_chain = None
-
- # We save off the previously-configured timeout and then set it to
- # zero. This is done because we use select and friends to handle the
- # timeouts, but if we leave the timeout set on the lower socket then
- # Python will "kindly" call select on that socket again for us. Avoid
- # that by forcing the timeout to zero.
- self._timeout = self.socket.gettimeout()
- self.socket.settimeout(0)
-
- @contextlib.contextmanager
- def _raise_on_error(self):
- """
- A context manager that can be used to wrap calls that do I/O from
- SecureTransport. If any of the I/O callbacks hit an exception, this
- context manager will correctly propagate the exception after the fact.
- This avoids silently swallowing those exceptions.
-
- It also correctly forces the socket closed.
- """
- self._exception = None
-
- # We explicitly don't catch around this yield because in the unlikely
- # event that an exception was hit in the block we don't want to swallow
- # it.
- yield
- if self._exception is not None:
- exception, self._exception = self._exception, None
- self.close()
- raise exception
-
- def _set_ciphers(self):
- """
- Sets up the allowed ciphers. By default this matches the set in
- util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
- custom and doesn't allow changing at this time, mostly because parsing
- OpenSSL cipher strings is going to be a freaking nightmare.
- """
- ciphers = (Security.SSLCipherSuite * len(CIPHER_SUITES))(*CIPHER_SUITES)
- result = Security.SSLSetEnabledCiphers(
- self.context, ciphers, len(CIPHER_SUITES)
- )
- _assert_no_error(result)
-
- def _custom_validate(self, verify, trust_bundle):
- """
- Called when we have set custom validation. We do this in two cases:
- first, when cert validation is entirely disabled; and second, when
- using a custom trust DB.
- """
- # If we disabled cert validation, just say: cool.
- if not verify:
- return
-
- # We want data in memory, so load it up.
- if os.path.isfile(trust_bundle):
- with open(trust_bundle, 'rb') as f:
- trust_bundle = f.read()
-
- cert_array = None
- trust = Security.SecTrustRef()
-
- try:
- # Get a CFArray that contains the certs we want.
- cert_array = _cert_array_from_pem(trust_bundle)
-
- # Ok, now the hard part. We want to get the SecTrustRef that ST has
- # created for this connection, shove our CAs into it, tell ST to
- # ignore everything else it knows, and then ask if it can build a
- # chain. This is a buuuunch of code.
- result = Security.SSLCopyPeerTrust(
- self.context, ctypes.byref(trust)
- )
- _assert_no_error(result)
- if not trust:
- raise ssl.SSLError("Failed to copy trust reference")
-
- result = Security.SecTrustSetAnchorCertificates(trust, cert_array)
- _assert_no_error(result)
-
- result = Security.SecTrustSetAnchorCertificatesOnly(trust, True)
- _assert_no_error(result)
-
- trust_result = Security.SecTrustResultType()
- result = Security.SecTrustEvaluate(
- trust, ctypes.byref(trust_result)
- )
- _assert_no_error(result)
- finally:
- if trust:
- CoreFoundation.CFRelease(trust)
-
- if cert_array is not None:
- CoreFoundation.CFRelease(cert_array)
-
- # Ok, now we can look at what the result was.
- successes = (
- SecurityConst.kSecTrustResultUnspecified,
- SecurityConst.kSecTrustResultProceed
- )
- if trust_result.value not in successes:
- raise ssl.SSLError(
- "certificate verify failed, error code: %d" %
- trust_result.value
- )
-
- def handshake(self,
- server_hostname,
- verify,
- trust_bundle,
- min_version,
- max_version,
- client_cert,
- client_key,
- client_key_passphrase):
- """
- Actually performs the TLS handshake. This is run automatically by
- wrapped socket, and shouldn't be needed in user code.
- """
- # First, we do the initial bits of connection setup. We need to create
- # a context, set its I/O funcs, and set the connection reference.
- self.context = Security.SSLCreateContext(
- None, SecurityConst.kSSLClientSide, SecurityConst.kSSLStreamType
- )
- result = Security.SSLSetIOFuncs(
- self.context, _read_callback_pointer, _write_callback_pointer
- )
- _assert_no_error(result)
-
- # Here we need to compute the handle to use. We do this by taking the
- # id of self modulo 2**31 - 1. If this is already in the dictionary, we
- # just keep incrementing by one until we find a free space.
- with _connection_ref_lock:
- handle = id(self) % 2147483647
- while handle in _connection_refs:
- handle = (handle + 1) % 2147483647
- _connection_refs[handle] = self
-
- result = Security.SSLSetConnection(self.context, handle)
- _assert_no_error(result)
-
- # If we have a server hostname, we should set that too.
- if server_hostname:
- if not isinstance(server_hostname, bytes):
- server_hostname = server_hostname.encode('utf-8')
-
- result = Security.SSLSetPeerDomainName(
- self.context, server_hostname, len(server_hostname)
- )
- _assert_no_error(result)
-
- # Setup the ciphers.
- self._set_ciphers()
-
- # Set the minimum and maximum TLS versions.
- result = Security.SSLSetProtocolVersionMin(self.context, min_version)
- _assert_no_error(result)
- result = Security.SSLSetProtocolVersionMax(self.context, max_version)
- _assert_no_error(result)
-
- # If there's a trust DB, we need to use it. We do that by telling
- # SecureTransport to break on server auth. We also do that if we don't
- # want to validate the certs at all: we just won't actually do any
- # authing in that case.
- if not verify or trust_bundle is not None:
- result = Security.SSLSetSessionOption(
- self.context,
- SecurityConst.kSSLSessionOptionBreakOnServerAuth,
- True
- )
- _assert_no_error(result)
-
- # If there's a client cert, we need to use it.
- if client_cert:
- self._keychain, self._keychain_dir = _temporary_keychain()
- self._client_cert_chain = _load_client_cert_chain(
- self._keychain, client_cert, client_key
- )
- result = Security.SSLSetCertificate(
- self.context, self._client_cert_chain
- )
- _assert_no_error(result)
-
- while True:
- with self._raise_on_error():
- result = Security.SSLHandshake(self.context)
-
- if result == SecurityConst.errSSLWouldBlock:
- raise socket.timeout("handshake timed out")
- elif result == SecurityConst.errSSLServerAuthCompleted:
- self._custom_validate(verify, trust_bundle)
- continue
- else:
- _assert_no_error(result)
- break
-
- def fileno(self):
- return self.socket.fileno()
-
- # Copy-pasted from Python 3.5 source code
- def _decref_socketios(self):
- if self._makefile_refs > 0:
- self._makefile_refs -= 1
- if self._closed:
- self.close()
-
- def recv(self, bufsiz):
- buffer = ctypes.create_string_buffer(bufsiz)
- bytes_read = self.recv_into(buffer, bufsiz)
- data = buffer[:bytes_read]
- return data
-
- def recv_into(self, buffer, nbytes=None):
- # Read short on EOF.
- if self._closed:
- return 0
-
- if nbytes is None:
- nbytes = len(buffer)
-
- buffer = (ctypes.c_char * nbytes).from_buffer(buffer)
- processed_bytes = ctypes.c_size_t(0)
-
- with self._raise_on_error():
- result = Security.SSLRead(
- self.context, buffer, nbytes, ctypes.byref(processed_bytes)
- )
-
- # There are some result codes that we want to treat as "not always
- # errors". Specifically, those are errSSLWouldBlock,
- # errSSLClosedGraceful, and errSSLClosedNoNotify.
- if (result == SecurityConst.errSSLWouldBlock):
- # If we didn't process any bytes, then this was just a time out.
- # However, we can get errSSLWouldBlock in situations when we *did*
- # read some data, and in those cases we should just read "short"
- # and return.
- if processed_bytes.value == 0:
- # Timed out, no data read.
- raise socket.timeout("recv timed out")
- elif result in (SecurityConst.errSSLClosedGraceful, SecurityConst.errSSLClosedNoNotify):
- # The remote peer has closed this connection. We should do so as
- # well. Note that we don't actually return here because in
- # principle this could actually be fired along with return data.
- # It's unlikely though.
- self.close()
- else:
- _assert_no_error(result)
-
- # Ok, we read and probably succeeded. We should return whatever data
- # was actually read.
- return processed_bytes.value
-
- def settimeout(self, timeout):
- self._timeout = timeout
-
- def gettimeout(self):
- return self._timeout
-
- def send(self, data):
- processed_bytes = ctypes.c_size_t(0)
-
- with self._raise_on_error():
- result = Security.SSLWrite(
- self.context, data, len(data), ctypes.byref(processed_bytes)
- )
-
- if result == SecurityConst.errSSLWouldBlock and processed_bytes.value == 0:
- # Timed out
- raise socket.timeout("send timed out")
- else:
- _assert_no_error(result)
-
- # We sent, and probably succeeded. Tell them how much we sent.
- return processed_bytes.value
-
- def sendall(self, data):
- total_sent = 0
- while total_sent < len(data):
- sent = self.send(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
- total_sent += sent
-
- def shutdown(self):
- with self._raise_on_error():
- Security.SSLClose(self.context)
-
- def close(self):
- # TODO: should I do clean shutdown here? Do I have to?
- if self._makefile_refs < 1:
- self._closed = True
- if self.context:
- CoreFoundation.CFRelease(self.context)
- self.context = None
- if self._client_cert_chain:
- CoreFoundation.CFRelease(self._client_cert_chain)
- self._client_cert_chain = None
- if self._keychain:
- Security.SecKeychainDelete(self._keychain)
- CoreFoundation.CFRelease(self._keychain)
- shutil.rmtree(self._keychain_dir)
- self._keychain = self._keychain_dir = None
- return self.socket.close()
- else:
- self._makefile_refs -= 1
-
- def getpeercert(self, binary_form=False):
- # Urgh, annoying.
- #
- # Here's how we do this:
- #
- # 1. Call SSLCopyPeerTrust to get hold of the trust object for this
- # connection.
- # 2. Call SecTrustGetCertificateAtIndex for index 0 to get the leaf.
- # 3. To get the CN, call SecCertificateCopyCommonName and process that
- # string so that it's of the appropriate type.
- # 4. To get the SAN, we need to do something a bit more complex:
- # a. Call SecCertificateCopyValues to get the data, requesting
- # kSecOIDSubjectAltName.
- # b. Mess about with this dictionary to try to get the SANs out.
- #
- # This is gross. Really gross. It's going to be a few hundred LoC extra
- # just to repeat something that SecureTransport can *already do*. So my
- # operating assumption at this time is that what we want to do is
- # instead to just flag to urllib3 that it shouldn't do its own hostname
- # validation when using SecureTransport.
- if not binary_form:
- raise ValueError(
- "SecureTransport only supports dumping binary certs"
- )
- trust = Security.SecTrustRef()
- certdata = None
- der_bytes = None
-
- try:
- # Grab the trust store.
- result = Security.SSLCopyPeerTrust(
- self.context, ctypes.byref(trust)
- )
- _assert_no_error(result)
- if not trust:
- # Probably we haven't done the handshake yet. No biggie.
- return None
-
- cert_count = Security.SecTrustGetCertificateCount(trust)
- if not cert_count:
- # Also a case that might happen if we haven't handshaked.
- # Handshook? Handshaken?
- return None
-
- leaf = Security.SecTrustGetCertificateAtIndex(trust, 0)
- assert leaf
-
- # Ok, now we want the DER bytes.
- certdata = Security.SecCertificateCopyData(leaf)
- assert certdata
-
- data_length = CoreFoundation.CFDataGetLength(certdata)
- data_buffer = CoreFoundation.CFDataGetBytePtr(certdata)
- der_bytes = ctypes.string_at(data_buffer, data_length)
- finally:
- if certdata:
- CoreFoundation.CFRelease(certdata)
- if trust:
- CoreFoundation.CFRelease(trust)
-
- return der_bytes
-
- def _reuse(self):
- self._makefile_refs += 1
-
- def _drop(self):
- if self._makefile_refs < 1:
- self.close()
- else:
- self._makefile_refs -= 1
-
-
-if _fileobject: # Platform-specific: Python 2
- def makefile(self, mode, bufsize=-1):
- self._makefile_refs += 1
- return _fileobject(self, mode, bufsize, close=True)
-else: # Platform-specific: Python 3
- def makefile(self, mode="r", buffering=None, *args, **kwargs):
- # We disable buffering with SecureTransport because it conflicts with
- # the buffering that ST does internally (see issue #1153 for more).
- buffering = 0
- return backport_makefile(self, mode, buffering, *args, **kwargs)
-
-WrappedSocket.makefile = makefile
-
-
-class SecureTransportContext(object):
- """
- I am a wrapper class for the SecureTransport library, to translate the
- interface of the standard library ``SSLContext`` object to calls into
- SecureTransport.
- """
- def __init__(self, protocol):
- self._min_version, self._max_version = _protocol_to_min_max[protocol]
- self._options = 0
- self._verify = False
- self._trust_bundle = None
- self._client_cert = None
- self._client_key = None
- self._client_key_passphrase = None
-
- @property
- def check_hostname(self):
- """
- SecureTransport cannot have its hostname checking disabled. For more,
- see the comment on getpeercert() in this file.
- """
- return True
-
- @check_hostname.setter
- def check_hostname(self, value):
- """
- SecureTransport cannot have its hostname checking disabled. For more,
- see the comment on getpeercert() in this file.
- """
- pass
-
- @property
- def options(self):
- # TODO: Well, crap.
- #
- # So this is the bit of the code that is the most likely to cause us
- # trouble. Essentially we need to enumerate all of the SSL options that
- # users might want to use and try to see if we can sensibly translate
- # them, or whether we should just ignore them.
- return self._options
-
- @options.setter
- def options(self, value):
- # TODO: Update in line with above.
- self._options = value
-
- @property
- def verify_mode(self):
- return ssl.CERT_REQUIRED if self._verify else ssl.CERT_NONE
-
- @verify_mode.setter
- def verify_mode(self, value):
- self._verify = True if value == ssl.CERT_REQUIRED else False
-
- def set_default_verify_paths(self):
- # So, this has to do something a bit weird. Specifically, what it does
- # is nothing.
- #
- # This means that, if we had previously had load_verify_locations
- # called, this does not undo that. We need to do that because it turns
- # out that the rest of the urllib3 code will attempt to load the
- # default verify paths if it hasn't been told about any paths, even if
- # the context itself was sometime earlier. We resolve that by just
- # ignoring it.
- pass
-
- def load_default_certs(self):
- return self.set_default_verify_paths()
-
- def set_ciphers(self, ciphers):
- # For now, we just require the default cipher string.
- if ciphers != util.ssl_.DEFAULT_CIPHERS:
- raise ValueError(
- "SecureTransport doesn't support custom cipher strings"
- )
-
- def load_verify_locations(self, cafile=None, capath=None, cadata=None):
- # OK, we only really support cadata and cafile.
- if capath is not None:
- raise ValueError(
- "SecureTransport does not support cert directories"
- )
-
- self._trust_bundle = cafile or cadata
-
- def load_cert_chain(self, certfile, keyfile=None, password=None):
- self._client_cert = certfile
- self._client_key = keyfile
- self._client_cert_passphrase = password
-
- def wrap_socket(self, sock, server_side=False,
- do_handshake_on_connect=True, suppress_ragged_eofs=True,
- server_hostname=None):
- # So, what do we do here? Firstly, we assert some properties. This is a
- # stripped down shim, so there is some functionality we don't support.
- # See PEP 543 for the real deal.
- assert not server_side
- assert do_handshake_on_connect
- assert suppress_ragged_eofs
-
- # Ok, we're good to go. Now we want to create the wrapped socket object
- # and store it in the appropriate place.
- wrapped_socket = WrappedSocket(sock)
-
- # Now we can handshake
- wrapped_socket.handshake(
- server_hostname, self._verify, self._trust_bundle,
- self._min_version, self._max_version, self._client_cert,
- self._client_key, self._client_key_passphrase
- )
- return wrapped_socket
diff --git a/python/urllib3/contrib/socks.py b/python/urllib3/contrib/socks.py
deleted file mode 100644
index 811e312..0000000
--- a/python/urllib3/contrib/socks.py
+++ /dev/null
@@ -1,192 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-This module contains provisional support for SOCKS proxies from within
-urllib3. This module supports SOCKS4 (specifically the SOCKS4A variant) and
-SOCKS5. To enable its functionality, either install PySocks or install this
-module with the ``socks`` extra.
-
-The SOCKS implementation supports the full range of urllib3 features. It also
-supports the following SOCKS features:
-
-- SOCKS4
-- SOCKS4a
-- SOCKS5
-- Usernames and passwords for the SOCKS proxy
-
-Known Limitations:
-
-- Currently PySocks does not support contacting remote websites via literal
- IPv6 addresses. Any such connection attempt will fail. You must use a domain
- name.
-- Currently PySocks does not support IPv6 connections to the SOCKS proxy. Any
- such connection attempt will fail.
-"""
-from __future__ import absolute_import
-
-try:
- import socks
-except ImportError:
- import warnings
- from ..exceptions import DependencyWarning
-
- warnings.warn((
- 'SOCKS support in urllib3 requires the installation of optional '
- 'dependencies: specifically, PySocks. For more information, see '
- 'https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies'
- ),
- DependencyWarning
- )
- raise
-
-from socket import error as SocketError, timeout as SocketTimeout
-
-from ..connection import (
- HTTPConnection, HTTPSConnection
-)
-from ..connectionpool import (
- HTTPConnectionPool, HTTPSConnectionPool
-)
-from ..exceptions import ConnectTimeoutError, NewConnectionError
-from ..poolmanager import PoolManager
-from ..util.url import parse_url
-
-try:
- import ssl
-except ImportError:
- ssl = None
-
-
-class SOCKSConnection(HTTPConnection):
- """
- A plain-text HTTP connection that connects via a SOCKS proxy.
- """
- def __init__(self, *args, **kwargs):
- self._socks_options = kwargs.pop('_socks_options')
- super(SOCKSConnection, self).__init__(*args, **kwargs)
-
- def _new_conn(self):
- """
- Establish a new connection via the SOCKS proxy.
- """
- extra_kw = {}
- if self.source_address:
- extra_kw['source_address'] = self.source_address
-
- if self.socket_options:
- extra_kw['socket_options'] = self.socket_options
-
- try:
- conn = socks.create_connection(
- (self.host, self.port),
- proxy_type=self._socks_options['socks_version'],
- proxy_addr=self._socks_options['proxy_host'],
- proxy_port=self._socks_options['proxy_port'],
- proxy_username=self._socks_options['username'],
- proxy_password=self._socks_options['password'],
- proxy_rdns=self._socks_options['rdns'],
- timeout=self.timeout,
- **extra_kw
- )
-
- except SocketTimeout as e:
- raise ConnectTimeoutError(
- self, "Connection to %s timed out. (connect timeout=%s)" %
- (self.host, self.timeout))
-
- except socks.ProxyError as e:
- # This is fragile as hell, but it seems to be the only way to raise
- # useful errors here.
- if e.socket_err:
- error = e.socket_err
- if isinstance(error, SocketTimeout):
- raise ConnectTimeoutError(
- self,
- "Connection to %s timed out. (connect timeout=%s)" %
- (self.host, self.timeout)
- )
- else:
- raise NewConnectionError(
- self,
- "Failed to establish a new connection: %s" % error
- )
- else:
- raise NewConnectionError(
- self,
- "Failed to establish a new connection: %s" % e
- )
-
- except SocketError as e: # Defensive: PySocks should catch all these.
- raise NewConnectionError(
- self, "Failed to establish a new connection: %s" % e)
-
- return conn
-
-
-# We don't need to duplicate the Verified/Unverified distinction from
-# urllib3/connection.py here because the HTTPSConnection will already have been
-# correctly set to either the Verified or Unverified form by that module. This
-# means the SOCKSHTTPSConnection will automatically be the correct type.
-class SOCKSHTTPSConnection(SOCKSConnection, HTTPSConnection):
- pass
-
-
-class SOCKSHTTPConnectionPool(HTTPConnectionPool):
- ConnectionCls = SOCKSConnection
-
-
-class SOCKSHTTPSConnectionPool(HTTPSConnectionPool):
- ConnectionCls = SOCKSHTTPSConnection
-
-
-class SOCKSProxyManager(PoolManager):
- """
- A version of the urllib3 ProxyManager that routes connections via the
- defined SOCKS proxy.
- """
- pool_classes_by_scheme = {
- 'http': SOCKSHTTPConnectionPool,
- 'https': SOCKSHTTPSConnectionPool,
- }
-
- def __init__(self, proxy_url, username=None, password=None,
- num_pools=10, headers=None, **connection_pool_kw):
- parsed = parse_url(proxy_url)
-
- if username is None and password is None and parsed.auth is not None:
- split = parsed.auth.split(':')
- if len(split) == 2:
- username, password = split
- if parsed.scheme == 'socks5':
- socks_version = socks.PROXY_TYPE_SOCKS5
- rdns = False
- elif parsed.scheme == 'socks5h':
- socks_version = socks.PROXY_TYPE_SOCKS5
- rdns = True
- elif parsed.scheme == 'socks4':
- socks_version = socks.PROXY_TYPE_SOCKS4
- rdns = False
- elif parsed.scheme == 'socks4a':
- socks_version = socks.PROXY_TYPE_SOCKS4
- rdns = True
- else:
- raise ValueError(
- "Unable to determine SOCKS version from %s" % proxy_url
- )
-
- self.proxy_url = proxy_url
-
- socks_options = {
- 'socks_version': socks_version,
- 'proxy_host': parsed.host,
- 'proxy_port': parsed.port,
- 'username': username,
- 'password': password,
- 'rdns': rdns
- }
- connection_pool_kw['_socks_options'] = socks_options
-
- super(SOCKSProxyManager, self).__init__(
- num_pools, headers, **connection_pool_kw
- )
-
- self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme
diff --git a/python/urllib3/exceptions.py b/python/urllib3/exceptions.py
deleted file mode 100644
index 7bbaa98..0000000
--- a/python/urllib3/exceptions.py
+++ /dev/null
@@ -1,246 +0,0 @@
-from __future__ import absolute_import
-from .packages.six.moves.http_client import (
- IncompleteRead as httplib_IncompleteRead
-)
-# Base Exceptions
-
-
-class HTTPError(Exception):
- "Base exception used by this module."
- pass
-
-
-class HTTPWarning(Warning):
- "Base warning used by this module."
- pass
-
-
-class PoolError(HTTPError):
- "Base exception for errors caused within a pool."
- def __init__(self, pool, message):
- self.pool = pool
- HTTPError.__init__(self, "%s: %s" % (pool, message))
-
- def __reduce__(self):
- # For pickling purposes.
- return self.__class__, (None, None)
-
-
-class RequestError(PoolError):
- "Base exception for PoolErrors that have associated URLs."
- def __init__(self, pool, url, message):
- self.url = url
- PoolError.__init__(self, pool, message)
-
- def __reduce__(self):
- # For pickling purposes.
- return self.__class__, (None, self.url, None)
-
-
-class SSLError(HTTPError):
- "Raised when SSL certificate fails in an HTTPS connection."
- pass
-
-
-class ProxyError(HTTPError):
- "Raised when the connection to a proxy fails."
- pass
-
-
-class DecodeError(HTTPError):
- "Raised when automatic decoding based on Content-Type fails."
- pass
-
-
-class ProtocolError(HTTPError):
- "Raised when something unexpected happens mid-request/response."
- pass
-
-
-#: Renamed to ProtocolError but aliased for backwards compatibility.
-ConnectionError = ProtocolError
-
-
-# Leaf Exceptions
-
-class MaxRetryError(RequestError):
- """Raised when the maximum number of retries is exceeded.
-
- :param pool: The connection pool
- :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
- :param string url: The requested Url
- :param exceptions.Exception reason: The underlying error
-
- """
-
- def __init__(self, pool, url, reason=None):
- self.reason = reason
-
- message = "Max retries exceeded with url: %s (Caused by %r)" % (
- url, reason)
-
- RequestError.__init__(self, pool, url, message)
-
-
-class HostChangedError(RequestError):
- "Raised when an existing pool gets a request for a foreign host."
-
- def __init__(self, pool, url, retries=3):
- message = "Tried to open a foreign host with url: %s" % url
- RequestError.__init__(self, pool, url, message)
- self.retries = retries
-
-
-class TimeoutStateError(HTTPError):
- """ Raised when passing an invalid state to a timeout """
- pass
-
-
-class TimeoutError(HTTPError):
- """ Raised when a socket timeout error occurs.
-
- Catching this error will catch both :exc:`ReadTimeoutErrors
- <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
- """
- pass
-
-
-class ReadTimeoutError(TimeoutError, RequestError):
- "Raised when a socket timeout occurs while receiving data from a server"
- pass
-
-
-# This timeout error does not have a URL attached and needs to inherit from the
-# base HTTPError
-class ConnectTimeoutError(TimeoutError):
- "Raised when a socket timeout occurs while connecting to a server"
- pass
-
-
-class NewConnectionError(ConnectTimeoutError, PoolError):
- "Raised when we fail to establish a new connection. Usually ECONNREFUSED."
- pass
-
-
-class EmptyPoolError(PoolError):
- "Raised when a pool runs out of connections and no more are allowed."
- pass
-
-
-class ClosedPoolError(PoolError):
- "Raised when a request enters a pool after the pool has been closed."
- pass
-
-
-class LocationValueError(ValueError, HTTPError):
- "Raised when there is something wrong with a given URL input."
- pass
-
-
-class LocationParseError(LocationValueError):
- "Raised when get_host or similar fails to parse the URL input."
-
- def __init__(self, location):
- message = "Failed to parse: %s" % location
- HTTPError.__init__(self, message)
-
- self.location = location
-
-
-class ResponseError(HTTPError):
- "Used as a container for an error reason supplied in a MaxRetryError."
- GENERIC_ERROR = 'too many error responses'
- SPECIFIC_ERROR = 'too many {status_code} error responses'
-
-
-class SecurityWarning(HTTPWarning):
- "Warned when performing security reducing actions"
- pass
-
-
-class SubjectAltNameWarning(SecurityWarning):
- "Warned when connecting to a host with a certificate missing a SAN."
- pass
-
-
-class InsecureRequestWarning(SecurityWarning):
- "Warned when making an unverified HTTPS request."
- pass
-
-
-class SystemTimeWarning(SecurityWarning):
- "Warned when system time is suspected to be wrong"
- pass
-
-
-class InsecurePlatformWarning(SecurityWarning):
- "Warned when certain SSL configuration is not available on a platform."
- pass
-
-
-class SNIMissingWarning(HTTPWarning):
- "Warned when making a HTTPS request without SNI available."
- pass
-
-
-class DependencyWarning(HTTPWarning):
- """
- Warned when an attempt is made to import a module with missing optional
- dependencies.
- """
- pass
-
-
-class ResponseNotChunked(ProtocolError, ValueError):
- "Response needs to be chunked in order to read it as chunks."
- pass
-
-
-class BodyNotHttplibCompatible(HTTPError):
- """
- Body should be httplib.HTTPResponse like (have an fp attribute which
- returns raw chunks) for read_chunked().
- """
- pass
-
-
-class IncompleteRead(HTTPError, httplib_IncompleteRead):
- """
- Response length doesn't match expected Content-Length
-
- Subclass of http_client.IncompleteRead to allow int value
- for `partial` to avoid creating large objects on streamed
- reads.
- """
- def __init__(self, partial, expected):
- super(IncompleteRead, self).__init__(partial, expected)
-
- def __repr__(self):
- return ('IncompleteRead(%i bytes read, '
- '%i more expected)' % (self.partial, self.expected))
-
-
-class InvalidHeader(HTTPError):
- "The header provided was somehow invalid."
- pass
-
-
-class ProxySchemeUnknown(AssertionError, ValueError):
- "ProxyManager does not support the supplied scheme"
- # TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
-
- def __init__(self, scheme):
- message = "Not supported proxy scheme %s" % scheme
- super(ProxySchemeUnknown, self).__init__(message)
-
-
-class HeaderParsingError(HTTPError):
- "Raised by assert_header_parsing, but we convert it to a log.warning statement."
- def __init__(self, defects, unparsed_data):
- message = '%s, unparsed data: %r' % (defects or 'Unknown', unparsed_data)
- super(HeaderParsingError, self).__init__(message)
-
-
-class UnrewindableBodyError(HTTPError):
- "urllib3 encountered an error when trying to rewind a body"
- pass
diff --git a/python/urllib3/fields.py b/python/urllib3/fields.py
deleted file mode 100644
index 37fe64a..0000000
--- a/python/urllib3/fields.py
+++ /dev/null
@@ -1,178 +0,0 @@
-from __future__ import absolute_import
-import email.utils
-import mimetypes
-
-from .packages import six
-
-
-def guess_content_type(filename, default='application/octet-stream'):
- """
- Guess the "Content-Type" of a file.
-
- :param filename:
- The filename to guess the "Content-Type" of using :mod:`mimetypes`.
- :param default:
- If no "Content-Type" can be guessed, default to `default`.
- """
- if filename:
- return mimetypes.guess_type(filename)[0] or default
- return default
-
-
-def format_header_param(name, value):
- """
- Helper function to format and quote a single header parameter.
-
- Particularly useful for header parameters which might contain
- non-ASCII values, like file names. This follows RFC 2231, as
- suggested by RFC 2388 Section 4.4.
-
- :param name:
- The name of the parameter, a string expected to be ASCII only.
- :param value:
- The value of the parameter, provided as a unicode string.
- """
- if not any(ch in value for ch in '"\\\r\n'):
- result = '%s="%s"' % (name, value)
- try:
- result.encode('ascii')
- except (UnicodeEncodeError, UnicodeDecodeError):
- pass
- else:
- return result
- if not six.PY3 and isinstance(value, six.text_type): # Python 2:
- value = value.encode('utf-8')
- value = email.utils.encode_rfc2231(value, 'utf-8')
- value = '%s*=%s' % (name, value)
- return value
-
-
-class RequestField(object):
- """
- A data container for request body parameters.
-
- :param name:
- The name of this request field.
- :param data:
- The data/value body.
- :param filename:
- An optional filename of the request field.
- :param headers:
- An optional dict-like object of headers to initially use for the field.
- """
- def __init__(self, name, data, filename=None, headers=None):
- self._name = name
- self._filename = filename
- self.data = data
- self.headers = {}
- if headers:
- self.headers = dict(headers)
-
- @classmethod
- def from_tuples(cls, fieldname, value):
- """
- A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
-
- Supports constructing :class:`~urllib3.fields.RequestField` from
- parameter of key/value strings AND key/filetuple. A filetuple is a
- (filename, data, MIME type) tuple where the MIME type is optional.
- For example::
-
- 'foo': 'bar',
- 'fakefile': ('foofile.txt', 'contents of foofile'),
- 'realfile': ('barfile.txt', open('realfile').read()),
- 'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
- 'nonamefile': 'contents of nonamefile field',
-
- Field names and filenames must be unicode.
- """
- if isinstance(value, tuple):
- if len(value) == 3:
- filename, data, content_type = value
- else:
- filename, data = value
- content_type = guess_content_type(filename)
- else:
- filename = None
- content_type = None
- data = value
-
- request_param = cls(fieldname, data, filename=filename)
- request_param.make_multipart(content_type=content_type)
-
- return request_param
-
- def _render_part(self, name, value):
- """
- Overridable helper function to format a single header parameter.
-
- :param name:
- The name of the parameter, a string expected to be ASCII only.
- :param value:
- The value of the parameter, provided as a unicode string.
- """
- return format_header_param(name, value)
-
- def _render_parts(self, header_parts):
- """
- Helper function to format and quote a single header.
-
- Useful for single headers that are composed of multiple items. E.g.,
- 'Content-Disposition' fields.
-
- :param header_parts:
- A sequence of (k, v) tuples or a :class:`dict` of (k, v) to format
- as `k1="v1"; k2="v2"; ...`.
- """
- parts = []
- iterable = header_parts
- if isinstance(header_parts, dict):
- iterable = header_parts.items()
-
- for name, value in iterable:
- if value is not None:
- parts.append(self._render_part(name, value))
-
- return '; '.join(parts)
-
- def render_headers(self):
- """
- Renders the headers for this request field.
- """
- lines = []
-
- sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location']
- for sort_key in sort_keys:
- if self.headers.get(sort_key, False):
- lines.append('%s: %s' % (sort_key, self.headers[sort_key]))
-
- for header_name, header_value in self.headers.items():
- if header_name not in sort_keys:
- if header_value:
- lines.append('%s: %s' % (header_name, header_value))
-
- lines.append('\r\n')
- return '\r\n'.join(lines)
-
- def make_multipart(self, content_disposition=None, content_type=None,
- content_location=None):
- """
- Makes this request field into a multipart request field.
-
- This method overrides "Content-Disposition", "Content-Type" and
- "Content-Location" headers to the request parameter.
-
- :param content_type:
- The 'Content-Type' of the request body.
- :param content_location:
- The 'Content-Location' of the request body.
-
- """
- self.headers['Content-Disposition'] = content_disposition or 'form-data'
- self.headers['Content-Disposition'] += '; '.join([
- '', self._render_parts(
- (('name', self._name), ('filename', self._filename))
- )
- ])
- self.headers['Content-Type'] = content_type
- self.headers['Content-Location'] = content_location
diff --git a/python/urllib3/filepost.py b/python/urllib3/filepost.py
deleted file mode 100644
index 78f1e19..0000000
--- a/python/urllib3/filepost.py
+++ /dev/null
@@ -1,98 +0,0 @@
-from __future__ import absolute_import
-import binascii
-import codecs
-import os
-
-from io import BytesIO
-
-from .packages import six
-from .packages.six import b
-from .fields import RequestField
-
-writer = codecs.lookup('utf-8')[3]
-
-
-def choose_boundary():
- """
- Our embarrassingly-simple replacement for mimetools.choose_boundary.
- """
- boundary = binascii.hexlify(os.urandom(16))
- if six.PY3:
- boundary = boundary.decode('ascii')
- return boundary
-
-
-def iter_field_objects(fields):
- """
- Iterate over fields.
-
- Supports list of (k, v) tuples and dicts, and lists of
- :class:`~urllib3.fields.RequestField`.
-
- """
- if isinstance(fields, dict):
- i = six.iteritems(fields)
- else:
- i = iter(fields)
-
- for field in i:
- if isinstance(field, RequestField):
- yield field
- else:
- yield RequestField.from_tuples(*field)
-
-
-def iter_fields(fields):
- """
- .. deprecated:: 1.6
-
- Iterate over fields.
-
- The addition of :class:`~urllib3.fields.RequestField` makes this function
- obsolete. Instead, use :func:`iter_field_objects`, which returns
- :class:`~urllib3.fields.RequestField` objects.
-
- Supports list of (k, v) tuples and dicts.
- """
- if isinstance(fields, dict):
- return ((k, v) for k, v in six.iteritems(fields))
-
- return ((k, v) for k, v in fields)
-
-
-def encode_multipart_formdata(fields, boundary=None):
- """
- Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
-
- :param fields:
- Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
-
- :param boundary:
- If not specified, then a random boundary will be generated using
- :func:`urllib3.filepost.choose_boundary`.
- """
- body = BytesIO()
- if boundary is None:
- boundary = choose_boundary()
-
- for field in iter_field_objects(fields):
- body.write(b('--%s\r\n' % (boundary)))
-
- writer(body).write(field.render_headers())
- data = field.data
-
- if isinstance(data, int):
- data = str(data) # Backwards compatibility
-
- if isinstance(data, six.text_type):
- writer(body).write(data)
- else:
- body.write(data)
-
- body.write(b'\r\n')
-
- body.write(b('--%s--\r\n' % (boundary)))
-
- content_type = str('multipart/form-data; boundary=%s' % boundary)
-
- return body.getvalue(), content_type
diff --git a/python/urllib3/packages/__init__.py b/python/urllib3/packages/__init__.py
deleted file mode 100644
index 170e974..0000000
--- a/python/urllib3/packages/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import absolute_import
-
-from . import ssl_match_hostname
-
-__all__ = ('ssl_match_hostname', )
diff --git a/python/urllib3/packages/backports/__init__.py b/python/urllib3/packages/backports/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/python/urllib3/packages/backports/__init__.py
+++ /dev/null
diff --git a/python/urllib3/packages/backports/makefile.py b/python/urllib3/packages/backports/makefile.py
deleted file mode 100644
index 740db37..0000000
--- a/python/urllib3/packages/backports/makefile.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-backports.makefile
-~~~~~~~~~~~~~~~~~~
-
-Backports the Python 3 ``socket.makefile`` method for use with anything that
-wants to create a "fake" socket object.
-"""
-import io
-
-from socket import SocketIO
-
-
-def backport_makefile(self, mode="r", buffering=None, encoding=None,
- errors=None, newline=None):
- """
- Backport of ``socket.makefile`` from Python 3.5.
- """
- if not set(mode) <= {"r", "w", "b"}:
- raise ValueError(
- "invalid mode %r (only r, w, b allowed)" % (mode,)
- )
- writing = "w" in mode
- reading = "r" in mode or not writing
- assert reading or writing
- binary = "b" in mode
- rawmode = ""
- if reading:
- rawmode += "r"
- if writing:
- rawmode += "w"
- raw = SocketIO(self, rawmode)
- self._makefile_refs += 1
- if buffering is None:
- buffering = -1
- if buffering < 0:
- buffering = io.DEFAULT_BUFFER_SIZE
- if buffering == 0:
- if not binary:
- raise ValueError("unbuffered streams must be binary")
- return raw
- if reading and writing:
- buffer = io.BufferedRWPair(raw, raw, buffering)
- elif reading:
- buffer = io.BufferedReader(raw, buffering)
- else:
- assert writing
- buffer = io.BufferedWriter(raw, buffering)
- if binary:
- return buffer
- text = io.TextIOWrapper(buffer, encoding, errors, newline)
- text.mode = mode
- return text
diff --git a/python/urllib3/packages/six.py b/python/urllib3/packages/six.py
deleted file mode 100644
index 190c023..0000000
--- a/python/urllib3/packages/six.py
+++ /dev/null
@@ -1,868 +0,0 @@
-"""Utilities for writing code that runs on Python 2 and 3"""
-
-# Copyright (c) 2010-2015 Benjamin Peterson
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-from __future__ import absolute_import
-
-import functools
-import itertools
-import operator
-import sys
-import types
-
-__author__ = "Benjamin Peterson <benjamin@python.org>"
-__version__ = "1.10.0"
-
-
-# Useful for very coarse version differentiation.
-PY2 = sys.version_info[0] == 2
-PY3 = sys.version_info[0] == 3
-PY34 = sys.version_info[0:2] >= (3, 4)
-
-if PY3:
- string_types = str,
- integer_types = int,
- class_types = type,
- text_type = str
- binary_type = bytes
-
- MAXSIZE = sys.maxsize
-else:
- string_types = basestring,
- integer_types = (int, long)
- class_types = (type, types.ClassType)
- text_type = unicode
- binary_type = str
-
- if sys.platform.startswith("java"):
- # Jython always uses 32 bits.
- MAXSIZE = int((1 << 31) - 1)
- else:
- # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
- class X(object):
-
- def __len__(self):
- return 1 << 31
- try:
- len(X())
- except OverflowError:
- # 32-bit
- MAXSIZE = int((1 << 31) - 1)
- else:
- # 64-bit
- MAXSIZE = int((1 << 63) - 1)
- del X
-
-
-def _add_doc(func, doc):
- """Add documentation to a function."""
- func.__doc__ = doc
-
-
-def _import_module(name):
- """Import module, returning the module after the last dot."""
- __import__(name)
- return sys.modules[name]
-
-
-class _LazyDescr(object):
-
- def __init__(self, name):
- self.name = name
-
- def __get__(self, obj, tp):
- result = self._resolve()
- setattr(obj, self.name, result) # Invokes __set__.
- try:
- # This is a bit ugly, but it avoids running this again by
- # removing this descriptor.
- delattr(obj.__class__, self.name)
- except AttributeError:
- pass
- return result
-
-
-class MovedModule(_LazyDescr):
-
- def __init__(self, name, old, new=None):
- super(MovedModule, self).__init__(name)
- if PY3:
- if new is None:
- new = name
- self.mod = new
- else:
- self.mod = old
-
- def _resolve(self):
- return _import_module(self.mod)
-
- def __getattr__(self, attr):
- _module = self._resolve()
- value = getattr(_module, attr)
- setattr(self, attr, value)
- return value
-
-
-class _LazyModule(types.ModuleType):
-
- def __init__(self, name):
- super(_LazyModule, self).__init__(name)
- self.__doc__ = self.__class__.__doc__
-
- def __dir__(self):
- attrs = ["__doc__", "__name__"]
- attrs += [attr.name for attr in self._moved_attributes]
- return attrs
-
- # Subclasses should override this
- _moved_attributes = []
-
-
-class MovedAttribute(_LazyDescr):
-
- def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
- super(MovedAttribute, self).__init__(name)
- if PY3:
- if new_mod is None:
- new_mod = name
- self.mod = new_mod
- if new_attr is None:
- if old_attr is None:
- new_attr = name
- else:
- new_attr = old_attr
- self.attr = new_attr
- else:
- self.mod = old_mod
- if old_attr is None:
- old_attr = name
- self.attr = old_attr
-
- def _resolve(self):
- module = _import_module(self.mod)
- return getattr(module, self.attr)
-
-
-class _SixMetaPathImporter(object):
-
- """
- A meta path importer to import six.moves and its submodules.
-
- This class implements a PEP302 finder and loader. It should be compatible
- with Python 2.5 and all existing versions of Python3
- """
-
- def __init__(self, six_module_name):
- self.name = six_module_name
- self.known_modules = {}
-
- def _add_module(self, mod, *fullnames):
- for fullname in fullnames:
- self.known_modules[self.name + "." + fullname] = mod
-
- def _get_module(self, fullname):
- return self.known_modules[self.name + "." + fullname]
-
- def find_module(self, fullname, path=None):
- if fullname in self.known_modules:
- return self
- return None
-
- def __get_module(self, fullname):
- try:
- return self.known_modules[fullname]
- except KeyError:
- raise ImportError("This loader does not know module " + fullname)
-
- def load_module(self, fullname):
- try:
- # in case of a reload
- return sys.modules[fullname]
- except KeyError:
- pass
- mod = self.__get_module(fullname)
- if isinstance(mod, MovedModule):
- mod = mod._resolve()
- else:
- mod.__loader__ = self
- sys.modules[fullname] = mod
- return mod
-
- def is_package(self, fullname):
- """
- Return true, if the named module is a package.
-
- We need this method to get correct spec objects with
- Python 3.4 (see PEP451)
- """
- return hasattr(self.__get_module(fullname), "__path__")
-
- def get_code(self, fullname):
- """Return None
-
- Required, if is_package is implemented"""
- self.__get_module(fullname) # eventually raises ImportError
- return None
- get_source = get_code # same as get_code
-
-_importer = _SixMetaPathImporter(__name__)
-
-
-class _MovedItems(_LazyModule):
-
- """Lazy loading of moved objects"""
- __path__ = [] # mark as package
-
-
-_moved_attributes = [
- MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
- MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
- MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
- MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
- MovedAttribute("intern", "__builtin__", "sys"),
- MovedAttribute("map", "itertools", "builtins", "imap", "map"),
- MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
- MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
- MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
- MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
- MovedAttribute("reduce", "__builtin__", "functools"),
- MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
- MovedAttribute("StringIO", "StringIO", "io"),
- MovedAttribute("UserDict", "UserDict", "collections"),
- MovedAttribute("UserList", "UserList", "collections"),
- MovedAttribute("UserString", "UserString", "collections"),
- MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
- MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
- MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
- MovedModule("builtins", "__builtin__"),
- MovedModule("configparser", "ConfigParser"),
- MovedModule("copyreg", "copy_reg"),
- MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
- MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
- MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
- MovedModule("http_cookies", "Cookie", "http.cookies"),
- MovedModule("html_entities", "htmlentitydefs", "html.entities"),
- MovedModule("html_parser", "HTMLParser", "html.parser"),
- MovedModule("http_client", "httplib", "http.client"),
- MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
- MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
- MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
- MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
- MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
- MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
- MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
- MovedModule("cPickle", "cPickle", "pickle"),
- MovedModule("queue", "Queue"),
- MovedModule("reprlib", "repr"),
- MovedModule("socketserver", "SocketServer"),
- MovedModule("_thread", "thread", "_thread"),
- MovedModule("tkinter", "Tkinter"),
- MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
- MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
- MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
- MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
- MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
- MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
- MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
- MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
- MovedModule("tkinter_colorchooser", "tkColorChooser",
- "tkinter.colorchooser"),
- MovedModule("tkinter_commondialog", "tkCommonDialog",
- "tkinter.commondialog"),
- MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
- MovedModule("tkinter_font", "tkFont", "tkinter.font"),
- MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
- MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
- "tkinter.simpledialog"),
- MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
- MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
- MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
- MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
- MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
- MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
-]
-# Add windows specific modules.
-if sys.platform == "win32":
- _moved_attributes += [
- MovedModule("winreg", "_winreg"),
- ]
-
-for attr in _moved_attributes:
- setattr(_MovedItems, attr.name, attr)
- if isinstance(attr, MovedModule):
- _importer._add_module(attr, "moves." + attr.name)
-del attr
-
-_MovedItems._moved_attributes = _moved_attributes
-
-moves = _MovedItems(__name__ + ".moves")
-_importer._add_module(moves, "moves")
-
-
-class Module_six_moves_urllib_parse(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_parse"""
-
-
-_urllib_parse_moved_attributes = [
- MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
- MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
- MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
- MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
- MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
- MovedAttribute("urljoin", "urlparse", "urllib.parse"),
- MovedAttribute("urlparse", "urlparse", "urllib.parse"),
- MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
- MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
- MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
- MovedAttribute("quote", "urllib", "urllib.parse"),
- MovedAttribute("quote_plus", "urllib", "urllib.parse"),
- MovedAttribute("unquote", "urllib", "urllib.parse"),
- MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
- MovedAttribute("urlencode", "urllib", "urllib.parse"),
- MovedAttribute("splitquery", "urllib", "urllib.parse"),
- MovedAttribute("splittag", "urllib", "urllib.parse"),
- MovedAttribute("splituser", "urllib", "urllib.parse"),
- MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
- MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
- MovedAttribute("uses_params", "urlparse", "urllib.parse"),
- MovedAttribute("uses_query", "urlparse", "urllib.parse"),
- MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
-]
-for attr in _urllib_parse_moved_attributes:
- setattr(Module_six_moves_urllib_parse, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
- "moves.urllib_parse", "moves.urllib.parse")
-
-
-class Module_six_moves_urllib_error(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_error"""
-
-
-_urllib_error_moved_attributes = [
- MovedAttribute("URLError", "urllib2", "urllib.error"),
- MovedAttribute("HTTPError", "urllib2", "urllib.error"),
- MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
-]
-for attr in _urllib_error_moved_attributes:
- setattr(Module_six_moves_urllib_error, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
- "moves.urllib_error", "moves.urllib.error")
-
-
-class Module_six_moves_urllib_request(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_request"""
-
-
-_urllib_request_moved_attributes = [
- MovedAttribute("urlopen", "urllib2", "urllib.request"),
- MovedAttribute("install_opener", "urllib2", "urllib.request"),
- MovedAttribute("build_opener", "urllib2", "urllib.request"),
- MovedAttribute("pathname2url", "urllib", "urllib.request"),
- MovedAttribute("url2pathname", "urllib", "urllib.request"),
- MovedAttribute("getproxies", "urllib", "urllib.request"),
- MovedAttribute("Request", "urllib2", "urllib.request"),
- MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
- MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
- MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
- MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
- MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
- MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
- MovedAttribute("FileHandler", "urllib2", "urllib.request"),
- MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
- MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
- MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
- MovedAttribute("urlretrieve", "urllib", "urllib.request"),
- MovedAttribute("urlcleanup", "urllib", "urllib.request"),
- MovedAttribute("URLopener", "urllib", "urllib.request"),
- MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
- MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
-]
-for attr in _urllib_request_moved_attributes:
- setattr(Module_six_moves_urllib_request, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
- "moves.urllib_request", "moves.urllib.request")
-
-
-class Module_six_moves_urllib_response(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_response"""
-
-
-_urllib_response_moved_attributes = [
- MovedAttribute("addbase", "urllib", "urllib.response"),
- MovedAttribute("addclosehook", "urllib", "urllib.response"),
- MovedAttribute("addinfo", "urllib", "urllib.response"),
- MovedAttribute("addinfourl", "urllib", "urllib.response"),
-]
-for attr in _urllib_response_moved_attributes:
- setattr(Module_six_moves_urllib_response, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
- "moves.urllib_response", "moves.urllib.response")
-
-
-class Module_six_moves_urllib_robotparser(_LazyModule):
-
- """Lazy loading of moved objects in six.moves.urllib_robotparser"""
-
-
-_urllib_robotparser_moved_attributes = [
- MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
-]
-for attr in _urllib_robotparser_moved_attributes:
- setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
- "moves.urllib_robotparser", "moves.urllib.robotparser")
-
-
-class Module_six_moves_urllib(types.ModuleType):
-
- """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
- __path__ = [] # mark as package
- parse = _importer._get_module("moves.urllib_parse")
- error = _importer._get_module("moves.urllib_error")
- request = _importer._get_module("moves.urllib_request")
- response = _importer._get_module("moves.urllib_response")
- robotparser = _importer._get_module("moves.urllib_robotparser")
-
- def __dir__(self):
- return ['parse', 'error', 'request', 'response', 'robotparser']
-
-_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
- "moves.urllib")
-
-
-def add_move(move):
- """Add an item to six.moves."""
- setattr(_MovedItems, move.name, move)
-
-
-def remove_move(name):
- """Remove item from six.moves."""
- try:
- delattr(_MovedItems, name)
- except AttributeError:
- try:
- del moves.__dict__[name]
- except KeyError:
- raise AttributeError("no such move, %r" % (name,))
-
-
-if PY3:
- _meth_func = "__func__"
- _meth_self = "__self__"
-
- _func_closure = "__closure__"
- _func_code = "__code__"
- _func_defaults = "__defaults__"
- _func_globals = "__globals__"
-else:
- _meth_func = "im_func"
- _meth_self = "im_self"
-
- _func_closure = "func_closure"
- _func_code = "func_code"
- _func_defaults = "func_defaults"
- _func_globals = "func_globals"
-
-
-try:
- advance_iterator = next
-except NameError:
- def advance_iterator(it):
- return it.next()
-next = advance_iterator
-
-
-try:
- callable = callable
-except NameError:
- def callable(obj):
- return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
-
-
-if PY3:
- def get_unbound_function(unbound):
- return unbound
-
- create_bound_method = types.MethodType
-
- def create_unbound_method(func, cls):
- return func
-
- Iterator = object
-else:
- def get_unbound_function(unbound):
- return unbound.im_func
-
- def create_bound_method(func, obj):
- return types.MethodType(func, obj, obj.__class__)
-
- def create_unbound_method(func, cls):
- return types.MethodType(func, None, cls)
-
- class Iterator(object):
-
- def next(self):
- return type(self).__next__(self)
-
- callable = callable
-_add_doc(get_unbound_function,
- """Get the function out of a possibly unbound function""")
-
-
-get_method_function = operator.attrgetter(_meth_func)
-get_method_self = operator.attrgetter(_meth_self)
-get_function_closure = operator.attrgetter(_func_closure)
-get_function_code = operator.attrgetter(_func_code)
-get_function_defaults = operator.attrgetter(_func_defaults)
-get_function_globals = operator.attrgetter(_func_globals)
-
-
-if PY3:
- def iterkeys(d, **kw):
- return iter(d.keys(**kw))
-
- def itervalues(d, **kw):
- return iter(d.values(**kw))
-
- def iteritems(d, **kw):
- return iter(d.items(**kw))
-
- def iterlists(d, **kw):
- return iter(d.lists(**kw))
-
- viewkeys = operator.methodcaller("keys")
-
- viewvalues = operator.methodcaller("values")
-
- viewitems = operator.methodcaller("items")
-else:
- def iterkeys(d, **kw):
- return d.iterkeys(**kw)
-
- def itervalues(d, **kw):
- return d.itervalues(**kw)
-
- def iteritems(d, **kw):
- return d.iteritems(**kw)
-
- def iterlists(d, **kw):
- return d.iterlists(**kw)
-
- viewkeys = operator.methodcaller("viewkeys")
-
- viewvalues = operator.methodcaller("viewvalues")
-
- viewitems = operator.methodcaller("viewitems")
-
-_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
-_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
-_add_doc(iteritems,
- "Return an iterator over the (key, value) pairs of a dictionary.")
-_add_doc(iterlists,
- "Return an iterator over the (key, [values]) pairs of a dictionary.")
-
-
-if PY3:
- def b(s):
- return s.encode("latin-1")
-
- def u(s):
- return s
- unichr = chr
- import struct
- int2byte = struct.Struct(">B").pack
- del struct
- byte2int = operator.itemgetter(0)
- indexbytes = operator.getitem
- iterbytes = iter
- import io
- StringIO = io.StringIO
- BytesIO = io.BytesIO
- _assertCountEqual = "assertCountEqual"
- if sys.version_info[1] <= 1:
- _assertRaisesRegex = "assertRaisesRegexp"
- _assertRegex = "assertRegexpMatches"
- else:
- _assertRaisesRegex = "assertRaisesRegex"
- _assertRegex = "assertRegex"
-else:
- def b(s):
- return s
- # Workaround for standalone backslash
-
- def u(s):
- return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
- unichr = unichr
- int2byte = chr
-
- def byte2int(bs):
- return ord(bs[0])
-
- def indexbytes(buf, i):
- return ord(buf[i])
- iterbytes = functools.partial(itertools.imap, ord)
- import StringIO
- StringIO = BytesIO = StringIO.StringIO
- _assertCountEqual = "assertItemsEqual"
- _assertRaisesRegex = "assertRaisesRegexp"
- _assertRegex = "assertRegexpMatches"
-_add_doc(b, """Byte literal""")
-_add_doc(u, """Text literal""")
-
-
-def assertCountEqual(self, *args, **kwargs):
- return getattr(self, _assertCountEqual)(*args, **kwargs)
-
-
-def assertRaisesRegex(self, *args, **kwargs):
- return getattr(self, _assertRaisesRegex)(*args, **kwargs)
-
-
-def assertRegex(self, *args, **kwargs):
- return getattr(self, _assertRegex)(*args, **kwargs)
-
-
-if PY3:
- exec_ = getattr(moves.builtins, "exec")
-
- def reraise(tp, value, tb=None):
- if value is None:
- value = tp()
- if value.__traceback__ is not tb:
- raise value.with_traceback(tb)
- raise value
-
-else:
- def exec_(_code_, _globs_=None, _locs_=None):
- """Execute code in a namespace."""
- if _globs_ is None:
- frame = sys._getframe(1)
- _globs_ = frame.f_globals
- if _locs_ is None:
- _locs_ = frame.f_locals
- del frame
- elif _locs_ is None:
- _locs_ = _globs_
- exec("""exec _code_ in _globs_, _locs_""")
-
- exec_("""def reraise(tp, value, tb=None):
- raise tp, value, tb
-""")
-
-
-if sys.version_info[:2] == (3, 2):
- exec_("""def raise_from(value, from_value):
- if from_value is None:
- raise value
- raise value from from_value
-""")
-elif sys.version_info[:2] > (3, 2):
- exec_("""def raise_from(value, from_value):
- raise value from from_value
-""")
-else:
- def raise_from(value, from_value):
- raise value
-
-
-print_ = getattr(moves.builtins, "print", None)
-if print_ is None:
- def print_(*args, **kwargs):
- """The new-style print function for Python 2.4 and 2.5."""
- fp = kwargs.pop("file", sys.stdout)
- if fp is None:
- return
-
- def write(data):
- if not isinstance(data, basestring):
- data = str(data)
- # If the file has an encoding, encode unicode with it.
- if (isinstance(fp, file) and
- isinstance(data, unicode) and
- fp.encoding is not None):
- errors = getattr(fp, "errors", None)
- if errors is None:
- errors = "strict"
- data = data.encode(fp.encoding, errors)
- fp.write(data)
- want_unicode = False
- sep = kwargs.pop("sep", None)
- if sep is not None:
- if isinstance(sep, unicode):
- want_unicode = True
- elif not isinstance(sep, str):
- raise TypeError("sep must be None or a string")
- end = kwargs.pop("end", None)
- if end is not None:
- if isinstance(end, unicode):
- want_unicode = True
- elif not isinstance(end, str):
- raise TypeError("end must be None or a string")
- if kwargs:
- raise TypeError("invalid keyword arguments to print()")
- if not want_unicode:
- for arg in args:
- if isinstance(arg, unicode):
- want_unicode = True
- break
- if want_unicode:
- newline = unicode("\n")
- space = unicode(" ")
- else:
- newline = "\n"
- space = " "
- if sep is None:
- sep = space
- if end is None:
- end = newline
- for i, arg in enumerate(args):
- if i:
- write(sep)
- write(arg)
- write(end)
-if sys.version_info[:2] < (3, 3):
- _print = print_
-
- def print_(*args, **kwargs):
- fp = kwargs.get("file", sys.stdout)
- flush = kwargs.pop("flush", False)
- _print(*args, **kwargs)
- if flush and fp is not None:
- fp.flush()
-
-_add_doc(reraise, """Reraise an exception.""")
-
-if sys.version_info[0:2] < (3, 4):
- def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
- updated=functools.WRAPPER_UPDATES):
- def wrapper(f):
- f = functools.wraps(wrapped, assigned, updated)(f)
- f.__wrapped__ = wrapped
- return f
- return wrapper
-else:
- wraps = functools.wraps
-
-
-def with_metaclass(meta, *bases):
- """Create a base class with a metaclass."""
- # This requires a bit of explanation: the basic idea is to make a dummy
- # metaclass for one level of class instantiation that replaces itself with
- # the actual metaclass.
- class metaclass(meta):
-
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
- return type.__new__(metaclass, 'temporary_class', (), {})
-
-
-def add_metaclass(metaclass):
- """Class decorator for creating a class with a metaclass."""
- def wrapper(cls):
- orig_vars = cls.__dict__.copy()
- slots = orig_vars.get('__slots__')
- if slots is not None:
- if isinstance(slots, str):
- slots = [slots]
- for slots_var in slots:
- orig_vars.pop(slots_var)
- orig_vars.pop('__dict__', None)
- orig_vars.pop('__weakref__', None)
- return metaclass(cls.__name__, cls.__bases__, orig_vars)
- return wrapper
-
-
-def python_2_unicode_compatible(klass):
- """
- A decorator that defines __unicode__ and __str__ methods under Python 2.
- Under Python 3 it does nothing.
-
- To support Python 2 and 3 with a single code base, define a __str__ method
- returning text and apply this decorator to the class.
- """
- if PY2:
- if '__str__' not in klass.__dict__:
- raise ValueError("@python_2_unicode_compatible cannot be applied "
- "to %s because it doesn't define __str__()." %
- klass.__name__)
- klass.__unicode__ = klass.__str__
- klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
- return klass
-
-
-# Complete the moves implementation.
-# This code is at the end of this module to speed up module loading.
-# Turn this module into a package.
-__path__ = [] # required for PEP 302 and PEP 451
-__package__ = __name__ # see PEP 366 @ReservedAssignment
-if globals().get("__spec__") is not None:
- __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
-# Remove other six meta path importers, since they cause problems. This can
-# happen if six is removed from sys.modules and then reloaded. (Setuptools does
-# this for some reason.)
-if sys.meta_path:
- for i, importer in enumerate(sys.meta_path):
- # Here's some real nastiness: Another "instance" of the six module might
- # be floating around. Therefore, we can't use isinstance() to check for
- # the six meta path importer, since the other six instance will have
- # inserted an importer with different class.
- if (type(importer).__name__ == "_SixMetaPathImporter" and
- importer.name == __name__):
- del sys.meta_path[i]
- break
- del i, importer
-# Finally, add the importer to the meta path import hook.
-sys.meta_path.append(_importer)
diff --git a/python/urllib3/packages/ssl_match_hostname/__init__.py b/python/urllib3/packages/ssl_match_hostname/__init__.py
deleted file mode 100644
index d6594eb..0000000
--- a/python/urllib3/packages/ssl_match_hostname/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import sys
-
-try:
- # Our match_hostname function is the same as 3.5's, so we only want to
- # import the match_hostname function if it's at least that good.
- if sys.version_info < (3, 5):
- raise ImportError("Fallback to vendored code")
-
- from ssl import CertificateError, match_hostname
-except ImportError:
- try:
- # Backport of the function from a pypi module
- from backports.ssl_match_hostname import CertificateError, match_hostname
- except ImportError:
- # Our vendored copy
- from ._implementation import CertificateError, match_hostname
-
-# Not needed, but documenting what we provide.
-__all__ = ('CertificateError', 'match_hostname')
diff --git a/python/urllib3/packages/ssl_match_hostname/_implementation.py b/python/urllib3/packages/ssl_match_hostname/_implementation.py
deleted file mode 100644
index d6e66c0..0000000
--- a/python/urllib3/packages/ssl_match_hostname/_implementation.py
+++ /dev/null
@@ -1,156 +0,0 @@
-"""The match_hostname() function from Python 3.3.3, essential when using SSL."""
-
-# Note: This file is under the PSF license as the code comes from the python
-# stdlib. http://docs.python.org/3/license.html
-
-import re
-import sys
-
-# ipaddress has been backported to 2.6+ in pypi. If it is installed on the
-# system, use it to handle IPAddress ServerAltnames (this was added in
-# python-3.5) otherwise only do DNS matching. This allows
-# backports.ssl_match_hostname to continue to be used in Python 2.7.
-try:
- import ipaddress
-except ImportError:
- ipaddress = None
-
-__version__ = '3.5.0.1'
-
-
-class CertificateError(ValueError):
- pass
-
-
-def _dnsname_match(dn, hostname, max_wildcards=1):
- """Matching according to RFC 6125, section 6.4.3
-
- http://tools.ietf.org/html/rfc6125#section-6.4.3
- """
- pats = []
- if not dn:
- return False
-
- # Ported from python3-syntax:
- # leftmost, *remainder = dn.split(r'.')
- parts = dn.split(r'.')
- leftmost = parts[0]
- remainder = parts[1:]
-
- wildcards = leftmost.count('*')
- if wildcards > max_wildcards:
- # Issue #17980: avoid denials of service by refusing more
- # than one wildcard per fragment. A survey of established
- # policy among SSL implementations showed it to be a
- # reasonable choice.
- raise CertificateError(
- "too many wildcards in certificate DNS name: " + repr(dn))
-
- # speed up common case w/o wildcards
- if not wildcards:
- return dn.lower() == hostname.lower()
-
- # RFC 6125, section 6.4.3, subitem 1.
- # The client SHOULD NOT attempt to match a presented identifier in which
- # the wildcard character comprises a label other than the left-most label.
- if leftmost == '*':
- # When '*' is a fragment by itself, it matches a non-empty dotless
- # fragment.
- pats.append('[^.]+')
- elif leftmost.startswith('xn--') or hostname.startswith('xn--'):
- # RFC 6125, section 6.4.3, subitem 3.
- # The client SHOULD NOT attempt to match a presented identifier
- # where the wildcard character is embedded within an A-label or
- # U-label of an internationalized domain name.
- pats.append(re.escape(leftmost))
- else:
- # Otherwise, '*' matches any dotless string, e.g. www*
- pats.append(re.escape(leftmost).replace(r'\*', '[^.]*'))
-
- # add the remaining fragments, ignore any wildcards
- for frag in remainder:
- pats.append(re.escape(frag))
-
- pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
- return pat.match(hostname)
-
-
-def _to_unicode(obj):
- if isinstance(obj, str) and sys.version_info < (3,):
- obj = unicode(obj, encoding='ascii', errors='strict')
- return obj
-
-def _ipaddress_match(ipname, host_ip):
- """Exact matching of IP addresses.
-
- RFC 6125 explicitly doesn't define an algorithm for this
- (section 1.7.2 - "Out of Scope").
- """
- # OpenSSL may add a trailing newline to a subjectAltName's IP address
- # Divergence from upstream: ipaddress can't handle byte str
- ip = ipaddress.ip_address(_to_unicode(ipname).rstrip())
- return ip == host_ip
-
-
-def match_hostname(cert, hostname):
- """Verify that *cert* (in decoded format as returned by
- SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
- rules are followed, but IP addresses are not accepted for *hostname*.
-
- CertificateError is raised on failure. On success, the function
- returns nothing.
- """
- if not cert:
- raise ValueError("empty or no certificate, match_hostname needs a "
- "SSL socket or SSL context with either "
- "CERT_OPTIONAL or CERT_REQUIRED")
- try:
- # Divergence from upstream: ipaddress can't handle byte str
- host_ip = ipaddress.ip_address(_to_unicode(hostname))
- except ValueError:
- # Not an IP address (common case)
- host_ip = None
- except UnicodeError:
- # Divergence from upstream: Have to deal with ipaddress not taking
- # byte strings. addresses should be all ascii, so we consider it not
- # an ipaddress in this case
- host_ip = None
- except AttributeError:
- # Divergence from upstream: Make ipaddress library optional
- if ipaddress is None:
- host_ip = None
- else:
- raise
- dnsnames = []
- san = cert.get('subjectAltName', ())
- for key, value in san:
- if key == 'DNS':
- if host_ip is None and _dnsname_match(value, hostname):
- return
- dnsnames.append(value)
- elif key == 'IP Address':
- if host_ip is not None and _ipaddress_match(value, host_ip):
- return
- dnsnames.append(value)
- if not dnsnames:
- # The subject is only checked when there is no dNSName entry
- # in subjectAltName
- for sub in cert.get('subject', ()):
- for key, value in sub:
- # XXX according to RFC 2818, the most specific Common Name
- # must be used.
- if key == 'commonName':
- if _dnsname_match(value, hostname):
- return
- dnsnames.append(value)
- if len(dnsnames) > 1:
- raise CertificateError("hostname %r "
- "doesn't match either of %s"
- % (hostname, ', '.join(map(repr, dnsnames))))
- elif len(dnsnames) == 1:
- raise CertificateError("hostname %r "
- "doesn't match %r"
- % (hostname, dnsnames[0]))
- else:
- raise CertificateError("no appropriate commonName or "
- "subjectAltName fields were found")
diff --git a/python/urllib3/poolmanager.py b/python/urllib3/poolmanager.py
deleted file mode 100644
index fe5491c..0000000
--- a/python/urllib3/poolmanager.py
+++ /dev/null
@@ -1,450 +0,0 @@
-from __future__ import absolute_import
-import collections
-import functools
-import logging
-
-from ._collections import RecentlyUsedContainer
-from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
-from .connectionpool import port_by_scheme
-from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
-from .packages.six.moves.urllib.parse import urljoin
-from .request import RequestMethods
-from .util.url import parse_url
-from .util.retry import Retry
-
-
-__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']
-
-
-log = logging.getLogger(__name__)
-
-SSL_KEYWORDS = ('key_file', 'cert_file', 'cert_reqs', 'ca_certs',
- 'ssl_version', 'ca_cert_dir', 'ssl_context')
-
-# All known keyword arguments that could be provided to the pool manager, its
-# pools, or the underlying connections. This is used to construct a pool key.
-_key_fields = (
- 'key_scheme', # str
- 'key_host', # str
- 'key_port', # int
- 'key_timeout', # int or float or Timeout
- 'key_retries', # int or Retry
- 'key_strict', # bool
- 'key_block', # bool
- 'key_source_address', # str
- 'key_key_file', # str
- 'key_cert_file', # str
- 'key_cert_reqs', # str
- 'key_ca_certs', # str
- 'key_ssl_version', # str
- 'key_ca_cert_dir', # str
- 'key_ssl_context', # instance of ssl.SSLContext or urllib3.util.ssl_.SSLContext
- 'key_maxsize', # int
- 'key_headers', # dict
- 'key__proxy', # parsed proxy url
- 'key__proxy_headers', # dict
- 'key_socket_options', # list of (level (int), optname (int), value (int or str)) tuples
- 'key__socks_options', # dict
- 'key_assert_hostname', # bool or string
- 'key_assert_fingerprint', # str
- 'key_server_hostname', #str
-)
-
-#: The namedtuple class used to construct keys for the connection pool.
-#: All custom key schemes should include the fields in this key at a minimum.
-PoolKey = collections.namedtuple('PoolKey', _key_fields)
-
-
-def _default_key_normalizer(key_class, request_context):
- """
- Create a pool key out of a request context dictionary.
-
- According to RFC 3986, both the scheme and host are case-insensitive.
- Therefore, this function normalizes both before constructing the pool
- key for an HTTPS request. If you wish to change this behaviour, provide
- alternate callables to ``key_fn_by_scheme``.
-
- :param key_class:
- The class to use when constructing the key. This should be a namedtuple
- with the ``scheme`` and ``host`` keys at a minimum.
- :type key_class: namedtuple
- :param request_context:
- A dictionary-like object that contain the context for a request.
- :type request_context: dict
-
- :return: A namedtuple that can be used as a connection pool key.
- :rtype: PoolKey
- """
- # Since we mutate the dictionary, make a copy first
- context = request_context.copy()
- context['scheme'] = context['scheme'].lower()
- context['host'] = context['host'].lower()
-
- # These are both dictionaries and need to be transformed into frozensets
- for key in ('headers', '_proxy_headers', '_socks_options'):
- if key in context and context[key] is not None:
- context[key] = frozenset(context[key].items())
-
- # The socket_options key may be a list and needs to be transformed into a
- # tuple.
- socket_opts = context.get('socket_options')
- if socket_opts is not None:
- context['socket_options'] = tuple(socket_opts)
-
- # Map the kwargs to the names in the namedtuple - this is necessary since
- # namedtuples can't have fields starting with '_'.
- for key in list(context.keys()):
- context['key_' + key] = context.pop(key)
-
- # Default to ``None`` for keys missing from the context
- for field in key_class._fields:
- if field not in context:
- context[field] = None
-
- return key_class(**context)
-
-
-#: A dictionary that maps a scheme to a callable that creates a pool key.
-#: This can be used to alter the way pool keys are constructed, if desired.
-#: Each PoolManager makes a copy of this dictionary so they can be configured
-#: globally here, or individually on the instance.
-key_fn_by_scheme = {
- 'http': functools.partial(_default_key_normalizer, PoolKey),
- 'https': functools.partial(_default_key_normalizer, PoolKey),
-}
-
-pool_classes_by_scheme = {
- 'http': HTTPConnectionPool,
- 'https': HTTPSConnectionPool,
-}
-
-
-class PoolManager(RequestMethods):
- """
- Allows for arbitrary requests while transparently keeping track of
- necessary connection pools for you.
-
- :param num_pools:
- Number of connection pools to cache before discarding the least
- recently used pool.
-
- :param headers:
- Headers to include with all requests, unless other headers are given
- explicitly.
-
- :param \\**connection_pool_kw:
- Additional parameters are used to create fresh
- :class:`urllib3.connectionpool.ConnectionPool` instances.
-
- Example::
-
- >>> manager = PoolManager(num_pools=2)
- >>> r = manager.request('GET', 'http://google.com/')
- >>> r = manager.request('GET', 'http://google.com/mail')
- >>> r = manager.request('GET', 'http://yahoo.com/')
- >>> len(manager.pools)
- 2
-
- """
-
- proxy = None
-
- def __init__(self, num_pools=10, headers=None, **connection_pool_kw):
- RequestMethods.__init__(self, headers)
- self.connection_pool_kw = connection_pool_kw
- self.pools = RecentlyUsedContainer(num_pools,
- dispose_func=lambda p: p.close())
-
- # Locally set the pool classes and keys so other PoolManagers can
- # override them.
- self.pool_classes_by_scheme = pool_classes_by_scheme
- self.key_fn_by_scheme = key_fn_by_scheme.copy()
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- self.clear()
- # Return False to re-raise any potential exceptions
- return False
-
- def _new_pool(self, scheme, host, port, request_context=None):
- """
- Create a new :class:`ConnectionPool` based on host, port, scheme, and
- any additional pool keyword arguments.
-
- If ``request_context`` is provided, it is provided as keyword arguments
- to the pool class used. This method is used to actually create the
- connection pools handed out by :meth:`connection_from_url` and
- companion methods. It is intended to be overridden for customization.
- """
- pool_cls = self.pool_classes_by_scheme[scheme]
- if request_context is None:
- request_context = self.connection_pool_kw.copy()
-
- # Although the context has everything necessary to create the pool,
- # this function has historically only used the scheme, host, and port
- # in the positional args. When an API change is acceptable these can
- # be removed.
- for key in ('scheme', 'host', 'port'):
- request_context.pop(key, None)
-
- if scheme == 'http':
- for kw in SSL_KEYWORDS:
- request_context.pop(kw, None)
-
- return pool_cls(host, port, **request_context)
-
- def clear(self):
- """
- Empty our store of pools and direct them all to close.
-
- This will not affect in-flight connections, but they will not be
- re-used after completion.
- """
- self.pools.clear()
-
- def connection_from_host(self, host, port=None, scheme='http', pool_kwargs=None):
- """
- Get a :class:`ConnectionPool` based on the host, port, and scheme.
-
- If ``port`` isn't given, it will be derived from the ``scheme`` using
- ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
- provided, it is merged with the instance's ``connection_pool_kw``
- variable and used to create the new connection pool, if one is
- needed.
- """
-
- if not host:
- raise LocationValueError("No host specified.")
-
- request_context = self._merge_pool_kwargs(pool_kwargs)
- request_context['scheme'] = scheme or 'http'
- if not port:
- port = port_by_scheme.get(request_context['scheme'].lower(), 80)
- request_context['port'] = port
- request_context['host'] = host
-
- return self.connection_from_context(request_context)
-
- def connection_from_context(self, request_context):
- """
- Get a :class:`ConnectionPool` based on the request context.
-
- ``request_context`` must at least contain the ``scheme`` key and its
- value must be a key in ``key_fn_by_scheme`` instance variable.
- """
- scheme = request_context['scheme'].lower()
- pool_key_constructor = self.key_fn_by_scheme[scheme]
- pool_key = pool_key_constructor(request_context)
-
- return self.connection_from_pool_key(pool_key, request_context=request_context)
-
- def connection_from_pool_key(self, pool_key, request_context=None):
- """
- Get a :class:`ConnectionPool` based on the provided pool key.
-
- ``pool_key`` should be a namedtuple that only contains immutable
- objects. At a minimum it must have the ``scheme``, ``host``, and
- ``port`` fields.
- """
- with self.pools.lock:
- # If the scheme, host, or port doesn't match existing open
- # connections, open a new ConnectionPool.
- pool = self.pools.get(pool_key)
- if pool:
- return pool
-
- # Make a fresh ConnectionPool of the desired type
- scheme = request_context['scheme']
- host = request_context['host']
- port = request_context['port']
- pool = self._new_pool(scheme, host, port, request_context=request_context)
- self.pools[pool_key] = pool
-
- return pool
-
- def connection_from_url(self, url, pool_kwargs=None):
- """
- Similar to :func:`urllib3.connectionpool.connection_from_url`.
-
- If ``pool_kwargs`` is not provided and a new pool needs to be
- constructed, ``self.connection_pool_kw`` is used to initialize
- the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
- is provided, it is used instead. Note that if a new pool does not
- need to be created for the request, the provided ``pool_kwargs`` are
- not used.
- """
- u = parse_url(url)
- return self.connection_from_host(u.host, port=u.port, scheme=u.scheme,
- pool_kwargs=pool_kwargs)
-
- def _merge_pool_kwargs(self, override):
- """
- Merge a dictionary of override values for self.connection_pool_kw.
-
- This does not modify self.connection_pool_kw and returns a new dict.
- Any keys in the override dictionary with a value of ``None`` are
- removed from the merged dictionary.
- """
- base_pool_kwargs = self.connection_pool_kw.copy()
- if override:
- for key, value in override.items():
- if value is None:
- try:
- del base_pool_kwargs[key]
- except KeyError:
- pass
- else:
- base_pool_kwargs[key] = value
- return base_pool_kwargs
-
- def urlopen(self, method, url, redirect=True, **kw):
- """
- Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
- with custom cross-host redirect logic and only sends the request-uri
- portion of the ``url``.
-
- The given ``url`` parameter must be absolute, such that an appropriate
- :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
- """
- u = parse_url(url)
- conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
-
- kw['assert_same_host'] = False
- kw['redirect'] = False
-
- if 'headers' not in kw:
- kw['headers'] = self.headers.copy()
-
- if self.proxy is not None and u.scheme == "http":
- response = conn.urlopen(method, url, **kw)
- else:
- response = conn.urlopen(method, u.request_uri, **kw)
-
- redirect_location = redirect and response.get_redirect_location()
- if not redirect_location:
- return response
-
- # Support relative URLs for redirecting.
- redirect_location = urljoin(url, redirect_location)
-
- # RFC 7231, Section 6.4.4
- if response.status == 303:
- method = 'GET'
-
- retries = kw.get('retries')
- if not isinstance(retries, Retry):
- retries = Retry.from_int(retries, redirect=redirect)
-
- # Strip headers marked as unsafe to forward to the redirected location.
- # Check remove_headers_on_redirect to avoid a potential network call within
- # conn.is_same_host() which may use socket.gethostbyname() in the future.
- if (retries.remove_headers_on_redirect
- and not conn.is_same_host(redirect_location)):
- for header in retries.remove_headers_on_redirect:
- kw['headers'].pop(header, None)
-
- try:
- retries = retries.increment(method, url, response=response, _pool=conn)
- except MaxRetryError:
- if retries.raise_on_redirect:
- raise
- return response
-
- kw['retries'] = retries
- kw['redirect'] = redirect
-
- log.info("Redirecting %s -> %s", url, redirect_location)
- return self.urlopen(method, redirect_location, **kw)
-
-
-class ProxyManager(PoolManager):
- """
- Behaves just like :class:`PoolManager`, but sends all requests through
- the defined proxy, using the CONNECT method for HTTPS URLs.
-
- :param proxy_url:
- The URL of the proxy to be used.
-
- :param proxy_headers:
- A dictionary containing headers that will be sent to the proxy. In case
- of HTTP they are being sent with each request, while in the
- HTTPS/CONNECT case they are sent only once. Could be used for proxy
- authentication.
-
- Example:
- >>> proxy = urllib3.ProxyManager('http://localhost:3128/')
- >>> r1 = proxy.request('GET', 'http://google.com/')
- >>> r2 = proxy.request('GET', 'http://httpbin.org/')
- >>> len(proxy.pools)
- 1
- >>> r3 = proxy.request('GET', 'https://httpbin.org/')
- >>> r4 = proxy.request('GET', 'https://twitter.com/')
- >>> len(proxy.pools)
- 3
-
- """
-
- def __init__(self, proxy_url, num_pools=10, headers=None,
- proxy_headers=None, **connection_pool_kw):
-
- if isinstance(proxy_url, HTTPConnectionPool):
- proxy_url = '%s://%s:%i' % (proxy_url.scheme, proxy_url.host,
- proxy_url.port)
- proxy = parse_url(proxy_url)
- if not proxy.port:
- port = port_by_scheme.get(proxy.scheme, 80)
- proxy = proxy._replace(port=port)
-
- if proxy.scheme not in ("http", "https"):
- raise ProxySchemeUnknown(proxy.scheme)
-
- self.proxy = proxy
- self.proxy_headers = proxy_headers or {}
-
- connection_pool_kw['_proxy'] = self.proxy
- connection_pool_kw['_proxy_headers'] = self.proxy_headers
-
- super(ProxyManager, self).__init__(
- num_pools, headers, **connection_pool_kw)
-
- def connection_from_host(self, host, port=None, scheme='http', pool_kwargs=None):
- if scheme == "https":
- return super(ProxyManager, self).connection_from_host(
- host, port, scheme, pool_kwargs=pool_kwargs)
-
- return super(ProxyManager, self).connection_from_host(
- self.proxy.host, self.proxy.port, self.proxy.scheme, pool_kwargs=pool_kwargs)
-
- def _set_proxy_headers(self, url, headers=None):
- """
- Sets headers needed by proxies: specifically, the Accept and Host
- headers. Only sets headers not provided by the user.
- """
- headers_ = {'Accept': '*/*'}
-
- netloc = parse_url(url).netloc
- if netloc:
- headers_['Host'] = netloc
-
- if headers:
- headers_.update(headers)
- return headers_
-
- def urlopen(self, method, url, redirect=True, **kw):
- "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
- u = parse_url(url)
-
- if u.scheme == "http":
- # For proxied HTTPS requests, httplib sets the necessary headers
- # on the CONNECT to the proxy. For HTTP, we'll definitely
- # need to set 'Host' at the very least.
- headers = kw.get('headers', self.headers)
- kw['headers'] = self._set_proxy_headers(url, headers)
-
- return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw)
-
-
-def proxy_from_url(url, **kw):
- return ProxyManager(proxy_url=url, **kw)
diff --git a/python/urllib3/request.py b/python/urllib3/request.py
deleted file mode 100644
index 8f2f44b..0000000
--- a/python/urllib3/request.py
+++ /dev/null
@@ -1,150 +0,0 @@
-from __future__ import absolute_import
-
-from .filepost import encode_multipart_formdata
-from .packages.six.moves.urllib.parse import urlencode
-
-
-__all__ = ['RequestMethods']
-
-
-class RequestMethods(object):
- """
- Convenience mixin for classes who implement a :meth:`urlopen` method, such
- as :class:`~urllib3.connectionpool.HTTPConnectionPool` and
- :class:`~urllib3.poolmanager.PoolManager`.
-
- Provides behavior for making common types of HTTP request methods and
- decides which type of request field encoding to use.
-
- Specifically,
-
- :meth:`.request_encode_url` is for sending requests whose fields are
- encoded in the URL (such as GET, HEAD, DELETE).
-
- :meth:`.request_encode_body` is for sending requests whose fields are
- encoded in the *body* of the request using multipart or www-form-urlencoded
- (such as for POST, PUT, PATCH).
-
- :meth:`.request` is for making any kind of request, it will look up the
- appropriate encoding format and use one of the above two methods to make
- the request.
-
- Initializer parameters:
-
- :param headers:
- Headers to include with all requests, unless other headers are given
- explicitly.
- """
-
- _encode_url_methods = {'DELETE', 'GET', 'HEAD', 'OPTIONS'}
-
- def __init__(self, headers=None):
- self.headers = headers or {}
-
- def urlopen(self, method, url, body=None, headers=None,
- encode_multipart=True, multipart_boundary=None,
- **kw): # Abstract
- raise NotImplementedError("Classes extending RequestMethods must implement "
- "their own ``urlopen`` method.")
-
- def request(self, method, url, fields=None, headers=None, **urlopen_kw):
- """
- Make a request using :meth:`urlopen` with the appropriate encoding of
- ``fields`` based on the ``method`` used.
-
- This is a convenience method that requires the least amount of manual
- effort. It can be used in most situations, while still having the
- option to drop down to more specific methods when necessary, such as
- :meth:`request_encode_url`, :meth:`request_encode_body`,
- or even the lowest level :meth:`urlopen`.
- """
- method = method.upper()
-
- urlopen_kw['request_url'] = url
-
- if method in self._encode_url_methods:
- return self.request_encode_url(method, url, fields=fields,
- headers=headers,
- **urlopen_kw)
- else:
- return self.request_encode_body(method, url, fields=fields,
- headers=headers,
- **urlopen_kw)
-
- def request_encode_url(self, method, url, fields=None, headers=None,
- **urlopen_kw):
- """
- Make a request using :meth:`urlopen` with the ``fields`` encoded in
- the url. This is useful for request methods like GET, HEAD, DELETE, etc.
- """
- if headers is None:
- headers = self.headers
-
- extra_kw = {'headers': headers}
- extra_kw.update(urlopen_kw)
-
- if fields:
- url += '?' + urlencode(fields)
-
- return self.urlopen(method, url, **extra_kw)
-
- def request_encode_body(self, method, url, fields=None, headers=None,
- encode_multipart=True, multipart_boundary=None,
- **urlopen_kw):
- """
- Make a request using :meth:`urlopen` with the ``fields`` encoded in
- the body. This is useful for request methods like POST, PUT, PATCH, etc.
-
- When ``encode_multipart=True`` (default), then
- :meth:`urllib3.filepost.encode_multipart_formdata` is used to encode
- the payload with the appropriate content type. Otherwise
- :meth:`urllib.urlencode` is used with the
- 'application/x-www-form-urlencoded' content type.
-
- Multipart encoding must be used when posting files, and it's reasonably
- safe to use it in other times too. However, it may break request
- signing, such as with OAuth.
-
- Supports an optional ``fields`` parameter of key/value strings AND
- key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
- the MIME type is optional. For example::
-
- fields = {
- 'foo': 'bar',
- 'fakefile': ('foofile.txt', 'contents of foofile'),
- 'realfile': ('barfile.txt', open('realfile').read()),
- 'typedfile': ('bazfile.bin', open('bazfile').read(),
- 'image/jpeg'),
- 'nonamefile': 'contents of nonamefile field',
- }
-
- When uploading a file, providing a filename (the first parameter of the
- tuple) is optional but recommended to best mimic behavior of browsers.
-
- Note that if ``headers`` are supplied, the 'Content-Type' header will
- be overwritten because it depends on the dynamic random boundary string
- which is used to compose the body of the request. The random boundary
- string can be explicitly set with the ``multipart_boundary`` parameter.
- """
- if headers is None:
- headers = self.headers
-
- extra_kw = {'headers': {}}
-
- if fields:
- if 'body' in urlopen_kw:
- raise TypeError(
- "request got values for both 'fields' and 'body', can only specify one.")
-
- if encode_multipart:
- body, content_type = encode_multipart_formdata(fields, boundary=multipart_boundary)
- else:
- body, content_type = urlencode(fields), 'application/x-www-form-urlencoded'
-
- extra_kw['body'] = body
- extra_kw['headers'] = {'Content-Type': content_type}
-
- extra_kw['headers'].update(headers)
- extra_kw.update(urlopen_kw)
-
- return self.urlopen(method, url, **extra_kw)
diff --git a/python/urllib3/response.py b/python/urllib3/response.py
deleted file mode 100644
index c112690..0000000
--- a/python/urllib3/response.py
+++ /dev/null
@@ -1,705 +0,0 @@
-from __future__ import absolute_import
-from contextlib import contextmanager
-import zlib
-import io
-import logging
-from socket import timeout as SocketTimeout
-from socket import error as SocketError
-
-from ._collections import HTTPHeaderDict
-from .exceptions import (
- BodyNotHttplibCompatible, ProtocolError, DecodeError, ReadTimeoutError,
- ResponseNotChunked, IncompleteRead, InvalidHeader
-)
-from .packages.six import string_types as basestring, PY3
-from .packages.six.moves import http_client as httplib
-from .connection import HTTPException, BaseSSLError
-from .util.response import is_fp_closed, is_response_to_head
-
-log = logging.getLogger(__name__)
-
-
-class DeflateDecoder(object):
-
- def __init__(self):
- self._first_try = True
- self._data = b''
- self._obj = zlib.decompressobj()
-
- def __getattr__(self, name):
- return getattr(self._obj, name)
-
- def decompress(self, data):
- if not data:
- return data
-
- if not self._first_try:
- return self._obj.decompress(data)
-
- self._data += data
- try:
- decompressed = self._obj.decompress(data)
- if decompressed:
- self._first_try = False
- self._data = None
- return decompressed
- except zlib.error:
- self._first_try = False
- self._obj = zlib.decompressobj(-zlib.MAX_WBITS)
- try:
- return self.decompress(self._data)
- finally:
- self._data = None
-
-
-class GzipDecoderState(object):
-
- FIRST_MEMBER = 0
- OTHER_MEMBERS = 1
- SWALLOW_DATA = 2
-
-
-class GzipDecoder(object):
-
- def __init__(self):
- self._obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
- self._state = GzipDecoderState.FIRST_MEMBER
-
- def __getattr__(self, name):
- return getattr(self._obj, name)
-
- def decompress(self, data):
- ret = bytearray()
- if self._state == GzipDecoderState.SWALLOW_DATA or not data:
- return bytes(ret)
- while True:
- try:
- ret += self._obj.decompress(data)
- except zlib.error:
- previous_state = self._state
- # Ignore data after the first error
- self._state = GzipDecoderState.SWALLOW_DATA
- if previous_state == GzipDecoderState.OTHER_MEMBERS:
- # Allow trailing garbage acceptable in other gzip clients
- return bytes(ret)
- raise
- data = self._obj.unused_data
- if not data:
- return bytes(ret)
- self._state = GzipDecoderState.OTHER_MEMBERS
- self._obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
-
-
-class MultiDecoder(object):
- """
- From RFC7231:
- If one or more encodings have been applied to a representation, the
- sender that applied the encodings MUST generate a Content-Encoding
- header field that lists the content codings in the order in which
- they were applied.
- """
-
- def __init__(self, modes):
- self._decoders = [_get_decoder(m.strip()) for m in modes.split(',')]
-
- def flush(self):
- return self._decoders[0].flush()
-
- def decompress(self, data):
- for d in reversed(self._decoders):
- data = d.decompress(data)
- return data
-
-
-def _get_decoder(mode):
- if ',' in mode:
- return MultiDecoder(mode)
-
- if mode == 'gzip':
- return GzipDecoder()
-
- return DeflateDecoder()
-
-
-class HTTPResponse(io.IOBase):
- """
- HTTP Response container.
-
- Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
- loaded and decoded on-demand when the ``data`` property is accessed. This
- class is also compatible with the Python standard library's :mod:`io`
- module, and can hence be treated as a readable object in the context of that
- framework.
-
- Extra parameters for behaviour not present in httplib.HTTPResponse:
-
- :param preload_content:
- If True, the response's body will be preloaded during construction.
-
- :param decode_content:
- If True, will attempt to decode the body based on the
- 'content-encoding' header.
-
- :param original_response:
- When this HTTPResponse wrapper is generated from an httplib.HTTPResponse
- object, it's convenient to include the original for debug purposes. It's
- otherwise unused.
-
- :param retries:
- The retries contains the last :class:`~urllib3.util.retry.Retry` that
- was used during the request.
-
- :param enforce_content_length:
- Enforce content length checking. Body returned by server must match
- value of Content-Length header, if present. Otherwise, raise error.
- """
-
- CONTENT_DECODERS = ['gzip', 'deflate']
- REDIRECT_STATUSES = [301, 302, 303, 307, 308]
-
- def __init__(self, body='', headers=None, status=0, version=0, reason=None,
- strict=0, preload_content=True, decode_content=True,
- original_response=None, pool=None, connection=None, msg=None,
- retries=None, enforce_content_length=False,
- request_method=None, request_url=None):
-
- if isinstance(headers, HTTPHeaderDict):
- self.headers = headers
- else:
- self.headers = HTTPHeaderDict(headers)
- self.status = status
- self.version = version
- self.reason = reason
- self.strict = strict
- self.decode_content = decode_content
- self.retries = retries
- self.enforce_content_length = enforce_content_length
-
- self._decoder = None
- self._body = None
- self._fp = None
- self._original_response = original_response
- self._fp_bytes_read = 0
- self.msg = msg
- self._request_url = request_url
-
- if body and isinstance(body, (basestring, bytes)):
- self._body = body
-
- self._pool = pool
- self._connection = connection
-
- if hasattr(body, 'read'):
- self._fp = body
-
- # Are we using the chunked-style of transfer encoding?
- self.chunked = False
- self.chunk_left = None
- tr_enc = self.headers.get('transfer-encoding', '').lower()
- # Don't incur the penalty of creating a list and then discarding it
- encodings = (enc.strip() for enc in tr_enc.split(","))
- if "chunked" in encodings:
- self.chunked = True
-
- # Determine length of response
- self.length_remaining = self._init_length(request_method)
-
- # If requested, preload the body.
- if preload_content and not self._body:
- self._body = self.read(decode_content=decode_content)
-
- def get_redirect_location(self):
- """
- Should we redirect and where to?
-
- :returns: Truthy redirect location string if we got a redirect status
- code and valid location. ``None`` if redirect status and no
- location. ``False`` if not a redirect status code.
- """
- if self.status in self.REDIRECT_STATUSES:
- return self.headers.get('location')
-
- return False
-
- def release_conn(self):
- if not self._pool or not self._connection:
- return
-
- self._pool._put_conn(self._connection)
- self._connection = None
-
- @property
- def data(self):
- # For backwords-compat with earlier urllib3 0.4 and earlier.
- if self._body:
- return self._body
-
- if self._fp:
- return self.read(cache_content=True)
-
- @property
- def connection(self):
- return self._connection
-
- def isclosed(self):
- return is_fp_closed(self._fp)
-
- def tell(self):
- """
- Obtain the number of bytes pulled over the wire so far. May differ from
- the amount of content returned by :meth:``HTTPResponse.read`` if bytes
- are encoded on the wire (e.g, compressed).
- """
- return self._fp_bytes_read
-
- def _init_length(self, request_method):
- """
- Set initial length value for Response content if available.
- """
- length = self.headers.get('content-length')
-
- if length is not None:
- if self.chunked:
- # This Response will fail with an IncompleteRead if it can't be
- # received as chunked. This method falls back to attempt reading
- # the response before raising an exception.
- log.warning("Received response with both Content-Length and "
- "Transfer-Encoding set. This is expressly forbidden "
- "by RFC 7230 sec 3.3.2. Ignoring Content-Length and "
- "attempting to process response as Transfer-Encoding: "
- "chunked.")
- return None
-
- try:
- # RFC 7230 section 3.3.2 specifies multiple content lengths can
- # be sent in a single Content-Length header
- # (e.g. Content-Length: 42, 42). This line ensures the values
- # are all valid ints and that as long as the `set` length is 1,
- # all values are the same. Otherwise, the header is invalid.
- lengths = set([int(val) for val in length.split(',')])
- if len(lengths) > 1:
- raise InvalidHeader("Content-Length contained multiple "
- "unmatching values (%s)" % length)
- length = lengths.pop()
- except ValueError:
- length = None
- else:
- if length < 0:
- length = None
-
- # Convert status to int for comparison
- # In some cases, httplib returns a status of "_UNKNOWN"
- try:
- status = int(self.status)
- except ValueError:
- status = 0
-
- # Check for responses that shouldn't include a body
- if status in (204, 304) or 100 <= status < 200 or request_method == 'HEAD':
- length = 0
-
- return length
-
- def _init_decoder(self):
- """
- Set-up the _decoder attribute if necessary.
- """
- # Note: content-encoding value should be case-insensitive, per RFC 7230
- # Section 3.2
- content_encoding = self.headers.get('content-encoding', '').lower()
- if self._decoder is None:
- if content_encoding in self.CONTENT_DECODERS:
- self._decoder = _get_decoder(content_encoding)
- elif ',' in content_encoding:
- encodings = [e.strip() for e in content_encoding.split(',') if e.strip() in self.CONTENT_DECODERS]
- if len(encodings):
- self._decoder = _get_decoder(content_encoding)
-
- def _decode(self, data, decode_content, flush_decoder):
- """
- Decode the data passed in and potentially flush the decoder.
- """
- try:
- if decode_content and self._decoder:
- data = self._decoder.decompress(data)
- except (IOError, zlib.error) as e:
- content_encoding = self.headers.get('content-encoding', '').lower()
- raise DecodeError(
- "Received response with content-encoding: %s, but "
- "failed to decode it." % content_encoding, e)
-
- if flush_decoder and decode_content:
- data += self._flush_decoder()
-
- return data
-
- def _flush_decoder(self):
- """
- Flushes the decoder. Should only be called if the decoder is actually
- being used.
- """
- if self._decoder:
- buf = self._decoder.decompress(b'')
- return buf + self._decoder.flush()
-
- return b''
-
- @contextmanager
- def _error_catcher(self):
- """
- Catch low-level python exceptions, instead re-raising urllib3
- variants, so that low-level exceptions are not leaked in the
- high-level api.
-
- On exit, release the connection back to the pool.
- """
- clean_exit = False
-
- try:
- try:
- yield
-
- except SocketTimeout:
- # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
- # there is yet no clean way to get at it from this context.
- raise ReadTimeoutError(self._pool, None, 'Read timed out.')
-
- except BaseSSLError as e:
- # FIXME: Is there a better way to differentiate between SSLErrors?
- if 'read operation timed out' not in str(e): # Defensive:
- # This shouldn't happen but just in case we're missing an edge
- # case, let's avoid swallowing SSL errors.
- raise
-
- raise ReadTimeoutError(self._pool, None, 'Read timed out.')
-
- except (HTTPException, SocketError) as e:
- # This includes IncompleteRead.
- raise ProtocolError('Connection broken: %r' % e, e)
-
- # If no exception is thrown, we should avoid cleaning up
- # unnecessarily.
- clean_exit = True
- finally:
- # If we didn't terminate cleanly, we need to throw away our
- # connection.
- if not clean_exit:
- # The response may not be closed but we're not going to use it
- # anymore so close it now to ensure that the connection is
- # released back to the pool.
- if self._original_response:
- self._original_response.close()
-
- # Closing the response may not actually be sufficient to close
- # everything, so if we have a hold of the connection close that
- # too.
- if self._connection:
- self._connection.close()
-
- # If we hold the original response but it's closed now, we should
- # return the connection back to the pool.
- if self._original_response and self._original_response.isclosed():
- self.release_conn()
-
- def read(self, amt=None, decode_content=None, cache_content=False):
- """
- Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
- parameters: ``decode_content`` and ``cache_content``.
-
- :param amt:
- How much of the content to read. If specified, caching is skipped
- because it doesn't make sense to cache partial content as the full
- response.
-
- :param decode_content:
- If True, will attempt to decode the body based on the
- 'content-encoding' header.
-
- :param cache_content:
- If True, will save the returned data such that the same result is
- returned despite of the state of the underlying file object. This
- is useful if you want the ``.data`` property to continue working
- after having ``.read()`` the file object. (Overridden if ``amt`` is
- set.)
- """
- self._init_decoder()
- if decode_content is None:
- decode_content = self.decode_content
-
- if self._fp is None:
- return
-
- flush_decoder = False
- data = None
-
- with self._error_catcher():
- if amt is None:
- # cStringIO doesn't like amt=None
- data = self._fp.read()
- flush_decoder = True
- else:
- cache_content = False
- data = self._fp.read(amt)
- if amt != 0 and not data: # Platform-specific: Buggy versions of Python.
- # Close the connection when no data is returned
- #
- # This is redundant to what httplib/http.client _should_
- # already do. However, versions of python released before
- # December 15, 2012 (http://bugs.python.org/issue16298) do
- # not properly close the connection in all cases. There is
- # no harm in redundantly calling close.
- self._fp.close()
- flush_decoder = True
- if self.enforce_content_length and self.length_remaining not in (0, None):
- # This is an edge case that httplib failed to cover due
- # to concerns of backward compatibility. We're
- # addressing it here to make sure IncompleteRead is
- # raised during streaming, so all calls with incorrect
- # Content-Length are caught.
- raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
-
- if data:
- self._fp_bytes_read += len(data)
- if self.length_remaining is not None:
- self.length_remaining -= len(data)
-
- data = self._decode(data, decode_content, flush_decoder)
-
- if cache_content:
- self._body = data
-
- return data
-
- def stream(self, amt=2**16, decode_content=None):
- """
- A generator wrapper for the read() method. A call will block until
- ``amt`` bytes have been read from the connection or until the
- connection is closed.
-
- :param amt:
- How much of the content to read. The generator will return up to
- much data per iteration, but may return less. This is particularly
- likely when using compressed data. However, the empty string will
- never be returned.
-
- :param decode_content:
- If True, will attempt to decode the body based on the
- 'content-encoding' header.
- """
- if self.chunked and self.supports_chunked_reads():
- for line in self.read_chunked(amt, decode_content=decode_content):
- yield line
- else:
- while not is_fp_closed(self._fp):
- data = self.read(amt=amt, decode_content=decode_content)
-
- if data:
- yield data
-
- @classmethod
- def from_httplib(ResponseCls, r, **response_kw):
- """
- Given an :class:`httplib.HTTPResponse` instance ``r``, return a
- corresponding :class:`urllib3.response.HTTPResponse` object.
-
- Remaining parameters are passed to the HTTPResponse constructor, along
- with ``original_response=r``.
- """
- headers = r.msg
-
- if not isinstance(headers, HTTPHeaderDict):
- if PY3: # Python 3
- headers = HTTPHeaderDict(headers.items())
- else: # Python 2
- headers = HTTPHeaderDict.from_httplib(headers)
-
- # HTTPResponse objects in Python 3 don't have a .strict attribute
- strict = getattr(r, 'strict', 0)
- resp = ResponseCls(body=r,
- headers=headers,
- status=r.status,
- version=r.version,
- reason=r.reason,
- strict=strict,
- original_response=r,
- **response_kw)
- return resp
-
- # Backwards-compatibility methods for httplib.HTTPResponse
- def getheaders(self):
- return self.headers
-
- def getheader(self, name, default=None):
- return self.headers.get(name, default)
-
- # Backwards compatibility for http.cookiejar
- def info(self):
- return self.headers
-
- # Overrides from io.IOBase
- def close(self):
- if not self.closed:
- self._fp.close()
-
- if self._connection:
- self._connection.close()
-
- @property
- def closed(self):
- if self._fp is None:
- return True
- elif hasattr(self._fp, 'isclosed'):
- return self._fp.isclosed()
- elif hasattr(self._fp, 'closed'):
- return self._fp.closed
- else:
- return True
-
- def fileno(self):
- if self._fp is None:
- raise IOError("HTTPResponse has no file to get a fileno from")
- elif hasattr(self._fp, "fileno"):
- return self._fp.fileno()
- else:
- raise IOError("The file-like object this HTTPResponse is wrapped "
- "around has no file descriptor")
-
- def flush(self):
- if self._fp is not None and hasattr(self._fp, 'flush'):
- return self._fp.flush()
-
- def readable(self):
- # This method is required for `io` module compatibility.
- return True
-
- def readinto(self, b):
- # This method is required for `io` module compatibility.
- temp = self.read(len(b))
- if len(temp) == 0:
- return 0
- else:
- b[:len(temp)] = temp
- return len(temp)
-
- def supports_chunked_reads(self):
- """
- Checks if the underlying file-like object looks like a
- httplib.HTTPResponse object. We do this by testing for the fp
- attribute. If it is present we assume it returns raw chunks as
- processed by read_chunked().
- """
- return hasattr(self._fp, 'fp')
-
- def _update_chunk_length(self):
- # First, we'll figure out length of a chunk and then
- # we'll try to read it from socket.
- if self.chunk_left is not None:
- return
- line = self._fp.fp.readline()
- line = line.split(b';', 1)[0]
- try:
- self.chunk_left = int(line, 16)
- except ValueError:
- # Invalid chunked protocol response, abort.
- self.close()
- raise httplib.IncompleteRead(line)
-
- def _handle_chunk(self, amt):
- returned_chunk = None
- if amt is None:
- chunk = self._fp._safe_read(self.chunk_left)
- returned_chunk = chunk
- self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
- self.chunk_left = None
- elif amt < self.chunk_left:
- value = self._fp._safe_read(amt)
- self.chunk_left = self.chunk_left - amt
- returned_chunk = value
- elif amt == self.chunk_left:
- value = self._fp._safe_read(amt)
- self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
- self.chunk_left = None
- returned_chunk = value
- else: # amt > self.chunk_left
- returned_chunk = self._fp._safe_read(self.chunk_left)
- self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
- self.chunk_left = None
- return returned_chunk
-
- def read_chunked(self, amt=None, decode_content=None):
- """
- Similar to :meth:`HTTPResponse.read`, but with an additional
- parameter: ``decode_content``.
-
- :param amt:
- How much of the content to read. If specified, caching is skipped
- because it doesn't make sense to cache partial content as the full
- response.
-
- :param decode_content:
- If True, will attempt to decode the body based on the
- 'content-encoding' header.
- """
- self._init_decoder()
- # FIXME: Rewrite this method and make it a class with a better structured logic.
- if not self.chunked:
- raise ResponseNotChunked(
- "Response is not chunked. "
- "Header 'transfer-encoding: chunked' is missing.")
- if not self.supports_chunked_reads():
- raise BodyNotHttplibCompatible(
- "Body should be httplib.HTTPResponse like. "
- "It should have have an fp attribute which returns raw chunks.")
-
- with self._error_catcher():
- # Don't bother reading the body of a HEAD request.
- if self._original_response and is_response_to_head(self._original_response):
- self._original_response.close()
- return
-
- # If a response is already read and closed
- # then return immediately.
- if self._fp.fp is None:
- return
-
- while True:
- self._update_chunk_length()
- if self.chunk_left == 0:
- break
- chunk = self._handle_chunk(amt)
- decoded = self._decode(chunk, decode_content=decode_content,
- flush_decoder=False)
- if decoded:
- yield decoded
-
- if decode_content:
- # On CPython and PyPy, we should never need to flush the
- # decoder. However, on Jython we *might* need to, so
- # lets defensively do it anyway.
- decoded = self._flush_decoder()
- if decoded: # Platform-specific: Jython.
- yield decoded
-
- # Chunk content ends with \r\n: discard it.
- while True:
- line = self._fp.fp.readline()
- if not line:
- # Some sites may not end with '\r\n'.
- break
- if line == b'\r\n':
- break
-
- # We read everything; close the "file".
- if self._original_response:
- self._original_response.close()
-
- def geturl(self):
- """
- Returns the URL that was the source of this response.
- If the request that generated this response redirected, this method
- will return the final redirect location.
- """
- if self.retries is not None and len(self.retries.history):
- return self.retries.history[-1].redirect_location
- else:
- return self._request_url
diff --git a/python/urllib3/util/__init__.py b/python/urllib3/util/__init__.py
deleted file mode 100644
index 2f2770b..0000000
--- a/python/urllib3/util/__init__.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import absolute_import
-# For backwards compatibility, provide imports that used to be here.
-from .connection import is_connection_dropped
-from .request import make_headers
-from .response import is_fp_closed
-from .ssl_ import (
- SSLContext,
- HAS_SNI,
- IS_PYOPENSSL,
- IS_SECURETRANSPORT,
- assert_fingerprint,
- resolve_cert_reqs,
- resolve_ssl_version,
- ssl_wrap_socket,
-)
-from .timeout import (
- current_time,
- Timeout,
-)
-
-from .retry import Retry
-from .url import (
- get_host,
- parse_url,
- split_first,
- Url,
-)
-from .wait import (
- wait_for_read,
- wait_for_write
-)
-
-__all__ = (
- 'HAS_SNI',
- 'IS_PYOPENSSL',
- 'IS_SECURETRANSPORT',
- 'SSLContext',
- 'Retry',
- 'Timeout',
- 'Url',
- 'assert_fingerprint',
- 'current_time',
- 'is_connection_dropped',
- 'is_fp_closed',
- 'get_host',
- 'parse_url',
- 'make_headers',
- 'resolve_cert_reqs',
- 'resolve_ssl_version',
- 'split_first',
- 'ssl_wrap_socket',
- 'wait_for_read',
- 'wait_for_write'
-)
diff --git a/python/urllib3/util/connection.py b/python/urllib3/util/connection.py
deleted file mode 100644
index 5ad70b2..0000000
--- a/python/urllib3/util/connection.py
+++ /dev/null
@@ -1,134 +0,0 @@
-from __future__ import absolute_import
-import socket
-from .wait import NoWayToWaitForSocketError, wait_for_read
-from ..contrib import _appengine_environ
-
-
-def is_connection_dropped(conn): # Platform-specific
- """
- Returns True if the connection is dropped and should be closed.
-
- :param conn:
- :class:`httplib.HTTPConnection` object.
-
- Note: For platforms like AppEngine, this will always return ``False`` to
- let the platform handle connection recycling transparently for us.
- """
- sock = getattr(conn, 'sock', False)
- if sock is False: # Platform-specific: AppEngine
- return False
- if sock is None: # Connection already closed (such as by httplib).
- return True
- try:
- # Returns True if readable, which here means it's been dropped
- return wait_for_read(sock, timeout=0.0)
- except NoWayToWaitForSocketError: # Platform-specific: AppEngine
- return False
-
-
-# This function is copied from socket.py in the Python 2.7 standard
-# library test suite. Added to its signature is only `socket_options`.
-# One additional modification is that we avoid binding to IPv6 servers
-# discovered in DNS if the system doesn't have IPv6 functionality.
-def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
- source_address=None, socket_options=None):
- """Connect to *address* and return the socket object.
-
- Convenience function. Connect to *address* (a 2-tuple ``(host,
- port)``) and return the socket object. Passing the optional
- *timeout* parameter will set the timeout on the socket instance
- before attempting to connect. If no *timeout* is supplied, the
- global default timeout setting returned by :func:`getdefaulttimeout`
- is used. If *source_address* is set it must be a tuple of (host, port)
- for the socket to bind as a source address before making the connection.
- An host of '' or port 0 tells the OS to use the default.
- """
-
- host, port = address
- if host.startswith('['):
- host = host.strip('[]')
- err = None
-
- # Using the value from allowed_gai_family() in the context of getaddrinfo lets
- # us select whether to work with IPv4 DNS records, IPv6 records, or both.
- # The original create_connection function always returns all records.
- family = allowed_gai_family()
-
- for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
- af, socktype, proto, canonname, sa = res
- sock = None
- try:
- sock = socket.socket(af, socktype, proto)
-
- # If provided, set socket level options before connecting.
- _set_socket_options(sock, socket_options)
-
- if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
- sock.settimeout(timeout)
- if source_address:
- sock.bind(source_address)
- sock.connect(sa)
- return sock
-
- except socket.error as e:
- err = e
- if sock is not None:
- sock.close()
- sock = None
-
- if err is not None:
- raise err
-
- raise socket.error("getaddrinfo returns an empty list")
-
-
-def _set_socket_options(sock, options):
- if options is None:
- return
-
- for opt in options:
- sock.setsockopt(*opt)
-
-
-def allowed_gai_family():
- """This function is designed to work in the context of
- getaddrinfo, where family=socket.AF_UNSPEC is the default and
- will perform a DNS search for both IPv6 and IPv4 records."""
-
- family = socket.AF_INET
- if HAS_IPV6:
- family = socket.AF_UNSPEC
- return family
-
-
-def _has_ipv6(host):
- """ Returns True if the system can bind an IPv6 address. """
- sock = None
- has_ipv6 = False
-
- # App Engine doesn't support IPV6 sockets and actually has a quota on the
- # number of sockets that can be used, so just early out here instead of
- # creating a socket needlessly.
- # See https://github.com/urllib3/urllib3/issues/1446
- if _appengine_environ.is_appengine_sandbox():
- return False
-
- if socket.has_ipv6:
- # has_ipv6 returns true if cPython was compiled with IPv6 support.
- # It does not tell us if the system has IPv6 support enabled. To
- # determine that we must bind to an IPv6 address.
- # https://github.com/shazow/urllib3/pull/611
- # https://bugs.python.org/issue658327
- try:
- sock = socket.socket(socket.AF_INET6)
- sock.bind((host, 0))
- has_ipv6 = True
- except Exception:
- pass
-
- if sock:
- sock.close()
- return has_ipv6
-
-
-HAS_IPV6 = _has_ipv6('::1')
diff --git a/python/urllib3/util/queue.py b/python/urllib3/util/queue.py
deleted file mode 100644
index d3d379a..0000000
--- a/python/urllib3/util/queue.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import collections
-from ..packages import six
-from ..packages.six.moves import queue
-
-if six.PY2:
- # Queue is imported for side effects on MS Windows. See issue #229.
- import Queue as _unused_module_Queue # noqa: F401
-
-
-class LifoQueue(queue.Queue):
- def _init(self, _):
- self.queue = collections.deque()
-
- def _qsize(self, len=len):
- return len(self.queue)
-
- def _put(self, item):
- self.queue.append(item)
-
- def _get(self):
- return self.queue.pop()
diff --git a/python/urllib3/util/request.py b/python/urllib3/util/request.py
deleted file mode 100644
index 3ddfcd5..0000000
--- a/python/urllib3/util/request.py
+++ /dev/null
@@ -1,118 +0,0 @@
-from __future__ import absolute_import
-from base64 import b64encode
-
-from ..packages.six import b, integer_types
-from ..exceptions import UnrewindableBodyError
-
-ACCEPT_ENCODING = 'gzip,deflate'
-_FAILEDTELL = object()
-
-
-def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,
- basic_auth=None, proxy_basic_auth=None, disable_cache=None):
- """
- Shortcuts for generating request headers.
-
- :param keep_alive:
- If ``True``, adds 'connection: keep-alive' header.
-
- :param accept_encoding:
- Can be a boolean, list, or string.
- ``True`` translates to 'gzip,deflate'.
- List will get joined by comma.
- String will be used as provided.
-
- :param user_agent:
- String representing the user-agent you want, such as
- "python-urllib3/0.6"
-
- :param basic_auth:
- Colon-separated username:password string for 'authorization: basic ...'
- auth header.
-
- :param proxy_basic_auth:
- Colon-separated username:password string for 'proxy-authorization: basic ...'
- auth header.
-
- :param disable_cache:
- If ``True``, adds 'cache-control: no-cache' header.
-
- Example::
-
- >>> make_headers(keep_alive=True, user_agent="Batman/1.0")
- {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
- >>> make_headers(accept_encoding=True)
- {'accept-encoding': 'gzip,deflate'}
- """
- headers = {}
- if accept_encoding:
- if isinstance(accept_encoding, str):
- pass
- elif isinstance(accept_encoding, list):
- accept_encoding = ','.join(accept_encoding)
- else:
- accept_encoding = ACCEPT_ENCODING
- headers['accept-encoding'] = accept_encoding
-
- if user_agent:
- headers['user-agent'] = user_agent
-
- if keep_alive:
- headers['connection'] = 'keep-alive'
-
- if basic_auth:
- headers['authorization'] = 'Basic ' + \
- b64encode(b(basic_auth)).decode('utf-8')
-
- if proxy_basic_auth:
- headers['proxy-authorization'] = 'Basic ' + \
- b64encode(b(proxy_basic_auth)).decode('utf-8')
-
- if disable_cache:
- headers['cache-control'] = 'no-cache'
-
- return headers
-
-
-def set_file_position(body, pos):
- """
- If a position is provided, move file to that point.
- Otherwise, we'll attempt to record a position for future use.
- """
- if pos is not None:
- rewind_body(body, pos)
- elif getattr(body, 'tell', None) is not None:
- try:
- pos = body.tell()
- except (IOError, OSError):
- # This differentiates from None, allowing us to catch
- # a failed `tell()` later when trying to rewind the body.
- pos = _FAILEDTELL
-
- return pos
-
-
-def rewind_body(body, body_pos):
- """
- Attempt to rewind body to a certain position.
- Primarily used for request redirects and retries.
-
- :param body:
- File-like object that supports seek.
-
- :param int pos:
- Position to seek to in file.
- """
- body_seek = getattr(body, 'seek', None)
- if body_seek is not None and isinstance(body_pos, integer_types):
- try:
- body_seek(body_pos)
- except (IOError, OSError):
- raise UnrewindableBodyError("An error occurred when rewinding request "
- "body for redirect/retry.")
- elif body_pos is _FAILEDTELL:
- raise UnrewindableBodyError("Unable to record file position for rewinding "
- "request body during a redirect/retry.")
- else:
- raise ValueError("body_pos must be of type integer, "
- "instead it was %s." % type(body_pos))
diff --git a/python/urllib3/util/response.py b/python/urllib3/util/response.py
deleted file mode 100644
index 3d54864..0000000
--- a/python/urllib3/util/response.py
+++ /dev/null
@@ -1,87 +0,0 @@
-from __future__ import absolute_import
-from ..packages.six.moves import http_client as httplib
-
-from ..exceptions import HeaderParsingError
-
-
-def is_fp_closed(obj):
- """
- Checks whether a given file-like object is closed.
-
- :param obj:
- The file-like object to check.
- """
-
- try:
- # Check `isclosed()` first, in case Python3 doesn't set `closed`.
- # GH Issue #928
- return obj.isclosed()
- except AttributeError:
- pass
-
- try:
- # Check via the official file-like-object way.
- return obj.closed
- except AttributeError:
- pass
-
- try:
- # Check if the object is a container for another file-like object that
- # gets released on exhaustion (e.g. HTTPResponse).
- return obj.fp is None
- except AttributeError:
- pass
-
- raise ValueError("Unable to determine whether fp is closed.")
-
-
-def assert_header_parsing(headers):
- """
- Asserts whether all headers have been successfully parsed.
- Extracts encountered errors from the result of parsing headers.
-
- Only works on Python 3.
-
- :param headers: Headers to verify.
- :type headers: `httplib.HTTPMessage`.
-
- :raises urllib3.exceptions.HeaderParsingError:
- If parsing errors are found.
- """
-
- # This will fail silently if we pass in the wrong kind of parameter.
- # To make debugging easier add an explicit check.
- if not isinstance(headers, httplib.HTTPMessage):
- raise TypeError('expected httplib.Message, got {0}.'.format(
- type(headers)))
-
- defects = getattr(headers, 'defects', None)
- get_payload = getattr(headers, 'get_payload', None)
-
- unparsed_data = None
- if get_payload:
- # get_payload is actually email.message.Message.get_payload;
- # we're only interested in the result if it's not a multipart message
- if not headers.is_multipart():
- payload = get_payload()
-
- if isinstance(payload, (bytes, str)):
- unparsed_data = payload
-
- if defects or unparsed_data:
- raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
-
-
-def is_response_to_head(response):
- """
- Checks whether the request of a response has been a HEAD-request.
- Handles the quirks of AppEngine.
-
- :param conn:
- :type conn: :class:`httplib.HTTPResponse`
- """
- # FIXME: Can we do this somehow without accessing private httplib _method?
- method = response._method
- if isinstance(method, int): # Platform-specific: Appengine
- return method == 3
- return method.upper() == 'HEAD'
diff --git a/python/urllib3/util/retry.py b/python/urllib3/util/retry.py
deleted file mode 100644
index e7d0abd..0000000
--- a/python/urllib3/util/retry.py
+++ /dev/null
@@ -1,411 +0,0 @@
-from __future__ import absolute_import
-import time
-import logging
-from collections import namedtuple
-from itertools import takewhile
-import email
-import re
-
-from ..exceptions import (
- ConnectTimeoutError,
- MaxRetryError,
- ProtocolError,
- ReadTimeoutError,
- ResponseError,
- InvalidHeader,
-)
-from ..packages import six
-
-
-log = logging.getLogger(__name__)
-
-
-# Data structure for representing the metadata of requests that result in a retry.
-RequestHistory = namedtuple('RequestHistory', ["method", "url", "error",
- "status", "redirect_location"])
-
-
-class Retry(object):
- """ Retry configuration.
-
- Each retry attempt will create a new Retry object with updated values, so
- they can be safely reused.
-
- Retries can be defined as a default for a pool::
-
- retries = Retry(connect=5, read=2, redirect=5)
- http = PoolManager(retries=retries)
- response = http.request('GET', 'http://example.com/')
-
- Or per-request (which overrides the default for the pool)::
-
- response = http.request('GET', 'http://example.com/', retries=Retry(10))
-
- Retries can be disabled by passing ``False``::
-
- response = http.request('GET', 'http://example.com/', retries=False)
-
- Errors will be wrapped in :class:`~urllib3.exceptions.MaxRetryError` unless
- retries are disabled, in which case the causing exception will be raised.
-
- :param int total:
- Total number of retries to allow. Takes precedence over other counts.
-
- Set to ``None`` to remove this constraint and fall back on other
- counts. It's a good idea to set this to some sensibly-high value to
- account for unexpected edge cases and avoid infinite retry loops.
-
- Set to ``0`` to fail on the first retry.
-
- Set to ``False`` to disable and imply ``raise_on_redirect=False``.
-
- :param int connect:
- How many connection-related errors to retry on.
-
- These are errors raised before the request is sent to the remote server,
- which we assume has not triggered the server to process the request.
-
- Set to ``0`` to fail on the first retry of this type.
-
- :param int read:
- How many times to retry on read errors.
-
- These errors are raised after the request was sent to the server, so the
- request may have side-effects.
-
- Set to ``0`` to fail on the first retry of this type.
-
- :param int redirect:
- How many redirects to perform. Limit this to avoid infinite redirect
- loops.
-
- A redirect is a HTTP response with a status code 301, 302, 303, 307 or
- 308.
-
- Set to ``0`` to fail on the first retry of this type.
-
- Set to ``False`` to disable and imply ``raise_on_redirect=False``.
-
- :param int status:
- How many times to retry on bad status codes.
-
- These are retries made on responses, where status code matches
- ``status_forcelist``.
-
- Set to ``0`` to fail on the first retry of this type.
-
- :param iterable method_whitelist:
- Set of uppercased HTTP method verbs that we should retry on.
-
- By default, we only retry on methods which are considered to be
- idempotent (multiple requests with the same parameters end with the
- same state). See :attr:`Retry.DEFAULT_METHOD_WHITELIST`.
-
- Set to a ``False`` value to retry on any verb.
-
- :param iterable status_forcelist:
- A set of integer HTTP status codes that we should force a retry on.
- A retry is initiated if the request method is in ``method_whitelist``
- and the response status code is in ``status_forcelist``.
-
- By default, this is disabled with ``None``.
-
- :param float backoff_factor:
- A backoff factor to apply between attempts after the second try
- (most errors are resolved immediately by a second try without a
- delay). urllib3 will sleep for::
-
- {backoff factor} * (2 ** ({number of total retries} - 1))
-
- seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep
- for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer
- than :attr:`Retry.BACKOFF_MAX`.
-
- By default, backoff is disabled (set to 0).
-
- :param bool raise_on_redirect: Whether, if the number of redirects is
- exhausted, to raise a MaxRetryError, or to return a response with a
- response code in the 3xx range.
-
- :param bool raise_on_status: Similar meaning to ``raise_on_redirect``:
- whether we should raise an exception, or return a response,
- if status falls in ``status_forcelist`` range and retries have
- been exhausted.
-
- :param tuple history: The history of the request encountered during
- each call to :meth:`~Retry.increment`. The list is in the order
- the requests occurred. Each list item is of class :class:`RequestHistory`.
-
- :param bool respect_retry_after_header:
- Whether to respect Retry-After header on status codes defined as
- :attr:`Retry.RETRY_AFTER_STATUS_CODES` or not.
-
- :param iterable remove_headers_on_redirect:
- Sequence of headers to remove from the request when a response
- indicating a redirect is returned before firing off the redirected
- request.
- """
-
- DEFAULT_METHOD_WHITELIST = frozenset([
- 'HEAD', 'GET', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'])
-
- RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503])
-
- DEFAULT_REDIRECT_HEADERS_BLACKLIST = frozenset(['Authorization'])
-
- #: Maximum backoff time.
- BACKOFF_MAX = 120
-
- def __init__(self, total=10, connect=None, read=None, redirect=None, status=None,
- method_whitelist=DEFAULT_METHOD_WHITELIST, status_forcelist=None,
- backoff_factor=0, raise_on_redirect=True, raise_on_status=True,
- history=None, respect_retry_after_header=True,
- remove_headers_on_redirect=DEFAULT_REDIRECT_HEADERS_BLACKLIST):
-
- self.total = total
- self.connect = connect
- self.read = read
- self.status = status
-
- if redirect is False or total is False:
- redirect = 0
- raise_on_redirect = False
-
- self.redirect = redirect
- self.status_forcelist = status_forcelist or set()
- self.method_whitelist = method_whitelist
- self.backoff_factor = backoff_factor
- self.raise_on_redirect = raise_on_redirect
- self.raise_on_status = raise_on_status
- self.history = history or tuple()
- self.respect_retry_after_header = respect_retry_after_header
- self.remove_headers_on_redirect = remove_headers_on_redirect
-
- def new(self, **kw):
- params = dict(
- total=self.total,
- connect=self.connect, read=self.read, redirect=self.redirect, status=self.status,
- method_whitelist=self.method_whitelist,
- status_forcelist=self.status_forcelist,
- backoff_factor=self.backoff_factor,
- raise_on_redirect=self.raise_on_redirect,
- raise_on_status=self.raise_on_status,
- history=self.history,
- remove_headers_on_redirect=self.remove_headers_on_redirect
- )
- params.update(kw)
- return type(self)(**params)
-
- @classmethod
- def from_int(cls, retries, redirect=True, default=None):
- """ Backwards-compatibility for the old retries format."""
- if retries is None:
- retries = default if default is not None else cls.DEFAULT
-
- if isinstance(retries, Retry):
- return retries
-
- redirect = bool(redirect) and None
- new_retries = cls(retries, redirect=redirect)
- log.debug("Converted retries value: %r -> %r", retries, new_retries)
- return new_retries
-
- def get_backoff_time(self):
- """ Formula for computing the current backoff
-
- :rtype: float
- """
- # We want to consider only the last consecutive errors sequence (Ignore redirects).
- consecutive_errors_len = len(list(takewhile(lambda x: x.redirect_location is None,
- reversed(self.history))))
- if consecutive_errors_len <= 1:
- return 0
-
- backoff_value = self.backoff_factor * (2 ** (consecutive_errors_len - 1))
- return min(self.BACKOFF_MAX, backoff_value)
-
- def parse_retry_after(self, retry_after):
- # Whitespace: https://tools.ietf.org/html/rfc7230#section-3.2.4
- if re.match(r"^\s*[0-9]+\s*$", retry_after):
- seconds = int(retry_after)
- else:
- retry_date_tuple = email.utils.parsedate(retry_after)
- if retry_date_tuple is None:
- raise InvalidHeader("Invalid Retry-After header: %s" % retry_after)
- retry_date = time.mktime(retry_date_tuple)
- seconds = retry_date - time.time()
-
- if seconds < 0:
- seconds = 0
-
- return seconds
-
- def get_retry_after(self, response):
- """ Get the value of Retry-After in seconds. """
-
- retry_after = response.getheader("Retry-After")
-
- if retry_after is None:
- return None
-
- return self.parse_retry_after(retry_after)
-
- def sleep_for_retry(self, response=None):
- retry_after = self.get_retry_after(response)
- if retry_after:
- time.sleep(retry_after)
- return True
-
- return False
-
- def _sleep_backoff(self):
- backoff = self.get_backoff_time()
- if backoff <= 0:
- return
- time.sleep(backoff)
-
- def sleep(self, response=None):
- """ Sleep between retry attempts.
-
- This method will respect a server's ``Retry-After`` response header
- and sleep the duration of the time requested. If that is not present, it
- will use an exponential backoff. By default, the backoff factor is 0 and
- this method will return immediately.
- """
-
- if response:
- slept = self.sleep_for_retry(response)
- if slept:
- return
-
- self._sleep_backoff()
-
- def _is_connection_error(self, err):
- """ Errors when we're fairly sure that the server did not receive the
- request, so it should be safe to retry.
- """
- return isinstance(err, ConnectTimeoutError)
-
- def _is_read_error(self, err):
- """ Errors that occur after the request has been started, so we should
- assume that the server began processing it.
- """
- return isinstance(err, (ReadTimeoutError, ProtocolError))
-
- def _is_method_retryable(self, method):
- """ Checks if a given HTTP method should be retried upon, depending if
- it is included on the method whitelist.
- """
- if self.method_whitelist and method.upper() not in self.method_whitelist:
- return False
-
- return True
-
- def is_retry(self, method, status_code, has_retry_after=False):
- """ Is this method/status code retryable? (Based on whitelists and control
- variables such as the number of total retries to allow, whether to
- respect the Retry-After header, whether this header is present, and
- whether the returned status code is on the list of status codes to
- be retried upon on the presence of the aforementioned header)
- """
- if not self._is_method_retryable(method):
- return False
-
- if self.status_forcelist and status_code in self.status_forcelist:
- return True
-
- return (self.total and self.respect_retry_after_header and
- has_retry_after and (status_code in self.RETRY_AFTER_STATUS_CODES))
-
- def is_exhausted(self):
- """ Are we out of retries? """
- retry_counts = (self.total, self.connect, self.read, self.redirect, self.status)
- retry_counts = list(filter(None, retry_counts))
- if not retry_counts:
- return False
-
- return min(retry_counts) < 0
-
- def increment(self, method=None, url=None, response=None, error=None,
- _pool=None, _stacktrace=None):
- """ Return a new Retry object with incremented retry counters.
-
- :param response: A response object, or None, if the server did not
- return a response.
- :type response: :class:`~urllib3.response.HTTPResponse`
- :param Exception error: An error encountered during the request, or
- None if the response was received successfully.
-
- :return: A new ``Retry`` object.
- """
- if self.total is False and error:
- # Disabled, indicate to re-raise the error.
- raise six.reraise(type(error), error, _stacktrace)
-
- total = self.total
- if total is not None:
- total -= 1
-
- connect = self.connect
- read = self.read
- redirect = self.redirect
- status_count = self.status
- cause = 'unknown'
- status = None
- redirect_location = None
-
- if error and self._is_connection_error(error):
- # Connect retry?
- if connect is False:
- raise six.reraise(type(error), error, _stacktrace)
- elif connect is not None:
- connect -= 1
-
- elif error and self._is_read_error(error):
- # Read retry?
- if read is False or not self._is_method_retryable(method):
- raise six.reraise(type(error), error, _stacktrace)
- elif read is not None:
- read -= 1
-
- elif response and response.get_redirect_location():
- # Redirect retry?
- if redirect is not None:
- redirect -= 1
- cause = 'too many redirects'
- redirect_location = response.get_redirect_location()
- status = response.status
-
- else:
- # Incrementing because of a server error like a 500 in
- # status_forcelist and a the given method is in the whitelist
- cause = ResponseError.GENERIC_ERROR
- if response and response.status:
- if status_count is not None:
- status_count -= 1
- cause = ResponseError.SPECIFIC_ERROR.format(
- status_code=response.status)
- status = response.status
-
- history = self.history + (RequestHistory(method, url, error, status, redirect_location),)
-
- new_retry = self.new(
- total=total,
- connect=connect, read=read, redirect=redirect, status=status_count,
- history=history)
-
- if new_retry.is_exhausted():
- raise MaxRetryError(_pool, url, error or ResponseError(cause))
-
- log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
-
- return new_retry
-
- def __repr__(self):
- return ('{cls.__name__}(total={self.total}, connect={self.connect}, '
- 'read={self.read}, redirect={self.redirect}, status={self.status})').format(
- cls=type(self), self=self)
-
-
-# For backwards compatibility (equivalent to pre-v1.9):
-Retry.DEFAULT = Retry(3)
diff --git a/python/urllib3/util/ssl_.py b/python/urllib3/util/ssl_.py
deleted file mode 100644
index 64ea192..0000000
--- a/python/urllib3/util/ssl_.py
+++ /dev/null
@@ -1,381 +0,0 @@
-from __future__ import absolute_import
-import errno
-import warnings
-import hmac
-import socket
-
-from binascii import hexlify, unhexlify
-from hashlib import md5, sha1, sha256
-
-from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning
-from ..packages import six
-
-
-SSLContext = None
-HAS_SNI = False
-IS_PYOPENSSL = False
-IS_SECURETRANSPORT = False
-
-# Maps the length of a digest to a possible hash function producing this digest
-HASHFUNC_MAP = {
- 32: md5,
- 40: sha1,
- 64: sha256,
-}
-
-
-def _const_compare_digest_backport(a, b):
- """
- Compare two digests of equal length in constant time.
-
- The digests must be of type str/bytes.
- Returns True if the digests match, and False otherwise.
- """
- result = abs(len(a) - len(b))
- for l, r in zip(bytearray(a), bytearray(b)):
- result |= l ^ r
- return result == 0
-
-
-_const_compare_digest = getattr(hmac, 'compare_digest',
- _const_compare_digest_backport)
-
-
-try: # Test for SSL features
- import ssl
- from ssl import wrap_socket, CERT_NONE, PROTOCOL_SSLv23
- from ssl import HAS_SNI # Has SNI?
-except ImportError:
- pass
-
-
-try:
- from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION
-except ImportError:
- OP_NO_SSLv2, OP_NO_SSLv3 = 0x1000000, 0x2000000
- OP_NO_COMPRESSION = 0x20000
-
-
-# Python 2.7 doesn't have inet_pton on non-Linux so we fallback on inet_aton in
-# those cases. This means that we can only detect IPv4 addresses in this case.
-if hasattr(socket, 'inet_pton'):
- inet_pton = socket.inet_pton
-else:
- # Maybe we can use ipaddress if the user has urllib3[secure]?
- try:
- import ipaddress
-
- def inet_pton(_, host):
- if isinstance(host, bytes):
- host = host.decode('ascii')
- return ipaddress.ip_address(host)
-
- except ImportError: # Platform-specific: Non-Linux
- def inet_pton(_, host):
- return socket.inet_aton(host)
-
-
-# A secure default.
-# Sources for more information on TLS ciphers:
-#
-# - https://wiki.mozilla.org/Security/Server_Side_TLS
-# - https://www.ssllabs.com/projects/best-practices/index.html
-# - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
-#
-# The general intent is:
-# - Prefer TLS 1.3 cipher suites
-# - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
-# - prefer ECDHE over DHE for better performance,
-# - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
-# security,
-# - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
-# - disable NULL authentication, MD5 MACs and DSS for security reasons.
-DEFAULT_CIPHERS = ':'.join([
- 'TLS13-AES-256-GCM-SHA384',
- 'TLS13-CHACHA20-POLY1305-SHA256',
- 'TLS13-AES-128-GCM-SHA256',
- 'ECDH+AESGCM',
- 'ECDH+CHACHA20',
- 'DH+AESGCM',
- 'DH+CHACHA20',
- 'ECDH+AES256',
- 'DH+AES256',
- 'ECDH+AES128',
- 'DH+AES',
- 'RSA+AESGCM',
- 'RSA+AES',
- '!aNULL',
- '!eNULL',
- '!MD5',
-])
-
-try:
- from ssl import SSLContext # Modern SSL?
-except ImportError:
- import sys
-
- class SSLContext(object): # Platform-specific: Python 2
- def __init__(self, protocol_version):
- self.protocol = protocol_version
- # Use default values from a real SSLContext
- self.check_hostname = False
- self.verify_mode = ssl.CERT_NONE
- self.ca_certs = None
- self.options = 0
- self.certfile = None
- self.keyfile = None
- self.ciphers = None
-
- def load_cert_chain(self, certfile, keyfile):
- self.certfile = certfile
- self.keyfile = keyfile
-
- def load_verify_locations(self, cafile=None, capath=None):
- self.ca_certs = cafile
-
- if capath is not None:
- raise SSLError("CA directories not supported in older Pythons")
-
- def set_ciphers(self, cipher_suite):
- self.ciphers = cipher_suite
-
- def wrap_socket(self, socket, server_hostname=None, server_side=False):
- warnings.warn(
- 'A true SSLContext object is not available. This prevents '
- 'urllib3 from configuring SSL appropriately and may cause '
- 'certain SSL connections to fail. You can upgrade to a newer '
- 'version of Python to solve this. For more information, see '
- 'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
- '#ssl-warnings',
- InsecurePlatformWarning
- )
- kwargs = {
- 'keyfile': self.keyfile,
- 'certfile': self.certfile,
- 'ca_certs': self.ca_certs,
- 'cert_reqs': self.verify_mode,
- 'ssl_version': self.protocol,
- 'server_side': server_side,
- }
- return wrap_socket(socket, ciphers=self.ciphers, **kwargs)
-
-
-def assert_fingerprint(cert, fingerprint):
- """
- Checks if given fingerprint matches the supplied certificate.
-
- :param cert:
- Certificate as bytes object.
- :param fingerprint:
- Fingerprint as string of hexdigits, can be interspersed by colons.
- """
-
- fingerprint = fingerprint.replace(':', '').lower()
- digest_length = len(fingerprint)
- hashfunc = HASHFUNC_MAP.get(digest_length)
- if not hashfunc:
- raise SSLError(
- 'Fingerprint of invalid length: {0}'.format(fingerprint))
-
- # We need encode() here for py32; works on py2 and p33.
- fingerprint_bytes = unhexlify(fingerprint.encode())
-
- cert_digest = hashfunc(cert).digest()
-
- if not _const_compare_digest(cert_digest, fingerprint_bytes):
- raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".'
- .format(fingerprint, hexlify(cert_digest)))
-
-
-def resolve_cert_reqs(candidate):
- """
- Resolves the argument to a numeric constant, which can be passed to
- the wrap_socket function/method from the ssl module.
- Defaults to :data:`ssl.CERT_NONE`.
- If given a string it is assumed to be the name of the constant in the
- :mod:`ssl` module or its abbreviation.
- (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
- If it's neither `None` nor a string we assume it is already the numeric
- constant which can directly be passed to wrap_socket.
- """
- if candidate is None:
- return CERT_NONE
-
- if isinstance(candidate, str):
- res = getattr(ssl, candidate, None)
- if res is None:
- res = getattr(ssl, 'CERT_' + candidate)
- return res
-
- return candidate
-
-
-def resolve_ssl_version(candidate):
- """
- like resolve_cert_reqs
- """
- if candidate is None:
- return PROTOCOL_SSLv23
-
- if isinstance(candidate, str):
- res = getattr(ssl, candidate, None)
- if res is None:
- res = getattr(ssl, 'PROTOCOL_' + candidate)
- return res
-
- return candidate
-
-
-def create_urllib3_context(ssl_version=None, cert_reqs=None,
- options=None, ciphers=None):
- """All arguments have the same meaning as ``ssl_wrap_socket``.
-
- By default, this function does a lot of the same work that
- ``ssl.create_default_context`` does on Python 3.4+. It:
-
- - Disables SSLv2, SSLv3, and compression
- - Sets a restricted set of server ciphers
-
- If you wish to enable SSLv3, you can do::
-
- from urllib3.util import ssl_
- context = ssl_.create_urllib3_context()
- context.options &= ~ssl_.OP_NO_SSLv3
-
- You can do the same to enable compression (substituting ``COMPRESSION``
- for ``SSLv3`` in the last line above).
-
- :param ssl_version:
- The desired protocol version to use. This will default to
- PROTOCOL_SSLv23 which will negotiate the highest protocol that both
- the server and your installation of OpenSSL support.
- :param cert_reqs:
- Whether to require the certificate verification. This defaults to
- ``ssl.CERT_REQUIRED``.
- :param options:
- Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
- ``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``.
- :param ciphers:
- Which cipher suites to allow the server to select.
- :returns:
- Constructed SSLContext object with specified options
- :rtype: SSLContext
- """
- context = SSLContext(ssl_version or ssl.PROTOCOL_SSLv23)
-
- context.set_ciphers(ciphers or DEFAULT_CIPHERS)
-
- # Setting the default here, as we may have no ssl module on import
- cert_reqs = ssl.CERT_REQUIRED if cert_reqs is None else cert_reqs
-
- if options is None:
- options = 0
- # SSLv2 is easily broken and is considered harmful and dangerous
- options |= OP_NO_SSLv2
- # SSLv3 has several problems and is now dangerous
- options |= OP_NO_SSLv3
- # Disable compression to prevent CRIME attacks for OpenSSL 1.0+
- # (issue #309)
- options |= OP_NO_COMPRESSION
-
- context.options |= options
-
- context.verify_mode = cert_reqs
- if getattr(context, 'check_hostname', None) is not None: # Platform-specific: Python 3.2
- # We do our own verification, including fingerprints and alternative
- # hostnames. So disable it here
- context.check_hostname = False
- return context
-
-
-def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
- ca_certs=None, server_hostname=None,
- ssl_version=None, ciphers=None, ssl_context=None,
- ca_cert_dir=None):
- """
- All arguments except for server_hostname, ssl_context, and ca_cert_dir have
- the same meaning as they do when using :func:`ssl.wrap_socket`.
-
- :param server_hostname:
- When SNI is supported, the expected hostname of the certificate
- :param ssl_context:
- A pre-made :class:`SSLContext` object. If none is provided, one will
- be created using :func:`create_urllib3_context`.
- :param ciphers:
- A string of ciphers we wish the client to support.
- :param ca_cert_dir:
- A directory containing CA certificates in multiple separate files, as
- supported by OpenSSL's -CApath flag or the capath argument to
- SSLContext.load_verify_locations().
- """
- context = ssl_context
- if context is None:
- # Note: This branch of code and all the variables in it are no longer
- # used by urllib3 itself. We should consider deprecating and removing
- # this code.
- context = create_urllib3_context(ssl_version, cert_reqs,
- ciphers=ciphers)
-
- if ca_certs or ca_cert_dir:
- try:
- context.load_verify_locations(ca_certs, ca_cert_dir)
- except IOError as e: # Platform-specific: Python 2.7
- raise SSLError(e)
- # Py33 raises FileNotFoundError which subclasses OSError
- # These are not equivalent unless we check the errno attribute
- except OSError as e: # Platform-specific: Python 3.3 and beyond
- if e.errno == errno.ENOENT:
- raise SSLError(e)
- raise
- elif getattr(context, 'load_default_certs', None) is not None:
- # try to load OS default certs; works well on Windows (require Python3.4+)
- context.load_default_certs()
-
- if certfile:
- context.load_cert_chain(certfile, keyfile)
-
- # If we detect server_hostname is an IP address then the SNI
- # extension should not be used according to RFC3546 Section 3.1
- # We shouldn't warn the user if SNI isn't available but we would
- # not be using SNI anyways due to IP address for server_hostname.
- if ((server_hostname is not None and not is_ipaddress(server_hostname))
- or IS_SECURETRANSPORT):
- if HAS_SNI and server_hostname is not None:
- return context.wrap_socket(sock, server_hostname=server_hostname)
-
- warnings.warn(
- 'An HTTPS request has been made, but the SNI (Server Name '
- 'Indication) extension to TLS is not available on this platform. '
- 'This may cause the server to present an incorrect TLS '
- 'certificate, which can cause validation failures. You can upgrade to '
- 'a newer version of Python to solve this. For more information, see '
- 'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
- '#ssl-warnings',
- SNIMissingWarning
- )
-
- return context.wrap_socket(sock)
-
-
-def is_ipaddress(hostname):
- """Detects whether the hostname given is an IP address.
-
- :param str hostname: Hostname to examine.
- :return: True if the hostname is an IP address, False otherwise.
- """
- if six.PY3 and isinstance(hostname, bytes):
- # IDN A-label bytes are ASCII compatible.
- hostname = hostname.decode('ascii')
-
- families = [socket.AF_INET]
- if hasattr(socket, 'AF_INET6'):
- families.append(socket.AF_INET6)
-
- for af in families:
- try:
- inet_pton(af, hostname)
- except (socket.error, ValueError, OSError):
- pass
- else:
- return True
- return False
diff --git a/python/urllib3/util/timeout.py b/python/urllib3/util/timeout.py
deleted file mode 100644
index cec817e..0000000
--- a/python/urllib3/util/timeout.py
+++ /dev/null
@@ -1,242 +0,0 @@
-from __future__ import absolute_import
-# The default socket timeout, used by httplib to indicate that no timeout was
-# specified by the user
-from socket import _GLOBAL_DEFAULT_TIMEOUT
-import time
-
-from ..exceptions import TimeoutStateError
-
-# A sentinel value to indicate that no timeout was specified by the user in
-# urllib3
-_Default = object()
-
-
-# Use time.monotonic if available.
-current_time = getattr(time, "monotonic", time.time)
-
-
-class Timeout(object):
- """ Timeout configuration.
-
- Timeouts can be defined as a default for a pool::
-
- timeout = Timeout(connect=2.0, read=7.0)
- http = PoolManager(timeout=timeout)
- response = http.request('GET', 'http://example.com/')
-
- Or per-request (which overrides the default for the pool)::
-
- response = http.request('GET', 'http://example.com/', timeout=Timeout(10))
-
- Timeouts can be disabled by setting all the parameters to ``None``::
-
- no_timeout = Timeout(connect=None, read=None)
- response = http.request('GET', 'http://example.com/, timeout=no_timeout)
-
-
- :param total:
- This combines the connect and read timeouts into one; the read timeout
- will be set to the time leftover from the connect attempt. In the
- event that both a connect timeout and a total are specified, or a read
- timeout and a total are specified, the shorter timeout will be applied.
-
- Defaults to None.
-
- :type total: integer, float, or None
-
- :param connect:
- The maximum amount of time to wait for a connection attempt to a server
- to succeed. Omitting the parameter will default the connect timeout to
- the system default, probably `the global default timeout in socket.py
- <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
- None will set an infinite timeout for connection attempts.
-
- :type connect: integer, float, or None
-
- :param read:
- The maximum amount of time to wait between consecutive
- read operations for a response from the server. Omitting
- the parameter will default the read timeout to the system
- default, probably `the global default timeout in socket.py
- <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
- None will set an infinite timeout.
-
- :type read: integer, float, or None
-
- .. note::
-
- Many factors can affect the total amount of time for urllib3 to return
- an HTTP response.
-
- For example, Python's DNS resolver does not obey the timeout specified
- on the socket. Other factors that can affect total request time include
- high CPU load, high swap, the program running at a low priority level,
- or other behaviors.
-
- In addition, the read and total timeouts only measure the time between
- read operations on the socket connecting the client and the server,
- not the total amount of time for the request to return a complete
- response. For most requests, the timeout is raised because the server
- has not sent the first byte in the specified time. This is not always
- the case; if a server streams one byte every fifteen seconds, a timeout
- of 20 seconds will not trigger, even though the request will take
- several minutes to complete.
-
- If your goal is to cut off any request after a set amount of wall clock
- time, consider having a second "watcher" thread to cut off a slow
- request.
- """
-
- #: A sentinel object representing the default timeout value
- DEFAULT_TIMEOUT = _GLOBAL_DEFAULT_TIMEOUT
-
- def __init__(self, total=None, connect=_Default, read=_Default):
- self._connect = self._validate_timeout(connect, 'connect')
- self._read = self._validate_timeout(read, 'read')
- self.total = self._validate_timeout(total, 'total')
- self._start_connect = None
-
- def __str__(self):
- return '%s(connect=%r, read=%r, total=%r)' % (
- type(self).__name__, self._connect, self._read, self.total)
-
- @classmethod
- def _validate_timeout(cls, value, name):
- """ Check that a timeout attribute is valid.
-
- :param value: The timeout value to validate
- :param name: The name of the timeout attribute to validate. This is
- used to specify in error messages.
- :return: The validated and casted version of the given value.
- :raises ValueError: If it is a numeric value less than or equal to
- zero, or the type is not an integer, float, or None.
- """
- if value is _Default:
- return cls.DEFAULT_TIMEOUT
-
- if value is None or value is cls.DEFAULT_TIMEOUT:
- return value
-
- if isinstance(value, bool):
- raise ValueError("Timeout cannot be a boolean value. It must "
- "be an int, float or None.")
- try:
- float(value)
- except (TypeError, ValueError):
- raise ValueError("Timeout value %s was %s, but it must be an "
- "int, float or None." % (name, value))
-
- try:
- if value <= 0:
- raise ValueError("Attempted to set %s timeout to %s, but the "
- "timeout cannot be set to a value less "
- "than or equal to 0." % (name, value))
- except TypeError: # Python 3
- raise ValueError("Timeout value %s was %s, but it must be an "
- "int, float or None." % (name, value))
-
- return value
-
- @classmethod
- def from_float(cls, timeout):
- """ Create a new Timeout from a legacy timeout value.
-
- The timeout value used by httplib.py sets the same timeout on the
- connect(), and recv() socket requests. This creates a :class:`Timeout`
- object that sets the individual timeouts to the ``timeout`` value
- passed to this function.
-
- :param timeout: The legacy timeout value.
- :type timeout: integer, float, sentinel default object, or None
- :return: Timeout object
- :rtype: :class:`Timeout`
- """
- return Timeout(read=timeout, connect=timeout)
-
- def clone(self):
- """ Create a copy of the timeout object
-
- Timeout properties are stored per-pool but each request needs a fresh
- Timeout object to ensure each one has its own start/stop configured.
-
- :return: a copy of the timeout object
- :rtype: :class:`Timeout`
- """
- # We can't use copy.deepcopy because that will also create a new object
- # for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to
- # detect the user default.
- return Timeout(connect=self._connect, read=self._read,
- total=self.total)
-
- def start_connect(self):
- """ Start the timeout clock, used during a connect() attempt
-
- :raises urllib3.exceptions.TimeoutStateError: if you attempt
- to start a timer that has been started already.
- """
- if self._start_connect is not None:
- raise TimeoutStateError("Timeout timer has already been started.")
- self._start_connect = current_time()
- return self._start_connect
-
- def get_connect_duration(self):
- """ Gets the time elapsed since the call to :meth:`start_connect`.
-
- :return: Elapsed time.
- :rtype: float
- :raises urllib3.exceptions.TimeoutStateError: if you attempt
- to get duration for a timer that hasn't been started.
- """
- if self._start_connect is None:
- raise TimeoutStateError("Can't get connect duration for timer "
- "that has not started.")
- return current_time() - self._start_connect
-
- @property
- def connect_timeout(self):
- """ Get the value to use when setting a connection timeout.
-
- This will be a positive float or integer, the value None
- (never timeout), or the default system timeout.
-
- :return: Connect timeout.
- :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
- """
- if self.total is None:
- return self._connect
-
- if self._connect is None or self._connect is self.DEFAULT_TIMEOUT:
- return self.total
-
- return min(self._connect, self.total)
-
- @property
- def read_timeout(self):
- """ Get the value for the read timeout.
-
- This assumes some time has elapsed in the connection timeout and
- computes the read timeout appropriately.
-
- If self.total is set, the read timeout is dependent on the amount of
- time taken by the connect timeout. If the connection time has not been
- established, a :exc:`~urllib3.exceptions.TimeoutStateError` will be
- raised.
-
- :return: Value to use for the read timeout.
- :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
- :raises urllib3.exceptions.TimeoutStateError: If :meth:`start_connect`
- has not yet been called on this object.
- """
- if (self.total is not None and
- self.total is not self.DEFAULT_TIMEOUT and
- self._read is not None and
- self._read is not self.DEFAULT_TIMEOUT):
- # In case the connect timeout has not yet been established.
- if self._start_connect is None:
- return self._read
- return max(0, min(self.total - self.get_connect_duration(),
- self._read))
- elif self.total is not None and self.total is not self.DEFAULT_TIMEOUT:
- return max(0, self.total - self.get_connect_duration())
- else:
- return self._read
diff --git a/python/urllib3/util/url.py b/python/urllib3/util/url.py
deleted file mode 100644
index 6b6f996..0000000
--- a/python/urllib3/util/url.py
+++ /dev/null
@@ -1,230 +0,0 @@
-from __future__ import absolute_import
-from collections import namedtuple
-
-from ..exceptions import LocationParseError
-
-
-url_attrs = ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment']
-
-# We only want to normalize urls with an HTTP(S) scheme.
-# urllib3 infers URLs without a scheme (None) to be http.
-NORMALIZABLE_SCHEMES = ('http', 'https', None)
-
-
-class Url(namedtuple('Url', url_attrs)):
- """
- Datastructure for representing an HTTP URL. Used as a return value for
- :func:`parse_url`. Both the scheme and host are normalized as they are
- both case-insensitive according to RFC 3986.
- """
- __slots__ = ()
-
- def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None,
- query=None, fragment=None):
- if path and not path.startswith('/'):
- path = '/' + path
- if scheme:
- scheme = scheme.lower()
- if host and scheme in NORMALIZABLE_SCHEMES:
- host = host.lower()
- return super(Url, cls).__new__(cls, scheme, auth, host, port, path,
- query, fragment)
-
- @property
- def hostname(self):
- """For backwards-compatibility with urlparse. We're nice like that."""
- return self.host
-
- @property
- def request_uri(self):
- """Absolute path including the query string."""
- uri = self.path or '/'
-
- if self.query is not None:
- uri += '?' + self.query
-
- return uri
-
- @property
- def netloc(self):
- """Network location including host and port"""
- if self.port:
- return '%s:%d' % (self.host, self.port)
- return self.host
-
- @property
- def url(self):
- """
- Convert self into a url
-
- This function should more or less round-trip with :func:`.parse_url`. The
- returned url may not be exactly the same as the url inputted to
- :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls
- with a blank port will have : removed).
-
- Example: ::
-
- >>> U = parse_url('http://google.com/mail/')
- >>> U.url
- 'http://google.com/mail/'
- >>> Url('http', 'username:password', 'host.com', 80,
- ... '/path', 'query', 'fragment').url
- 'http://username:password@host.com:80/path?query#fragment'
- """
- scheme, auth, host, port, path, query, fragment = self
- url = ''
-
- # We use "is not None" we want things to happen with empty strings (or 0 port)
- if scheme is not None:
- url += scheme + '://'
- if auth is not None:
- url += auth + '@'
- if host is not None:
- url += host
- if port is not None:
- url += ':' + str(port)
- if path is not None:
- url += path
- if query is not None:
- url += '?' + query
- if fragment is not None:
- url += '#' + fragment
-
- return url
-
- def __str__(self):
- return self.url
-
-
-def split_first(s, delims):
- """
- Given a string and an iterable of delimiters, split on the first found
- delimiter. Return two split parts and the matched delimiter.
-
- If not found, then the first part is the full input string.
-
- Example::
-
- >>> split_first('foo/bar?baz', '?/=')
- ('foo', 'bar?baz', '/')
- >>> split_first('foo/bar?baz', '123')
- ('foo/bar?baz', '', None)
-
- Scales linearly with number of delims. Not ideal for large number of delims.
- """
- min_idx = None
- min_delim = None
- for d in delims:
- idx = s.find(d)
- if idx < 0:
- continue
-
- if min_idx is None or idx < min_idx:
- min_idx = idx
- min_delim = d
-
- if min_idx is None or min_idx < 0:
- return s, '', None
-
- return s[:min_idx], s[min_idx + 1:], min_delim
-
-
-def parse_url(url):
- """
- Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
- performed to parse incomplete urls. Fields not provided will be None.
-
- Partly backwards-compatible with :mod:`urlparse`.
-
- Example::
-
- >>> parse_url('http://google.com/mail/')
- Url(scheme='http', host='google.com', port=None, path='/mail/', ...)
- >>> parse_url('google.com:80')
- Url(scheme=None, host='google.com', port=80, path=None, ...)
- >>> parse_url('/foo?bar')
- Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
- """
-
- # While this code has overlap with stdlib's urlparse, it is much
- # simplified for our needs and less annoying.
- # Additionally, this implementations does silly things to be optimal
- # on CPython.
-
- if not url:
- # Empty
- return Url()
-
- scheme = None
- auth = None
- host = None
- port = None
- path = None
- fragment = None
- query = None
-
- # Scheme
- if '://' in url:
- scheme, url = url.split('://', 1)
-
- # Find the earliest Authority Terminator
- # (http://tools.ietf.org/html/rfc3986#section-3.2)
- url, path_, delim = split_first(url, ['/', '?', '#'])
-
- if delim:
- # Reassemble the path
- path = delim + path_
-
- # Auth
- if '@' in url:
- # Last '@' denotes end of auth part
- auth, url = url.rsplit('@', 1)
-
- # IPv6
- if url and url[0] == '[':
- host, url = url.split(']', 1)
- host += ']'
-
- # Port
- if ':' in url:
- _host, port = url.split(':', 1)
-
- if not host:
- host = _host
-
- if port:
- # If given, ports must be integers. No whitespace, no plus or
- # minus prefixes, no non-integer digits such as ^2 (superscript).
- if not port.isdigit():
- raise LocationParseError(url)
- try:
- port = int(port)
- except ValueError:
- raise LocationParseError(url)
- else:
- # Blank ports are cool, too. (rfc3986#section-3.2.3)
- port = None
-
- elif not host and url:
- host = url
-
- if not path:
- return Url(scheme, auth, host, port, path, query, fragment)
-
- # Fragment
- if '#' in path:
- path, fragment = path.split('#', 1)
-
- # Query
- if '?' in path:
- path, query = path.split('?', 1)
-
- return Url(scheme, auth, host, port, path, query, fragment)
-
-
-def get_host(url):
- """
- Deprecated. Use :func:`parse_url` instead.
- """
- p = parse_url(url)
- return p.scheme or 'http', p.hostname, p.port
diff --git a/python/urllib3/util/wait.py b/python/urllib3/util/wait.py
deleted file mode 100644
index 4db71ba..0000000
--- a/python/urllib3/util/wait.py
+++ /dev/null
@@ -1,150 +0,0 @@
-import errno
-from functools import partial
-import select
-import sys
-try:
- from time import monotonic
-except ImportError:
- from time import time as monotonic
-
-__all__ = ["NoWayToWaitForSocketError", "wait_for_read", "wait_for_write"]
-
-
-class NoWayToWaitForSocketError(Exception):
- pass
-
-
-# How should we wait on sockets?
-#
-# There are two types of APIs you can use for waiting on sockets: the fancy
-# modern stateful APIs like epoll/kqueue, and the older stateless APIs like
-# select/poll. The stateful APIs are more efficient when you have a lots of
-# sockets to keep track of, because you can set them up once and then use them
-# lots of times. But we only ever want to wait on a single socket at a time
-# and don't want to keep track of state, so the stateless APIs are actually
-# more efficient. So we want to use select() or poll().
-#
-# Now, how do we choose between select() and poll()? On traditional Unixes,
-# select() has a strange calling convention that makes it slow, or fail
-# altogether, for high-numbered file descriptors. The point of poll() is to fix
-# that, so on Unixes, we prefer poll().
-#
-# On Windows, there is no poll() (or at least Python doesn't provide a wrapper
-# for it), but that's OK, because on Windows, select() doesn't have this
-# strange calling convention; plain select() works fine.
-#
-# So: on Windows we use select(), and everywhere else we use poll(). We also
-# fall back to select() in case poll() is somehow broken or missing.
-
-if sys.version_info >= (3, 5):
- # Modern Python, that retries syscalls by default
- def _retry_on_intr(fn, timeout):
- return fn(timeout)
-else:
- # Old and broken Pythons.
- def _retry_on_intr(fn, timeout):
- if timeout is None:
- deadline = float("inf")
- else:
- deadline = monotonic() + timeout
-
- while True:
- try:
- return fn(timeout)
- # OSError for 3 <= pyver < 3.5, select.error for pyver <= 2.7
- except (OSError, select.error) as e:
- # 'e.args[0]' incantation works for both OSError and select.error
- if e.args[0] != errno.EINTR:
- raise
- else:
- timeout = deadline - monotonic()
- if timeout < 0:
- timeout = 0
- if timeout == float("inf"):
- timeout = None
- continue
-
-
-def select_wait_for_socket(sock, read=False, write=False, timeout=None):
- if not read and not write:
- raise RuntimeError("must specify at least one of read=True, write=True")
- rcheck = []
- wcheck = []
- if read:
- rcheck.append(sock)
- if write:
- wcheck.append(sock)
- # When doing a non-blocking connect, most systems signal success by
- # marking the socket writable. Windows, though, signals success by marked
- # it as "exceptional". We paper over the difference by checking the write
- # sockets for both conditions. (The stdlib selectors module does the same
- # thing.)
- fn = partial(select.select, rcheck, wcheck, wcheck)
- rready, wready, xready = _retry_on_intr(fn, timeout)
- return bool(rready or wready or xready)
-
-
-def poll_wait_for_socket(sock, read=False, write=False, timeout=None):
- if not read and not write:
- raise RuntimeError("must specify at least one of read=True, write=True")
- mask = 0
- if read:
- mask |= select.POLLIN
- if write:
- mask |= select.POLLOUT
- poll_obj = select.poll()
- poll_obj.register(sock, mask)
-
- # For some reason, poll() takes timeout in milliseconds
- def do_poll(t):
- if t is not None:
- t *= 1000
- return poll_obj.poll(t)
-
- return bool(_retry_on_intr(do_poll, timeout))
-
-
-def null_wait_for_socket(*args, **kwargs):
- raise NoWayToWaitForSocketError("no select-equivalent available")
-
-
-def _have_working_poll():
- # Apparently some systems have a select.poll that fails as soon as you try
- # to use it, either due to strange configuration or broken monkeypatching
- # from libraries like eventlet/greenlet.
- try:
- poll_obj = select.poll()
- _retry_on_intr(poll_obj.poll, 0)
- except (AttributeError, OSError):
- return False
- else:
- return True
-
-
-def wait_for_socket(*args, **kwargs):
- # We delay choosing which implementation to use until the first time we're
- # called. We could do it at import time, but then we might make the wrong
- # decision if someone goes wild with monkeypatching select.poll after
- # we're imported.
- global wait_for_socket
- if _have_working_poll():
- wait_for_socket = poll_wait_for_socket
- elif hasattr(select, "select"):
- wait_for_socket = select_wait_for_socket
- else: # Platform-specific: Appengine.
- wait_for_socket = null_wait_for_socket
- return wait_for_socket(*args, **kwargs)
-
-
-def wait_for_read(sock, timeout=None):
- """ Waits for reading to be available on a given socket.
- Returns True if the socket is readable, or False if the timeout expired.
- """
- return wait_for_socket(sock, read=True, timeout=timeout)
-
-
-def wait_for_write(sock, timeout=None):
- """ Waits for writing to be available on a given socket.
- Returns True if the socket is readable, or False if the timeout expired.
- """
- return wait_for_socket(sock, write=True, timeout=timeout)
diff --git a/python/vcruntime140.dll b/python/vcruntime140.dll
deleted file mode 100644
index 8ec21b7..0000000
--- a/python/vcruntime140.dll
+++ /dev/null
Binary files differ
diff --git a/python/werkzeug/__init__.py b/python/werkzeug/__init__.py
deleted file mode 100644
index e460e75..0000000
--- a/python/werkzeug/__init__.py
+++ /dev/null
@@ -1,233 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug
- ~~~~~~~~
-
- Werkzeug is the Swiss Army knife of Python web development.
-
- It provides useful classes and functions for any WSGI application to make
- the life of a python web developer much easier. All of the provided
- classes are independent from each other so you can mix it with any other
- library.
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import sys
-from types import ModuleType
-
-__version__ = "0.15.4"
-
-# This import magic raises concerns quite often which is why the implementation
-# and motivation is explained here in detail now.
-#
-# The majority of the functions and classes provided by Werkzeug work on the
-# HTTP and WSGI layer. There is no useful grouping for those which is why
-# they are all importable from "werkzeug" instead of the modules where they are
-# implemented. The downside of that is, that now everything would be loaded at
-# once, even if unused.
-#
-# The implementation of a lazy-loading module in this file replaces the
-# werkzeug package when imported from within. Attribute access to the werkzeug
-# module will then lazily import from the modules that implement the objects.
-
-# import mapping to objects in other modules
-all_by_module = {
- "werkzeug.debug": ["DebuggedApplication"],
- "werkzeug.local": [
- "Local",
- "LocalManager",
- "LocalProxy",
- "LocalStack",
- "release_local",
- ],
- "werkzeug.serving": ["run_simple"],
- "werkzeug.test": ["Client", "EnvironBuilder", "create_environ", "run_wsgi_app"],
- "werkzeug.testapp": ["test_app"],
- "werkzeug.exceptions": ["abort", "Aborter"],
- "werkzeug.urls": [
- "url_decode",
- "url_encode",
- "url_quote",
- "url_quote_plus",
- "url_unquote",
- "url_unquote_plus",
- "url_fix",
- "Href",
- "iri_to_uri",
- "uri_to_iri",
- ],
- "werkzeug.formparser": ["parse_form_data"],
- "werkzeug.utils": [
- "escape",
- "environ_property",
- "append_slash_redirect",
- "redirect",
- "cached_property",
- "import_string",
- "dump_cookie",
- "parse_cookie",
- "unescape",
- "format_string",
- "find_modules",
- "header_property",
- "html",
- "xhtml",
- "HTMLBuilder",
- "validate_arguments",
- "ArgumentValidationError",
- "bind_arguments",
- "secure_filename",
- ],
- "werkzeug.wsgi": [
- "get_current_url",
- "get_host",
- "pop_path_info",
- "peek_path_info",
- "ClosingIterator",
- "FileWrapper",
- "make_line_iter",
- "LimitedStream",
- "responder",
- "wrap_file",
- "extract_path_info",
- ],
- "werkzeug.datastructures": [
- "MultiDict",
- "CombinedMultiDict",
- "Headers",
- "EnvironHeaders",
- "ImmutableList",
- "ImmutableDict",
- "ImmutableMultiDict",
- "TypeConversionDict",
- "ImmutableTypeConversionDict",
- "Accept",
- "MIMEAccept",
- "CharsetAccept",
- "LanguageAccept",
- "RequestCacheControl",
- "ResponseCacheControl",
- "ETags",
- "HeaderSet",
- "WWWAuthenticate",
- "Authorization",
- "FileMultiDict",
- "CallbackDict",
- "FileStorage",
- "OrderedMultiDict",
- "ImmutableOrderedMultiDict",
- ],
- "werkzeug.useragents": ["UserAgent"],
- "werkzeug.http": [
- "parse_etags",
- "parse_date",
- "http_date",
- "cookie_date",
- "parse_cache_control_header",
- "is_resource_modified",
- "parse_accept_header",
- "parse_set_header",
- "quote_etag",
- "unquote_etag",
- "generate_etag",
- "dump_header",
- "parse_list_header",
- "parse_dict_header",
- "parse_authorization_header",
- "parse_www_authenticate_header",
- "remove_entity_headers",
- "is_entity_header",
- "remove_hop_by_hop_headers",
- "parse_options_header",
- "dump_options_header",
- "is_hop_by_hop_header",
- "unquote_header_value",
- "quote_header_value",
- "HTTP_STATUS_CODES",
- ],
- "werkzeug.wrappers": [
- "BaseResponse",
- "BaseRequest",
- "Request",
- "Response",
- "AcceptMixin",
- "ETagRequestMixin",
- "ETagResponseMixin",
- "ResponseStreamMixin",
- "CommonResponseDescriptorsMixin",
- "UserAgentMixin",
- "AuthorizationMixin",
- "WWWAuthenticateMixin",
- "CommonRequestDescriptorsMixin",
- ],
- "werkzeug.middleware.dispatcher": ["DispatcherMiddleware"],
- "werkzeug.middleware.shared_data": ["SharedDataMiddleware"],
- "werkzeug.security": ["generate_password_hash", "check_password_hash"],
- # the undocumented easteregg ;-)
- "werkzeug._internal": ["_easteregg"],
-}
-
-# modules that should be imported when accessed as attributes of werkzeug
-attribute_modules = frozenset(["exceptions", "routing"])
-
-object_origins = {}
-for module, items in all_by_module.items():
- for item in items:
- object_origins[item] = module
-
-
-class module(ModuleType):
- """Automatically import objects from the modules."""
-
- def __getattr__(self, name):
- if name in object_origins:
- module = __import__(object_origins[name], None, None, [name])
- for extra_name in all_by_module[module.__name__]:
- setattr(self, extra_name, getattr(module, extra_name))
- return getattr(module, name)
- elif name in attribute_modules:
- __import__("werkzeug." + name)
- return ModuleType.__getattribute__(self, name)
-
- def __dir__(self):
- """Just show what we want to show."""
- result = list(new_module.__all__)
- result.extend(
- (
- "__file__",
- "__doc__",
- "__all__",
- "__docformat__",
- "__name__",
- "__path__",
- "__package__",
- "__version__",
- )
- )
- return result
-
-
-# keep a reference to this module so that it's not garbage collected
-old_module = sys.modules["werkzeug"]
-
-
-# setup the new module and patch it into the dict of loaded modules
-new_module = sys.modules["werkzeug"] = module("werkzeug")
-new_module.__dict__.update(
- {
- "__file__": __file__,
- "__package__": "werkzeug",
- "__path__": __path__,
- "__doc__": __doc__,
- "__version__": __version__,
- "__all__": tuple(object_origins) + tuple(attribute_modules),
- "__docformat__": "restructuredtext en",
- }
-)
-
-
-# Due to bootstrapping issues we need to import exceptions here.
-# Don't ask :-(
-__import__("werkzeug.exceptions")
diff --git a/python/werkzeug/_compat.py b/python/werkzeug/_compat.py
deleted file mode 100644
index 1097983..0000000
--- a/python/werkzeug/_compat.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# flake8: noqa
-# This whole file is full of lint errors
-import functools
-import operator
-import sys
-
-try:
- import builtins
-except ImportError:
- import __builtin__ as builtins
-
-
-PY2 = sys.version_info[0] == 2
-WIN = sys.platform.startswith("win")
-
-_identity = lambda x: x
-
-if PY2:
- unichr = unichr
- text_type = unicode
- string_types = (str, unicode)
- integer_types = (int, long)
-
- iterkeys = lambda d, *args, **kwargs: d.iterkeys(*args, **kwargs)
- itervalues = lambda d, *args, **kwargs: d.itervalues(*args, **kwargs)
- iteritems = lambda d, *args, **kwargs: d.iteritems(*args, **kwargs)
-
- iterlists = lambda d, *args, **kwargs: d.iterlists(*args, **kwargs)
- iterlistvalues = lambda d, *args, **kwargs: d.iterlistvalues(*args, **kwargs)
-
- int_to_byte = chr
- iter_bytes = iter
-
- import collections as collections_abc
-
- exec("def reraise(tp, value, tb=None):\n raise tp, value, tb")
-
- def fix_tuple_repr(obj):
- def __repr__(self):
- cls = self.__class__
- return "%s(%s)" % (
- cls.__name__,
- ", ".join(
- "%s=%r" % (field, self[index])
- for index, field in enumerate(cls._fields)
- ),
- )
-
- obj.__repr__ = __repr__
- return obj
-
- def implements_iterator(cls):
- cls.next = cls.__next__
- del cls.__next__
- return cls
-
- def implements_to_string(cls):
- cls.__unicode__ = cls.__str__
- cls.__str__ = lambda x: x.__unicode__().encode("utf-8")
- return cls
-
- def native_string_result(func):
- def wrapper(*args, **kwargs):
- return func(*args, **kwargs).encode("utf-8")
-
- return functools.update_wrapper(wrapper, func)
-
- def implements_bool(cls):
- cls.__nonzero__ = cls.__bool__
- del cls.__bool__
- return cls
-
- from itertools import imap, izip, ifilter
-
- range_type = xrange
-
- from StringIO import StringIO
- from cStringIO import StringIO as BytesIO
-
- NativeStringIO = BytesIO
-
- def make_literal_wrapper(reference):
- return _identity
-
- def normalize_string_tuple(tup):
- """Normalizes a string tuple to a common type. Following Python 2
- rules, upgrades to unicode are implicit.
- """
- if any(isinstance(x, text_type) for x in tup):
- return tuple(to_unicode(x) for x in tup)
- return tup
-
- def try_coerce_native(s):
- """Try to coerce a unicode string to native if possible. Otherwise,
- leave it as unicode.
- """
- try:
- return to_native(s)
- except UnicodeError:
- return s
-
- wsgi_get_bytes = _identity
-
- def wsgi_decoding_dance(s, charset="utf-8", errors="replace"):
- return s.decode(charset, errors)
-
- def wsgi_encoding_dance(s, charset="utf-8", errors="replace"):
- if isinstance(s, bytes):
- return s
- return s.encode(charset, errors)
-
- def to_bytes(x, charset=sys.getdefaultencoding(), errors="strict"):
- if x is None:
- return None
- if isinstance(x, (bytes, bytearray, buffer)):
- return bytes(x)
- if isinstance(x, unicode):
- return x.encode(charset, errors)
- raise TypeError("Expected bytes")
-
- def to_native(x, charset=sys.getdefaultencoding(), errors="strict"):
- if x is None or isinstance(x, str):
- return x
- return x.encode(charset, errors)
-
-
-else:
- unichr = chr
- text_type = str
- string_types = (str,)
- integer_types = (int,)
-
- iterkeys = lambda d, *args, **kwargs: iter(d.keys(*args, **kwargs))
- itervalues = lambda d, *args, **kwargs: iter(d.values(*args, **kwargs))
- iteritems = lambda d, *args, **kwargs: iter(d.items(*args, **kwargs))
-
- iterlists = lambda d, *args, **kwargs: iter(d.lists(*args, **kwargs))
- iterlistvalues = lambda d, *args, **kwargs: iter(d.listvalues(*args, **kwargs))
-
- int_to_byte = operator.methodcaller("to_bytes", 1, "big")
- iter_bytes = functools.partial(map, int_to_byte)
-
- import collections.abc as collections_abc
-
- def reraise(tp, value, tb=None):
- if value.__traceback__ is not tb:
- raise value.with_traceback(tb)
- raise value
-
- fix_tuple_repr = _identity
- implements_iterator = _identity
- implements_to_string = _identity
- implements_bool = _identity
- native_string_result = _identity
- imap = map
- izip = zip
- ifilter = filter
- range_type = range
-
- from io import StringIO, BytesIO
-
- NativeStringIO = StringIO
-
- _latin1_encode = operator.methodcaller("encode", "latin1")
-
- def make_literal_wrapper(reference):
- if isinstance(reference, text_type):
- return _identity
- return _latin1_encode
-
- def normalize_string_tuple(tup):
- """Ensures that all types in the tuple are either strings
- or bytes.
- """
- tupiter = iter(tup)
- is_text = isinstance(next(tupiter, None), text_type)
- for arg in tupiter:
- if isinstance(arg, text_type) != is_text:
- raise TypeError(
- "Cannot mix str and bytes arguments (got %s)" % repr(tup)
- )
- return tup
-
- try_coerce_native = _identity
- wsgi_get_bytes = _latin1_encode
-
- def wsgi_decoding_dance(s, charset="utf-8", errors="replace"):
- return s.encode("latin1").decode(charset, errors)
-
- def wsgi_encoding_dance(s, charset="utf-8", errors="replace"):
- if isinstance(s, text_type):
- s = s.encode(charset)
- return s.decode("latin1", errors)
-
- def to_bytes(x, charset=sys.getdefaultencoding(), errors="strict"):
- if x is None:
- return None
- if isinstance(x, (bytes, bytearray, memoryview)): # noqa
- return bytes(x)
- if isinstance(x, str):
- return x.encode(charset, errors)
- raise TypeError("Expected bytes")
-
- def to_native(x, charset=sys.getdefaultencoding(), errors="strict"):
- if x is None or isinstance(x, str):
- return x
- return x.decode(charset, errors)
-
-
-def to_unicode(
- x, charset=sys.getdefaultencoding(), errors="strict", allow_none_charset=False
-):
- if x is None:
- return None
- if not isinstance(x, bytes):
- return text_type(x)
- if charset is None and allow_none_charset:
- return x
- return x.decode(charset, errors)
diff --git a/python/werkzeug/_internal.py b/python/werkzeug/_internal.py
deleted file mode 100644
index 90e3dd9..0000000
--- a/python/werkzeug/_internal.py
+++ /dev/null
@@ -1,484 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug._internal
- ~~~~~~~~~~~~~~~~~~
-
- This module provides internally used helpers and constants.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import inspect
-import logging
-import re
-import string
-from datetime import date
-from datetime import datetime
-from itertools import chain
-from weakref import WeakKeyDictionary
-
-from ._compat import int_to_byte
-from ._compat import integer_types
-from ._compat import iter_bytes
-from ._compat import range_type
-from ._compat import text_type
-
-
-_logger = None
-_signature_cache = WeakKeyDictionary()
-_epoch_ord = date(1970, 1, 1).toordinal()
-_cookie_params = {
- b"expires",
- b"path",
- b"comment",
- b"max-age",
- b"secure",
- b"httponly",
- b"version",
-}
-_legal_cookie_chars = (
- string.ascii_letters + string.digits + u"/=!#$%&'*+-.^_`|~:"
-).encode("ascii")
-
-_cookie_quoting_map = {b",": b"\\054", b";": b"\\073", b'"': b'\\"', b"\\": b"\\\\"}
-for _i in chain(range_type(32), range_type(127, 256)):
- _cookie_quoting_map[int_to_byte(_i)] = ("\\%03o" % _i).encode("latin1")
-
-_octal_re = re.compile(br"\\[0-3][0-7][0-7]")
-_quote_re = re.compile(br"[\\].")
-_legal_cookie_chars_re = br"[\w\d!#%&\'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"
-_cookie_re = re.compile(
- br"""
- (?P<key>[^=;]+)
- (?:\s*=\s*
- (?P<val>
- "(?:[^\\"]|\\.)*" |
- (?:.*?)
- )
- )?
- \s*;
-""",
- flags=re.VERBOSE,
-)
-
-
-class _Missing(object):
- def __repr__(self):
- return "no value"
-
- def __reduce__(self):
- return "_missing"
-
-
-_missing = _Missing()
-
-
-def _get_environ(obj):
- env = getattr(obj, "environ", obj)
- assert isinstance(env, dict), (
- "%r is not a WSGI environment (has to be a dict)" % type(obj).__name__
- )
- return env
-
-
-def _has_level_handler(logger):
- """Check if there is a handler in the logging chain that will handle
- the given logger's effective level.
- """
- level = logger.getEffectiveLevel()
- current = logger
-
- while current:
- if any(handler.level <= level for handler in current.handlers):
- return True
-
- if not current.propagate:
- break
-
- current = current.parent
-
- return False
-
-
-def _log(type, message, *args, **kwargs):
- """Log a message to the 'werkzeug' logger.
-
- The logger is created the first time it is needed. If there is no
- level set, it is set to :data:`logging.INFO`. If there is no handler
- for the logger's effective level, a :class:`logging.StreamHandler`
- is added.
- """
- global _logger
-
- if _logger is None:
- _logger = logging.getLogger("werkzeug")
-
- if _logger.level == logging.NOTSET:
- _logger.setLevel(logging.INFO)
-
- if not _has_level_handler(_logger):
- _logger.addHandler(logging.StreamHandler())
-
- getattr(_logger, type)(message.rstrip(), *args, **kwargs)
-
-
-def _parse_signature(func):
- """Return a signature object for the function."""
- if hasattr(func, "im_func"):
- func = func.im_func
-
- # if we have a cached validator for this function, return it
- parse = _signature_cache.get(func)
- if parse is not None:
- return parse
-
- # inspect the function signature and collect all the information
- if hasattr(inspect, "getfullargspec"):
- tup = inspect.getfullargspec(func)
- else:
- tup = inspect.getargspec(func)
- positional, vararg_var, kwarg_var, defaults = tup[:4]
- defaults = defaults or ()
- arg_count = len(positional)
- arguments = []
- for idx, name in enumerate(positional):
- if isinstance(name, list):
- raise TypeError(
- "cannot parse functions that unpack tuples in the function signature"
- )
- try:
- default = defaults[idx - arg_count]
- except IndexError:
- param = (name, False, None)
- else:
- param = (name, True, default)
- arguments.append(param)
- arguments = tuple(arguments)
-
- def parse(args, kwargs):
- new_args = []
- missing = []
- extra = {}
-
- # consume as many arguments as positional as possible
- for idx, (name, has_default, default) in enumerate(arguments):
- try:
- new_args.append(args[idx])
- except IndexError:
- try:
- new_args.append(kwargs.pop(name))
- except KeyError:
- if has_default:
- new_args.append(default)
- else:
- missing.append(name)
- else:
- if name in kwargs:
- extra[name] = kwargs.pop(name)
-
- # handle extra arguments
- extra_positional = args[arg_count:]
- if vararg_var is not None:
- new_args.extend(extra_positional)
- extra_positional = ()
- if kwargs and kwarg_var is None:
- extra.update(kwargs)
- kwargs = {}
-
- return (
- new_args,
- kwargs,
- missing,
- extra,
- extra_positional,
- arguments,
- vararg_var,
- kwarg_var,
- )
-
- _signature_cache[func] = parse
- return parse
-
-
-def _date_to_unix(arg):
- """Converts a timetuple, integer or datetime object into the seconds from
- epoch in utc.
- """
- if isinstance(arg, datetime):
- arg = arg.utctimetuple()
- elif isinstance(arg, integer_types + (float,)):
- return int(arg)
- year, month, day, hour, minute, second = arg[:6]
- days = date(year, month, 1).toordinal() - _epoch_ord + day - 1
- hours = days * 24 + hour
- minutes = hours * 60 + minute
- seconds = minutes * 60 + second
- return seconds
-
-
-class _DictAccessorProperty(object):
- """Baseclass for `environ_property` and `header_property`."""
-
- read_only = False
-
- def __init__(
- self,
- name,
- default=None,
- load_func=None,
- dump_func=None,
- read_only=None,
- doc=None,
- ):
- self.name = name
- self.default = default
- self.load_func = load_func
- self.dump_func = dump_func
- if read_only is not None:
- self.read_only = read_only
- self.__doc__ = doc
-
- def __get__(self, obj, type=None):
- if obj is None:
- return self
- storage = self.lookup(obj)
- if self.name not in storage:
- return self.default
- rv = storage[self.name]
- if self.load_func is not None:
- try:
- rv = self.load_func(rv)
- except (ValueError, TypeError):
- rv = self.default
- return rv
-
- def __set__(self, obj, value):
- if self.read_only:
- raise AttributeError("read only property")
- if self.dump_func is not None:
- value = self.dump_func(value)
- self.lookup(obj)[self.name] = value
-
- def __delete__(self, obj):
- if self.read_only:
- raise AttributeError("read only property")
- self.lookup(obj).pop(self.name, None)
-
- def __repr__(self):
- return "<%s %s>" % (self.__class__.__name__, self.name)
-
-
-def _cookie_quote(b):
- buf = bytearray()
- all_legal = True
- _lookup = _cookie_quoting_map.get
- _push = buf.extend
-
- for char in iter_bytes(b):
- if char not in _legal_cookie_chars:
- all_legal = False
- char = _lookup(char, char)
- _push(char)
-
- if all_legal:
- return bytes(buf)
- return bytes(b'"' + buf + b'"')
-
-
-def _cookie_unquote(b):
- if len(b) < 2:
- return b
- if b[:1] != b'"' or b[-1:] != b'"':
- return b
-
- b = b[1:-1]
-
- i = 0
- n = len(b)
- rv = bytearray()
- _push = rv.extend
-
- while 0 <= i < n:
- o_match = _octal_re.search(b, i)
- q_match = _quote_re.search(b, i)
- if not o_match and not q_match:
- rv.extend(b[i:])
- break
- j = k = -1
- if o_match:
- j = o_match.start(0)
- if q_match:
- k = q_match.start(0)
- if q_match and (not o_match or k < j):
- _push(b[i:k])
- _push(b[k + 1 : k + 2])
- i = k + 2
- else:
- _push(b[i:j])
- rv.append(int(b[j + 1 : j + 4], 8))
- i = j + 4
-
- return bytes(rv)
-
-
-def _cookie_parse_impl(b):
- """Lowlevel cookie parsing facility that operates on bytes."""
- i = 0
- n = len(b)
-
- while i < n:
- match = _cookie_re.search(b + b";", i)
- if not match:
- break
-
- key = match.group("key").strip()
- value = match.group("val") or b""
- i = match.end(0)
-
- # Ignore parameters. We have no interest in them.
- if key.lower() not in _cookie_params:
- yield _cookie_unquote(key), _cookie_unquote(value)
-
-
-def _encode_idna(domain):
- # If we're given bytes, make sure they fit into ASCII
- if not isinstance(domain, text_type):
- domain.decode("ascii")
- return domain
-
- # Otherwise check if it's already ascii, then return
- try:
- return domain.encode("ascii")
- except UnicodeError:
- pass
-
- # Otherwise encode each part separately
- parts = domain.split(".")
- for idx, part in enumerate(parts):
- parts[idx] = part.encode("idna")
- return b".".join(parts)
-
-
-def _decode_idna(domain):
- # If the input is a string try to encode it to ascii to
- # do the idna decoding. if that fails because of an
- # unicode error, then we already have a decoded idna domain
- if isinstance(domain, text_type):
- try:
- domain = domain.encode("ascii")
- except UnicodeError:
- return domain
-
- # Decode each part separately. If a part fails, try to
- # decode it with ascii and silently ignore errors. This makes
- # most sense because the idna codec does not have error handling
- parts = domain.split(b".")
- for idx, part in enumerate(parts):
- try:
- parts[idx] = part.decode("idna")
- except UnicodeError:
- parts[idx] = part.decode("ascii", "ignore")
-
- return ".".join(parts)
-
-
-def _make_cookie_domain(domain):
- if domain is None:
- return None
- domain = _encode_idna(domain)
- if b":" in domain:
- domain = domain.split(b":", 1)[0]
- if b"." in domain:
- return domain
- raise ValueError(
- "Setting 'domain' for a cookie on a server running locally (ex: "
- "localhost) is not supported by complying browsers. You should "
- "have something like: '127.0.0.1 localhost dev.localhost' on "
- "your hosts file and then point your server to run on "
- "'dev.localhost' and also set 'domain' for 'dev.localhost'"
- )
-
-
-def _easteregg(app=None):
- """Like the name says. But who knows how it works?"""
-
- def bzzzzzzz(gyver):
- import base64
- import zlib
-
- return zlib.decompress(base64.b64decode(gyver)).decode("ascii")
-
- gyver = u"\n".join(
- [
- x + (77 - len(x)) * u" "
- for x in bzzzzzzz(
- b"""
-eJyFlzuOJDkMRP06xRjymKgDJCDQStBYT8BCgK4gTwfQ2fcFs2a2FzvZk+hvlcRvRJD148efHt9m
-9Xz94dRY5hGt1nrYcXx7us9qlcP9HHNh28rz8dZj+q4rynVFFPdlY4zH873NKCexrDM6zxxRymzz
-4QIxzK4bth1PV7+uHn6WXZ5C4ka/+prFzx3zWLMHAVZb8RRUxtFXI5DTQ2n3Hi2sNI+HK43AOWSY
-jmEzE4naFp58PdzhPMdslLVWHTGUVpSxImw+pS/D+JhzLfdS1j7PzUMxij+mc2U0I9zcbZ/HcZxc
-q1QjvvcThMYFnp93agEx392ZdLJWXbi/Ca4Oivl4h/Y1ErEqP+lrg7Xa4qnUKu5UE9UUA4xeqLJ5
-jWlPKJvR2yhRI7xFPdzPuc6adXu6ovwXwRPXXnZHxlPtkSkqWHilsOrGrvcVWXgGP3daXomCj317
-8P2UOw/NnA0OOikZyFf3zZ76eN9QXNwYdD8f8/LdBRFg0BO3bB+Pe/+G8er8tDJv83XTkj7WeMBJ
-v/rnAfdO51d6sFglfi8U7zbnr0u9tyJHhFZNXYfH8Iafv2Oa+DT6l8u9UYlajV/hcEgk1x8E8L/r
-XJXl2SK+GJCxtnyhVKv6GFCEB1OO3f9YWAIEbwcRWv/6RPpsEzOkXURMN37J0PoCSYeBnJQd9Giu
-LxYQJNlYPSo/iTQwgaihbART7Fcyem2tTSCcwNCs85MOOpJtXhXDe0E7zgZJkcxWTar/zEjdIVCk
-iXy87FW6j5aGZhttDBoAZ3vnmlkx4q4mMmCdLtnHkBXFMCReqthSGkQ+MDXLLCpXwBs0t+sIhsDI
-tjBB8MwqYQpLygZ56rRHHpw+OAVyGgaGRHWy2QfXez+ZQQTTBkmRXdV/A9LwH6XGZpEAZU8rs4pE
-1R4FQ3Uwt8RKEtRc0/CrANUoes3EzM6WYcFyskGZ6UTHJWenBDS7h163Eo2bpzqxNE9aVgEM2CqI
-GAJe9Yra4P5qKmta27VjzYdR04Vc7KHeY4vs61C0nbywFmcSXYjzBHdiEjraS7PGG2jHHTpJUMxN
-Jlxr3pUuFvlBWLJGE3GcA1/1xxLcHmlO+LAXbhrXah1tD6Ze+uqFGdZa5FM+3eHcKNaEarutAQ0A
-QMAZHV+ve6LxAwWnXbbSXEG2DmCX5ijeLCKj5lhVFBrMm+ryOttCAeFpUdZyQLAQkA06RLs56rzG
-8MID55vqr/g64Qr/wqwlE0TVxgoiZhHrbY2h1iuuyUVg1nlkpDrQ7Vm1xIkI5XRKLedN9EjzVchu
-jQhXcVkjVdgP2O99QShpdvXWoSwkp5uMwyjt3jiWCqWGSiaaPAzohjPanXVLbM3x0dNskJsaCEyz
-DTKIs+7WKJD4ZcJGfMhLFBf6hlbnNkLEePF8Cx2o2kwmYF4+MzAxa6i+6xIQkswOqGO+3x9NaZX8
-MrZRaFZpLeVTYI9F/djY6DDVVs340nZGmwrDqTCiiqD5luj3OzwpmQCiQhdRYowUYEA3i1WWGwL4
-GCtSoO4XbIPFeKGU13XPkDf5IdimLpAvi2kVDVQbzOOa4KAXMFlpi/hV8F6IDe0Y2reg3PuNKT3i
-RYhZqtkQZqSB2Qm0SGtjAw7RDwaM1roESC8HWiPxkoOy0lLTRFG39kvbLZbU9gFKFRvixDZBJmpi
-Xyq3RE5lW00EJjaqwp/v3EByMSpVZYsEIJ4APaHmVtpGSieV5CALOtNUAzTBiw81GLgC0quyzf6c
-NlWknzJeCsJ5fup2R4d8CYGN77mu5vnO1UqbfElZ9E6cR6zbHjgsr9ly18fXjZoPeDjPuzlWbFwS
-pdvPkhntFvkc13qb9094LL5NrA3NIq3r9eNnop9DizWOqCEbyRBFJTHn6Tt3CG1o8a4HevYh0XiJ
-sR0AVVHuGuMOIfbuQ/OKBkGRC6NJ4u7sbPX8bG/n5sNIOQ6/Y/BX3IwRlTSabtZpYLB85lYtkkgm
-p1qXK3Du2mnr5INXmT/78KI12n11EFBkJHHp0wJyLe9MvPNUGYsf+170maayRoy2lURGHAIapSpQ
-krEDuNoJCHNlZYhKpvw4mspVWxqo415n8cD62N9+EfHrAvqQnINStetek7RY2Urv8nxsnGaZfRr/
-nhXbJ6m/yl1LzYqscDZA9QHLNbdaSTTr+kFg3bC0iYbX/eQy0Bv3h4B50/SGYzKAXkCeOLI3bcAt
-mj2Z/FM1vQWgDynsRwNvrWnJHlespkrp8+vO1jNaibm+PhqXPPv30YwDZ6jApe3wUjFQobghvW9p
-7f2zLkGNv8b191cD/3vs9Q833z8t"""
- ).splitlines()
- ]
- )
-
- def easteregged(environ, start_response):
- def injecting_start_response(status, headers, exc_info=None):
- headers.append(("X-Powered-By", "Werkzeug"))
- return start_response(status, headers, exc_info)
-
- if app is not None and environ.get("QUERY_STRING") != "macgybarchakku":
- return app(environ, injecting_start_response)
- injecting_start_response("200 OK", [("Content-Type", "text/html")])
- return [
- (
- u"""
-<!DOCTYPE html>
-<html>
-<head>
-<title>About Werkzeug</title>
-<style type="text/css">
- body { font: 15px Georgia, serif; text-align: center; }
- a { color: #333; text-decoration: none; }
- h1 { font-size: 30px; margin: 20px 0 10px 0; }
- p { margin: 0 0 30px 0; }
- pre { font: 11px 'Consolas', 'Monaco', monospace; line-height: 0.95; }
-</style>
-</head>
-<body>
-<h1><a href="http://werkzeug.pocoo.org/">Werkzeug</a></h1>
-<p>the Swiss Army knife of Python web development.</p>
-<pre>%s\n\n\n</pre>
-</body>
-</html>"""
- % gyver
- ).encode("latin1")
- ]
-
- return easteregged
diff --git a/python/werkzeug/_reloader.py b/python/werkzeug/_reloader.py
deleted file mode 100644
index f06a63d..0000000
--- a/python/werkzeug/_reloader.py
+++ /dev/null
@@ -1,334 +0,0 @@
-import os
-import subprocess
-import sys
-import threading
-import time
-from itertools import chain
-
-from ._compat import iteritems
-from ._compat import PY2
-from ._compat import text_type
-from ._internal import _log
-
-
-def _iter_module_files():
- """This iterates over all relevant Python files. It goes through all
- loaded files from modules, all files in folders of already loaded modules
- as well as all files reachable through a package.
- """
- # The list call is necessary on Python 3 in case the module
- # dictionary modifies during iteration.
- for module in list(sys.modules.values()):
- if module is None:
- continue
- filename = getattr(module, "__file__", None)
- if filename:
- if os.path.isdir(filename) and os.path.exists(
- os.path.join(filename, "__init__.py")
- ):
- filename = os.path.join(filename, "__init__.py")
-
- old = None
- while not os.path.isfile(filename):
- old = filename
- filename = os.path.dirname(filename)
- if filename == old:
- break
- else:
- if filename[-4:] in (".pyc", ".pyo"):
- filename = filename[:-1]
- yield filename
-
-
-def _find_observable_paths(extra_files=None):
- """Finds all paths that should be observed."""
- rv = set(
- os.path.dirname(os.path.abspath(x)) if os.path.isfile(x) else os.path.abspath(x)
- for x in sys.path
- )
-
- for filename in extra_files or ():
- rv.add(os.path.dirname(os.path.abspath(filename)))
-
- for module in list(sys.modules.values()):
- fn = getattr(module, "__file__", None)
- if fn is None:
- continue
- fn = os.path.abspath(fn)
- rv.add(os.path.dirname(fn))
-
- return _find_common_roots(rv)
-
-
-def _get_args_for_reloading():
- """Returns the executable. This contains a workaround for windows
- if the executable is incorrectly reported to not have the .exe
- extension which can cause bugs on reloading. This also contains
- a workaround for linux where the file is executable (possibly with
- a program other than python)
- """
- rv = [sys.executable]
- py_script = os.path.abspath(sys.argv[0])
- args = sys.argv[1:]
- # Need to look at main module to determine how it was executed.
- __main__ = sys.modules["__main__"]
-
- if __main__.__package__ is None:
- # Executed a file, like "python app.py".
- if os.name == "nt":
- # Windows entry points have ".exe" extension and should be
- # called directly.
- if not os.path.exists(py_script) and os.path.exists(py_script + ".exe"):
- py_script += ".exe"
-
- if (
- os.path.splitext(rv[0])[1] == ".exe"
- and os.path.splitext(py_script)[1] == ".exe"
- ):
- rv.pop(0)
-
- elif os.path.isfile(py_script) and os.access(py_script, os.X_OK):
- # The file is marked as executable. Nix adds a wrapper that
- # shouldn't be called with the Python executable.
- rv.pop(0)
-
- rv.append(py_script)
- else:
- # Executed a module, like "python -m werkzeug.serving".
- if sys.argv[0] == "-m":
- # Flask works around previous behavior by putting
- # "-m flask" in sys.argv.
- # TODO remove this once Flask no longer misbehaves
- args = sys.argv
- else:
- py_module = __main__.__package__
- name = os.path.splitext(os.path.basename(py_script))[0]
-
- if name != "__main__":
- py_module += "." + name
-
- rv.extend(("-m", py_module.lstrip(".")))
-
- rv.extend(args)
- return rv
-
-
-def _find_common_roots(paths):
- """Out of some paths it finds the common roots that need monitoring."""
- paths = [x.split(os.path.sep) for x in paths]
- root = {}
- for chunks in sorted(paths, key=len, reverse=True):
- node = root
- for chunk in chunks:
- node = node.setdefault(chunk, {})
- node.clear()
-
- rv = set()
-
- def _walk(node, path):
- for prefix, child in iteritems(node):
- _walk(child, path + (prefix,))
- if not node:
- rv.add("/".join(path))
-
- _walk(root, ())
- return rv
-
-
-class ReloaderLoop(object):
- name = None
-
- # monkeypatched by testsuite. wrapping with `staticmethod` is required in
- # case time.sleep has been replaced by a non-c function (e.g. by
- # `eventlet.monkey_patch`) before we get here
- _sleep = staticmethod(time.sleep)
-
- def __init__(self, extra_files=None, interval=1):
- self.extra_files = set(os.path.abspath(x) for x in extra_files or ())
- self.interval = interval
-
- def run(self):
- pass
-
- def restart_with_reloader(self):
- """Spawn a new Python interpreter with the same arguments as this one,
- but running the reloader thread.
- """
- while 1:
- _log("info", " * Restarting with %s" % self.name)
- args = _get_args_for_reloading()
-
- # a weird bug on windows. sometimes unicode strings end up in the
- # environment and subprocess.call does not like this, encode them
- # to latin1 and continue.
- if os.name == "nt" and PY2:
- new_environ = {}
- for key, value in iteritems(os.environ):
- if isinstance(key, text_type):
- key = key.encode("iso-8859-1")
- if isinstance(value, text_type):
- value = value.encode("iso-8859-1")
- new_environ[key] = value
- else:
- new_environ = os.environ.copy()
-
- new_environ["WERKZEUG_RUN_MAIN"] = "true"
- exit_code = subprocess.call(args, env=new_environ, close_fds=False)
- if exit_code != 3:
- return exit_code
-
- def trigger_reload(self, filename):
- self.log_reload(filename)
- sys.exit(3)
-
- def log_reload(self, filename):
- filename = os.path.abspath(filename)
- _log("info", " * Detected change in %r, reloading" % filename)
-
-
-class StatReloaderLoop(ReloaderLoop):
- name = "stat"
-
- def run(self):
- mtimes = {}
- while 1:
- for filename in chain(_iter_module_files(), self.extra_files):
- try:
- mtime = os.stat(filename).st_mtime
- except OSError:
- continue
-
- old_time = mtimes.get(filename)
- if old_time is None:
- mtimes[filename] = mtime
- continue
- elif mtime > old_time:
- self.trigger_reload(filename)
- self._sleep(self.interval)
-
-
-class WatchdogReloaderLoop(ReloaderLoop):
- def __init__(self, *args, **kwargs):
- ReloaderLoop.__init__(self, *args, **kwargs)
- from watchdog.observers import Observer
- from watchdog.events import FileSystemEventHandler
-
- self.observable_paths = set()
-
- def _check_modification(filename):
- if filename in self.extra_files:
- self.trigger_reload(filename)
- dirname = os.path.dirname(filename)
- if dirname.startswith(tuple(self.observable_paths)):
- if filename.endswith((".pyc", ".pyo", ".py")):
- self.trigger_reload(filename)
-
- class _CustomHandler(FileSystemEventHandler):
- def on_created(self, event):
- _check_modification(event.src_path)
-
- def on_modified(self, event):
- _check_modification(event.src_path)
-
- def on_moved(self, event):
- _check_modification(event.src_path)
- _check_modification(event.dest_path)
-
- def on_deleted(self, event):
- _check_modification(event.src_path)
-
- reloader_name = Observer.__name__.lower()
- if reloader_name.endswith("observer"):
- reloader_name = reloader_name[:-8]
- reloader_name += " reloader"
-
- self.name = reloader_name
-
- self.observer_class = Observer
- self.event_handler = _CustomHandler()
- self.should_reload = False
-
- def trigger_reload(self, filename):
- # This is called inside an event handler, which means throwing
- # SystemExit has no effect.
- # https://github.com/gorakhargosh/watchdog/issues/294
- self.should_reload = True
- self.log_reload(filename)
-
- def run(self):
- watches = {}
- observer = self.observer_class()
- observer.start()
-
- try:
- while not self.should_reload:
- to_delete = set(watches)
- paths = _find_observable_paths(self.extra_files)
- for path in paths:
- if path not in watches:
- try:
- watches[path] = observer.schedule(
- self.event_handler, path, recursive=True
- )
- except OSError:
- # Clear this path from list of watches We don't want
- # the same error message showing again in the next
- # iteration.
- watches[path] = None
- to_delete.discard(path)
- for path in to_delete:
- watch = watches.pop(path, None)
- if watch is not None:
- observer.unschedule(watch)
- self.observable_paths = paths
- self._sleep(self.interval)
- finally:
- observer.stop()
- observer.join()
-
- sys.exit(3)
-
-
-reloader_loops = {"stat": StatReloaderLoop, "watchdog": WatchdogReloaderLoop}
-
-try:
- __import__("watchdog.observers")
-except ImportError:
- reloader_loops["auto"] = reloader_loops["stat"]
-else:
- reloader_loops["auto"] = reloader_loops["watchdog"]
-
-
-def ensure_echo_on():
- """Ensure that echo mode is enabled. Some tools such as PDB disable
- it which causes usability issues after reload."""
- # tcgetattr will fail if stdin isn't a tty
- if not sys.stdin.isatty():
- return
- try:
- import termios
- except ImportError:
- return
- attributes = termios.tcgetattr(sys.stdin)
- if not attributes[3] & termios.ECHO:
- attributes[3] |= termios.ECHO
- termios.tcsetattr(sys.stdin, termios.TCSANOW, attributes)
-
-
-def run_with_reloader(main_func, extra_files=None, interval=1, reloader_type="auto"):
- """Run the given function in an independent python interpreter."""
- import signal
-
- reloader = reloader_loops[reloader_type](extra_files, interval)
- signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
- try:
- if os.environ.get("WERKZEUG_RUN_MAIN") == "true":
- ensure_echo_on()
- t = threading.Thread(target=main_func, args=())
- t.setDaemon(True)
- t.start()
- reloader.run()
- else:
- sys.exit(reloader.restart_with_reloader())
- except KeyboardInterrupt:
- pass
diff --git a/python/werkzeug/contrib/__init__.py b/python/werkzeug/contrib/__init__.py
deleted file mode 100644
index 0e741f0..0000000
--- a/python/werkzeug/contrib/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.contrib
- ~~~~~~~~~~~~~~~~
-
- Contains user-submitted code that other users may find useful, but which
- is not part of the Werkzeug core. Anyone can write code for inclusion in
- the `contrib` package. All modules in this package are distributed as an
- add-on library and thus are not part of Werkzeug itself.
-
- This file itself is mostly for informational purposes and to tell the
- Python interpreter that `contrib` is a package.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
diff --git a/python/werkzeug/contrib/atom.py b/python/werkzeug/contrib/atom.py
deleted file mode 100644
index d079d2b..0000000
--- a/python/werkzeug/contrib/atom.py
+++ /dev/null
@@ -1,362 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.contrib.atom
- ~~~~~~~~~~~~~~~~~~~~~
-
- This module provides a class called :class:`AtomFeed` which can be
- used to generate feeds in the Atom syndication format (see :rfc:`4287`).
-
- Example::
-
- def atom_feed(request):
- feed = AtomFeed("My Blog", feed_url=request.url,
- url=request.host_url,
- subtitle="My example blog for a feed test.")
- for post in Post.query.limit(10).all():
- feed.add(post.title, post.body, content_type='html',
- author=post.author, url=post.url, id=post.uid,
- updated=post.last_update, published=post.pub_date)
- return feed.get_response()
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import warnings
-from datetime import datetime
-
-from .._compat import implements_to_string
-from .._compat import string_types
-from ..utils import escape
-from ..wrappers import BaseResponse
-
-warnings.warn(
- "'werkzeug.contrib.atom' is deprecated as of version 0.15 and will"
- " be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
-
-
-def _make_text_block(name, content, content_type=None):
- """Helper function for the builder that creates an XML text block."""
- if content_type == "xhtml":
- return u'<%s type="xhtml"><div xmlns="%s">%s</div></%s>\n' % (
- name,
- XHTML_NAMESPACE,
- content,
- name,
- )
- if not content_type:
- return u"<%s>%s</%s>\n" % (name, escape(content), name)
- return u'<%s type="%s">%s</%s>\n' % (name, content_type, escape(content), name)
-
-
-def format_iso8601(obj):
- """Format a datetime object for iso8601"""
- iso8601 = obj.isoformat()
- if obj.tzinfo:
- return iso8601
- return iso8601 + "Z"
-
-
-@implements_to_string
-class AtomFeed(object):
-
- """A helper class that creates Atom feeds.
-
- :param title: the title of the feed. Required.
- :param title_type: the type attribute for the title element. One of
- ``'html'``, ``'text'`` or ``'xhtml'``.
- :param url: the url for the feed (not the url *of* the feed)
- :param id: a globally unique id for the feed. Must be an URI. If
- not present the `feed_url` is used, but one of both is
- required.
- :param updated: the time the feed was modified the last time. Must
- be a :class:`datetime.datetime` object. If not
- present the latest entry's `updated` is used.
- Treated as UTC if naive datetime.
- :param feed_url: the URL to the feed. Should be the URL that was
- requested.
- :param author: the author of the feed. Must be either a string (the
- name) or a dict with name (required) and uri or
- email (both optional). Can be a list of (may be
- mixed, too) strings and dicts, too, if there are
- multiple authors. Required if not every entry has an
- author element.
- :param icon: an icon for the feed.
- :param logo: a logo for the feed.
- :param rights: copyright information for the feed.
- :param rights_type: the type attribute for the rights element. One of
- ``'html'``, ``'text'`` or ``'xhtml'``. Default is
- ``'text'``.
- :param subtitle: a short description of the feed.
- :param subtitle_type: the type attribute for the subtitle element.
- One of ``'text'``, ``'html'``, ``'text'``
- or ``'xhtml'``. Default is ``'text'``.
- :param links: additional links. Must be a list of dictionaries with
- href (required) and rel, type, hreflang, title, length
- (all optional)
- :param generator: the software that generated this feed. This must be
- a tuple in the form ``(name, url, version)``. If
- you don't want to specify one of them, set the item
- to `None`.
- :param entries: a list with the entries for the feed. Entries can also
- be added later with :meth:`add`.
-
- For more information on the elements see
- http://www.atomenabled.org/developers/syndication/
-
- Everywhere where a list is demanded, any iterable can be used.
- """
-
- default_generator = ("Werkzeug", None, None)
-
- def __init__(self, title=None, entries=None, **kwargs):
- self.title = title
- self.title_type = kwargs.get("title_type", "text")
- self.url = kwargs.get("url")
- self.feed_url = kwargs.get("feed_url", self.url)
- self.id = kwargs.get("id", self.feed_url)
- self.updated = kwargs.get("updated")
- self.author = kwargs.get("author", ())
- self.icon = kwargs.get("icon")
- self.logo = kwargs.get("logo")
- self.rights = kwargs.get("rights")
- self.rights_type = kwargs.get("rights_type")
- self.subtitle = kwargs.get("subtitle")
- self.subtitle_type = kwargs.get("subtitle_type", "text")
- self.generator = kwargs.get("generator")
- if self.generator is None:
- self.generator = self.default_generator
- self.links = kwargs.get("links", [])
- self.entries = list(entries) if entries else []
-
- if not hasattr(self.author, "__iter__") or isinstance(
- self.author, string_types + (dict,)
- ):
- self.author = [self.author]
- for i, author in enumerate(self.author):
- if not isinstance(author, dict):
- self.author[i] = {"name": author}
-
- if not self.title:
- raise ValueError("title is required")
- if not self.id:
- raise ValueError("id is required")
- for author in self.author:
- if "name" not in author:
- raise TypeError("author must contain at least a name")
-
- def add(self, *args, **kwargs):
- """Add a new entry to the feed. This function can either be called
- with a :class:`FeedEntry` or some keyword and positional arguments
- that are forwarded to the :class:`FeedEntry` constructor.
- """
- if len(args) == 1 and not kwargs and isinstance(args[0], FeedEntry):
- self.entries.append(args[0])
- else:
- kwargs["feed_url"] = self.feed_url
- self.entries.append(FeedEntry(*args, **kwargs))
-
- def __repr__(self):
- return "<%s %r (%d entries)>" % (
- self.__class__.__name__,
- self.title,
- len(self.entries),
- )
-
- def generate(self):
- """Return a generator that yields pieces of XML."""
- # atom demands either an author element in every entry or a global one
- if not self.author:
- if any(not e.author for e in self.entries):
- self.author = ({"name": "Unknown author"},)
-
- if not self.updated:
- dates = sorted([entry.updated for entry in self.entries])
- self.updated = dates[-1] if dates else datetime.utcnow()
-
- yield u'<?xml version="1.0" encoding="utf-8"?>\n'
- yield u'<feed xmlns="http://www.w3.org/2005/Atom">\n'
- yield " " + _make_text_block("title", self.title, self.title_type)
- yield u" <id>%s</id>\n" % escape(self.id)
- yield u" <updated>%s</updated>\n" % format_iso8601(self.updated)
- if self.url:
- yield u' <link href="%s" />\n' % escape(self.url)
- if self.feed_url:
- yield u' <link href="%s" rel="self" />\n' % escape(self.feed_url)
- for link in self.links:
- yield u" <link %s/>\n" % "".join(
- '%s="%s" ' % (k, escape(link[k])) for k in link
- )
- for author in self.author:
- yield u" <author>\n"
- yield u" <name>%s</name>\n" % escape(author["name"])
- if "uri" in author:
- yield u" <uri>%s</uri>\n" % escape(author["uri"])
- if "email" in author:
- yield " <email>%s</email>\n" % escape(author["email"])
- yield " </author>\n"
- if self.subtitle:
- yield " " + _make_text_block("subtitle", self.subtitle, self.subtitle_type)
- if self.icon:
- yield u" <icon>%s</icon>\n" % escape(self.icon)
- if self.logo:
- yield u" <logo>%s</logo>\n" % escape(self.logo)
- if self.rights:
- yield " " + _make_text_block("rights", self.rights, self.rights_type)
- generator_name, generator_url, generator_version = self.generator
- if generator_name or generator_url or generator_version:
- tmp = [u" <generator"]
- if generator_url:
- tmp.append(u' uri="%s"' % escape(generator_url))
- if generator_version:
- tmp.append(u' version="%s"' % escape(generator_version))
- tmp.append(u">%s</generator>\n" % escape(generator_name))
- yield u"".join(tmp)
- for entry in self.entries:
- for line in entry.generate():
- yield u" " + line
- yield u"</feed>\n"
-
- def to_string(self):
- """Convert the feed into a string."""
- return u"".join(self.generate())
-
- def get_response(self):
- """Return a response object for the feed."""
- return BaseResponse(self.to_string(), mimetype="application/atom+xml")
-
- def __call__(self, environ, start_response):
- """Use the class as WSGI response object."""
- return self.get_response()(environ, start_response)
-
- def __str__(self):
- return self.to_string()
-
-
-@implements_to_string
-class FeedEntry(object):
-
- """Represents a single entry in a feed.
-
- :param title: the title of the entry. Required.
- :param title_type: the type attribute for the title element. One of
- ``'html'``, ``'text'`` or ``'xhtml'``.
- :param content: the content of the entry.
- :param content_type: the type attribute for the content element. One
- of ``'html'``, ``'text'`` or ``'xhtml'``.
- :param summary: a summary of the entry's content.
- :param summary_type: the type attribute for the summary element. One
- of ``'html'``, ``'text'`` or ``'xhtml'``.
- :param url: the url for the entry.
- :param id: a globally unique id for the entry. Must be an URI. If
- not present the URL is used, but one of both is required.
- :param updated: the time the entry was modified the last time. Must
- be a :class:`datetime.datetime` object. Treated as
- UTC if naive datetime. Required.
- :param author: the author of the entry. Must be either a string (the
- name) or a dict with name (required) and uri or
- email (both optional). Can be a list of (may be
- mixed, too) strings and dicts, too, if there are
- multiple authors. Required if the feed does not have an
- author element.
- :param published: the time the entry was initially published. Must
- be a :class:`datetime.datetime` object. Treated as
- UTC if naive datetime.
- :param rights: copyright information for the entry.
- :param rights_type: the type attribute for the rights element. One of
- ``'html'``, ``'text'`` or ``'xhtml'``. Default is
- ``'text'``.
- :param links: additional links. Must be a list of dictionaries with
- href (required) and rel, type, hreflang, title, length
- (all optional)
- :param categories: categories for the entry. Must be a list of dictionaries
- with term (required), scheme and label (all optional)
- :param xml_base: The xml base (url) for this feed item. If not provided
- it will default to the item url.
-
- For more information on the elements see
- http://www.atomenabled.org/developers/syndication/
-
- Everywhere where a list is demanded, any iterable can be used.
- """
-
- def __init__(self, title=None, content=None, feed_url=None, **kwargs):
- self.title = title
- self.title_type = kwargs.get("title_type", "text")
- self.content = content
- self.content_type = kwargs.get("content_type", "html")
- self.url = kwargs.get("url")
- self.id = kwargs.get("id", self.url)
- self.updated = kwargs.get("updated")
- self.summary = kwargs.get("summary")
- self.summary_type = kwargs.get("summary_type", "html")
- self.author = kwargs.get("author", ())
- self.published = kwargs.get("published")
- self.rights = kwargs.get("rights")
- self.links = kwargs.get("links", [])
- self.categories = kwargs.get("categories", [])
- self.xml_base = kwargs.get("xml_base", feed_url)
-
- if not hasattr(self.author, "__iter__") or isinstance(
- self.author, string_types + (dict,)
- ):
- self.author = [self.author]
- for i, author in enumerate(self.author):
- if not isinstance(author, dict):
- self.author[i] = {"name": author}
-
- if not self.title:
- raise ValueError("title is required")
- if not self.id:
- raise ValueError("id is required")
- if not self.updated:
- raise ValueError("updated is required")
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, self.title)
-
- def generate(self):
- """Yields pieces of ATOM XML."""
- base = ""
- if self.xml_base:
- base = ' xml:base="%s"' % escape(self.xml_base)
- yield u"<entry%s>\n" % base
- yield u" " + _make_text_block("title", self.title, self.title_type)
- yield u" <id>%s</id>\n" % escape(self.id)
- yield u" <updated>%s</updated>\n" % format_iso8601(self.updated)
- if self.published:
- yield u" <published>%s</published>\n" % format_iso8601(self.published)
- if self.url:
- yield u' <link href="%s" />\n' % escape(self.url)
- for author in self.author:
- yield u" <author>\n"
- yield u" <name>%s</name>\n" % escape(author["name"])
- if "uri" in author:
- yield u" <uri>%s</uri>\n" % escape(author["uri"])
- if "email" in author:
- yield u" <email>%s</email>\n" % escape(author["email"])
- yield u" </author>\n"
- for link in self.links:
- yield u" <link %s/>\n" % "".join(
- '%s="%s" ' % (k, escape(link[k])) for k in link
- )
- for category in self.categories:
- yield u" <category %s/>\n" % "".join(
- '%s="%s" ' % (k, escape(category[k])) for k in category
- )
- if self.summary:
- yield u" " + _make_text_block("summary", self.summary, self.summary_type)
- if self.content:
- yield u" " + _make_text_block("content", self.content, self.content_type)
- yield u"</entry>\n"
-
- def to_string(self):
- """Convert the feed item into a unicode object."""
- return u"".join(self.generate())
-
- def __str__(self):
- return self.to_string()
diff --git a/python/werkzeug/contrib/cache.py b/python/werkzeug/contrib/cache.py
deleted file mode 100644
index 79c749b..0000000
--- a/python/werkzeug/contrib/cache.py
+++ /dev/null
@@ -1,933 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.contrib.cache
- ~~~~~~~~~~~~~~~~~~~~~~
-
- The main problem with dynamic Web sites is, well, they're dynamic. Each
- time a user requests a page, the webserver executes a lot of code, queries
- the database, renders templates until the visitor gets the page he sees.
-
- This is a lot more expensive than just loading a file from the file system
- and sending it to the visitor.
-
- For most Web applications, this overhead isn't a big deal but once it
- becomes, you will be glad to have a cache system in place.
-
- How Caching Works
- =================
-
- Caching is pretty simple. Basically you have a cache object lurking around
- somewhere that is connected to a remote cache or the file system or
- something else. When the request comes in you check if the current page
- is already in the cache and if so, you're returning it from the cache.
- Otherwise you generate the page and put it into the cache. (Or a fragment
- of the page, you don't have to cache the full thing)
-
- Here is a simple example of how to cache a sidebar for 5 minutes::
-
- def get_sidebar(user):
- identifier = 'sidebar_for/user%d' % user.id
- value = cache.get(identifier)
- if value is not None:
- return value
- value = generate_sidebar_for(user=user)
- cache.set(identifier, value, timeout=60 * 5)
- return value
-
- Creating a Cache Object
- =======================
-
- To create a cache object you just import the cache system of your choice
- from the cache module and instantiate it. Then you can start working
- with that object:
-
- >>> from werkzeug.contrib.cache import SimpleCache
- >>> c = SimpleCache()
- >>> c.set("foo", "value")
- >>> c.get("foo")
- 'value'
- >>> c.get("missing") is None
- True
-
- Please keep in mind that you have to create the cache and put it somewhere
- you have access to it (either as a module global you can import or you just
- put it into your WSGI application).
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import errno
-import os
-import platform
-import re
-import tempfile
-import warnings
-from hashlib import md5
-from time import time
-
-from .._compat import integer_types
-from .._compat import iteritems
-from .._compat import string_types
-from .._compat import text_type
-from .._compat import to_native
-from ..posixemulation import rename
-
-try:
- import cPickle as pickle
-except ImportError: # pragma: no cover
- import pickle
-
-warnings.warn(
- "'werkzeug.contrib.cache' is deprecated as of version 0.15 and will"
- " be removed in version 1.0. It has moved to https://github.com"
- "/pallets/cachelib.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-
-def _items(mappingorseq):
- """Wrapper for efficient iteration over mappings represented by dicts
- or sequences::
-
- >>> for k, v in _items((i, i*i) for i in xrange(5)):
- ... assert k*k == v
-
- >>> for k, v in _items(dict((i, i*i) for i in xrange(5))):
- ... assert k*k == v
-
- """
- if hasattr(mappingorseq, "items"):
- return iteritems(mappingorseq)
- return mappingorseq
-
-
-class BaseCache(object):
- """Baseclass for the cache systems. All the cache systems implement this
- API or a superset of it.
-
- :param default_timeout: the default timeout (in seconds) that is used if
- no timeout is specified on :meth:`set`. A timeout
- of 0 indicates that the cache never expires.
- """
-
- def __init__(self, default_timeout=300):
- self.default_timeout = default_timeout
-
- def _normalize_timeout(self, timeout):
- if timeout is None:
- timeout = self.default_timeout
- return timeout
-
- def get(self, key):
- """Look up key in the cache and return the value for it.
-
- :param key: the key to be looked up.
- :returns: The value if it exists and is readable, else ``None``.
- """
- return None
-
- def delete(self, key):
- """Delete `key` from the cache.
-
- :param key: the key to delete.
- :returns: Whether the key existed and has been deleted.
- :rtype: boolean
- """
- return True
-
- def get_many(self, *keys):
- """Returns a list of values for the given keys.
- For each key an item in the list is created::
-
- foo, bar = cache.get_many("foo", "bar")
-
- Has the same error handling as :meth:`get`.
-
- :param keys: The function accepts multiple keys as positional
- arguments.
- """
- return [self.get(k) for k in keys]
-
- def get_dict(self, *keys):
- """Like :meth:`get_many` but return a dict::
-
- d = cache.get_dict("foo", "bar")
- foo = d["foo"]
- bar = d["bar"]
-
- :param keys: The function accepts multiple keys as positional
- arguments.
- """
- return dict(zip(keys, self.get_many(*keys)))
-
- def set(self, key, value, timeout=None):
- """Add a new key/value to the cache (overwrites value, if key already
- exists in the cache).
-
- :param key: the key to set
- :param value: the value for the key
- :param timeout: the cache timeout for the key in seconds (if not
- specified, it uses the default timeout). A timeout of
- 0 idicates that the cache never expires.
- :returns: ``True`` if key has been updated, ``False`` for backend
- errors. Pickling errors, however, will raise a subclass of
- ``pickle.PickleError``.
- :rtype: boolean
- """
- return True
-
- def add(self, key, value, timeout=None):
- """Works like :meth:`set` but does not overwrite the values of already
- existing keys.
-
- :param key: the key to set
- :param value: the value for the key
- :param timeout: the cache timeout for the key in seconds (if not
- specified, it uses the default timeout). A timeout of
- 0 idicates that the cache never expires.
- :returns: Same as :meth:`set`, but also ``False`` for already
- existing keys.
- :rtype: boolean
- """
- return True
-
- def set_many(self, mapping, timeout=None):
- """Sets multiple keys and values from a mapping.
-
- :param mapping: a mapping with the keys/values to set.
- :param timeout: the cache timeout for the key in seconds (if not
- specified, it uses the default timeout). A timeout of
- 0 idicates that the cache never expires.
- :returns: Whether all given keys have been set.
- :rtype: boolean
- """
- rv = True
- for key, value in _items(mapping):
- if not self.set(key, value, timeout):
- rv = False
- return rv
-
- def delete_many(self, *keys):
- """Deletes multiple keys at once.
-
- :param keys: The function accepts multiple keys as positional
- arguments.
- :returns: Whether all given keys have been deleted.
- :rtype: boolean
- """
- return all(self.delete(key) for key in keys)
-
- def has(self, key):
- """Checks if a key exists in the cache without returning it. This is a
- cheap operation that bypasses loading the actual data on the backend.
-
- This method is optional and may not be implemented on all caches.
-
- :param key: the key to check
- """
- raise NotImplementedError(
- "%s doesn't have an efficient implementation of `has`. That "
- "means it is impossible to check whether a key exists without "
- "fully loading the key's data. Consider using `self.get` "
- "explicitly if you don't care about performance."
- )
-
- def clear(self):
- """Clears the cache. Keep in mind that not all caches support
- completely clearing the cache.
-
- :returns: Whether the cache has been cleared.
- :rtype: boolean
- """
- return True
-
- def inc(self, key, delta=1):
- """Increments the value of a key by `delta`. If the key does
- not yet exist it is initialized with `delta`.
-
- For supporting caches this is an atomic operation.
-
- :param key: the key to increment.
- :param delta: the delta to add.
- :returns: The new value or ``None`` for backend errors.
- """
- value = (self.get(key) or 0) + delta
- return value if self.set(key, value) else None
-
- def dec(self, key, delta=1):
- """Decrements the value of a key by `delta`. If the key does
- not yet exist it is initialized with `-delta`.
-
- For supporting caches this is an atomic operation.
-
- :param key: the key to increment.
- :param delta: the delta to subtract.
- :returns: The new value or `None` for backend errors.
- """
- value = (self.get(key) or 0) - delta
- return value if self.set(key, value) else None
-
-
-class NullCache(BaseCache):
- """A cache that doesn't cache. This can be useful for unit testing.
-
- :param default_timeout: a dummy parameter that is ignored but exists
- for API compatibility with other caches.
- """
-
- def has(self, key):
- return False
-
-
-class SimpleCache(BaseCache):
- """Simple memory cache for single process environments. This class exists
- mainly for the development server and is not 100% thread safe. It tries
- to use as many atomic operations as possible and no locks for simplicity
- but it could happen under heavy load that keys are added multiple times.
-
- :param threshold: the maximum number of items the cache stores before
- it starts deleting some.
- :param default_timeout: the default timeout that is used if no timeout is
- specified on :meth:`~BaseCache.set`. A timeout of
- 0 indicates that the cache never expires.
- """
-
- def __init__(self, threshold=500, default_timeout=300):
- BaseCache.__init__(self, default_timeout)
- self._cache = {}
- self.clear = self._cache.clear
- self._threshold = threshold
-
- def _prune(self):
- if len(self._cache) > self._threshold:
- now = time()
- toremove = []
- for idx, (key, (expires, _)) in enumerate(self._cache.items()):
- if (expires != 0 and expires <= now) or idx % 3 == 0:
- toremove.append(key)
- for key in toremove:
- self._cache.pop(key, None)
-
- def _normalize_timeout(self, timeout):
- timeout = BaseCache._normalize_timeout(self, timeout)
- if timeout > 0:
- timeout = time() + timeout
- return timeout
-
- def get(self, key):
- try:
- expires, value = self._cache[key]
- if expires == 0 or expires > time():
- return pickle.loads(value)
- except (KeyError, pickle.PickleError):
- return None
-
- def set(self, key, value, timeout=None):
- expires = self._normalize_timeout(timeout)
- self._prune()
- self._cache[key] = (expires, pickle.dumps(value, pickle.HIGHEST_PROTOCOL))
- return True
-
- def add(self, key, value, timeout=None):
- expires = self._normalize_timeout(timeout)
- self._prune()
- item = (expires, pickle.dumps(value, pickle.HIGHEST_PROTOCOL))
- if key in self._cache:
- return False
- self._cache.setdefault(key, item)
- return True
-
- def delete(self, key):
- return self._cache.pop(key, None) is not None
-
- def has(self, key):
- try:
- expires, value = self._cache[key]
- return expires == 0 or expires > time()
- except KeyError:
- return False
-
-
-_test_memcached_key = re.compile(r"[^\x00-\x21\xff]{1,250}$").match
-
-
-class MemcachedCache(BaseCache):
- """A cache that uses memcached as backend.
-
- The first argument can either be an object that resembles the API of a
- :class:`memcache.Client` or a tuple/list of server addresses. In the
- event that a tuple/list is passed, Werkzeug tries to import the best
- available memcache library.
-
- This cache looks into the following packages/modules to find bindings for
- memcached:
-
- - ``pylibmc``
- - ``google.appengine.api.memcached``
- - ``memcached``
- - ``libmc``
-
- Implementation notes: This cache backend works around some limitations in
- memcached to simplify the interface. For example unicode keys are encoded
- to utf-8 on the fly. Methods such as :meth:`~BaseCache.get_dict` return
- the keys in the same format as passed. Furthermore all get methods
- silently ignore key errors to not cause problems when untrusted user data
- is passed to the get methods which is often the case in web applications.
-
- :param servers: a list or tuple of server addresses or alternatively
- a :class:`memcache.Client` or a compatible client.
- :param default_timeout: the default timeout that is used if no timeout is
- specified on :meth:`~BaseCache.set`. A timeout of
- 0 indicates that the cache never expires.
- :param key_prefix: a prefix that is added before all keys. This makes it
- possible to use the same memcached server for different
- applications. Keep in mind that
- :meth:`~BaseCache.clear` will also clear keys with a
- different prefix.
- """
-
- def __init__(self, servers=None, default_timeout=300, key_prefix=None):
- BaseCache.__init__(self, default_timeout)
- if servers is None or isinstance(servers, (list, tuple)):
- if servers is None:
- servers = ["127.0.0.1:11211"]
- self._client = self.import_preferred_memcache_lib(servers)
- if self._client is None:
- raise RuntimeError("no memcache module found")
- else:
- # NOTE: servers is actually an already initialized memcache
- # client.
- self._client = servers
-
- self.key_prefix = to_native(key_prefix)
-
- def _normalize_key(self, key):
- key = to_native(key, "utf-8")
- if self.key_prefix:
- key = self.key_prefix + key
- return key
-
- def _normalize_timeout(self, timeout):
- timeout = BaseCache._normalize_timeout(self, timeout)
- if timeout > 0:
- timeout = int(time()) + timeout
- return timeout
-
- def get(self, key):
- key = self._normalize_key(key)
- # memcached doesn't support keys longer than that. Because often
- # checks for so long keys can occur because it's tested from user
- # submitted data etc we fail silently for getting.
- if _test_memcached_key(key):
- return self._client.get(key)
-
- def get_dict(self, *keys):
- key_mapping = {}
- have_encoded_keys = False
- for key in keys:
- encoded_key = self._normalize_key(key)
- if not isinstance(key, str):
- have_encoded_keys = True
- if _test_memcached_key(key):
- key_mapping[encoded_key] = key
- _keys = list(key_mapping)
- d = rv = self._client.get_multi(_keys)
- if have_encoded_keys or self.key_prefix:
- rv = {}
- for key, value in iteritems(d):
- rv[key_mapping[key]] = value
- if len(rv) < len(keys):
- for key in keys:
- if key not in rv:
- rv[key] = None
- return rv
-
- def add(self, key, value, timeout=None):
- key = self._normalize_key(key)
- timeout = self._normalize_timeout(timeout)
- return self._client.add(key, value, timeout)
-
- def set(self, key, value, timeout=None):
- key = self._normalize_key(key)
- timeout = self._normalize_timeout(timeout)
- return self._client.set(key, value, timeout)
-
- def get_many(self, *keys):
- d = self.get_dict(*keys)
- return [d[key] for key in keys]
-
- def set_many(self, mapping, timeout=None):
- new_mapping = {}
- for key, value in _items(mapping):
- key = self._normalize_key(key)
- new_mapping[key] = value
-
- timeout = self._normalize_timeout(timeout)
- failed_keys = self._client.set_multi(new_mapping, timeout)
- return not failed_keys
-
- def delete(self, key):
- key = self._normalize_key(key)
- if _test_memcached_key(key):
- return self._client.delete(key)
-
- def delete_many(self, *keys):
- new_keys = []
- for key in keys:
- key = self._normalize_key(key)
- if _test_memcached_key(key):
- new_keys.append(key)
- return self._client.delete_multi(new_keys)
-
- def has(self, key):
- key = self._normalize_key(key)
- if _test_memcached_key(key):
- return self._client.append(key, "")
- return False
-
- def clear(self):
- return self._client.flush_all()
-
- def inc(self, key, delta=1):
- key = self._normalize_key(key)
- return self._client.incr(key, delta)
-
- def dec(self, key, delta=1):
- key = self._normalize_key(key)
- return self._client.decr(key, delta)
-
- def import_preferred_memcache_lib(self, servers):
- """Returns an initialized memcache client. Used by the constructor."""
- try:
- import pylibmc
- except ImportError:
- pass
- else:
- return pylibmc.Client(servers)
-
- try:
- from google.appengine.api import memcache
- except ImportError:
- pass
- else:
- return memcache.Client()
-
- try:
- import memcache
- except ImportError:
- pass
- else:
- return memcache.Client(servers)
-
- try:
- import libmc
- except ImportError:
- pass
- else:
- return libmc.Client(servers)
-
-
-# backwards compatibility
-GAEMemcachedCache = MemcachedCache
-
-
-class RedisCache(BaseCache):
- """Uses the Redis key-value store as a cache backend.
-
- The first argument can be either a string denoting address of the Redis
- server or an object resembling an instance of a redis.Redis class.
-
- Note: Python Redis API already takes care of encoding unicode strings on
- the fly.
-
- .. versionadded:: 0.7
-
- .. versionadded:: 0.8
- `key_prefix` was added.
-
- .. versionchanged:: 0.8
- This cache backend now properly serializes objects.
-
- .. versionchanged:: 0.8.3
- This cache backend now supports password authentication.
-
- .. versionchanged:: 0.10
- ``**kwargs`` is now passed to the redis object.
-
- :param host: address of the Redis server or an object which API is
- compatible with the official Python Redis client (redis-py).
- :param port: port number on which Redis server listens for connections.
- :param password: password authentication for the Redis server.
- :param db: db (zero-based numeric index) on Redis Server to connect.
- :param default_timeout: the default timeout that is used if no timeout is
- specified on :meth:`~BaseCache.set`. A timeout of
- 0 indicates that the cache never expires.
- :param key_prefix: A prefix that should be added to all keys.
-
- Any additional keyword arguments will be passed to ``redis.Redis``.
- """
-
- def __init__(
- self,
- host="localhost",
- port=6379,
- password=None,
- db=0,
- default_timeout=300,
- key_prefix=None,
- **kwargs
- ):
- BaseCache.__init__(self, default_timeout)
- if host is None:
- raise ValueError("RedisCache host parameter may not be None")
- if isinstance(host, string_types):
- try:
- import redis
- except ImportError:
- raise RuntimeError("no redis module found")
- if kwargs.get("decode_responses", None):
- raise ValueError("decode_responses is not supported by RedisCache.")
- self._client = redis.Redis(
- host=host, port=port, password=password, db=db, **kwargs
- )
- else:
- self._client = host
- self.key_prefix = key_prefix or ""
-
- def _normalize_timeout(self, timeout):
- timeout = BaseCache._normalize_timeout(self, timeout)
- if timeout == 0:
- timeout = -1
- return timeout
-
- def dump_object(self, value):
- """Dumps an object into a string for redis. By default it serializes
- integers as regular string and pickle dumps everything else.
- """
- t = type(value)
- if t in integer_types:
- return str(value).encode("ascii")
- return b"!" + pickle.dumps(value)
-
- def load_object(self, value):
- """The reversal of :meth:`dump_object`. This might be called with
- None.
- """
- if value is None:
- return None
- if value.startswith(b"!"):
- try:
- return pickle.loads(value[1:])
- except pickle.PickleError:
- return None
- try:
- return int(value)
- except ValueError:
- # before 0.8 we did not have serialization. Still support that.
- return value
-
- def get(self, key):
- return self.load_object(self._client.get(self.key_prefix + key))
-
- def get_many(self, *keys):
- if self.key_prefix:
- keys = [self.key_prefix + key for key in keys]
- return [self.load_object(x) for x in self._client.mget(keys)]
-
- def set(self, key, value, timeout=None):
- timeout = self._normalize_timeout(timeout)
- dump = self.dump_object(value)
- if timeout == -1:
- result = self._client.set(name=self.key_prefix + key, value=dump)
- else:
- result = self._client.setex(
- name=self.key_prefix + key, value=dump, time=timeout
- )
- return result
-
- def add(self, key, value, timeout=None):
- timeout = self._normalize_timeout(timeout)
- dump = self.dump_object(value)
- return self._client.setnx(
- name=self.key_prefix + key, value=dump
- ) and self._client.expire(name=self.key_prefix + key, time=timeout)
-
- def set_many(self, mapping, timeout=None):
- timeout = self._normalize_timeout(timeout)
- # Use transaction=False to batch without calling redis MULTI
- # which is not supported by twemproxy
- pipe = self._client.pipeline(transaction=False)
-
- for key, value in _items(mapping):
- dump = self.dump_object(value)
- if timeout == -1:
- pipe.set(name=self.key_prefix + key, value=dump)
- else:
- pipe.setex(name=self.key_prefix + key, value=dump, time=timeout)
- return pipe.execute()
-
- def delete(self, key):
- return self._client.delete(self.key_prefix + key)
-
- def delete_many(self, *keys):
- if not keys:
- return
- if self.key_prefix:
- keys = [self.key_prefix + key for key in keys]
- return self._client.delete(*keys)
-
- def has(self, key):
- return self._client.exists(self.key_prefix + key)
-
- def clear(self):
- status = False
- if self.key_prefix:
- keys = self._client.keys(self.key_prefix + "*")
- if keys:
- status = self._client.delete(*keys)
- else:
- status = self._client.flushdb()
- return status
-
- def inc(self, key, delta=1):
- return self._client.incr(name=self.key_prefix + key, amount=delta)
-
- def dec(self, key, delta=1):
- return self._client.decr(name=self.key_prefix + key, amount=delta)
-
-
-class FileSystemCache(BaseCache):
- """A cache that stores the items on the file system. This cache depends
- on being the only user of the `cache_dir`. Make absolutely sure that
- nobody but this cache stores files there or otherwise the cache will
- randomly delete files therein.
-
- :param cache_dir: the directory where cache files are stored.
- :param threshold: the maximum number of items the cache stores before
- it starts deleting some. A threshold value of 0
- indicates no threshold.
- :param default_timeout: the default timeout that is used if no timeout is
- specified on :meth:`~BaseCache.set`. A timeout of
- 0 indicates that the cache never expires.
- :param mode: the file mode wanted for the cache files, default 0600
- """
-
- #: used for temporary files by the FileSystemCache
- _fs_transaction_suffix = ".__wz_cache"
- #: keep amount of files in a cache element
- _fs_count_file = "__wz_cache_count"
-
- def __init__(self, cache_dir, threshold=500, default_timeout=300, mode=0o600):
- BaseCache.__init__(self, default_timeout)
- self._path = cache_dir
- self._threshold = threshold
- self._mode = mode
-
- try:
- os.makedirs(self._path)
- except OSError as ex:
- if ex.errno != errno.EEXIST:
- raise
-
- self._update_count(value=len(self._list_dir()))
-
- @property
- def _file_count(self):
- return self.get(self._fs_count_file) or 0
-
- def _update_count(self, delta=None, value=None):
- # If we have no threshold, don't count files
- if self._threshold == 0:
- return
-
- if delta:
- new_count = self._file_count + delta
- else:
- new_count = value or 0
- self.set(self._fs_count_file, new_count, mgmt_element=True)
-
- def _normalize_timeout(self, timeout):
- timeout = BaseCache._normalize_timeout(self, timeout)
- if timeout != 0:
- timeout = time() + timeout
- return int(timeout)
-
- def _list_dir(self):
- """return a list of (fully qualified) cache filenames
- """
- mgmt_files = [
- self._get_filename(name).split("/")[-1] for name in (self._fs_count_file,)
- ]
- return [
- os.path.join(self._path, fn)
- for fn in os.listdir(self._path)
- if not fn.endswith(self._fs_transaction_suffix) and fn not in mgmt_files
- ]
-
- def _prune(self):
- if self._threshold == 0 or not self._file_count > self._threshold:
- return
-
- entries = self._list_dir()
- now = time()
- for idx, fname in enumerate(entries):
- try:
- remove = False
- with open(fname, "rb") as f:
- expires = pickle.load(f)
- remove = (expires != 0 and expires <= now) or idx % 3 == 0
-
- if remove:
- os.remove(fname)
- except (IOError, OSError):
- pass
- self._update_count(value=len(self._list_dir()))
-
- def clear(self):
- for fname in self._list_dir():
- try:
- os.remove(fname)
- except (IOError, OSError):
- self._update_count(value=len(self._list_dir()))
- return False
- self._update_count(value=0)
- return True
-
- def _get_filename(self, key):
- if isinstance(key, text_type):
- key = key.encode("utf-8") # XXX unicode review
- hash = md5(key).hexdigest()
- return os.path.join(self._path, hash)
-
- def get(self, key):
- filename = self._get_filename(key)
- try:
- with open(filename, "rb") as f:
- pickle_time = pickle.load(f)
- if pickle_time == 0 or pickle_time >= time():
- return pickle.load(f)
- else:
- os.remove(filename)
- return None
- except (IOError, OSError, pickle.PickleError):
- return None
-
- def add(self, key, value, timeout=None):
- filename = self._get_filename(key)
- if not os.path.exists(filename):
- return self.set(key, value, timeout)
- return False
-
- def set(self, key, value, timeout=None, mgmt_element=False):
- # Management elements have no timeout
- if mgmt_element:
- timeout = 0
-
- # Don't prune on management element update, to avoid loop
- else:
- self._prune()
-
- timeout = self._normalize_timeout(timeout)
- filename = self._get_filename(key)
- try:
- fd, tmp = tempfile.mkstemp(
- suffix=self._fs_transaction_suffix, dir=self._path
- )
- with os.fdopen(fd, "wb") as f:
- pickle.dump(timeout, f, 1)
- pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
- rename(tmp, filename)
- os.chmod(filename, self._mode)
- except (IOError, OSError):
- return False
- else:
- # Management elements should not count towards threshold
- if not mgmt_element:
- self._update_count(delta=1)
- return True
-
- def delete(self, key, mgmt_element=False):
- try:
- os.remove(self._get_filename(key))
- except (IOError, OSError):
- return False
- else:
- # Management elements should not count towards threshold
- if not mgmt_element:
- self._update_count(delta=-1)
- return True
-
- def has(self, key):
- filename = self._get_filename(key)
- try:
- with open(filename, "rb") as f:
- pickle_time = pickle.load(f)
- if pickle_time == 0 or pickle_time >= time():
- return True
- else:
- os.remove(filename)
- return False
- except (IOError, OSError, pickle.PickleError):
- return False
-
-
-class UWSGICache(BaseCache):
- """Implements the cache using uWSGI's caching framework.
-
- .. note::
- This class cannot be used when running under PyPy, because the uWSGI
- API implementation for PyPy is lacking the needed functionality.
-
- :param default_timeout: The default timeout in seconds.
- :param cache: The name of the caching instance to connect to, for
- example: mycache@localhost:3031, defaults to an empty string, which
- means uWSGI will cache in the local instance. If the cache is in the
- same instance as the werkzeug app, you only have to provide the name of
- the cache.
- """
-
- def __init__(self, default_timeout=300, cache=""):
- BaseCache.__init__(self, default_timeout)
-
- if platform.python_implementation() == "PyPy":
- raise RuntimeError(
- "uWSGI caching does not work under PyPy, see "
- "the docs for more details."
- )
-
- try:
- import uwsgi
-
- self._uwsgi = uwsgi
- except ImportError:
- raise RuntimeError(
- "uWSGI could not be imported, are you running under uWSGI?"
- )
-
- self.cache = cache
-
- def get(self, key):
- rv = self._uwsgi.cache_get(key, self.cache)
- if rv is None:
- return
- return pickle.loads(rv)
-
- def delete(self, key):
- return self._uwsgi.cache_del(key, self.cache)
-
- def set(self, key, value, timeout=None):
- return self._uwsgi.cache_update(
- key, pickle.dumps(value), self._normalize_timeout(timeout), self.cache
- )
-
- def add(self, key, value, timeout=None):
- return self._uwsgi.cache_set(
- key, pickle.dumps(value), self._normalize_timeout(timeout), self.cache
- )
-
- def clear(self):
- return self._uwsgi.cache_clear(self.cache)
-
- def has(self, key):
- return self._uwsgi.cache_exists(key, self.cache) is not None
diff --git a/python/werkzeug/contrib/fixers.py b/python/werkzeug/contrib/fixers.py
deleted file mode 100644
index 8df0afd..0000000
--- a/python/werkzeug/contrib/fixers.py
+++ /dev/null
@@ -1,262 +0,0 @@
-"""
-Fixers
-======
-
-.. warning::
- .. deprecated:: 0.15
- ``ProxyFix`` has moved to :mod:`werkzeug.middleware.proxy_fix`.
- All other code in this module is deprecated and will be removed
- in version 1.0.
-
-.. versionadded:: 0.5
-
-This module includes various helpers that fix web server behavior.
-
-.. autoclass:: ProxyFix
- :members:
-
-.. autoclass:: CGIRootFix
-
-.. autoclass:: PathInfoFromRequestUriFix
-
-.. autoclass:: HeaderRewriterFix
-
-.. autoclass:: InternetExplorerFix
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-import warnings
-
-from ..datastructures import Headers
-from ..datastructures import ResponseCacheControl
-from ..http import parse_cache_control_header
-from ..http import parse_options_header
-from ..http import parse_set_header
-from ..middleware.proxy_fix import ProxyFix as _ProxyFix
-from ..useragents import UserAgent
-
-try:
- from urllib.parse import unquote
-except ImportError:
- from urllib import unquote
-
-
-class CGIRootFix(object):
- """Wrap the application in this middleware if you are using FastCGI
- or CGI and you have problems with your app root being set to the CGI
- script's path instead of the path users are going to visit.
-
- :param app: the WSGI application
- :param app_root: Defaulting to ``'/'``, you can set this to
- something else if your app is mounted somewhere else.
-
- .. deprecated:: 0.15
- This middleware will be removed in version 1.0.
-
- .. versionchanged:: 0.9
- Added `app_root` parameter and renamed from
- ``LighttpdCGIRootFix``.
- """
-
- def __init__(self, app, app_root="/"):
- warnings.warn(
- "'CGIRootFix' is deprecated as of version 0.15 and will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- self.app = app
- self.app_root = app_root.strip("/")
-
- def __call__(self, environ, start_response):
- environ["SCRIPT_NAME"] = self.app_root
- return self.app(environ, start_response)
-
-
-class LighttpdCGIRootFix(CGIRootFix):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'LighttpdCGIRootFix' is renamed 'CGIRootFix'. Both will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(LighttpdCGIRootFix, self).__init__(*args, **kwargs)
-
-
-class PathInfoFromRequestUriFix(object):
- """On windows environment variables are limited to the system charset
- which makes it impossible to store the `PATH_INFO` variable in the
- environment without loss of information on some systems.
-
- This is for example a problem for CGI scripts on a Windows Apache.
-
- This fixer works by recreating the `PATH_INFO` from `REQUEST_URI`,
- `REQUEST_URL`, or `UNENCODED_URL` (whatever is available). Thus the
- fix can only be applied if the webserver supports either of these
- variables.
-
- :param app: the WSGI application
-
- .. deprecated:: 0.15
- This middleware will be removed in version 1.0.
- """
-
- def __init__(self, app):
- warnings.warn(
- "'PathInfoFromRequestUriFix' is deprecated as of version"
- " 0.15 and will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- self.app = app
-
- def __call__(self, environ, start_response):
- for key in "REQUEST_URL", "REQUEST_URI", "UNENCODED_URL":
- if key not in environ:
- continue
- request_uri = unquote(environ[key])
- script_name = unquote(environ.get("SCRIPT_NAME", ""))
- if request_uri.startswith(script_name):
- environ["PATH_INFO"] = request_uri[len(script_name) :].split("?", 1)[0]
- break
- return self.app(environ, start_response)
-
-
-class ProxyFix(_ProxyFix):
- """
- .. deprecated:: 0.15
- ``werkzeug.contrib.fixers.ProxyFix`` has moved to
- :mod:`werkzeug.middleware.proxy_fix`. This import will be
- removed in 1.0.
- """
-
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.contrib.fixers.ProxyFix' has moved to 'werkzeug"
- ".middleware.proxy_fix.ProxyFix'. This import is deprecated"
- " as of version 0.15 and will be removed in 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(ProxyFix, self).__init__(*args, **kwargs)
-
-
-class HeaderRewriterFix(object):
- """This middleware can remove response headers and add others. This
- is for example useful to remove the `Date` header from responses if you
- are using a server that adds that header, no matter if it's present or
- not or to add `X-Powered-By` headers::
-
- app = HeaderRewriterFix(app, remove_headers=['Date'],
- add_headers=[('X-Powered-By', 'WSGI')])
-
- :param app: the WSGI application
- :param remove_headers: a sequence of header keys that should be
- removed.
- :param add_headers: a sequence of ``(key, value)`` tuples that should
- be added.
-
- .. deprecated:: 0.15
- This middleware will be removed in 1.0.
- """
-
- def __init__(self, app, remove_headers=None, add_headers=None):
- warnings.warn(
- "'HeaderRewriterFix' is deprecated as of version 0.15 and"
- " will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- self.app = app
- self.remove_headers = set(x.lower() for x in (remove_headers or ()))
- self.add_headers = list(add_headers or ())
-
- def __call__(self, environ, start_response):
- def rewriting_start_response(status, headers, exc_info=None):
- new_headers = []
- for key, value in headers:
- if key.lower() not in self.remove_headers:
- new_headers.append((key, value))
- new_headers += self.add_headers
- return start_response(status, new_headers, exc_info)
-
- return self.app(environ, rewriting_start_response)
-
-
-class InternetExplorerFix(object):
- """This middleware fixes a couple of bugs with Microsoft Internet
- Explorer. Currently the following fixes are applied:
-
- - removing of `Vary` headers for unsupported mimetypes which
- causes troubles with caching. Can be disabled by passing
- ``fix_vary=False`` to the constructor.
- see: https://support.microsoft.com/en-us/help/824847
-
- - removes offending headers to work around caching bugs in
- Internet Explorer if `Content-Disposition` is set. Can be
- disabled by passing ``fix_attach=False`` to the constructor.
-
- If it does not detect affected Internet Explorer versions it won't touch
- the request / response.
-
- .. deprecated:: 0.15
- This middleware will be removed in 1.0.
- """
-
- # This code was inspired by Django fixers for the same bugs. The
- # fix_vary and fix_attach fixers were originally implemented in Django
- # by Michael Axiak and is available as part of the Django project:
- # https://code.djangoproject.com/ticket/4148
-
- def __init__(self, app, fix_vary=True, fix_attach=True):
- warnings.warn(
- "'InternetExplorerFix' is deprecated as of version 0.15 and"
- " will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- self.app = app
- self.fix_vary = fix_vary
- self.fix_attach = fix_attach
-
- def fix_headers(self, environ, headers, status=None):
- if self.fix_vary:
- header = headers.get("content-type", "")
- mimetype, options = parse_options_header(header)
- if mimetype not in ("text/html", "text/plain", "text/sgml"):
- headers.pop("vary", None)
-
- if self.fix_attach and "content-disposition" in headers:
- pragma = parse_set_header(headers.get("pragma", ""))
- pragma.discard("no-cache")
- header = pragma.to_header()
- if not header:
- headers.pop("pragma", "")
- else:
- headers["Pragma"] = header
- header = headers.get("cache-control", "")
- if header:
- cc = parse_cache_control_header(header, cls=ResponseCacheControl)
- cc.no_cache = None
- cc.no_store = False
- header = cc.to_header()
- if not header:
- headers.pop("cache-control", "")
- else:
- headers["Cache-Control"] = header
-
- def run_fixed(self, environ, start_response):
- def fixing_start_response(status, headers, exc_info=None):
- headers = Headers(headers)
- self.fix_headers(environ, headers, status)
- return start_response(status, headers.to_wsgi_list(), exc_info)
-
- return self.app(environ, fixing_start_response)
-
- def __call__(self, environ, start_response):
- ua = UserAgent(environ)
- if ua.browser != "msie":
- return self.app(environ, start_response)
- return self.run_fixed(environ, start_response)
diff --git a/python/werkzeug/contrib/iterio.py b/python/werkzeug/contrib/iterio.py
deleted file mode 100644
index b672454..0000000
--- a/python/werkzeug/contrib/iterio.py
+++ /dev/null
@@ -1,358 +0,0 @@
-# -*- coding: utf-8 -*-
-r"""
- werkzeug.contrib.iterio
- ~~~~~~~~~~~~~~~~~~~~~~~
-
- This module implements a :class:`IterIO` that converts an iterator into
- a stream object and the other way round. Converting streams into
- iterators requires the `greenlet`_ module.
-
- To convert an iterator into a stream all you have to do is to pass it
- directly to the :class:`IterIO` constructor. In this example we pass it
- a newly created generator::
-
- def foo():
- yield "something\n"
- yield "otherthings"
- stream = IterIO(foo())
- print stream.read() # read the whole iterator
-
- The other way round works a bit different because we have to ensure that
- the code execution doesn't take place yet. An :class:`IterIO` call with a
- callable as first argument does two things. The function itself is passed
- an :class:`IterIO` stream it can feed. The object returned by the
- :class:`IterIO` constructor on the other hand is not an stream object but
- an iterator::
-
- def foo(stream):
- stream.write("some")
- stream.write("thing")
- stream.flush()
- stream.write("otherthing")
- iterator = IterIO(foo)
- print iterator.next() # prints something
- print iterator.next() # prints otherthing
- iterator.next() # raises StopIteration
-
- .. _greenlet: https://github.com/python-greenlet/greenlet
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import warnings
-
-from .._compat import implements_iterator
-
-try:
- import greenlet
-except ImportError:
- greenlet = None
-
-warnings.warn(
- "'werkzeug.contrib.iterio' is deprecated as of version 0.15 and"
- " will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-
-def _mixed_join(iterable, sentinel):
- """concatenate any string type in an intelligent way."""
- iterator = iter(iterable)
- first_item = next(iterator, sentinel)
- if isinstance(first_item, bytes):
- return first_item + b"".join(iterator)
- return first_item + u"".join(iterator)
-
-
-def _newline(reference_string):
- if isinstance(reference_string, bytes):
- return b"\n"
- return u"\n"
-
-
-@implements_iterator
-class IterIO(object):
- """Instances of this object implement an interface compatible with the
- standard Python :class:`file` object. Streams are either read-only or
- write-only depending on how the object is created.
-
- If the first argument is an iterable a file like object is returned that
- returns the contents of the iterable. In case the iterable is empty
- read operations will return the sentinel value.
-
- If the first argument is a callable then the stream object will be
- created and passed to that function. The caller itself however will
- not receive a stream but an iterable. The function will be executed
- step by step as something iterates over the returned iterable. Each
- call to :meth:`flush` will create an item for the iterable. If
- :meth:`flush` is called without any writes in-between the sentinel
- value will be yielded.
-
- Note for Python 3: due to the incompatible interface of bytes and
- streams you should set the sentinel value explicitly to an empty
- bytestring (``b''``) if you are expecting to deal with bytes as
- otherwise the end of the stream is marked with the wrong sentinel
- value.
-
- .. versionadded:: 0.9
- `sentinel` parameter was added.
- """
-
- def __new__(cls, obj, sentinel=""):
- try:
- iterator = iter(obj)
- except TypeError:
- return IterI(obj, sentinel)
- return IterO(iterator, sentinel)
-
- def __iter__(self):
- return self
-
- def tell(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- return self.pos
-
- def isatty(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- return False
-
- def seek(self, pos, mode=0):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def truncate(self, size=None):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def write(self, s):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def writelines(self, list):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def read(self, n=-1):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def readlines(self, sizehint=0):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def readline(self, length=None):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def flush(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- raise IOError(9, "Bad file descriptor")
-
- def __next__(self):
- if self.closed:
- raise StopIteration()
- line = self.readline()
- if not line:
- raise StopIteration()
- return line
-
-
-class IterI(IterIO):
- """Convert an stream into an iterator."""
-
- def __new__(cls, func, sentinel=""):
- if greenlet is None:
- raise RuntimeError("IterI requires greenlet support")
- stream = object.__new__(cls)
- stream._parent = greenlet.getcurrent()
- stream._buffer = []
- stream.closed = False
- stream.sentinel = sentinel
- stream.pos = 0
-
- def run():
- func(stream)
- stream.close()
-
- g = greenlet.greenlet(run, stream._parent)
- while 1:
- rv = g.switch()
- if not rv:
- return
- yield rv[0]
-
- def close(self):
- if not self.closed:
- self.closed = True
- self._flush_impl()
-
- def write(self, s):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- if s:
- self.pos += len(s)
- self._buffer.append(s)
-
- def writelines(self, list):
- for item in list:
- self.write(item)
-
- def flush(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- self._flush_impl()
-
- def _flush_impl(self):
- data = _mixed_join(self._buffer, self.sentinel)
- self._buffer = []
- if not data and self.closed:
- self._parent.switch()
- else:
- self._parent.switch((data,))
-
-
-class IterO(IterIO):
- """Iter output. Wrap an iterator and give it a stream like interface."""
-
- def __new__(cls, gen, sentinel=""):
- self = object.__new__(cls)
- self._gen = gen
- self._buf = None
- self.sentinel = sentinel
- self.closed = False
- self.pos = 0
- return self
-
- def __iter__(self):
- return self
-
- def _buf_append(self, string):
- """Replace string directly without appending to an empty string,
- avoiding type issues."""
- if not self._buf:
- self._buf = string
- else:
- self._buf += string
-
- def close(self):
- if not self.closed:
- self.closed = True
- if hasattr(self._gen, "close"):
- self._gen.close()
-
- def seek(self, pos, mode=0):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- if mode == 1:
- pos += self.pos
- elif mode == 2:
- self.read()
- self.pos = min(self.pos, self.pos + pos)
- return
- elif mode != 0:
- raise IOError("Invalid argument")
- buf = []
- try:
- tmp_end_pos = len(self._buf or "")
- while pos > tmp_end_pos:
- item = next(self._gen)
- tmp_end_pos += len(item)
- buf.append(item)
- except StopIteration:
- pass
- if buf:
- self._buf_append(_mixed_join(buf, self.sentinel))
- self.pos = max(0, pos)
-
- def read(self, n=-1):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- if n < 0:
- self._buf_append(_mixed_join(self._gen, self.sentinel))
- result = self._buf[self.pos :]
- self.pos += len(result)
- return result
- new_pos = self.pos + n
- buf = []
- try:
- tmp_end_pos = 0 if self._buf is None else len(self._buf)
- while new_pos > tmp_end_pos or (self._buf is None and not buf):
- item = next(self._gen)
- tmp_end_pos += len(item)
- buf.append(item)
- except StopIteration:
- pass
- if buf:
- self._buf_append(_mixed_join(buf, self.sentinel))
-
- if self._buf is None:
- return self.sentinel
-
- new_pos = max(0, new_pos)
- try:
- return self._buf[self.pos : new_pos]
- finally:
- self.pos = min(new_pos, len(self._buf))
-
- def readline(self, length=None):
- if self.closed:
- raise ValueError("I/O operation on closed file")
-
- nl_pos = -1
- if self._buf:
- nl_pos = self._buf.find(_newline(self._buf), self.pos)
- buf = []
- try:
- if self._buf is None:
- pos = self.pos
- else:
- pos = len(self._buf)
- while nl_pos < 0:
- item = next(self._gen)
- local_pos = item.find(_newline(item))
- buf.append(item)
- if local_pos >= 0:
- nl_pos = pos + local_pos
- break
- pos += len(item)
- except StopIteration:
- pass
- if buf:
- self._buf_append(_mixed_join(buf, self.sentinel))
-
- if self._buf is None:
- return self.sentinel
-
- if nl_pos < 0:
- new_pos = len(self._buf)
- else:
- new_pos = nl_pos + 1
- if length is not None and self.pos + length < new_pos:
- new_pos = self.pos + length
- try:
- return self._buf[self.pos : new_pos]
- finally:
- self.pos = min(new_pos, len(self._buf))
-
- def readlines(self, sizehint=0):
- total = 0
- lines = []
- line = self.readline()
- while line:
- lines.append(line)
- total += len(line)
- if 0 < sizehint <= total:
- break
- line = self.readline()
- return lines
diff --git a/python/werkzeug/contrib/lint.py b/python/werkzeug/contrib/lint.py
deleted file mode 100644
index 8bd8b8a..0000000
--- a/python/werkzeug/contrib/lint.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import warnings
-
-from ..middleware.lint import * # noqa: F401, F403
-
-warnings.warn(
- "'werkzeug.contrib.lint' has moved to 'werkzeug.middleware.lint'."
- " This import is deprecated as of version 0.15 and will be removed"
- " in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
-)
diff --git a/python/werkzeug/contrib/profiler.py b/python/werkzeug/contrib/profiler.py
deleted file mode 100644
index b79fe56..0000000
--- a/python/werkzeug/contrib/profiler.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import warnings
-
-from ..middleware.profiler import * # noqa: F401, F403
-
-warnings.warn(
- "'werkzeug.contrib.profiler' has moved to"
- "'werkzeug.middleware.profiler'. This import is deprecated as of"
- "version 0.15 and will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-
-class MergeStream(object):
- """An object that redirects ``write`` calls to multiple streams.
- Use this to log to both ``sys.stdout`` and a file::
-
- f = open('profiler.log', 'w')
- stream = MergeStream(sys.stdout, f)
- profiler = ProfilerMiddleware(app, stream)
-
- .. deprecated:: 0.15
- Use the ``tee`` command in your terminal instead. This class
- will be removed in 1.0.
- """
-
- def __init__(self, *streams):
- warnings.warn(
- "'MergeStream' is deprecated as of version 0.15 and will be removed in"
- " version 1.0. Use your terminal's 'tee' command instead.",
- DeprecationWarning,
- stacklevel=2,
- )
-
- if not streams:
- raise TypeError("At least one stream must be given.")
-
- self.streams = streams
-
- def write(self, data):
- for stream in self.streams:
- stream.write(data)
diff --git a/python/werkzeug/contrib/securecookie.py b/python/werkzeug/contrib/securecookie.py
deleted file mode 100644
index c4c9eee..0000000
--- a/python/werkzeug/contrib/securecookie.py
+++ /dev/null
@@ -1,362 +0,0 @@
-# -*- coding: utf-8 -*-
-r"""
- werkzeug.contrib.securecookie
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- This module implements a cookie that is not alterable from the client
- because it adds a checksum the server checks for. You can use it as
- session replacement if all you have is a user id or something to mark
- a logged in user.
-
- Keep in mind that the data is still readable from the client as a
- normal cookie is. However you don't have to store and flush the
- sessions you have at the server.
-
- Example usage:
-
- >>> from werkzeug.contrib.securecookie import SecureCookie
- >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef")
-
- Dumping into a string so that one can store it in a cookie:
-
- >>> value = x.serialize()
-
- Loading from that string again:
-
- >>> x = SecureCookie.unserialize(value, "deadbeef")
- >>> x["baz"]
- (1, 2, 3)
-
- If someone modifies the cookie and the checksum is wrong the unserialize
- method will fail silently and return a new empty `SecureCookie` object.
-
- Keep in mind that the values will be visible in the cookie so do not
- store data in a cookie you don't want the user to see.
-
- Application Integration
- =======================
-
- If you are using the werkzeug request objects you could integrate the
- secure cookie into your application like this::
-
- from werkzeug.utils import cached_property
- from werkzeug.wrappers import BaseRequest
- from werkzeug.contrib.securecookie import SecureCookie
-
- # don't use this key but a different one; you could just use
- # os.urandom(20) to get something random
- SECRET_KEY = '\xfa\xdd\xb8z\xae\xe0}4\x8b\xea'
-
- class Request(BaseRequest):
-
- @cached_property
- def client_session(self):
- data = self.cookies.get('session_data')
- if not data:
- return SecureCookie(secret_key=SECRET_KEY)
- return SecureCookie.unserialize(data, SECRET_KEY)
-
- def application(environ, start_response):
- request = Request(environ)
-
- # get a response object here
- response = ...
-
- if request.client_session.should_save:
- session_data = request.client_session.serialize()
- response.set_cookie('session_data', session_data,
- httponly=True)
- return response(environ, start_response)
-
- A less verbose integration can be achieved by using shorthand methods::
-
- class Request(BaseRequest):
-
- @cached_property
- def client_session(self):
- return SecureCookie.load_cookie(self, secret_key=COOKIE_SECRET)
-
- def application(environ, start_response):
- request = Request(environ)
-
- # get a response object here
- response = ...
-
- request.client_session.save_cookie(response)
- return response(environ, start_response)
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import base64
-import pickle
-import warnings
-from hashlib import sha1 as _default_hash
-from hmac import new as hmac
-from time import time
-
-from .._compat import iteritems
-from .._compat import text_type
-from .._compat import to_bytes
-from .._compat import to_native
-from .._internal import _date_to_unix
-from ..contrib.sessions import ModificationTrackingDict
-from ..security import safe_str_cmp
-from ..urls import url_quote_plus
-from ..urls import url_unquote_plus
-
-warnings.warn(
- "'werkzeug.contrib.securecookie' is deprecated as of version 0.15"
- " and will be removed in version 1.0. It has moved to"
- " https://github.com/pallets/secure-cookie.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-
-class UnquoteError(Exception):
- """Internal exception used to signal failures on quoting."""
-
-
-class SecureCookie(ModificationTrackingDict):
- """Represents a secure cookie. You can subclass this class and provide
- an alternative mac method. The import thing is that the mac method
- is a function with a similar interface to the hashlib. Required
- methods are update() and digest().
-
- Example usage:
-
- >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef")
- >>> x["foo"]
- 42
- >>> x["baz"]
- (1, 2, 3)
- >>> x["blafasel"] = 23
- >>> x.should_save
- True
-
- :param data: the initial data. Either a dict, list of tuples or `None`.
- :param secret_key: the secret key. If not set `None` or not specified
- it has to be set before :meth:`serialize` is called.
- :param new: The initial value of the `new` flag.
- """
-
- #: The hash method to use. This has to be a module with a new function
- #: or a function that creates a hashlib object. Such as `hashlib.md5`
- #: Subclasses can override this attribute. The default hash is sha1.
- #: Make sure to wrap this in staticmethod() if you store an arbitrary
- #: function there such as hashlib.sha1 which might be implemented
- #: as a function.
- hash_method = staticmethod(_default_hash)
-
- #: The module used for serialization. Should have a ``dumps`` and a
- #: ``loads`` method that takes bytes. The default is :mod:`pickle`.
- #:
- #: .. versionchanged:: 0.15
- #: The default of ``pickle`` will change to :mod:`json` in 1.0.
- serialization_method = pickle
-
- #: if the contents should be base64 quoted. This can be disabled if the
- #: serialization process returns cookie safe strings only.
- quote_base64 = True
-
- def __init__(self, data=None, secret_key=None, new=True):
- ModificationTrackingDict.__init__(self, data or ())
- # explicitly convert it into a bytestring because python 2.6
- # no longer performs an implicit string conversion on hmac
- if secret_key is not None:
- secret_key = to_bytes(secret_key, "utf-8")
- self.secret_key = secret_key
- self.new = new
-
- if self.serialization_method is pickle:
- warnings.warn(
- "The default 'SecureCookie.serialization_method' will"
- " change from pickle to json in version 1.0. To upgrade"
- " existing tokens, override 'unquote' to try pickle if"
- " json fails.",
- stacklevel=2,
- )
-
- def __repr__(self):
- return "<%s %s%s>" % (
- self.__class__.__name__,
- dict.__repr__(self),
- "*" if self.should_save else "",
- )
-
- @property
- def should_save(self):
- """True if the session should be saved. By default this is only true
- for :attr:`modified` cookies, not :attr:`new`.
- """
- return self.modified
-
- @classmethod
- def quote(cls, value):
- """Quote the value for the cookie. This can be any object supported
- by :attr:`serialization_method`.
-
- :param value: the value to quote.
- """
- if cls.serialization_method is not None:
- value = cls.serialization_method.dumps(value)
- if cls.quote_base64:
- value = b"".join(
- base64.b64encode(to_bytes(value, "utf8")).splitlines()
- ).strip()
- return value
-
- @classmethod
- def unquote(cls, value):
- """Unquote the value for the cookie. If unquoting does not work a
- :exc:`UnquoteError` is raised.
-
- :param value: the value to unquote.
- """
- try:
- if cls.quote_base64:
- value = base64.b64decode(value)
- if cls.serialization_method is not None:
- value = cls.serialization_method.loads(value)
- return value
- except Exception:
- # unfortunately pickle and other serialization modules can
- # cause pretty every error here. if we get one we catch it
- # and convert it into an UnquoteError
- raise UnquoteError()
-
- def serialize(self, expires=None):
- """Serialize the secure cookie into a string.
-
- If expires is provided, the session will be automatically invalidated
- after expiration when you unseralize it. This provides better
- protection against session cookie theft.
-
- :param expires: an optional expiration date for the cookie (a
- :class:`datetime.datetime` object)
- """
- if self.secret_key is None:
- raise RuntimeError("no secret key defined")
- if expires:
- self["_expires"] = _date_to_unix(expires)
- result = []
- mac = hmac(self.secret_key, None, self.hash_method)
- for key, value in sorted(self.items()):
- result.append(
- (
- "%s=%s" % (url_quote_plus(key), self.quote(value).decode("ascii"))
- ).encode("ascii")
- )
- mac.update(b"|" + result[-1])
- return b"?".join([base64.b64encode(mac.digest()).strip(), b"&".join(result)])
-
- @classmethod
- def unserialize(cls, string, secret_key):
- """Load the secure cookie from a serialized string.
-
- :param string: the cookie value to unserialize.
- :param secret_key: the secret key used to serialize the cookie.
- :return: a new :class:`SecureCookie`.
- """
- if isinstance(string, text_type):
- string = string.encode("utf-8", "replace")
- if isinstance(secret_key, text_type):
- secret_key = secret_key.encode("utf-8", "replace")
- try:
- base64_hash, data = string.split(b"?", 1)
- except (ValueError, IndexError):
- items = ()
- else:
- items = {}
- mac = hmac(secret_key, None, cls.hash_method)
- for item in data.split(b"&"):
- mac.update(b"|" + item)
- if b"=" not in item:
- items = None
- break
- key, value = item.split(b"=", 1)
- # try to make the key a string
- key = url_unquote_plus(key.decode("ascii"))
- try:
- key = to_native(key)
- except UnicodeError:
- pass
- items[key] = value
-
- # no parsing error and the mac looks okay, we can now
- # sercurely unpickle our cookie.
- try:
- client_hash = base64.b64decode(base64_hash)
- except TypeError:
- items = client_hash = None
- if items is not None and safe_str_cmp(client_hash, mac.digest()):
- try:
- for key, value in iteritems(items):
- items[key] = cls.unquote(value)
- except UnquoteError:
- items = ()
- else:
- if "_expires" in items:
- if time() > items["_expires"]:
- items = ()
- else:
- del items["_expires"]
- else:
- items = ()
- return cls(items, secret_key, False)
-
- @classmethod
- def load_cookie(cls, request, key="session", secret_key=None):
- """Loads a :class:`SecureCookie` from a cookie in request. If the
- cookie is not set, a new :class:`SecureCookie` instanced is
- returned.
-
- :param request: a request object that has a `cookies` attribute
- which is a dict of all cookie values.
- :param key: the name of the cookie.
- :param secret_key: the secret key used to unquote the cookie.
- Always provide the value even though it has
- no default!
- """
- data = request.cookies.get(key)
- if not data:
- return cls(secret_key=secret_key)
- return cls.unserialize(data, secret_key)
-
- def save_cookie(
- self,
- response,
- key="session",
- expires=None,
- session_expires=None,
- max_age=None,
- path="/",
- domain=None,
- secure=None,
- httponly=False,
- force=False,
- ):
- """Saves the SecureCookie in a cookie on response object. All
- parameters that are not described here are forwarded directly
- to :meth:`~BaseResponse.set_cookie`.
-
- :param response: a response object that has a
- :meth:`~BaseResponse.set_cookie` method.
- :param key: the name of the cookie.
- :param session_expires: the expiration date of the secure cookie
- stored information. If this is not provided
- the cookie `expires` date is used instead.
- """
- if force or self.should_save:
- data = self.serialize(session_expires or expires)
- response.set_cookie(
- key,
- data,
- expires=expires,
- max_age=max_age,
- path=path,
- domain=domain,
- secure=secure,
- httponly=httponly,
- )
diff --git a/python/werkzeug/contrib/sessions.py b/python/werkzeug/contrib/sessions.py
deleted file mode 100644
index 866e827..0000000
--- a/python/werkzeug/contrib/sessions.py
+++ /dev/null
@@ -1,389 +0,0 @@
-# -*- coding: utf-8 -*-
-r"""
- werkzeug.contrib.sessions
- ~~~~~~~~~~~~~~~~~~~~~~~~~
-
- This module contains some helper classes that help one to add session
- support to a python WSGI application. For full client-side session
- storage see :mod:`~werkzeug.contrib.securecookie` which implements a
- secure, client-side session storage.
-
-
- Application Integration
- =======================
-
- ::
-
- from werkzeug.contrib.sessions import SessionMiddleware, \
- FilesystemSessionStore
-
- app = SessionMiddleware(app, FilesystemSessionStore())
-
- The current session will then appear in the WSGI environment as
- `werkzeug.session`. However it's recommended to not use the middleware
- but the stores directly in the application. However for very simple
- scripts a middleware for sessions could be sufficient.
-
- This module does not implement methods or ways to check if a session is
- expired. That should be done by a cronjob and storage specific. For
- example to prune unused filesystem sessions one could check the modified
- time of the files. If sessions are stored in the database the new()
- method should add an expiration timestamp for the session.
-
- For better flexibility it's recommended to not use the middleware but the
- store and session object directly in the application dispatching::
-
- session_store = FilesystemSessionStore()
-
- def application(environ, start_response):
- request = Request(environ)
- sid = request.cookies.get('cookie_name')
- if sid is None:
- request.session = session_store.new()
- else:
- request.session = session_store.get(sid)
- response = get_the_response_object(request)
- if request.session.should_save:
- session_store.save(request.session)
- response.set_cookie('cookie_name', request.session.sid)
- return response(environ, start_response)
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import os
-import re
-import tempfile
-import warnings
-from hashlib import sha1
-from os import path
-from pickle import dump
-from pickle import HIGHEST_PROTOCOL
-from pickle import load
-from random import random
-from time import time
-
-from .._compat import PY2
-from .._compat import text_type
-from ..datastructures import CallbackDict
-from ..filesystem import get_filesystem_encoding
-from ..posixemulation import rename
-from ..utils import dump_cookie
-from ..utils import parse_cookie
-from ..wsgi import ClosingIterator
-
-warnings.warn(
- "'werkzeug.contrib.sessions' is deprecated as of version 0.15 and"
- " will be removed in version 1.0. It has moved to"
- " https://github.com/pallets/secure-cookie.",
- DeprecationWarning,
- stacklevel=2,
-)
-
-_sha1_re = re.compile(r"^[a-f0-9]{40}$")
-
-
-def _urandom():
- if hasattr(os, "urandom"):
- return os.urandom(30)
- return text_type(random()).encode("ascii")
-
-
-def generate_key(salt=None):
- if salt is None:
- salt = repr(salt).encode("ascii")
- return sha1(b"".join([salt, str(time()).encode("ascii"), _urandom()])).hexdigest()
-
-
-class ModificationTrackingDict(CallbackDict):
- __slots__ = ("modified",)
-
- def __init__(self, *args, **kwargs):
- def on_update(self):
- self.modified = True
-
- self.modified = False
- CallbackDict.__init__(self, on_update=on_update)
- dict.update(self, *args, **kwargs)
-
- def copy(self):
- """Create a flat copy of the dict."""
- missing = object()
- result = object.__new__(self.__class__)
- for name in self.__slots__:
- val = getattr(self, name, missing)
- if val is not missing:
- setattr(result, name, val)
- return result
-
- def __copy__(self):
- return self.copy()
-
-
-class Session(ModificationTrackingDict):
- """Subclass of a dict that keeps track of direct object changes. Changes
- in mutable structures are not tracked, for those you have to set
- `modified` to `True` by hand.
- """
-
- __slots__ = ModificationTrackingDict.__slots__ + ("sid", "new")
-
- def __init__(self, data, sid, new=False):
- ModificationTrackingDict.__init__(self, data)
- self.sid = sid
- self.new = new
-
- def __repr__(self):
- return "<%s %s%s>" % (
- self.__class__.__name__,
- dict.__repr__(self),
- "*" if self.should_save else "",
- )
-
- @property
- def should_save(self):
- """True if the session should be saved.
-
- .. versionchanged:: 0.6
- By default the session is now only saved if the session is
- modified, not if it is new like it was before.
- """
- return self.modified
-
-
-class SessionStore(object):
- """Baseclass for all session stores. The Werkzeug contrib module does not
- implement any useful stores besides the filesystem store, application
- developers are encouraged to create their own stores.
-
- :param session_class: The session class to use. Defaults to
- :class:`Session`.
- """
-
- def __init__(self, session_class=None):
- if session_class is None:
- session_class = Session
- self.session_class = session_class
-
- def is_valid_key(self, key):
- """Check if a key has the correct format."""
- return _sha1_re.match(key) is not None
-
- def generate_key(self, salt=None):
- """Simple function that generates a new session key."""
- return generate_key(salt)
-
- def new(self):
- """Generate a new session."""
- return self.session_class({}, self.generate_key(), True)
-
- def save(self, session):
- """Save a session."""
-
- def save_if_modified(self, session):
- """Save if a session class wants an update."""
- if session.should_save:
- self.save(session)
-
- def delete(self, session):
- """Delete a session."""
-
- def get(self, sid):
- """Get a session for this sid or a new session object. This method
- has to check if the session key is valid and create a new session if
- that wasn't the case.
- """
- return self.session_class({}, sid, True)
-
-
-#: used for temporary files by the filesystem session store
-_fs_transaction_suffix = ".__wz_sess"
-
-
-class FilesystemSessionStore(SessionStore):
- """Simple example session store that saves sessions on the filesystem.
- This store works best on POSIX systems and Windows Vista / Windows
- Server 2008 and newer.
-
- .. versionchanged:: 0.6
- `renew_missing` was added. Previously this was considered `True`,
- now the default changed to `False` and it can be explicitly
- deactivated.
-
- :param path: the path to the folder used for storing the sessions.
- If not provided the default temporary directory is used.
- :param filename_template: a string template used to give the session
- a filename. ``%s`` is replaced with the
- session id.
- :param session_class: The session class to use. Defaults to
- :class:`Session`.
- :param renew_missing: set to `True` if you want the store to
- give the user a new sid if the session was
- not yet saved.
- """
-
- def __init__(
- self,
- path=None,
- filename_template="werkzeug_%s.sess",
- session_class=None,
- renew_missing=False,
- mode=0o644,
- ):
- SessionStore.__init__(self, session_class)
- if path is None:
- path = tempfile.gettempdir()
- self.path = path
- if isinstance(filename_template, text_type) and PY2:
- filename_template = filename_template.encode(get_filesystem_encoding())
- assert not filename_template.endswith(_fs_transaction_suffix), (
- "filename templates may not end with %s" % _fs_transaction_suffix
- )
- self.filename_template = filename_template
- self.renew_missing = renew_missing
- self.mode = mode
-
- def get_session_filename(self, sid):
- # out of the box, this should be a strict ASCII subset but
- # you might reconfigure the session object to have a more
- # arbitrary string.
- if isinstance(sid, text_type) and PY2:
- sid = sid.encode(get_filesystem_encoding())
- return path.join(self.path, self.filename_template % sid)
-
- def save(self, session):
- fn = self.get_session_filename(session.sid)
- fd, tmp = tempfile.mkstemp(suffix=_fs_transaction_suffix, dir=self.path)
- f = os.fdopen(fd, "wb")
- try:
- dump(dict(session), f, HIGHEST_PROTOCOL)
- finally:
- f.close()
- try:
- rename(tmp, fn)
- os.chmod(fn, self.mode)
- except (IOError, OSError):
- pass
-
- def delete(self, session):
- fn = self.get_session_filename(session.sid)
- try:
- os.unlink(fn)
- except OSError:
- pass
-
- def get(self, sid):
- if not self.is_valid_key(sid):
- return self.new()
- try:
- f = open(self.get_session_filename(sid), "rb")
- except IOError:
- if self.renew_missing:
- return self.new()
- data = {}
- else:
- try:
- try:
- data = load(f)
- except Exception:
- data = {}
- finally:
- f.close()
- return self.session_class(data, sid, False)
-
- def list(self):
- """Lists all sessions in the store.
-
- .. versionadded:: 0.6
- """
- before, after = self.filename_template.split("%s", 1)
- filename_re = re.compile(
- r"%s(.{5,})%s$" % (re.escape(before), re.escape(after))
- )
- result = []
- for filename in os.listdir(self.path):
- #: this is a session that is still being saved.
- if filename.endswith(_fs_transaction_suffix):
- continue
- match = filename_re.match(filename)
- if match is not None:
- result.append(match.group(1))
- return result
-
-
-class SessionMiddleware(object):
- """A simple middleware that puts the session object of a store provided
- into the WSGI environ. It automatically sets cookies and restores
- sessions.
-
- However a middleware is not the preferred solution because it won't be as
- fast as sessions managed by the application itself and will put a key into
- the WSGI environment only relevant for the application which is against
- the concept of WSGI.
-
- The cookie parameters are the same as for the :func:`~dump_cookie`
- function just prefixed with ``cookie_``. Additionally `max_age` is
- called `cookie_age` and not `cookie_max_age` because of backwards
- compatibility.
- """
-
- def __init__(
- self,
- app,
- store,
- cookie_name="session_id",
- cookie_age=None,
- cookie_expires=None,
- cookie_path="/",
- cookie_domain=None,
- cookie_secure=None,
- cookie_httponly=False,
- cookie_samesite="Lax",
- environ_key="werkzeug.session",
- ):
- self.app = app
- self.store = store
- self.cookie_name = cookie_name
- self.cookie_age = cookie_age
- self.cookie_expires = cookie_expires
- self.cookie_path = cookie_path
- self.cookie_domain = cookie_domain
- self.cookie_secure = cookie_secure
- self.cookie_httponly = cookie_httponly
- self.cookie_samesite = cookie_samesite
- self.environ_key = environ_key
-
- def __call__(self, environ, start_response):
- cookie = parse_cookie(environ.get("HTTP_COOKIE", ""))
- sid = cookie.get(self.cookie_name, None)
- if sid is None:
- session = self.store.new()
- else:
- session = self.store.get(sid)
- environ[self.environ_key] = session
-
- def injecting_start_response(status, headers, exc_info=None):
- if session.should_save:
- self.store.save(session)
- headers.append(
- (
- "Set-Cookie",
- dump_cookie(
- self.cookie_name,
- session.sid,
- self.cookie_age,
- self.cookie_expires,
- self.cookie_path,
- self.cookie_domain,
- self.cookie_secure,
- self.cookie_httponly,
- samesite=self.cookie_samesite,
- ),
- )
- )
- return start_response(status, headers, exc_info)
-
- return ClosingIterator(
- self.app(environ, injecting_start_response),
- lambda: self.store.save_if_modified(session),
- )
diff --git a/python/werkzeug/contrib/wrappers.py b/python/werkzeug/contrib/wrappers.py
deleted file mode 100644
index 49b82a7..0000000
--- a/python/werkzeug/contrib/wrappers.py
+++ /dev/null
@@ -1,385 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.contrib.wrappers
- ~~~~~~~~~~~~~~~~~~~~~~~~~
-
- Extra wrappers or mixins contributed by the community. These wrappers can
- be mixed in into request objects to add extra functionality.
-
- Example::
-
- from werkzeug.wrappers import Request as RequestBase
- from werkzeug.contrib.wrappers import JSONRequestMixin
-
- class Request(RequestBase, JSONRequestMixin):
- pass
-
- Afterwards this request object provides the extra functionality of the
- :class:`JSONRequestMixin`.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import warnings
-
-from .._compat import wsgi_decoding_dance
-from ..exceptions import BadRequest
-from ..http import dump_options_header
-from ..http import parse_options_header
-from ..utils import cached_property
-from ..wrappers.json import JSONMixin as _JSONMixin
-
-
-def is_known_charset(charset):
- """Checks if the given charset is known to Python."""
- try:
- codecs.lookup(charset)
- except LookupError:
- return False
- return True
-
-
-class JSONRequestMixin(_JSONMixin):
- """
- .. deprecated:: 0.15
- Moved to :class:`werkzeug.wrappers.json.JSONMixin`. This old
- import will be removed in version 1.0.
- """
-
- @property
- def json(self):
- warnings.warn(
- "'werkzeug.contrib.wrappers.JSONRequestMixin' has moved to"
- " 'werkzeug.wrappers.json.JSONMixin'. This old import will"
- " be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- return super(JSONRequestMixin, self).json
-
-
-class ProtobufRequestMixin(object):
-
- """Add protobuf parsing method to a request object. This will parse the
- input data through `protobuf`_ if possible.
-
- :exc:`~werkzeug.exceptions.BadRequest` will be raised if the content-type
- is not protobuf or if the data itself cannot be parsed property.
-
- .. _protobuf: https://github.com/protocolbuffers/protobuf
-
- .. deprecated:: 0.15
- This mixin will be removed in version 1.0.
- """
-
- #: by default the :class:`ProtobufRequestMixin` will raise a
- #: :exc:`~werkzeug.exceptions.BadRequest` if the object is not
- #: initialized. You can bypass that check by setting this
- #: attribute to `False`.
- protobuf_check_initialization = True
-
- def parse_protobuf(self, proto_type):
- """Parse the data into an instance of proto_type."""
- warnings.warn(
- "'werkzeug.contrib.wrappers.ProtobufRequestMixin' is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- if "protobuf" not in self.environ.get("CONTENT_TYPE", ""):
- raise BadRequest("Not a Protobuf request")
-
- obj = proto_type()
- try:
- obj.ParseFromString(self.data)
- except Exception:
- raise BadRequest("Unable to parse Protobuf request")
-
- # Fail if not all required fields are set
- if self.protobuf_check_initialization and not obj.IsInitialized():
- raise BadRequest("Partial Protobuf request")
-
- return obj
-
-
-class RoutingArgsRequestMixin(object):
-
- """This request mixin adds support for the wsgiorg routing args
- `specification`_.
-
- .. _specification: https://wsgi.readthedocs.io/en/latest/
- specifications/routing_args.html
-
- .. deprecated:: 0.15
- This mixin will be removed in version 1.0.
- """
-
- def _get_routing_args(self):
- warnings.warn(
- "'werkzeug.contrib.wrappers.RoutingArgsRequestMixin' is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.environ.get("wsgiorg.routing_args", (()))[0]
-
- def _set_routing_args(self, value):
- warnings.warn(
- "'werkzeug.contrib.wrappers.RoutingArgsRequestMixin' is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- if self.shallow:
- raise RuntimeError(
- "A shallow request tried to modify the WSGI "
- "environment. If you really want to do that, "
- "set `shallow` to False."
- )
- self.environ["wsgiorg.routing_args"] = (value, self.routing_vars)
-
- routing_args = property(
- _get_routing_args,
- _set_routing_args,
- doc="""
- The positional URL arguments as `tuple`.""",
- )
- del _get_routing_args, _set_routing_args
-
- def _get_routing_vars(self):
- warnings.warn(
- "'werkzeug.contrib.wrappers.RoutingArgsRequestMixin' is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- rv = self.environ.get("wsgiorg.routing_args")
- if rv is not None:
- return rv[1]
- rv = {}
- if not self.shallow:
- self.routing_vars = rv
- return rv
-
- def _set_routing_vars(self, value):
- warnings.warn(
- "'werkzeug.contrib.wrappers.RoutingArgsRequestMixin' is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- if self.shallow:
- raise RuntimeError(
- "A shallow request tried to modify the WSGI "
- "environment. If you really want to do that, "
- "set `shallow` to False."
- )
- self.environ["wsgiorg.routing_args"] = (self.routing_args, value)
-
- routing_vars = property(
- _get_routing_vars,
- _set_routing_vars,
- doc="""
- The keyword URL arguments as `dict`.""",
- )
- del _get_routing_vars, _set_routing_vars
-
-
-class ReverseSlashBehaviorRequestMixin(object):
-
- """This mixin reverses the trailing slash behavior of :attr:`script_root`
- and :attr:`path`. This makes it possible to use :func:`~urlparse.urljoin`
- directly on the paths.
-
- Because it changes the behavior or :class:`Request` this class has to be
- mixed in *before* the actual request class::
-
- class MyRequest(ReverseSlashBehaviorRequestMixin, Request):
- pass
-
- This example shows the differences (for an application mounted on
- `/application` and the request going to `/application/foo/bar`):
-
- +---------------+-------------------+---------------------+
- | | normal behavior | reverse behavior |
- +===============+===================+=====================+
- | `script_root` | ``/application`` | ``/application/`` |
- +---------------+-------------------+---------------------+
- | `path` | ``/foo/bar`` | ``foo/bar`` |
- +---------------+-------------------+---------------------+
-
- .. deprecated:: 0.15
- This mixin will be removed in version 1.0.
- """
-
- @cached_property
- def path(self):
- """Requested path as unicode. This works a bit like the regular path
- info in the WSGI environment but will not include a leading slash.
- """
- warnings.warn(
- "'werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin'"
- " is deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- path = wsgi_decoding_dance(
- self.environ.get("PATH_INFO") or "", self.charset, self.encoding_errors
- )
- return path.lstrip("/")
-
- @cached_property
- def script_root(self):
- """The root path of the script includling a trailing slash."""
- warnings.warn(
- "'werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin'"
- " is deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- path = wsgi_decoding_dance(
- self.environ.get("SCRIPT_NAME") or "", self.charset, self.encoding_errors
- )
- return path.rstrip("/") + "/"
-
-
-class DynamicCharsetRequestMixin(object):
-
- """"If this mixin is mixed into a request class it will provide
- a dynamic `charset` attribute. This means that if the charset is
- transmitted in the content type headers it's used from there.
-
- Because it changes the behavior or :class:`Request` this class has
- to be mixed in *before* the actual request class::
-
- class MyRequest(DynamicCharsetRequestMixin, Request):
- pass
-
- By default the request object assumes that the URL charset is the
- same as the data charset. If the charset varies on each request
- based on the transmitted data it's not a good idea to let the URLs
- change based on that. Most browsers assume either utf-8 or latin1
- for the URLs if they have troubles figuring out. It's strongly
- recommended to set the URL charset to utf-8::
-
- class MyRequest(DynamicCharsetRequestMixin, Request):
- url_charset = 'utf-8'
-
- .. deprecated:: 0.15
- This mixin will be removed in version 1.0.
-
- .. versionadded:: 0.6
- """
-
- #: the default charset that is assumed if the content type header
- #: is missing or does not contain a charset parameter. The default
- #: is latin1 which is what HTTP specifies as default charset.
- #: You may however want to set this to utf-8 to better support
- #: browsers that do not transmit a charset for incoming data.
- default_charset = "latin1"
-
- def unknown_charset(self, charset):
- """Called if a charset was provided but is not supported by
- the Python codecs module. By default latin1 is assumed then
- to not lose any information, you may override this method to
- change the behavior.
-
- :param charset: the charset that was not found.
- :return: the replacement charset.
- """
- return "latin1"
-
- @cached_property
- def charset(self):
- """The charset from the content type."""
- warnings.warn(
- "'werkzeug.contrib.wrappers.DynamicCharsetRequestMixin'"
- " is deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- header = self.environ.get("CONTENT_TYPE")
- if header:
- ct, options = parse_options_header(header)
- charset = options.get("charset")
- if charset:
- if is_known_charset(charset):
- return charset
- return self.unknown_charset(charset)
- return self.default_charset
-
-
-class DynamicCharsetResponseMixin(object):
-
- """If this mixin is mixed into a response class it will provide
- a dynamic `charset` attribute. This means that if the charset is
- looked up and stored in the `Content-Type` header and updates
- itself automatically. This also means a small performance hit but
- can be useful if you're working with different charsets on
- responses.
-
- Because the charset attribute is no a property at class-level, the
- default value is stored in `default_charset`.
-
- Because it changes the behavior or :class:`Response` this class has
- to be mixed in *before* the actual response class::
-
- class MyResponse(DynamicCharsetResponseMixin, Response):
- pass
-
- .. deprecated:: 0.15
- This mixin will be removed in version 1.0.
-
- .. versionadded:: 0.6
- """
-
- #: the default charset.
- default_charset = "utf-8"
-
- def _get_charset(self):
- warnings.warn(
- "'werkzeug.contrib.wrappers.DynamicCharsetResponseMixin'"
- " is deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- header = self.headers.get("content-type")
- if header:
- charset = parse_options_header(header)[1].get("charset")
- if charset:
- return charset
- return self.default_charset
-
- def _set_charset(self, charset):
- warnings.warn(
- "'werkzeug.contrib.wrappers.DynamicCharsetResponseMixin'"
- " is deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- header = self.headers.get("content-type")
- ct, options = parse_options_header(header)
- if not ct:
- raise TypeError("Cannot set charset if Content-Type header is missing.")
- options["charset"] = charset
- self.headers["Content-Type"] = dump_options_header(ct, options)
-
- charset = property(
- _get_charset,
- _set_charset,
- doc="""
- The charset for the response. It's stored inside the
- Content-Type header as a parameter.""",
- )
- del _get_charset, _set_charset
diff --git a/python/werkzeug/datastructures.py b/python/werkzeug/datastructures.py
deleted file mode 100644
index 9643db9..0000000
--- a/python/werkzeug/datastructures.py
+++ /dev/null
@@ -1,2852 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.datastructures
- ~~~~~~~~~~~~~~~~~~~~~~~
-
- This module provides mixins and classes with an immutable interface.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import mimetypes
-import re
-from copy import deepcopy
-from itertools import repeat
-
-from ._compat import BytesIO
-from ._compat import collections_abc
-from ._compat import integer_types
-from ._compat import iteritems
-from ._compat import iterkeys
-from ._compat import iterlists
-from ._compat import itervalues
-from ._compat import make_literal_wrapper
-from ._compat import PY2
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import to_native
-from ._internal import _missing
-from .filesystem import get_filesystem_encoding
-
-_locale_delim_re = re.compile(r"[_-]")
-
-
-def is_immutable(self):
- raise TypeError("%r objects are immutable" % self.__class__.__name__)
-
-
-def iter_multi_items(mapping):
- """Iterates over the items of a mapping yielding keys and values
- without dropping any from more complex structures.
- """
- if isinstance(mapping, MultiDict):
- for item in iteritems(mapping, multi=True):
- yield item
- elif isinstance(mapping, dict):
- for key, value in iteritems(mapping):
- if isinstance(value, (tuple, list)):
- for value in value:
- yield key, value
- else:
- yield key, value
- else:
- for item in mapping:
- yield item
-
-
-def native_itermethods(names):
- if not PY2:
- return lambda x: x
-
- def setviewmethod(cls, name):
- viewmethod_name = "view%s" % name
- repr_name = "view_%s" % name
-
- def viewmethod(self, *a, **kw):
- return ViewItems(self, name, repr_name, *a, **kw)
-
- viewmethod.__name__ = viewmethod_name
- viewmethod.__doc__ = "`%s()` object providing a view on %s" % (
- viewmethod_name,
- name,
- )
- setattr(cls, viewmethod_name, viewmethod)
-
- def setitermethod(cls, name):
- itermethod = getattr(cls, name)
- setattr(cls, "iter%s" % name, itermethod)
-
- def listmethod(self, *a, **kw):
- return list(itermethod(self, *a, **kw))
-
- listmethod.__name__ = name
- listmethod.__doc__ = "Like :py:meth:`iter%s`, but returns a list." % name
- setattr(cls, name, listmethod)
-
- def wrap(cls):
- for name in names:
- setitermethod(cls, name)
- setviewmethod(cls, name)
- return cls
-
- return wrap
-
-
-class ImmutableListMixin(object):
- """Makes a :class:`list` immutable.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- _hash_cache = None
-
- def __hash__(self):
- if self._hash_cache is not None:
- return self._hash_cache
- rv = self._hash_cache = hash(tuple(self))
- return rv
-
- def __reduce_ex__(self, protocol):
- return type(self), (list(self),)
-
- def __delitem__(self, key):
- is_immutable(self)
-
- def __iadd__(self, other):
- is_immutable(self)
-
- __imul__ = __iadd__
-
- def __setitem__(self, key, value):
- is_immutable(self)
-
- def append(self, item):
- is_immutable(self)
-
- remove = append
-
- def extend(self, iterable):
- is_immutable(self)
-
- def insert(self, pos, value):
- is_immutable(self)
-
- def pop(self, index=-1):
- is_immutable(self)
-
- def reverse(self):
- is_immutable(self)
-
- def sort(self, cmp=None, key=None, reverse=None):
- is_immutable(self)
-
-
-class ImmutableList(ImmutableListMixin, list):
- """An immutable :class:`list`.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- def __repr__(self):
- return "%s(%s)" % (self.__class__.__name__, list.__repr__(self))
-
-
-class ImmutableDictMixin(object):
- """Makes a :class:`dict` immutable.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- _hash_cache = None
-
- @classmethod
- def fromkeys(cls, keys, value=None):
- instance = super(cls, cls).__new__(cls)
- instance.__init__(zip(keys, repeat(value)))
- return instance
-
- def __reduce_ex__(self, protocol):
- return type(self), (dict(self),)
-
- def _iter_hashitems(self):
- return iteritems(self)
-
- def __hash__(self):
- if self._hash_cache is not None:
- return self._hash_cache
- rv = self._hash_cache = hash(frozenset(self._iter_hashitems()))
- return rv
-
- def setdefault(self, key, default=None):
- is_immutable(self)
-
- def update(self, *args, **kwargs):
- is_immutable(self)
-
- def pop(self, key, default=None):
- is_immutable(self)
-
- def popitem(self):
- is_immutable(self)
-
- def __setitem__(self, key, value):
- is_immutable(self)
-
- def __delitem__(self, key):
- is_immutable(self)
-
- def clear(self):
- is_immutable(self)
-
-
-class ImmutableMultiDictMixin(ImmutableDictMixin):
- """Makes a :class:`MultiDict` immutable.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- def __reduce_ex__(self, protocol):
- return type(self), (list(iteritems(self, multi=True)),)
-
- def _iter_hashitems(self):
- return iteritems(self, multi=True)
-
- def add(self, key, value):
- is_immutable(self)
-
- def popitemlist(self):
- is_immutable(self)
-
- def poplist(self, key):
- is_immutable(self)
-
- def setlist(self, key, new_list):
- is_immutable(self)
-
- def setlistdefault(self, key, default_list=None):
- is_immutable(self)
-
-
-class UpdateDictMixin(object):
- """Makes dicts call `self.on_update` on modifications.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- on_update = None
-
- def calls_update(name): # noqa: B902
- def oncall(self, *args, **kw):
- rv = getattr(super(UpdateDictMixin, self), name)(*args, **kw)
- if self.on_update is not None:
- self.on_update(self)
- return rv
-
- oncall.__name__ = name
- return oncall
-
- def setdefault(self, key, default=None):
- modified = key not in self
- rv = super(UpdateDictMixin, self).setdefault(key, default)
- if modified and self.on_update is not None:
- self.on_update(self)
- return rv
-
- def pop(self, key, default=_missing):
- modified = key in self
- if default is _missing:
- rv = super(UpdateDictMixin, self).pop(key)
- else:
- rv = super(UpdateDictMixin, self).pop(key, default)
- if modified and self.on_update is not None:
- self.on_update(self)
- return rv
-
- __setitem__ = calls_update("__setitem__")
- __delitem__ = calls_update("__delitem__")
- clear = calls_update("clear")
- popitem = calls_update("popitem")
- update = calls_update("update")
- del calls_update
-
-
-class TypeConversionDict(dict):
- """Works like a regular dict but the :meth:`get` method can perform
- type conversions. :class:`MultiDict` and :class:`CombinedMultiDict`
- are subclasses of this class and provide the same feature.
-
- .. versionadded:: 0.5
- """
-
- def get(self, key, default=None, type=None):
- """Return the default value if the requested data doesn't exist.
- If `type` is provided and is a callable it should convert the value,
- return it or raise a :exc:`ValueError` if that is not possible. In
- this case the function will return the default as if the value was not
- found:
-
- >>> d = TypeConversionDict(foo='42', bar='blub')
- >>> d.get('foo', type=int)
- 42
- >>> d.get('bar', -1, type=int)
- -1
-
- :param key: The key to be looked up.
- :param default: The default value to be returned if the key can't
- be looked up. If not further specified `None` is
- returned.
- :param type: A callable that is used to cast the value in the
- :class:`MultiDict`. If a :exc:`ValueError` is raised
- by this callable the default value is returned.
- """
- try:
- rv = self[key]
- except KeyError:
- return default
- if type is not None:
- try:
- rv = type(rv)
- except ValueError:
- rv = default
- return rv
-
-
-class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict):
- """Works like a :class:`TypeConversionDict` but does not support
- modifications.
-
- .. versionadded:: 0.5
- """
-
- def copy(self):
- """Return a shallow mutable copy of this object. Keep in mind that
- the standard library's :func:`copy` function is a no-op for this class
- like for any other python immutable type (eg: :class:`tuple`).
- """
- return TypeConversionDict(self)
-
- def __copy__(self):
- return self
-
-
-class ViewItems(object):
- def __init__(self, multi_dict, method, repr_name, *a, **kw):
- self.__multi_dict = multi_dict
- self.__method = method
- self.__repr_name = repr_name
- self.__a = a
- self.__kw = kw
-
- def __get_items(self):
- return getattr(self.__multi_dict, self.__method)(*self.__a, **self.__kw)
-
- def __repr__(self):
- return "%s(%r)" % (self.__repr_name, list(self.__get_items()))
-
- def __iter__(self):
- return iter(self.__get_items())
-
-
-@native_itermethods(["keys", "values", "items", "lists", "listvalues"])
-class MultiDict(TypeConversionDict):
- """A :class:`MultiDict` is a dictionary subclass customized to deal with
- multiple values for the same key which is for example used by the parsing
- functions in the wrappers. This is necessary because some HTML form
- elements pass multiple values for the same key.
-
- :class:`MultiDict` implements all standard dictionary methods.
- Internally, it saves all values for a key as a list, but the standard dict
- access methods will only return the first value for a key. If you want to
- gain access to the other values, too, you have to use the `list` methods as
- explained below.
-
- Basic Usage:
-
- >>> d = MultiDict([('a', 'b'), ('a', 'c')])
- >>> d
- MultiDict([('a', 'b'), ('a', 'c')])
- >>> d['a']
- 'b'
- >>> d.getlist('a')
- ['b', 'c']
- >>> 'a' in d
- True
-
- It behaves like a normal dict thus all dict functions will only return the
- first value when multiple values for one key are found.
-
- From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
- subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
- render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP
- exceptions.
-
- A :class:`MultiDict` can be constructed from an iterable of
- ``(key, value)`` tuples, a dict, a :class:`MultiDict` or from Werkzeug 0.2
- onwards some keyword parameters.
-
- :param mapping: the initial value for the :class:`MultiDict`. Either a
- regular dict, an iterable of ``(key, value)`` tuples
- or `None`.
- """
-
- def __init__(self, mapping=None):
- if isinstance(mapping, MultiDict):
- dict.__init__(self, ((k, l[:]) for k, l in iterlists(mapping)))
- elif isinstance(mapping, dict):
- tmp = {}
- for key, value in iteritems(mapping):
- if isinstance(value, (tuple, list)):
- if len(value) == 0:
- continue
- value = list(value)
- else:
- value = [value]
- tmp[key] = value
- dict.__init__(self, tmp)
- else:
- tmp = {}
- for key, value in mapping or ():
- tmp.setdefault(key, []).append(value)
- dict.__init__(self, tmp)
-
- def __getstate__(self):
- return dict(self.lists())
-
- def __setstate__(self, value):
- dict.clear(self)
- dict.update(self, value)
-
- def __getitem__(self, key):
- """Return the first data value for this key;
- raises KeyError if not found.
-
- :param key: The key to be looked up.
- :raise KeyError: if the key does not exist.
- """
-
- if key in self:
- lst = dict.__getitem__(self, key)
- if len(lst) > 0:
- return lst[0]
- raise exceptions.BadRequestKeyError(key)
-
- def __setitem__(self, key, value):
- """Like :meth:`add` but removes an existing key first.
-
- :param key: the key for the value.
- :param value: the value to set.
- """
- dict.__setitem__(self, key, [value])
-
- def add(self, key, value):
- """Adds a new value for the key.
-
- .. versionadded:: 0.6
-
- :param key: the key for the value.
- :param value: the value to add.
- """
- dict.setdefault(self, key, []).append(value)
-
- def getlist(self, key, type=None):
- """Return the list of items for a given key. If that key is not in the
- `MultiDict`, the return value will be an empty list. Just as `get`
- `getlist` accepts a `type` parameter. All items will be converted
- with the callable defined there.
-
- :param key: The key to be looked up.
- :param type: A callable that is used to cast the value in the
- :class:`MultiDict`. If a :exc:`ValueError` is raised
- by this callable the value will be removed from the list.
- :return: a :class:`list` of all the values for the key.
- """
- try:
- rv = dict.__getitem__(self, key)
- except KeyError:
- return []
- if type is None:
- return list(rv)
- result = []
- for item in rv:
- try:
- result.append(type(item))
- except ValueError:
- pass
- return result
-
- def setlist(self, key, new_list):
- """Remove the old values for a key and add new ones. Note that the list
- you pass the values in will be shallow-copied before it is inserted in
- the dictionary.
-
- >>> d = MultiDict()
- >>> d.setlist('foo', ['1', '2'])
- >>> d['foo']
- '1'
- >>> d.getlist('foo')
- ['1', '2']
-
- :param key: The key for which the values are set.
- :param new_list: An iterable with the new values for the key. Old values
- are removed first.
- """
- dict.__setitem__(self, key, list(new_list))
-
- def setdefault(self, key, default=None):
- """Returns the value for the key if it is in the dict, otherwise it
- returns `default` and sets that value for `key`.
-
- :param key: The key to be looked up.
- :param default: The default value to be returned if the key is not
- in the dict. If not further specified it's `None`.
- """
- if key not in self:
- self[key] = default
- else:
- default = self[key]
- return default
-
- def setlistdefault(self, key, default_list=None):
- """Like `setdefault` but sets multiple values. The list returned
- is not a copy, but the list that is actually used internally. This
- means that you can put new values into the dict by appending items
- to the list:
-
- >>> d = MultiDict({"foo": 1})
- >>> d.setlistdefault("foo").extend([2, 3])
- >>> d.getlist("foo")
- [1, 2, 3]
-
- :param key: The key to be looked up.
- :param default_list: An iterable of default values. It is either copied
- (in case it was a list) or converted into a list
- before returned.
- :return: a :class:`list`
- """
- if key not in self:
- default_list = list(default_list or ())
- dict.__setitem__(self, key, default_list)
- else:
- default_list = dict.__getitem__(self, key)
- return default_list
-
- def items(self, multi=False):
- """Return an iterator of ``(key, value)`` pairs.
-
- :param multi: If set to `True` the iterator returned will have a pair
- for each value of each key. Otherwise it will only
- contain pairs for the first value of each key.
- """
-
- for key, values in iteritems(dict, self):
- if multi:
- for value in values:
- yield key, value
- else:
- yield key, values[0]
-
- def lists(self):
- """Return a iterator of ``(key, values)`` pairs, where values is the list
- of all values associated with the key."""
-
- for key, values in iteritems(dict, self):
- yield key, list(values)
-
- def keys(self):
- return iterkeys(dict, self)
-
- __iter__ = keys
-
- def values(self):
- """Returns an iterator of the first value on every key's value list."""
- for values in itervalues(dict, self):
- yield values[0]
-
- def listvalues(self):
- """Return an iterator of all values associated with a key. Zipping
- :meth:`keys` and this is the same as calling :meth:`lists`:
-
- >>> d = MultiDict({"foo": [1, 2, 3]})
- >>> zip(d.keys(), d.listvalues()) == d.lists()
- True
- """
-
- return itervalues(dict, self)
-
- def copy(self):
- """Return a shallow copy of this object."""
- return self.__class__(self)
-
- def deepcopy(self, memo=None):
- """Return a deep copy of this object."""
- return self.__class__(deepcopy(self.to_dict(flat=False), memo))
-
- def to_dict(self, flat=True):
- """Return the contents as regular dict. If `flat` is `True` the
- returned dict will only have the first item present, if `flat` is
- `False` all values will be returned as lists.
-
- :param flat: If set to `False` the dict returned will have lists
- with all the values in it. Otherwise it will only
- contain the first value for each key.
- :return: a :class:`dict`
- """
- if flat:
- return dict(iteritems(self))
- return dict(self.lists())
-
- def update(self, other_dict):
- """update() extends rather than replaces existing key lists:
-
- >>> a = MultiDict({'x': 1})
- >>> b = MultiDict({'x': 2, 'y': 3})
- >>> a.update(b)
- >>> a
- MultiDict([('y', 3), ('x', 1), ('x', 2)])
-
- If the value list for a key in ``other_dict`` is empty, no new values
- will be added to the dict and the key will not be created:
-
- >>> x = {'empty_list': []}
- >>> y = MultiDict()
- >>> y.update(x)
- >>> y
- MultiDict([])
- """
- for key, value in iter_multi_items(other_dict):
- MultiDict.add(self, key, value)
-
- def pop(self, key, default=_missing):
- """Pop the first item for a list on the dict. Afterwards the
- key is removed from the dict, so additional values are discarded:
-
- >>> d = MultiDict({"foo": [1, 2, 3]})
- >>> d.pop("foo")
- 1
- >>> "foo" in d
- False
-
- :param key: the key to pop.
- :param default: if provided the value to return if the key was
- not in the dictionary.
- """
- try:
- lst = dict.pop(self, key)
-
- if len(lst) == 0:
- raise exceptions.BadRequestKeyError(key)
-
- return lst[0]
- except KeyError:
- if default is not _missing:
- return default
- raise exceptions.BadRequestKeyError(key)
-
- def popitem(self):
- """Pop an item from the dict."""
- try:
- item = dict.popitem(self)
-
- if len(item[1]) == 0:
- raise exceptions.BadRequestKeyError(item)
-
- return (item[0], item[1][0])
- except KeyError as e:
- raise exceptions.BadRequestKeyError(e.args[0])
-
- def poplist(self, key):
- """Pop the list for a key from the dict. If the key is not in the dict
- an empty list is returned.
-
- .. versionchanged:: 0.5
- If the key does no longer exist a list is returned instead of
- raising an error.
- """
- return dict.pop(self, key, [])
-
- def popitemlist(self):
- """Pop a ``(key, list)`` tuple from the dict."""
- try:
- return dict.popitem(self)
- except KeyError as e:
- raise exceptions.BadRequestKeyError(e.args[0])
-
- def __copy__(self):
- return self.copy()
-
- def __deepcopy__(self, memo):
- return self.deepcopy(memo=memo)
-
- def __repr__(self):
- return "%s(%r)" % (self.__class__.__name__, list(iteritems(self, multi=True)))
-
-
-class _omd_bucket(object):
- """Wraps values in the :class:`OrderedMultiDict`. This makes it
- possible to keep an order over multiple different keys. It requires
- a lot of extra memory and slows down access a lot, but makes it
- possible to access elements in O(1) and iterate in O(n).
- """
-
- __slots__ = ("prev", "key", "value", "next")
-
- def __init__(self, omd, key, value):
- self.prev = omd._last_bucket
- self.key = key
- self.value = value
- self.next = None
-
- if omd._first_bucket is None:
- omd._first_bucket = self
- if omd._last_bucket is not None:
- omd._last_bucket.next = self
- omd._last_bucket = self
-
- def unlink(self, omd):
- if self.prev:
- self.prev.next = self.next
- if self.next:
- self.next.prev = self.prev
- if omd._first_bucket is self:
- omd._first_bucket = self.next
- if omd._last_bucket is self:
- omd._last_bucket = self.prev
-
-
-@native_itermethods(["keys", "values", "items", "lists", "listvalues"])
-class OrderedMultiDict(MultiDict):
- """Works like a regular :class:`MultiDict` but preserves the
- order of the fields. To convert the ordered multi dict into a
- list you can use the :meth:`items` method and pass it ``multi=True``.
-
- In general an :class:`OrderedMultiDict` is an order of magnitude
- slower than a :class:`MultiDict`.
-
- .. admonition:: note
-
- Due to a limitation in Python you cannot convert an ordered
- multi dict into a regular dict by using ``dict(multidict)``.
- Instead you have to use the :meth:`to_dict` method, otherwise
- the internal bucket objects are exposed.
- """
-
- def __init__(self, mapping=None):
- dict.__init__(self)
- self._first_bucket = self._last_bucket = None
- if mapping is not None:
- OrderedMultiDict.update(self, mapping)
-
- def __eq__(self, other):
- if not isinstance(other, MultiDict):
- return NotImplemented
- if isinstance(other, OrderedMultiDict):
- iter1 = iteritems(self, multi=True)
- iter2 = iteritems(other, multi=True)
- try:
- for k1, v1 in iter1:
- k2, v2 = next(iter2)
- if k1 != k2 or v1 != v2:
- return False
- except StopIteration:
- return False
- try:
- next(iter2)
- except StopIteration:
- return True
- return False
- if len(self) != len(other):
- return False
- for key, values in iterlists(self):
- if other.getlist(key) != values:
- return False
- return True
-
- __hash__ = None
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __reduce_ex__(self, protocol):
- return type(self), (list(iteritems(self, multi=True)),)
-
- def __getstate__(self):
- return list(iteritems(self, multi=True))
-
- def __setstate__(self, values):
- dict.clear(self)
- for key, value in values:
- self.add(key, value)
-
- def __getitem__(self, key):
- if key in self:
- return dict.__getitem__(self, key)[0].value
- raise exceptions.BadRequestKeyError(key)
-
- def __setitem__(self, key, value):
- self.poplist(key)
- self.add(key, value)
-
- def __delitem__(self, key):
- self.pop(key)
-
- def keys(self):
- return (key for key, value in iteritems(self))
-
- __iter__ = keys
-
- def values(self):
- return (value for key, value in iteritems(self))
-
- def items(self, multi=False):
- ptr = self._first_bucket
- if multi:
- while ptr is not None:
- yield ptr.key, ptr.value
- ptr = ptr.next
- else:
- returned_keys = set()
- while ptr is not None:
- if ptr.key not in returned_keys:
- returned_keys.add(ptr.key)
- yield ptr.key, ptr.value
- ptr = ptr.next
-
- def lists(self):
- returned_keys = set()
- ptr = self._first_bucket
- while ptr is not None:
- if ptr.key not in returned_keys:
- yield ptr.key, self.getlist(ptr.key)
- returned_keys.add(ptr.key)
- ptr = ptr.next
-
- def listvalues(self):
- for _key, values in iterlists(self):
- yield values
-
- def add(self, key, value):
- dict.setdefault(self, key, []).append(_omd_bucket(self, key, value))
-
- def getlist(self, key, type=None):
- try:
- rv = dict.__getitem__(self, key)
- except KeyError:
- return []
- if type is None:
- return [x.value for x in rv]
- result = []
- for item in rv:
- try:
- result.append(type(item.value))
- except ValueError:
- pass
- return result
-
- def setlist(self, key, new_list):
- self.poplist(key)
- for value in new_list:
- self.add(key, value)
-
- def setlistdefault(self, key, default_list=None):
- raise TypeError("setlistdefault is unsupported for ordered multi dicts")
-
- def update(self, mapping):
- for key, value in iter_multi_items(mapping):
- OrderedMultiDict.add(self, key, value)
-
- def poplist(self, key):
- buckets = dict.pop(self, key, ())
- for bucket in buckets:
- bucket.unlink(self)
- return [x.value for x in buckets]
-
- def pop(self, key, default=_missing):
- try:
- buckets = dict.pop(self, key)
- except KeyError:
- if default is not _missing:
- return default
- raise exceptions.BadRequestKeyError(key)
- for bucket in buckets:
- bucket.unlink(self)
- return buckets[0].value
-
- def popitem(self):
- try:
- key, buckets = dict.popitem(self)
- except KeyError as e:
- raise exceptions.BadRequestKeyError(e.args[0])
- for bucket in buckets:
- bucket.unlink(self)
- return key, buckets[0].value
-
- def popitemlist(self):
- try:
- key, buckets = dict.popitem(self)
- except KeyError as e:
- raise exceptions.BadRequestKeyError(e.args[0])
- for bucket in buckets:
- bucket.unlink(self)
- return key, [x.value for x in buckets]
-
-
-def _options_header_vkw(value, kw):
- return dump_options_header(
- value, dict((k.replace("_", "-"), v) for k, v in kw.items())
- )
-
-
-def _unicodify_header_value(value):
- if isinstance(value, bytes):
- value = value.decode("latin-1")
- if not isinstance(value, text_type):
- value = text_type(value)
- return value
-
-
-@native_itermethods(["keys", "values", "items"])
-class Headers(object):
- """An object that stores some headers. It has a dict-like interface
- but is ordered and can store the same keys multiple times.
-
- This data structure is useful if you want a nicer way to handle WSGI
- headers which are stored as tuples in a list.
-
- From Werkzeug 0.3 onwards, the :exc:`KeyError` raised by this class is
- also a subclass of the :class:`~exceptions.BadRequest` HTTP exception
- and will render a page for a ``400 BAD REQUEST`` if caught in a
- catch-all for HTTP exceptions.
-
- Headers is mostly compatible with the Python :class:`wsgiref.headers.Headers`
- class, with the exception of `__getitem__`. :mod:`wsgiref` will return
- `None` for ``headers['missing']``, whereas :class:`Headers` will raise
- a :class:`KeyError`.
-
- To create a new :class:`Headers` object pass it a list or dict of headers
- which are used as default values. This does not reuse the list passed
- to the constructor for internal usage.
-
- :param defaults: The list of default values for the :class:`Headers`.
-
- .. versionchanged:: 0.9
- This data structure now stores unicode values similar to how the
- multi dicts do it. The main difference is that bytes can be set as
- well which will automatically be latin1 decoded.
-
- .. versionchanged:: 0.9
- The :meth:`linked` function was removed without replacement as it
- was an API that does not support the changes to the encoding model.
- """
-
- def __init__(self, defaults=None):
- self._list = []
- if defaults is not None:
- if isinstance(defaults, (list, Headers)):
- self._list.extend(defaults)
- else:
- self.extend(defaults)
-
- def __getitem__(self, key, _get_mode=False):
- if not _get_mode:
- if isinstance(key, integer_types):
- return self._list[key]
- elif isinstance(key, slice):
- return self.__class__(self._list[key])
- if not isinstance(key, string_types):
- raise exceptions.BadRequestKeyError(key)
- ikey = key.lower()
- for k, v in self._list:
- if k.lower() == ikey:
- return v
- # micro optimization: if we are in get mode we will catch that
- # exception one stack level down so we can raise a standard
- # key error instead of our special one.
- if _get_mode:
- raise KeyError()
- raise exceptions.BadRequestKeyError(key)
-
- def __eq__(self, other):
- return other.__class__ is self.__class__ and set(other._list) == set(self._list)
-
- __hash__ = None
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def get(self, key, default=None, type=None, as_bytes=False):
- """Return the default value if the requested data doesn't exist.
- If `type` is provided and is a callable it should convert the value,
- return it or raise a :exc:`ValueError` if that is not possible. In
- this case the function will return the default as if the value was not
- found:
-
- >>> d = Headers([('Content-Length', '42')])
- >>> d.get('Content-Length', type=int)
- 42
-
- If a headers object is bound you must not add unicode strings
- because no encoding takes place.
-
- .. versionadded:: 0.9
- Added support for `as_bytes`.
-
- :param key: The key to be looked up.
- :param default: The default value to be returned if the key can't
- be looked up. If not further specified `None` is
- returned.
- :param type: A callable that is used to cast the value in the
- :class:`Headers`. If a :exc:`ValueError` is raised
- by this callable the default value is returned.
- :param as_bytes: return bytes instead of unicode strings.
- """
- try:
- rv = self.__getitem__(key, _get_mode=True)
- except KeyError:
- return default
- if as_bytes:
- rv = rv.encode("latin1")
- if type is None:
- return rv
- try:
- return type(rv)
- except ValueError:
- return default
-
- def getlist(self, key, type=None, as_bytes=False):
- """Return the list of items for a given key. If that key is not in the
- :class:`Headers`, the return value will be an empty list. Just as
- :meth:`get` :meth:`getlist` accepts a `type` parameter. All items will
- be converted with the callable defined there.
-
- .. versionadded:: 0.9
- Added support for `as_bytes`.
-
- :param key: The key to be looked up.
- :param type: A callable that is used to cast the value in the
- :class:`Headers`. If a :exc:`ValueError` is raised
- by this callable the value will be removed from the list.
- :return: a :class:`list` of all the values for the key.
- :param as_bytes: return bytes instead of unicode strings.
- """
- ikey = key.lower()
- result = []
- for k, v in self:
- if k.lower() == ikey:
- if as_bytes:
- v = v.encode("latin1")
- if type is not None:
- try:
- v = type(v)
- except ValueError:
- continue
- result.append(v)
- return result
-
- def get_all(self, name):
- """Return a list of all the values for the named field.
-
- This method is compatible with the :mod:`wsgiref`
- :meth:`~wsgiref.headers.Headers.get_all` method.
- """
- return self.getlist(name)
-
- def items(self, lower=False):
- for key, value in self:
- if lower:
- key = key.lower()
- yield key, value
-
- def keys(self, lower=False):
- for key, _ in iteritems(self, lower):
- yield key
-
- def values(self):
- for _, value in iteritems(self):
- yield value
-
- def extend(self, iterable):
- """Extend the headers with a dict or an iterable yielding keys and
- values.
- """
- if isinstance(iterable, dict):
- for key, value in iteritems(iterable):
- if isinstance(value, (tuple, list)):
- for v in value:
- self.add(key, v)
- else:
- self.add(key, value)
- else:
- for key, value in iterable:
- self.add(key, value)
-
- def __delitem__(self, key, _index_operation=True):
- if _index_operation and isinstance(key, (integer_types, slice)):
- del self._list[key]
- return
- key = key.lower()
- new = []
- for k, v in self._list:
- if k.lower() != key:
- new.append((k, v))
- self._list[:] = new
-
- def remove(self, key):
- """Remove a key.
-
- :param key: The key to be removed.
- """
- return self.__delitem__(key, _index_operation=False)
-
- def pop(self, key=None, default=_missing):
- """Removes and returns a key or index.
-
- :param key: The key to be popped. If this is an integer the item at
- that position is removed, if it's a string the value for
- that key is. If the key is omitted or `None` the last
- item is removed.
- :return: an item.
- """
- if key is None:
- return self._list.pop()
- if isinstance(key, integer_types):
- return self._list.pop(key)
- try:
- rv = self[key]
- self.remove(key)
- except KeyError:
- if default is not _missing:
- return default
- raise
- return rv
-
- def popitem(self):
- """Removes a key or index and returns a (key, value) item."""
- return self.pop()
-
- def __contains__(self, key):
- """Check if a key is present."""
- try:
- self.__getitem__(key, _get_mode=True)
- except KeyError:
- return False
- return True
-
- has_key = __contains__
-
- def __iter__(self):
- """Yield ``(key, value)`` tuples."""
- return iter(self._list)
-
- def __len__(self):
- return len(self._list)
-
- def add(self, _key, _value, **kw):
- """Add a new header tuple to the list.
-
- Keyword arguments can specify additional parameters for the header
- value, with underscores converted to dashes::
-
- >>> d = Headers()
- >>> d.add('Content-Type', 'text/plain')
- >>> d.add('Content-Disposition', 'attachment', filename='foo.png')
-
- The keyword argument dumping uses :func:`dump_options_header`
- behind the scenes.
-
- .. versionadded:: 0.4.1
- keyword arguments were added for :mod:`wsgiref` compatibility.
- """
- if kw:
- _value = _options_header_vkw(_value, kw)
- _key = _unicodify_header_value(_key)
- _value = _unicodify_header_value(_value)
- self._validate_value(_value)
- self._list.append((_key, _value))
-
- def _validate_value(self, value):
- if not isinstance(value, text_type):
- raise TypeError("Value should be unicode.")
- if u"\n" in value or u"\r" in value:
- raise ValueError(
- "Detected newline in header value. This is "
- "a potential security problem"
- )
-
- def add_header(self, _key, _value, **_kw):
- """Add a new header tuple to the list.
-
- An alias for :meth:`add` for compatibility with the :mod:`wsgiref`
- :meth:`~wsgiref.headers.Headers.add_header` method.
- """
- self.add(_key, _value, **_kw)
-
- def clear(self):
- """Clears all headers."""
- del self._list[:]
-
- def set(self, _key, _value, **kw):
- """Remove all header tuples for `key` and add a new one. The newly
- added key either appears at the end of the list if there was no
- entry or replaces the first one.
-
- Keyword arguments can specify additional parameters for the header
- value, with underscores converted to dashes. See :meth:`add` for
- more information.
-
- .. versionchanged:: 0.6.1
- :meth:`set` now accepts the same arguments as :meth:`add`.
-
- :param key: The key to be inserted.
- :param value: The value to be inserted.
- """
- if kw:
- _value = _options_header_vkw(_value, kw)
- _key = _unicodify_header_value(_key)
- _value = _unicodify_header_value(_value)
- self._validate_value(_value)
- if not self._list:
- self._list.append((_key, _value))
- return
- listiter = iter(self._list)
- ikey = _key.lower()
- for idx, (old_key, _old_value) in enumerate(listiter):
- if old_key.lower() == ikey:
- # replace first ocurrence
- self._list[idx] = (_key, _value)
- break
- else:
- self._list.append((_key, _value))
- return
- self._list[idx + 1 :] = [t for t in listiter if t[0].lower() != ikey]
-
- def setdefault(self, key, default):
- """Returns the value for the key if it is in the dict, otherwise it
- returns `default` and sets that value for `key`.
-
- :param key: The key to be looked up.
- :param default: The default value to be returned if the key is not
- in the dict. If not further specified it's `None`.
- """
- if key in self:
- return self[key]
- self.set(key, default)
- return default
-
- def __setitem__(self, key, value):
- """Like :meth:`set` but also supports index/slice based setting."""
- if isinstance(key, (slice, integer_types)):
- if isinstance(key, integer_types):
- value = [value]
- value = [
- (_unicodify_header_value(k), _unicodify_header_value(v))
- for (k, v) in value
- ]
- [self._validate_value(v) for (k, v) in value]
- if isinstance(key, integer_types):
- self._list[key] = value[0]
- else:
- self._list[key] = value
- else:
- self.set(key, value)
-
- def to_list(self, charset="iso-8859-1"):
- """Convert the headers into a list suitable for WSGI.
-
- .. deprecated:: 0.9
- """
- from warnings import warn
-
- warn(
- "'to_list' deprecated as of version 0.9 and will be removed"
- " in version 1.0. Use 'to_wsgi_list' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.to_wsgi_list()
-
- def to_wsgi_list(self):
- """Convert the headers into a list suitable for WSGI.
-
- The values are byte strings in Python 2 converted to latin1 and unicode
- strings in Python 3 for the WSGI server to encode.
-
- :return: list
- """
- if PY2:
- return [(to_native(k), v.encode("latin1")) for k, v in self]
- return list(self)
-
- def copy(self):
- return self.__class__(self._list)
-
- def __copy__(self):
- return self.copy()
-
- def __str__(self):
- """Returns formatted headers suitable for HTTP transmission."""
- strs = []
- for key, value in self.to_wsgi_list():
- strs.append("%s: %s" % (key, value))
- strs.append("\r\n")
- return "\r\n".join(strs)
-
- def __repr__(self):
- return "%s(%r)" % (self.__class__.__name__, list(self))
-
-
-class ImmutableHeadersMixin(object):
- """Makes a :class:`Headers` immutable. We do not mark them as
- hashable though since the only usecase for this datastructure
- in Werkzeug is a view on a mutable structure.
-
- .. versionadded:: 0.5
-
- :private:
- """
-
- def __delitem__(self, key, **kwargs):
- is_immutable(self)
-
- def __setitem__(self, key, value):
- is_immutable(self)
-
- set = __setitem__
-
- def add(self, item):
- is_immutable(self)
-
- remove = add_header = add
-
- def extend(self, iterable):
- is_immutable(self)
-
- def insert(self, pos, value):
- is_immutable(self)
-
- def pop(self, index=-1):
- is_immutable(self)
-
- def popitem(self):
- is_immutable(self)
-
- def setdefault(self, key, default):
- is_immutable(self)
-
-
-class EnvironHeaders(ImmutableHeadersMixin, Headers):
- """Read only version of the headers from a WSGI environment. This
- provides the same interface as `Headers` and is constructed from
- a WSGI environment.
-
- From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
- subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
- render a page for a ``400 BAD REQUEST`` if caught in a catch-all for
- HTTP exceptions.
- """
-
- def __init__(self, environ):
- self.environ = environ
-
- def __eq__(self, other):
- return self.environ is other.environ
-
- __hash__ = None
-
- def __getitem__(self, key, _get_mode=False):
- # _get_mode is a no-op for this class as there is no index but
- # used because get() calls it.
- if not isinstance(key, string_types):
- raise KeyError(key)
- key = key.upper().replace("-", "_")
- if key in ("CONTENT_TYPE", "CONTENT_LENGTH"):
- return _unicodify_header_value(self.environ[key])
- return _unicodify_header_value(self.environ["HTTP_" + key])
-
- def __len__(self):
- # the iter is necessary because otherwise list calls our
- # len which would call list again and so forth.
- return len(list(iter(self)))
-
- def __iter__(self):
- for key, value in iteritems(self.environ):
- if key.startswith("HTTP_") and key not in (
- "HTTP_CONTENT_TYPE",
- "HTTP_CONTENT_LENGTH",
- ):
- yield (
- key[5:].replace("_", "-").title(),
- _unicodify_header_value(value),
- )
- elif key in ("CONTENT_TYPE", "CONTENT_LENGTH") and value:
- yield (key.replace("_", "-").title(), _unicodify_header_value(value))
-
- def copy(self):
- raise TypeError("cannot create %r copies" % self.__class__.__name__)
-
-
-@native_itermethods(["keys", "values", "items", "lists", "listvalues"])
-class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict):
- """A read only :class:`MultiDict` that you can pass multiple :class:`MultiDict`
- instances as sequence and it will combine the return values of all wrapped
- dicts:
-
- >>> from werkzeug.datastructures import CombinedMultiDict, MultiDict
- >>> post = MultiDict([('foo', 'bar')])
- >>> get = MultiDict([('blub', 'blah')])
- >>> combined = CombinedMultiDict([get, post])
- >>> combined['foo']
- 'bar'
- >>> combined['blub']
- 'blah'
-
- This works for all read operations and will raise a `TypeError` for
- methods that usually change data which isn't possible.
-
- From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
- subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
- render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP
- exceptions.
- """
-
- def __reduce_ex__(self, protocol):
- return type(self), (self.dicts,)
-
- def __init__(self, dicts=None):
- self.dicts = dicts or []
-
- @classmethod
- def fromkeys(cls):
- raise TypeError("cannot create %r instances by fromkeys" % cls.__name__)
-
- def __getitem__(self, key):
- for d in self.dicts:
- if key in d:
- return d[key]
- raise exceptions.BadRequestKeyError(key)
-
- def get(self, key, default=None, type=None):
- for d in self.dicts:
- if key in d:
- if type is not None:
- try:
- return type(d[key])
- except ValueError:
- continue
- return d[key]
- return default
-
- def getlist(self, key, type=None):
- rv = []
- for d in self.dicts:
- rv.extend(d.getlist(key, type))
- return rv
-
- def _keys_impl(self):
- """This function exists so __len__ can be implemented more efficiently,
- saving one list creation from an iterator.
-
- Using this for Python 2's ``dict.keys`` behavior would be useless since
- `dict.keys` in Python 2 returns a list, while we have a set here.
- """
- rv = set()
- for d in self.dicts:
- rv.update(iterkeys(d))
- return rv
-
- def keys(self):
- return iter(self._keys_impl())
-
- __iter__ = keys
-
- def items(self, multi=False):
- found = set()
- for d in self.dicts:
- for key, value in iteritems(d, multi):
- if multi:
- yield key, value
- elif key not in found:
- found.add(key)
- yield key, value
-
- def values(self):
- for _key, value in iteritems(self):
- yield value
-
- def lists(self):
- rv = {}
- for d in self.dicts:
- for key, values in iterlists(d):
- rv.setdefault(key, []).extend(values)
- return iteritems(rv)
-
- def listvalues(self):
- return (x[1] for x in self.lists())
-
- def copy(self):
- """Return a shallow mutable copy of this object.
-
- This returns a :class:`MultiDict` representing the data at the
- time of copying. The copy will no longer reflect changes to the
- wrapped dicts.
-
- .. versionchanged:: 0.15
- Return a mutable :class:`MultiDict`.
- """
- return MultiDict(self)
-
- def to_dict(self, flat=True):
- """Return the contents as regular dict. If `flat` is `True` the
- returned dict will only have the first item present, if `flat` is
- `False` all values will be returned as lists.
-
- :param flat: If set to `False` the dict returned will have lists
- with all the values in it. Otherwise it will only
- contain the first item for each key.
- :return: a :class:`dict`
- """
- rv = {}
- for d in reversed(self.dicts):
- rv.update(d.to_dict(flat))
- return rv
-
- def __len__(self):
- return len(self._keys_impl())
-
- def __contains__(self, key):
- for d in self.dicts:
- if key in d:
- return True
- return False
-
- has_key = __contains__
-
- def __repr__(self):
- return "%s(%r)" % (self.__class__.__name__, self.dicts)
-
-
-class FileMultiDict(MultiDict):
- """A special :class:`MultiDict` that has convenience methods to add
- files to it. This is used for :class:`EnvironBuilder` and generally
- useful for unittesting.
-
- .. versionadded:: 0.5
- """
-
- def add_file(self, name, file, filename=None, content_type=None):
- """Adds a new file to the dict. `file` can be a file name or
- a :class:`file`-like or a :class:`FileStorage` object.
-
- :param name: the name of the field.
- :param file: a filename or :class:`file`-like object
- :param filename: an optional filename
- :param content_type: an optional content type
- """
- if isinstance(file, FileStorage):
- value = file
- else:
- if isinstance(file, string_types):
- if filename is None:
- filename = file
- file = open(file, "rb")
- if filename and content_type is None:
- content_type = (
- mimetypes.guess_type(filename)[0] or "application/octet-stream"
- )
- value = FileStorage(file, filename, name, content_type)
-
- self.add(name, value)
-
-
-class ImmutableDict(ImmutableDictMixin, dict):
- """An immutable :class:`dict`.
-
- .. versionadded:: 0.5
- """
-
- def __repr__(self):
- return "%s(%s)" % (self.__class__.__name__, dict.__repr__(self))
-
- def copy(self):
- """Return a shallow mutable copy of this object. Keep in mind that
- the standard library's :func:`copy` function is a no-op for this class
- like for any other python immutable type (eg: :class:`tuple`).
- """
- return dict(self)
-
- def __copy__(self):
- return self
-
-
-class ImmutableMultiDict(ImmutableMultiDictMixin, MultiDict):
- """An immutable :class:`MultiDict`.
-
- .. versionadded:: 0.5
- """
-
- def copy(self):
- """Return a shallow mutable copy of this object. Keep in mind that
- the standard library's :func:`copy` function is a no-op for this class
- like for any other python immutable type (eg: :class:`tuple`).
- """
- return MultiDict(self)
-
- def __copy__(self):
- return self
-
-
-class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict):
- """An immutable :class:`OrderedMultiDict`.
-
- .. versionadded:: 0.6
- """
-
- def _iter_hashitems(self):
- return enumerate(iteritems(self, multi=True))
-
- def copy(self):
- """Return a shallow mutable copy of this object. Keep in mind that
- the standard library's :func:`copy` function is a no-op for this class
- like for any other python immutable type (eg: :class:`tuple`).
- """
- return OrderedMultiDict(self)
-
- def __copy__(self):
- return self
-
-
-@native_itermethods(["values"])
-class Accept(ImmutableList):
- """An :class:`Accept` object is just a list subclass for lists of
- ``(value, quality)`` tuples. It is automatically sorted by specificity
- and quality.
-
- All :class:`Accept` objects work similar to a list but provide extra
- functionality for working with the data. Containment checks are
- normalized to the rules of that header:
-
- >>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)])
- >>> a.best
- 'ISO-8859-1'
- >>> 'iso-8859-1' in a
- True
- >>> 'UTF8' in a
- True
- >>> 'utf7' in a
- False
-
- To get the quality for an item you can use normal item lookup:
-
- >>> print a['utf-8']
- 0.7
- >>> a['utf7']
- 0
-
- .. versionchanged:: 0.5
- :class:`Accept` objects are forced immutable now.
- """
-
- def __init__(self, values=()):
- if values is None:
- list.__init__(self)
- self.provided = False
- elif isinstance(values, Accept):
- self.provided = values.provided
- list.__init__(self, values)
- else:
- self.provided = True
- values = sorted(
- values,
- key=lambda x: (self._specificity(x[0]), x[1], x[0]),
- reverse=True,
- )
- list.__init__(self, values)
-
- def _specificity(self, value):
- """Returns a tuple describing the value's specificity."""
- return (value != "*",)
-
- def _value_matches(self, value, item):
- """Check if a value matches a given accept item."""
- return item == "*" or item.lower() == value.lower()
-
- def __getitem__(self, key):
- """Besides index lookup (getting item n) you can also pass it a string
- to get the quality for the item. If the item is not in the list, the
- returned quality is ``0``.
- """
- if isinstance(key, string_types):
- return self.quality(key)
- return list.__getitem__(self, key)
-
- def quality(self, key):
- """Returns the quality of the key.
-
- .. versionadded:: 0.6
- In previous versions you had to use the item-lookup syntax
- (eg: ``obj[key]`` instead of ``obj.quality(key)``)
- """
- for item, quality in self:
- if self._value_matches(key, item):
- return quality
- return 0
-
- def __contains__(self, value):
- for item, _quality in self:
- if self._value_matches(value, item):
- return True
- return False
-
- def __repr__(self):
- return "%s([%s])" % (
- self.__class__.__name__,
- ", ".join("(%r, %s)" % (x, y) for x, y in self),
- )
-
- def index(self, key):
- """Get the position of an entry or raise :exc:`ValueError`.
-
- :param key: The key to be looked up.
-
- .. versionchanged:: 0.5
- This used to raise :exc:`IndexError`, which was inconsistent
- with the list API.
- """
- if isinstance(key, string_types):
- for idx, (item, _quality) in enumerate(self):
- if self._value_matches(key, item):
- return idx
- raise ValueError(key)
- return list.index(self, key)
-
- def find(self, key):
- """Get the position of an entry or return -1.
-
- :param key: The key to be looked up.
- """
- try:
- return self.index(key)
- except ValueError:
- return -1
-
- def values(self):
- """Iterate over all values."""
- for item in self:
- yield item[0]
-
- def to_header(self):
- """Convert the header set into an HTTP header string."""
- result = []
- for value, quality in self:
- if quality != 1:
- value = "%s;q=%s" % (value, quality)
- result.append(value)
- return ",".join(result)
-
- def __str__(self):
- return self.to_header()
-
- def _best_single_match(self, match):
- for client_item, quality in self:
- if self._value_matches(match, client_item):
- # self is sorted by specificity descending, we can exit
- return client_item, quality
-
- def best_match(self, matches, default=None):
- """Returns the best match from a list of possible matches based
- on the specificity and quality of the client. If two items have the
- same quality and specificity, the one is returned that comes first.
-
- :param matches: a list of matches to check for
- :param default: the value that is returned if none match
- """
- result = default
- best_quality = -1
- best_specificity = (-1,)
- for server_item in matches:
- match = self._best_single_match(server_item)
- if not match:
- continue
- client_item, quality = match
- specificity = self._specificity(client_item)
- if quality <= 0 or quality < best_quality:
- continue
- # better quality or same quality but more specific => better match
- if quality > best_quality or specificity > best_specificity:
- result = server_item
- best_quality = quality
- best_specificity = specificity
- return result
-
- @property
- def best(self):
- """The best match as value."""
- if self:
- return self[0][0]
-
-
-class MIMEAccept(Accept):
- """Like :class:`Accept` but with special methods and behavior for
- mimetypes.
- """
-
- def _specificity(self, value):
- return tuple(x != "*" for x in value.split("/", 1))
-
- def _value_matches(self, value, item):
- def _normalize(x):
- x = x.lower()
- return ("*", "*") if x == "*" else x.split("/", 1)
-
- # this is from the application which is trusted. to avoid developer
- # frustration we actually check these for valid values
- if "/" not in value:
- raise ValueError("invalid mimetype %r" % value)
- value_type, value_subtype = _normalize(value)
- if value_type == "*" and value_subtype != "*":
- raise ValueError("invalid mimetype %r" % value)
-
- if "/" not in item:
- return False
- item_type, item_subtype = _normalize(item)
- if item_type == "*" and item_subtype != "*":
- return False
- return (
- item_type == item_subtype == "*" or value_type == value_subtype == "*"
- ) or (
- item_type == value_type
- and (
- item_subtype == "*"
- or value_subtype == "*"
- or item_subtype == value_subtype
- )
- )
-
- @property
- def accept_html(self):
- """True if this object accepts HTML."""
- return (
- "text/html" in self or "application/xhtml+xml" in self or self.accept_xhtml
- )
-
- @property
- def accept_xhtml(self):
- """True if this object accepts XHTML."""
- return "application/xhtml+xml" in self or "application/xml" in self
-
- @property
- def accept_json(self):
- """True if this object accepts JSON."""
- return "application/json" in self
-
-
-class LanguageAccept(Accept):
- """Like :class:`Accept` but with normalization for languages."""
-
- def _value_matches(self, value, item):
- def _normalize(language):
- return _locale_delim_re.split(language.lower())
-
- return item == "*" or _normalize(value) == _normalize(item)
-
-
-class CharsetAccept(Accept):
- """Like :class:`Accept` but with normalization for charsets."""
-
- def _value_matches(self, value, item):
- def _normalize(name):
- try:
- return codecs.lookup(name).name
- except LookupError:
- return name.lower()
-
- return item == "*" or _normalize(value) == _normalize(item)
-
-
-def cache_property(key, empty, type):
- """Return a new property object for a cache header. Useful if you
- want to add support for a cache extension in a subclass."""
- return property(
- lambda x: x._get_cache_value(key, empty, type),
- lambda x, v: x._set_cache_value(key, v, type),
- lambda x: x._del_cache_value(key),
- "accessor for %r" % key,
- )
-
-
-class _CacheControl(UpdateDictMixin, dict):
- """Subclass of a dict that stores values for a Cache-Control header. It
- has accessors for all the cache-control directives specified in RFC 2616.
- The class does not differentiate between request and response directives.
-
- Because the cache-control directives in the HTTP header use dashes the
- python descriptors use underscores for that.
-
- To get a header of the :class:`CacheControl` object again you can convert
- the object into a string or call the :meth:`to_header` method. If you plan
- to subclass it and add your own items have a look at the sourcecode for
- that class.
-
- .. versionchanged:: 0.4
-
- Setting `no_cache` or `private` to boolean `True` will set the implicit
- none-value which is ``*``:
-
- >>> cc = ResponseCacheControl()
- >>> cc.no_cache = True
- >>> cc
- <ResponseCacheControl 'no-cache'>
- >>> cc.no_cache
- '*'
- >>> cc.no_cache = None
- >>> cc
- <ResponseCacheControl ''>
-
- In versions before 0.5 the behavior documented here affected the now
- no longer existing `CacheControl` class.
- """
-
- no_cache = cache_property("no-cache", "*", None)
- no_store = cache_property("no-store", None, bool)
- max_age = cache_property("max-age", -1, int)
- no_transform = cache_property("no-transform", None, None)
-
- def __init__(self, values=(), on_update=None):
- dict.__init__(self, values or ())
- self.on_update = on_update
- self.provided = values is not None
-
- def _get_cache_value(self, key, empty, type):
- """Used internally by the accessor properties."""
- if type is bool:
- return key in self
- if key in self:
- value = self[key]
- if value is None:
- return empty
- elif type is not None:
- try:
- value = type(value)
- except ValueError:
- pass
- return value
-
- def _set_cache_value(self, key, value, type):
- """Used internally by the accessor properties."""
- if type is bool:
- if value:
- self[key] = None
- else:
- self.pop(key, None)
- else:
- if value is None:
- self.pop(key)
- elif value is True:
- self[key] = None
- else:
- self[key] = value
-
- def _del_cache_value(self, key):
- """Used internally by the accessor properties."""
- if key in self:
- del self[key]
-
- def to_header(self):
- """Convert the stored values into a cache control header."""
- return dump_header(self)
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "<%s %s>" % (
- self.__class__.__name__,
- " ".join("%s=%r" % (k, v) for k, v in sorted(self.items())),
- )
-
-
-class RequestCacheControl(ImmutableDictMixin, _CacheControl):
- """A cache control for requests. This is immutable and gives access
- to all the request-relevant cache control headers.
-
- To get a header of the :class:`RequestCacheControl` object again you can
- convert the object into a string or call the :meth:`to_header` method. If
- you plan to subclass it and add your own items have a look at the sourcecode
- for that class.
-
- .. versionadded:: 0.5
- In previous versions a `CacheControl` class existed that was used
- both for request and response.
- """
-
- max_stale = cache_property("max-stale", "*", int)
- min_fresh = cache_property("min-fresh", "*", int)
- no_transform = cache_property("no-transform", None, None)
- only_if_cached = cache_property("only-if-cached", None, bool)
-
-
-class ResponseCacheControl(_CacheControl):
- """A cache control for responses. Unlike :class:`RequestCacheControl`
- this is mutable and gives access to response-relevant cache control
- headers.
-
- To get a header of the :class:`ResponseCacheControl` object again you can
- convert the object into a string or call the :meth:`to_header` method. If
- you plan to subclass it and add your own items have a look at the sourcecode
- for that class.
-
- .. versionadded:: 0.5
- In previous versions a `CacheControl` class existed that was used
- both for request and response.
- """
-
- public = cache_property("public", None, bool)
- private = cache_property("private", "*", None)
- must_revalidate = cache_property("must-revalidate", None, bool)
- proxy_revalidate = cache_property("proxy-revalidate", None, bool)
- s_maxage = cache_property("s-maxage", None, None)
-
-
-# attach cache_property to the _CacheControl as staticmethod
-# so that others can reuse it.
-_CacheControl.cache_property = staticmethod(cache_property)
-
-
-class CallbackDict(UpdateDictMixin, dict):
- """A dict that calls a function passed every time something is changed.
- The function is passed the dict instance.
- """
-
- def __init__(self, initial=None, on_update=None):
- dict.__init__(self, initial or ())
- self.on_update = on_update
-
- def __repr__(self):
- return "<%s %s>" % (self.__class__.__name__, dict.__repr__(self))
-
-
-class HeaderSet(collections_abc.MutableSet):
- """Similar to the :class:`ETags` class this implements a set-like structure.
- Unlike :class:`ETags` this is case insensitive and used for vary, allow, and
- content-language headers.
-
- If not constructed using the :func:`parse_set_header` function the
- instantiation works like this:
-
- >>> hs = HeaderSet(['foo', 'bar', 'baz'])
- >>> hs
- HeaderSet(['foo', 'bar', 'baz'])
- """
-
- def __init__(self, headers=None, on_update=None):
- self._headers = list(headers or ())
- self._set = set([x.lower() for x in self._headers])
- self.on_update = on_update
-
- def add(self, header):
- """Add a new header to the set."""
- self.update((header,))
-
- def remove(self, header):
- """Remove a header from the set. This raises an :exc:`KeyError` if the
- header is not in the set.
-
- .. versionchanged:: 0.5
- In older versions a :exc:`IndexError` was raised instead of a
- :exc:`KeyError` if the object was missing.
-
- :param header: the header to be removed.
- """
- key = header.lower()
- if key not in self._set:
- raise KeyError(header)
- self._set.remove(key)
- for idx, key in enumerate(self._headers):
- if key.lower() == header:
- del self._headers[idx]
- break
- if self.on_update is not None:
- self.on_update(self)
-
- def update(self, iterable):
- """Add all the headers from the iterable to the set.
-
- :param iterable: updates the set with the items from the iterable.
- """
- inserted_any = False
- for header in iterable:
- key = header.lower()
- if key not in self._set:
- self._headers.append(header)
- self._set.add(key)
- inserted_any = True
- if inserted_any and self.on_update is not None:
- self.on_update(self)
-
- def discard(self, header):
- """Like :meth:`remove` but ignores errors.
-
- :param header: the header to be discarded.
- """
- try:
- return self.remove(header)
- except KeyError:
- pass
-
- def find(self, header):
- """Return the index of the header in the set or return -1 if not found.
-
- :param header: the header to be looked up.
- """
- header = header.lower()
- for idx, item in enumerate(self._headers):
- if item.lower() == header:
- return idx
- return -1
-
- def index(self, header):
- """Return the index of the header in the set or raise an
- :exc:`IndexError`.
-
- :param header: the header to be looked up.
- """
- rv = self.find(header)
- if rv < 0:
- raise IndexError(header)
- return rv
-
- def clear(self):
- """Clear the set."""
- self._set.clear()
- del self._headers[:]
- if self.on_update is not None:
- self.on_update(self)
-
- def as_set(self, preserve_casing=False):
- """Return the set as real python set type. When calling this, all
- the items are converted to lowercase and the ordering is lost.
-
- :param preserve_casing: if set to `True` the items in the set returned
- will have the original case like in the
- :class:`HeaderSet`, otherwise they will
- be lowercase.
- """
- if preserve_casing:
- return set(self._headers)
- return set(self._set)
-
- def to_header(self):
- """Convert the header set into an HTTP header string."""
- return ", ".join(map(quote_header_value, self._headers))
-
- def __getitem__(self, idx):
- return self._headers[idx]
-
- def __delitem__(self, idx):
- rv = self._headers.pop(idx)
- self._set.remove(rv.lower())
- if self.on_update is not None:
- self.on_update(self)
-
- def __setitem__(self, idx, value):
- old = self._headers[idx]
- self._set.remove(old.lower())
- self._headers[idx] = value
- self._set.add(value.lower())
- if self.on_update is not None:
- self.on_update(self)
-
- def __contains__(self, header):
- return header.lower() in self._set
-
- def __len__(self):
- return len(self._set)
-
- def __iter__(self):
- return iter(self._headers)
-
- def __nonzero__(self):
- return bool(self._set)
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "%s(%r)" % (self.__class__.__name__, self._headers)
-
-
-class ETags(collections_abc.Container, collections_abc.Iterable):
- """A set that can be used to check if one etag is present in a collection
- of etags.
- """
-
- def __init__(self, strong_etags=None, weak_etags=None, star_tag=False):
- self._strong = frozenset(not star_tag and strong_etags or ())
- self._weak = frozenset(weak_etags or ())
- self.star_tag = star_tag
-
- def as_set(self, include_weak=False):
- """Convert the `ETags` object into a python set. Per default all the
- weak etags are not part of this set."""
- rv = set(self._strong)
- if include_weak:
- rv.update(self._weak)
- return rv
-
- def is_weak(self, etag):
- """Check if an etag is weak."""
- return etag in self._weak
-
- def is_strong(self, etag):
- """Check if an etag is strong."""
- return etag in self._strong
-
- def contains_weak(self, etag):
- """Check if an etag is part of the set including weak and strong tags."""
- return self.is_weak(etag) or self.contains(etag)
-
- def contains(self, etag):
- """Check if an etag is part of the set ignoring weak tags.
- It is also possible to use the ``in`` operator.
- """
- if self.star_tag:
- return True
- return self.is_strong(etag)
-
- def contains_raw(self, etag):
- """When passed a quoted tag it will check if this tag is part of the
- set. If the tag is weak it is checked against weak and strong tags,
- otherwise strong only."""
- etag, weak = unquote_etag(etag)
- if weak:
- return self.contains_weak(etag)
- return self.contains(etag)
-
- def to_header(self):
- """Convert the etags set into a HTTP header string."""
- if self.star_tag:
- return "*"
- return ", ".join(
- ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak]
- )
-
- def __call__(self, etag=None, data=None, include_weak=False):
- if [etag, data].count(None) != 1:
- raise TypeError("either tag or data required, but at least one")
- if etag is None:
- etag = generate_etag(data)
- if include_weak:
- if etag in self._weak:
- return True
- return etag in self._strong
-
- def __bool__(self):
- return bool(self.star_tag or self._strong or self._weak)
-
- __nonzero__ = __bool__
-
- def __str__(self):
- return self.to_header()
-
- def __iter__(self):
- return iter(self._strong)
-
- def __contains__(self, etag):
- return self.contains(etag)
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, str(self))
-
-
-class IfRange(object):
- """Very simple object that represents the `If-Range` header in parsed
- form. It will either have neither a etag or date or one of either but
- never both.
-
- .. versionadded:: 0.7
- """
-
- def __init__(self, etag=None, date=None):
- #: The etag parsed and unquoted. Ranges always operate on strong
- #: etags so the weakness information is not necessary.
- self.etag = etag
- #: The date in parsed format or `None`.
- self.date = date
-
- def to_header(self):
- """Converts the object back into an HTTP header."""
- if self.date is not None:
- return http_date(self.date)
- if self.etag is not None:
- return quote_etag(self.etag)
- return ""
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, str(self))
-
-
-class Range(object):
- """Represents a ``Range`` header. All methods only support only
- bytes as the unit. Stores a list of ranges if given, but the methods
- only work if only one range is provided.
-
- :raise ValueError: If the ranges provided are invalid.
-
- .. versionchanged:: 0.15
- The ranges passed in are validated.
-
- .. versionadded:: 0.7
- """
-
- def __init__(self, units, ranges):
- #: The units of this range. Usually "bytes".
- self.units = units
- #: A list of ``(begin, end)`` tuples for the range header provided.
- #: The ranges are non-inclusive.
- self.ranges = ranges
-
- for start, end in ranges:
- if start is None or (end is not None and (start < 0 or start >= end)):
- raise ValueError("{} is not a valid range.".format((start, end)))
-
- def range_for_length(self, length):
- """If the range is for bytes, the length is not None and there is
- exactly one range and it is satisfiable it returns a ``(start, stop)``
- tuple, otherwise `None`.
- """
- if self.units != "bytes" or length is None or len(self.ranges) != 1:
- return None
- start, end = self.ranges[0]
- if end is None:
- end = length
- if start < 0:
- start += length
- if is_byte_range_valid(start, end, length):
- return start, min(end, length)
-
- def make_content_range(self, length):
- """Creates a :class:`~werkzeug.datastructures.ContentRange` object
- from the current range and given content length.
- """
- rng = self.range_for_length(length)
- if rng is not None:
- return ContentRange(self.units, rng[0], rng[1], length)
-
- def to_header(self):
- """Converts the object back into an HTTP header."""
- ranges = []
- for begin, end in self.ranges:
- if end is None:
- ranges.append("%s-" % begin if begin >= 0 else str(begin))
- else:
- ranges.append("%s-%s" % (begin, end - 1))
- return "%s=%s" % (self.units, ",".join(ranges))
-
- def to_content_range_header(self, length):
- """Converts the object into `Content-Range` HTTP header,
- based on given length
- """
- range_for_length = self.range_for_length(length)
- if range_for_length is not None:
- return "%s %d-%d/%d" % (
- self.units,
- range_for_length[0],
- range_for_length[1] - 1,
- length,
- )
- return None
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, str(self))
-
-
-class ContentRange(object):
- """Represents the content range header.
-
- .. versionadded:: 0.7
- """
-
- def __init__(self, units, start, stop, length=None, on_update=None):
- assert is_byte_range_valid(start, stop, length), "Bad range provided"
- self.on_update = on_update
- self.set(start, stop, length, units)
-
- def _callback_property(name): # noqa: B902
- def fget(self):
- return getattr(self, name)
-
- def fset(self, value):
- setattr(self, name, value)
- if self.on_update is not None:
- self.on_update(self)
-
- return property(fget, fset)
-
- #: The units to use, usually "bytes"
- units = _callback_property("_units")
- #: The start point of the range or `None`.
- start = _callback_property("_start")
- #: The stop point of the range (non-inclusive) or `None`. Can only be
- #: `None` if also start is `None`.
- stop = _callback_property("_stop")
- #: The length of the range or `None`.
- length = _callback_property("_length")
- del _callback_property
-
- def set(self, start, stop, length=None, units="bytes"):
- """Simple method to update the ranges."""
- assert is_byte_range_valid(start, stop, length), "Bad range provided"
- self._units = units
- self._start = start
- self._stop = stop
- self._length = length
- if self.on_update is not None:
- self.on_update(self)
-
- def unset(self):
- """Sets the units to `None` which indicates that the header should
- no longer be used.
- """
- self.set(None, None, units=None)
-
- def to_header(self):
- if self.units is None:
- return ""
- if self.length is None:
- length = "*"
- else:
- length = self.length
- if self.start is None:
- return "%s */%s" % (self.units, length)
- return "%s %s-%s/%s" % (self.units, self.start, self.stop - 1, length)
-
- def __nonzero__(self):
- return self.units is not None
-
- __bool__ = __nonzero__
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, str(self))
-
-
-class Authorization(ImmutableDictMixin, dict):
- """Represents an `Authorization` header sent by the client. You should
- not create this kind of object yourself but use it when it's returned by
- the `parse_authorization_header` function.
-
- This object is a dict subclass and can be altered by setting dict items
- but it should be considered immutable as it's returned by the client and
- not meant for modifications.
-
- .. versionchanged:: 0.5
- This object became immutable.
- """
-
- def __init__(self, auth_type, data=None):
- dict.__init__(self, data or {})
- self.type = auth_type
-
- username = property(
- lambda self: self.get("username"),
- doc="""
- The username transmitted. This is set for both basic and digest
- auth all the time.""",
- )
- password = property(
- lambda self: self.get("password"),
- doc="""
- When the authentication type is basic this is the password
- transmitted by the client, else `None`.""",
- )
- realm = property(
- lambda self: self.get("realm"),
- doc="""
- This is the server realm sent back for HTTP digest auth.""",
- )
- nonce = property(
- lambda self: self.get("nonce"),
- doc="""
- The nonce the server sent for digest auth, sent back by the client.
- A nonce should be unique for every 401 response for HTTP digest
- auth.""",
- )
- uri = property(
- lambda self: self.get("uri"),
- doc="""
- The URI from Request-URI of the Request-Line; duplicated because
- proxies are allowed to change the Request-Line in transit. HTTP
- digest auth only.""",
- )
- nc = property(
- lambda self: self.get("nc"),
- doc="""
- The nonce count value transmitted by clients if a qop-header is
- also transmitted. HTTP digest auth only.""",
- )
- cnonce = property(
- lambda self: self.get("cnonce"),
- doc="""
- If the server sent a qop-header in the ``WWW-Authenticate``
- header, the client has to provide this value for HTTP digest auth.
- See the RFC for more details.""",
- )
- response = property(
- lambda self: self.get("response"),
- doc="""
- A string of 32 hex digits computed as defined in RFC 2617, which
- proves that the user knows a password. Digest auth only.""",
- )
- opaque = property(
- lambda self: self.get("opaque"),
- doc="""
- The opaque header from the server returned unchanged by the client.
- It is recommended that this string be base64 or hexadecimal data.
- Digest auth only.""",
- )
- qop = property(
- lambda self: self.get("qop"),
- doc="""
- Indicates what "quality of protection" the client has applied to
- the message for HTTP digest auth. Note that this is a single token,
- not a quoted list of alternatives as in WWW-Authenticate.""",
- )
-
-
-class WWWAuthenticate(UpdateDictMixin, dict):
- """Provides simple access to `WWW-Authenticate` headers."""
-
- #: list of keys that require quoting in the generated header
- _require_quoting = frozenset(["domain", "nonce", "opaque", "realm", "qop"])
-
- def __init__(self, auth_type=None, values=None, on_update=None):
- dict.__init__(self, values or ())
- if auth_type:
- self["__auth_type__"] = auth_type
- self.on_update = on_update
-
- def set_basic(self, realm="authentication required"):
- """Clear the auth info and enable basic auth."""
- dict.clear(self)
- dict.update(self, {"__auth_type__": "basic", "realm": realm})
- if self.on_update:
- self.on_update(self)
-
- def set_digest(
- self, realm, nonce, qop=("auth",), opaque=None, algorithm=None, stale=False
- ):
- """Clear the auth info and enable digest auth."""
- d = {
- "__auth_type__": "digest",
- "realm": realm,
- "nonce": nonce,
- "qop": dump_header(qop),
- }
- if stale:
- d["stale"] = "TRUE"
- if opaque is not None:
- d["opaque"] = opaque
- if algorithm is not None:
- d["algorithm"] = algorithm
- dict.clear(self)
- dict.update(self, d)
- if self.on_update:
- self.on_update(self)
-
- def to_header(self):
- """Convert the stored values into a WWW-Authenticate header."""
- d = dict(self)
- auth_type = d.pop("__auth_type__", None) or "basic"
- return "%s %s" % (
- auth_type.title(),
- ", ".join(
- [
- "%s=%s"
- % (
- key,
- quote_header_value(
- value, allow_token=key not in self._require_quoting
- ),
- )
- for key, value in iteritems(d)
- ]
- ),
- )
-
- def __str__(self):
- return self.to_header()
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, self.to_header())
-
- def auth_property(name, doc=None): # noqa: B902
- """A static helper function for subclasses to add extra authentication
- system properties onto a class::
-
- class FooAuthenticate(WWWAuthenticate):
- special_realm = auth_property('special_realm')
-
- For more information have a look at the sourcecode to see how the
- regular properties (:attr:`realm` etc.) are implemented.
- """
-
- def _set_value(self, value):
- if value is None:
- self.pop(name, None)
- else:
- self[name] = str(value)
-
- return property(lambda x: x.get(name), _set_value, doc=doc)
-
- def _set_property(name, doc=None): # noqa: B902
- def fget(self):
- def on_update(header_set):
- if not header_set and name in self:
- del self[name]
- elif header_set:
- self[name] = header_set.to_header()
-
- return parse_set_header(self.get(name), on_update)
-
- return property(fget, doc=doc)
-
- type = auth_property(
- "__auth_type__",
- doc="""The type of the auth mechanism. HTTP currently specifies
- ``Basic`` and ``Digest``.""",
- )
- realm = auth_property(
- "realm",
- doc="""A string to be displayed to users so they know which
- username and password to use. This string should contain at
- least the name of the host performing the authentication and
- might additionally indicate the collection of users who might
- have access.""",
- )
- domain = _set_property(
- "domain",
- doc="""A list of URIs that define the protection space. If a URI
- is an absolute path, it is relative to the canonical root URL of
- the server being accessed.""",
- )
- nonce = auth_property(
- "nonce",
- doc="""
- A server-specified data string which should be uniquely generated
- each time a 401 response is made. It is recommended that this
- string be base64 or hexadecimal data.""",
- )
- opaque = auth_property(
- "opaque",
- doc="""A string of data, specified by the server, which should
- be returned by the client unchanged in the Authorization header
- of subsequent requests with URIs in the same protection space.
- It is recommended that this string be base64 or hexadecimal
- data.""",
- )
- algorithm = auth_property(
- "algorithm",
- doc="""A string indicating a pair of algorithms used to produce
- the digest and a checksum. If this is not present it is assumed
- to be "MD5". If the algorithm is not understood, the challenge
- should be ignored (and a different one used, if there is more
- than one).""",
- )
- qop = _set_property(
- "qop",
- doc="""A set of quality-of-privacy directives such as auth and
- auth-int.""",
- )
-
- @property
- def stale(self):
- """A flag, indicating that the previous request from the client
- was rejected because the nonce value was stale.
- """
- val = self.get("stale")
- if val is not None:
- return val.lower() == "true"
-
- @stale.setter
- def stale(self, value):
- if value is None:
- self.pop("stale", None)
- else:
- self["stale"] = "TRUE" if value else "FALSE"
-
- auth_property = staticmethod(auth_property)
- del _set_property
-
-
-class FileStorage(object):
- """The :class:`FileStorage` class is a thin wrapper over incoming files.
- It is used by the request object to represent uploaded files. All the
- attributes of the wrapper stream are proxied by the file storage so
- it's possible to do ``storage.read()`` instead of the long form
- ``storage.stream.read()``.
- """
-
- def __init__(
- self,
- stream=None,
- filename=None,
- name=None,
- content_type=None,
- content_length=None,
- headers=None,
- ):
- self.name = name
- self.stream = stream or BytesIO()
-
- # if no filename is provided we can attempt to get the filename
- # from the stream object passed. There we have to be careful to
- # skip things like <fdopen>, <stderr> etc. Python marks these
- # special filenames with angular brackets.
- if filename is None:
- filename = getattr(stream, "name", None)
- s = make_literal_wrapper(filename)
- if filename and filename[0] == s("<") and filename[-1] == s(">"):
- filename = None
-
- # On Python 3 we want to make sure the filename is always unicode.
- # This might not be if the name attribute is bytes due to the
- # file being opened from the bytes API.
- if not PY2 and isinstance(filename, bytes):
- filename = filename.decode(get_filesystem_encoding(), "replace")
-
- self.filename = filename
- if headers is None:
- headers = Headers()
- self.headers = headers
- if content_type is not None:
- headers["Content-Type"] = content_type
- if content_length is not None:
- headers["Content-Length"] = str(content_length)
-
- def _parse_content_type(self):
- if not hasattr(self, "_parsed_content_type"):
- self._parsed_content_type = parse_options_header(self.content_type)
-
- @property
- def content_type(self):
- """The content-type sent in the header. Usually not available"""
- return self.headers.get("content-type")
-
- @property
- def content_length(self):
- """The content-length sent in the header. Usually not available"""
- return int(self.headers.get("content-length") or 0)
-
- @property
- def mimetype(self):
- """Like :attr:`content_type`, but without parameters (eg, without
- charset, type etc.) and always lowercase. For example if the content
- type is ``text/HTML; charset=utf-8`` the mimetype would be
- ``'text/html'``.
-
- .. versionadded:: 0.7
- """
- self._parse_content_type()
- return self._parsed_content_type[0].lower()
-
- @property
- def mimetype_params(self):
- """The mimetype parameters as dict. For example if the content
- type is ``text/html; charset=utf-8`` the params would be
- ``{'charset': 'utf-8'}``.
-
- .. versionadded:: 0.7
- """
- self._parse_content_type()
- return self._parsed_content_type[1]
-
- def save(self, dst, buffer_size=16384):
- """Save the file to a destination path or file object. If the
- destination is a file object you have to close it yourself after the
- call. The buffer size is the number of bytes held in memory during
- the copy process. It defaults to 16KB.
-
- For secure file saving also have a look at :func:`secure_filename`.
-
- :param dst: a filename or open file object the uploaded file
- is saved to.
- :param buffer_size: the size of the buffer. This works the same as
- the `length` parameter of
- :func:`shutil.copyfileobj`.
- """
- from shutil import copyfileobj
-
- close_dst = False
- if isinstance(dst, string_types):
- dst = open(dst, "wb")
- close_dst = True
- try:
- copyfileobj(self.stream, dst, buffer_size)
- finally:
- if close_dst:
- dst.close()
-
- def close(self):
- """Close the underlying file if possible."""
- try:
- self.stream.close()
- except Exception:
- pass
-
- def __nonzero__(self):
- return bool(self.filename)
-
- __bool__ = __nonzero__
-
- def __getattr__(self, name):
- try:
- return getattr(self.stream, name)
- except AttributeError:
- # SpooledTemporaryFile doesn't implement IOBase, get the
- # attribute from its backing file instead.
- # https://github.com/python/cpython/pull/3249
- if hasattr(self.stream, "_file"):
- return getattr(self.stream._file, name)
- raise
-
- def __iter__(self):
- return iter(self.stream)
-
- def __repr__(self):
- return "<%s: %r (%r)>" % (
- self.__class__.__name__,
- self.filename,
- self.content_type,
- )
-
-
-# circular dependencies
-from . import exceptions
-from .http import dump_header
-from .http import dump_options_header
-from .http import generate_etag
-from .http import http_date
-from .http import is_byte_range_valid
-from .http import parse_options_header
-from .http import parse_set_header
-from .http import quote_etag
-from .http import quote_header_value
-from .http import unquote_etag
diff --git a/python/werkzeug/exceptions.py b/python/werkzeug/exceptions.py
deleted file mode 100644
index fb6528d..0000000
--- a/python/werkzeug/exceptions.py
+++ /dev/null
@@ -1,774 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.exceptions
- ~~~~~~~~~~~~~~~~~~~
-
- This module implements a number of Python exceptions you can raise from
- within your views to trigger a standard non-200 response.
-
-
- Usage Example
- -------------
-
- ::
-
- from werkzeug.wrappers import BaseRequest
- from werkzeug.wsgi import responder
- from werkzeug.exceptions import HTTPException, NotFound
-
- def view(request):
- raise NotFound()
-
- @responder
- def application(environ, start_response):
- request = BaseRequest(environ)
- try:
- return view(request)
- except HTTPException as e:
- return e
-
-
- As you can see from this example those exceptions are callable WSGI
- applications. Because of Python 2.4 compatibility those do not extend
- from the response objects but only from the python exception class.
-
- As a matter of fact they are not Werkzeug response objects. However you
- can get a response object by calling ``get_response()`` on a HTTP
- exception.
-
- Keep in mind that you have to pass an environment to ``get_response()``
- because some errors fetch additional information from the WSGI
- environment.
-
- If you want to hook in a different exception page to say, a 404 status
- code, you can add a second except for a specific subclass of an error::
-
- @responder
- def application(environ, start_response):
- request = BaseRequest(environ)
- try:
- return view(request)
- except NotFound, e:
- return not_found(request)
- except HTTPException, e:
- return e
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import sys
-
-import werkzeug
-
-# Because of bootstrapping reasons we need to manually patch ourselves
-# onto our parent module.
-werkzeug.exceptions = sys.modules[__name__]
-
-from ._compat import implements_to_string
-from ._compat import integer_types
-from ._compat import iteritems
-from ._compat import text_type
-from ._internal import _get_environ
-from .wrappers import Response
-
-
-@implements_to_string
-class HTTPException(Exception):
- """Baseclass for all HTTP exceptions. This exception can be called as WSGI
- application to render a default error page or you can catch the subclasses
- of it independently and render nicer error messages.
- """
-
- code = None
- description = None
-
- def __init__(self, description=None, response=None):
- super(Exception, self).__init__()
- if description is not None:
- self.description = description
- self.response = response
-
- @classmethod
- def wrap(cls, exception, name=None):
- """Create an exception that is a subclass of the calling HTTP
- exception and the ``exception`` argument.
-
- The first argument to the class will be passed to the
- wrapped ``exception``, the rest to the HTTP exception. If
- ``self.args`` is not empty, the wrapped exception message is
- added to the HTTP exception description.
-
- .. versionchanged:: 0.15
- The description includes the wrapped exception message.
- """
-
- class newcls(cls, exception):
- def __init__(self, arg=None, *args, **kwargs):
- super(cls, self).__init__(*args, **kwargs)
-
- if arg is None:
- exception.__init__(self)
- else:
- exception.__init__(self, arg)
-
- def get_description(self, environ=None):
- out = super(cls, self).get_description(environ=environ)
-
- if self.args:
- out += "<p><pre><code>{}: {}</code></pre></p>".format(
- exception.__name__, escape(exception.__str__(self))
- )
-
- return out
-
- newcls.__module__ = sys._getframe(1).f_globals.get("__name__")
- newcls.__name__ = name or cls.__name__ + exception.__name__
- return newcls
-
- @property
- def name(self):
- """The status name."""
- return HTTP_STATUS_CODES.get(self.code, "Unknown Error")
-
- def get_description(self, environ=None):
- """Get the description."""
- return u"<p>%s</p>" % escape(self.description)
-
- def get_body(self, environ=None):
- """Get the HTML body."""
- return text_type(
- (
- u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
- u"<title>%(code)s %(name)s</title>\n"
- u"<h1>%(name)s</h1>\n"
- u"%(description)s\n"
- )
- % {
- "code": self.code,
- "name": escape(self.name),
- "description": self.get_description(environ),
- }
- )
-
- def get_headers(self, environ=None):
- """Get a list of headers."""
- return [("Content-Type", "text/html")]
-
- def get_response(self, environ=None):
- """Get a response object. If one was passed to the exception
- it's returned directly.
-
- :param environ: the optional environ for the request. This
- can be used to modify the response depending
- on how the request looked like.
- :return: a :class:`Response` object or a subclass thereof.
- """
- if self.response is not None:
- return self.response
- if environ is not None:
- environ = _get_environ(environ)
- headers = self.get_headers(environ)
- return Response(self.get_body(environ), self.code, headers)
-
- def __call__(self, environ, start_response):
- """Call the exception as WSGI application.
-
- :param environ: the WSGI environment.
- :param start_response: the response callable provided by the WSGI
- server.
- """
- response = self.get_response(environ)
- return response(environ, start_response)
-
- def __str__(self):
- code = self.code if self.code is not None else "???"
- return "%s %s: %s" % (code, self.name, self.description)
-
- def __repr__(self):
- code = self.code if self.code is not None else "???"
- return "<%s '%s: %s'>" % (self.__class__.__name__, code, self.name)
-
-
-class BadRequest(HTTPException):
- """*400* `Bad Request`
-
- Raise if the browser sends something to the application the application
- or server cannot handle.
- """
-
- code = 400
- description = (
- "The browser (or proxy) sent a request that this server could "
- "not understand."
- )
-
-
-class ClientDisconnected(BadRequest):
- """Internal exception that is raised if Werkzeug detects a disconnected
- client. Since the client is already gone at that point attempting to
- send the error message to the client might not work and might ultimately
- result in another exception in the server. Mainly this is here so that
- it is silenced by default as far as Werkzeug is concerned.
-
- Since disconnections cannot be reliably detected and are unspecified
- by WSGI to a large extent this might or might not be raised if a client
- is gone.
-
- .. versionadded:: 0.8
- """
-
-
-class SecurityError(BadRequest):
- """Raised if something triggers a security error. This is otherwise
- exactly like a bad request error.
-
- .. versionadded:: 0.9
- """
-
-
-class BadHost(BadRequest):
- """Raised if the submitted host is badly formatted.
-
- .. versionadded:: 0.11.2
- """
-
-
-class Unauthorized(HTTPException):
- """*401* ``Unauthorized``
-
- Raise if the user is not authorized to access a resource.
-
- The ``www_authenticate`` argument should be used to set the
- ``WWW-Authenticate`` header. This is used for HTTP basic auth and
- other schemes. Use :class:`~werkzeug.datastructures.WWWAuthenticate`
- to create correctly formatted values. Strictly speaking a 401
- response is invalid if it doesn't provide at least one value for
- this header, although real clients typically don't care.
-
- :param description: Override the default message used for the body
- of the response.
- :param www-authenticate: A single value, or list of values, for the
- WWW-Authenticate header.
-
- .. versionchanged:: 0.15.3
- If the ``www_authenticate`` argument is not set, the
- ``WWW-Authenticate`` header is not set.
-
- .. versionchanged:: 0.15.3
- The ``response`` argument was restored.
-
- .. versionchanged:: 0.15.1
- ``description`` was moved back as the first argument, restoring
- its previous position.
-
- .. versionchanged:: 0.15.0
- ``www_authenticate`` was added as the first argument, ahead of
- ``description``.
- """
-
- code = 401
- description = (
- "The server could not verify that you are authorized to access"
- " the URL requested. You either supplied the wrong credentials"
- " (e.g. a bad password), or your browser doesn't understand"
- " how to supply the credentials required."
- )
-
- def __init__(self, description=None, response=None, www_authenticate=None):
- HTTPException.__init__(self, description, response)
-
- if www_authenticate is not None:
- if not isinstance(www_authenticate, (tuple, list)):
- www_authenticate = (www_authenticate,)
-
- self.www_authenticate = www_authenticate
-
- def get_headers(self, environ=None):
- headers = HTTPException.get_headers(self, environ)
- if self.www_authenticate:
- headers.append(
- ("WWW-Authenticate", ", ".join([str(x) for x in self.www_authenticate]))
- )
- return headers
-
-
-class Forbidden(HTTPException):
- """*403* `Forbidden`
-
- Raise if the user doesn't have the permission for the requested resource
- but was authenticated.
- """
-
- code = 403
- description = (
- "You don't have the permission to access the requested"
- " resource. It is either read-protected or not readable by the"
- " server."
- )
-
-
-class NotFound(HTTPException):
- """*404* `Not Found`
-
- Raise if a resource does not exist and never existed.
- """
-
- code = 404
- description = (
- "The requested URL was not found on the server. If you entered"
- " the URL manually please check your spelling and try again."
- )
-
-
-class MethodNotAllowed(HTTPException):
- """*405* `Method Not Allowed`
-
- Raise if the server used a method the resource does not handle. For
- example `POST` if the resource is view only. Especially useful for REST.
-
- The first argument for this exception should be a list of allowed methods.
- Strictly speaking the response would be invalid if you don't provide valid
- methods in the header which you can do with that list.
- """
-
- code = 405
- description = "The method is not allowed for the requested URL."
-
- def __init__(self, valid_methods=None, description=None):
- """Takes an optional list of valid http methods
- starting with werkzeug 0.3 the list will be mandatory."""
- HTTPException.__init__(self, description)
- self.valid_methods = valid_methods
-
- def get_headers(self, environ=None):
- headers = HTTPException.get_headers(self, environ)
- if self.valid_methods:
- headers.append(("Allow", ", ".join(self.valid_methods)))
- return headers
-
-
-class NotAcceptable(HTTPException):
- """*406* `Not Acceptable`
-
- Raise if the server can't return any content conforming to the
- `Accept` headers of the client.
- """
-
- code = 406
-
- description = (
- "The resource identified by the request is only capable of"
- " generating response entities which have content"
- " characteristics not acceptable according to the accept"
- " headers sent in the request."
- )
-
-
-class RequestTimeout(HTTPException):
- """*408* `Request Timeout`
-
- Raise to signalize a timeout.
- """
-
- code = 408
- description = (
- "The server closed the network connection because the browser"
- " didn't finish the request within the specified time."
- )
-
-
-class Conflict(HTTPException):
- """*409* `Conflict`
-
- Raise to signal that a request cannot be completed because it conflicts
- with the current state on the server.
-
- .. versionadded:: 0.7
- """
-
- code = 409
- description = (
- "A conflict happened while processing the request. The"
- " resource might have been modified while the request was being"
- " processed."
- )
-
-
-class Gone(HTTPException):
- """*410* `Gone`
-
- Raise if a resource existed previously and went away without new location.
- """
-
- code = 410
- description = (
- "The requested URL is no longer available on this server and"
- " there is no forwarding address. If you followed a link from a"
- " foreign page, please contact the author of this page."
- )
-
-
-class LengthRequired(HTTPException):
- """*411* `Length Required`
-
- Raise if the browser submitted data but no ``Content-Length`` header which
- is required for the kind of processing the server does.
- """
-
- code = 411
- description = (
- "A request with this method requires a valid <code>Content-"
- "Length</code> header."
- )
-
-
-class PreconditionFailed(HTTPException):
- """*412* `Precondition Failed`
-
- Status code used in combination with ``If-Match``, ``If-None-Match``, or
- ``If-Unmodified-Since``.
- """
-
- code = 412
- description = (
- "The precondition on the request for the URL failed positive evaluation."
- )
-
-
-class RequestEntityTooLarge(HTTPException):
- """*413* `Request Entity Too Large`
-
- The status code one should return if the data submitted exceeded a given
- limit.
- """
-
- code = 413
- description = "The data value transmitted exceeds the capacity limit."
-
-
-class RequestURITooLarge(HTTPException):
- """*414* `Request URI Too Large`
-
- Like *413* but for too long URLs.
- """
-
- code = 414
- description = (
- "The length of the requested URL exceeds the capacity limit for"
- " this server. The request cannot be processed."
- )
-
-
-class UnsupportedMediaType(HTTPException):
- """*415* `Unsupported Media Type`
-
- The status code returned if the server is unable to handle the media type
- the client transmitted.
- """
-
- code = 415
- description = (
- "The server does not support the media type transmitted in the request."
- )
-
-
-class RequestedRangeNotSatisfiable(HTTPException):
- """*416* `Requested Range Not Satisfiable`
-
- The client asked for an invalid part of the file.
-
- .. versionadded:: 0.7
- """
-
- code = 416
- description = "The server cannot provide the requested range."
-
- def __init__(self, length=None, units="bytes", description=None):
- """Takes an optional `Content-Range` header value based on ``length``
- parameter.
- """
- HTTPException.__init__(self, description)
- self.length = length
- self.units = units
-
- def get_headers(self, environ=None):
- headers = HTTPException.get_headers(self, environ)
- if self.length is not None:
- headers.append(("Content-Range", "%s */%d" % (self.units, self.length)))
- return headers
-
-
-class ExpectationFailed(HTTPException):
- """*417* `Expectation Failed`
-
- The server cannot meet the requirements of the Expect request-header.
-
- .. versionadded:: 0.7
- """
-
- code = 417
- description = "The server could not meet the requirements of the Expect header"
-
-
-class ImATeapot(HTTPException):
- """*418* `I'm a teapot`
-
- The server should return this if it is a teapot and someone attempted
- to brew coffee with it.
-
- .. versionadded:: 0.7
- """
-
- code = 418
- description = "This server is a teapot, not a coffee machine"
-
-
-class UnprocessableEntity(HTTPException):
- """*422* `Unprocessable Entity`
-
- Used if the request is well formed, but the instructions are otherwise
- incorrect.
- """
-
- code = 422
- description = (
- "The request was well-formed but was unable to be followed due"
- " to semantic errors."
- )
-
-
-class Locked(HTTPException):
- """*423* `Locked`
-
- Used if the resource that is being accessed is locked.
- """
-
- code = 423
- description = "The resource that is being accessed is locked."
-
-
-class FailedDependency(HTTPException):
- """*424* `Failed Dependency`
-
- Used if the method could not be performed on the resource
- because the requested action depended on another action and that action failed.
- """
-
- code = 424
- description = (
- "The method could not be performed on the resource because the"
- " requested action depended on another action and that action"
- " failed."
- )
-
-
-class PreconditionRequired(HTTPException):
- """*428* `Precondition Required`
-
- The server requires this request to be conditional, typically to prevent
- the lost update problem, which is a race condition between two or more
- clients attempting to update a resource through PUT or DELETE. By requiring
- each client to include a conditional header ("If-Match" or "If-Unmodified-
- Since") with the proper value retained from a recent GET request, the
- server ensures that each client has at least seen the previous revision of
- the resource.
- """
-
- code = 428
- description = (
- "This request is required to be conditional; try using"
- ' "If-Match" or "If-Unmodified-Since".'
- )
-
-
-class TooManyRequests(HTTPException):
- """*429* `Too Many Requests`
-
- The server is limiting the rate at which this user receives responses, and
- this request exceeds that rate. (The server may use any convenient method
- to identify users and their request rates). The server may include a
- "Retry-After" header to indicate how long the user should wait before
- retrying.
- """
-
- code = 429
- description = "This user has exceeded an allotted request count. Try again later."
-
-
-class RequestHeaderFieldsTooLarge(HTTPException):
- """*431* `Request Header Fields Too Large`
-
- The server refuses to process the request because the header fields are too
- large. One or more individual fields may be too large, or the set of all
- headers is too large.
- """
-
- code = 431
- description = "One or more header fields exceeds the maximum size."
-
-
-class UnavailableForLegalReasons(HTTPException):
- """*451* `Unavailable For Legal Reasons`
-
- This status code indicates that the server is denying access to the
- resource as a consequence of a legal demand.
- """
-
- code = 451
- description = "Unavailable for legal reasons."
-
-
-class InternalServerError(HTTPException):
- """*500* `Internal Server Error`
-
- Raise if an internal server error occurred. This is a good fallback if an
- unknown error occurred in the dispatcher.
- """
-
- code = 500
- description = (
- "The server encountered an internal error and was unable to"
- " complete your request. Either the server is overloaded or"
- " there is an error in the application."
- )
-
-
-class NotImplemented(HTTPException):
- """*501* `Not Implemented`
-
- Raise if the application does not support the action requested by the
- browser.
- """
-
- code = 501
- description = "The server does not support the action requested by the browser."
-
-
-class BadGateway(HTTPException):
- """*502* `Bad Gateway`
-
- If you do proxying in your application you should return this status code
- if you received an invalid response from the upstream server it accessed
- in attempting to fulfill the request.
- """
-
- code = 502
- description = (
- "The proxy server received an invalid response from an upstream server."
- )
-
-
-class ServiceUnavailable(HTTPException):
- """*503* `Service Unavailable`
-
- Status code you should return if a service is temporarily unavailable.
- """
-
- code = 503
- description = (
- "The server is temporarily unable to service your request due"
- " to maintenance downtime or capacity problems. Please try"
- " again later."
- )
-
-
-class GatewayTimeout(HTTPException):
- """*504* `Gateway Timeout`
-
- Status code you should return if a connection to an upstream server
- times out.
- """
-
- code = 504
- description = "The connection to an upstream server timed out."
-
-
-class HTTPVersionNotSupported(HTTPException):
- """*505* `HTTP Version Not Supported`
-
- The server does not support the HTTP protocol version used in the request.
- """
-
- code = 505
- description = (
- "The server does not support the HTTP protocol version used in the request."
- )
-
-
-default_exceptions = {}
-__all__ = ["HTTPException"]
-
-
-def _find_exceptions():
- for _name, obj in iteritems(globals()):
- try:
- is_http_exception = issubclass(obj, HTTPException)
- except TypeError:
- is_http_exception = False
- if not is_http_exception or obj.code is None:
- continue
- __all__.append(obj.__name__)
- old_obj = default_exceptions.get(obj.code, None)
- if old_obj is not None and issubclass(obj, old_obj):
- continue
- default_exceptions[obj.code] = obj
-
-
-_find_exceptions()
-del _find_exceptions
-
-
-class Aborter(object):
- """When passed a dict of code -> exception items it can be used as
- callable that raises exceptions. If the first argument to the
- callable is an integer it will be looked up in the mapping, if it's
- a WSGI application it will be raised in a proxy exception.
-
- The rest of the arguments are forwarded to the exception constructor.
- """
-
- def __init__(self, mapping=None, extra=None):
- if mapping is None:
- mapping = default_exceptions
- self.mapping = dict(mapping)
- if extra is not None:
- self.mapping.update(extra)
-
- def __call__(self, code, *args, **kwargs):
- if not args and not kwargs and not isinstance(code, integer_types):
- raise HTTPException(response=code)
- if code not in self.mapping:
- raise LookupError("no exception for %r" % code)
- raise self.mapping[code](*args, **kwargs)
-
-
-def abort(status, *args, **kwargs):
- """Raises an :py:exc:`HTTPException` for the given status code or WSGI
- application::
-
- abort(404) # 404 Not Found
- abort(Response('Hello World'))
-
- Can be passed a WSGI application or a status code. If a status code is
- given it's looked up in the list of exceptions and will raise that
- exception, if passed a WSGI application it will wrap it in a proxy WSGI
- exception and raise that::
-
- abort(404)
- abort(Response('Hello World'))
-
- """
- return _aborter(status, *args, **kwargs)
-
-
-_aborter = Aborter()
-
-
-#: an exception that is used internally to signal both a key error and a
-#: bad request. Used by a lot of the datastructures.
-BadRequestKeyError = BadRequest.wrap(KeyError)
-
-# imported here because of circular dependencies of werkzeug.utils
-from .http import HTTP_STATUS_CODES
-from .utils import escape
diff --git a/python/werkzeug/filesystem.py b/python/werkzeug/filesystem.py
deleted file mode 100644
index d016cae..0000000
--- a/python/werkzeug/filesystem.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.filesystem
- ~~~~~~~~~~~~~~~~~~~
-
- Various utilities for the local filesystem.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import sys
-import warnings
-
-# We do not trust traditional unixes.
-has_likely_buggy_unicode_filesystem = (
- sys.platform.startswith("linux") or "bsd" in sys.platform
-)
-
-
-def _is_ascii_encoding(encoding):
- """Given an encoding this figures out if the encoding is actually ASCII (which
- is something we don't actually want in most cases). This is necessary
- because ASCII comes under many names such as ANSI_X3.4-1968.
- """
- if encoding is None:
- return False
- try:
- return codecs.lookup(encoding).name == "ascii"
- except LookupError:
- return False
-
-
-class BrokenFilesystemWarning(RuntimeWarning, UnicodeWarning):
- """The warning used by Werkzeug to signal a broken filesystem. Will only be
- used once per runtime."""
-
-
-_warned_about_filesystem_encoding = False
-
-
-def get_filesystem_encoding():
- """Returns the filesystem encoding that should be used. Note that this is
- different from the Python understanding of the filesystem encoding which
- might be deeply flawed. Do not use this value against Python's unicode APIs
- because it might be different. See :ref:`filesystem-encoding` for the exact
- behavior.
-
- The concept of a filesystem encoding in generally is not something you
- should rely on. As such if you ever need to use this function except for
- writing wrapper code reconsider.
- """
- global _warned_about_filesystem_encoding
- rv = sys.getfilesystemencoding()
- if has_likely_buggy_unicode_filesystem and not rv or _is_ascii_encoding(rv):
- if not _warned_about_filesystem_encoding:
- warnings.warn(
- "Detected a misconfigured UNIX filesystem: Will use"
- " UTF-8 as filesystem encoding instead of {0!r}".format(rv),
- BrokenFilesystemWarning,
- )
- _warned_about_filesystem_encoding = True
- return "utf-8"
- return rv
diff --git a/python/werkzeug/formparser.py b/python/werkzeug/formparser.py
deleted file mode 100644
index 0ddc5c8..0000000
--- a/python/werkzeug/formparser.py
+++ /dev/null
@@ -1,586 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.formparser
- ~~~~~~~~~~~~~~~~~~~
-
- This module implements the form parsing. It supports url-encoded forms
- as well as non-nested multipart uploads.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import re
-from functools import update_wrapper
-from itertools import chain
-from itertools import repeat
-from itertools import tee
-
-from ._compat import BytesIO
-from ._compat import text_type
-from ._compat import to_native
-from .datastructures import FileStorage
-from .datastructures import Headers
-from .datastructures import MultiDict
-from .http import parse_options_header
-from .urls import url_decode_stream
-from .wsgi import get_content_length
-from .wsgi import get_input_stream
-from .wsgi import make_line_iter
-
-# there are some platforms where SpooledTemporaryFile is not available.
-# In that case we need to provide a fallback.
-try:
- from tempfile import SpooledTemporaryFile
-except ImportError:
- from tempfile import TemporaryFile
-
- SpooledTemporaryFile = None
-
-
-#: an iterator that yields empty strings
-_empty_string_iter = repeat("")
-
-#: a regular expression for multipart boundaries
-_multipart_boundary_re = re.compile("^[ -~]{0,200}[!-~]$")
-
-#: supported http encodings that are also available in python we support
-#: for multipart messages.
-_supported_multipart_encodings = frozenset(["base64", "quoted-printable"])
-
-
-def default_stream_factory(
- total_content_length, filename, content_type, content_length=None
-):
- """The stream factory that is used per default."""
- max_size = 1024 * 500
- if SpooledTemporaryFile is not None:
- return SpooledTemporaryFile(max_size=max_size, mode="wb+")
- if total_content_length is None or total_content_length > max_size:
- return TemporaryFile("wb+")
- return BytesIO()
-
-
-def parse_form_data(
- environ,
- stream_factory=None,
- charset="utf-8",
- errors="replace",
- max_form_memory_size=None,
- max_content_length=None,
- cls=None,
- silent=True,
-):
- """Parse the form data in the environ and return it as tuple in the form
- ``(stream, form, files)``. You should only call this method if the
- transport method is `POST`, `PUT`, or `PATCH`.
-
- If the mimetype of the data transmitted is `multipart/form-data` the
- files multidict will be filled with `FileStorage` objects. If the
- mimetype is unknown the input stream is wrapped and returned as first
- argument, else the stream is empty.
-
- This is a shortcut for the common usage of :class:`FormDataParser`.
-
- Have a look at :ref:`dealing-with-request-data` for more details.
-
- .. versionadded:: 0.5
- The `max_form_memory_size`, `max_content_length` and
- `cls` parameters were added.
-
- .. versionadded:: 0.5.1
- The optional `silent` flag was added.
-
- :param environ: the WSGI environment to be used for parsing.
- :param stream_factory: An optional callable that returns a new read and
- writeable file descriptor. This callable works
- the same as :meth:`~BaseResponse._get_file_stream`.
- :param charset: The character set for URL and url encoded form data.
- :param errors: The encoding error behavior.
- :param max_form_memory_size: the maximum number of bytes to be accepted for
- in-memory stored form data. If the data
- exceeds the value specified an
- :exc:`~exceptions.RequestEntityTooLarge`
- exception is raised.
- :param max_content_length: If this is provided and the transmitted data
- is longer than this value an
- :exc:`~exceptions.RequestEntityTooLarge`
- exception is raised.
- :param cls: an optional dict class to use. If this is not specified
- or `None` the default :class:`MultiDict` is used.
- :param silent: If set to False parsing errors will not be caught.
- :return: A tuple in the form ``(stream, form, files)``.
- """
- return FormDataParser(
- stream_factory,
- charset,
- errors,
- max_form_memory_size,
- max_content_length,
- cls,
- silent,
- ).parse_from_environ(environ)
-
-
-def exhaust_stream(f):
- """Helper decorator for methods that exhausts the stream on return."""
-
- def wrapper(self, stream, *args, **kwargs):
- try:
- return f(self, stream, *args, **kwargs)
- finally:
- exhaust = getattr(stream, "exhaust", None)
- if exhaust is not None:
- exhaust()
- else:
- while 1:
- chunk = stream.read(1024 * 64)
- if not chunk:
- break
-
- return update_wrapper(wrapper, f)
-
-
-class FormDataParser(object):
- """This class implements parsing of form data for Werkzeug. By itself
- it can parse multipart and url encoded form data. It can be subclassed
- and extended but for most mimetypes it is a better idea to use the
- untouched stream and expose it as separate attributes on a request
- object.
-
- .. versionadded:: 0.8
-
- :param stream_factory: An optional callable that returns a new read and
- writeable file descriptor. This callable works
- the same as :meth:`~BaseResponse._get_file_stream`.
- :param charset: The character set for URL and url encoded form data.
- :param errors: The encoding error behavior.
- :param max_form_memory_size: the maximum number of bytes to be accepted for
- in-memory stored form data. If the data
- exceeds the value specified an
- :exc:`~exceptions.RequestEntityTooLarge`
- exception is raised.
- :param max_content_length: If this is provided and the transmitted data
- is longer than this value an
- :exc:`~exceptions.RequestEntityTooLarge`
- exception is raised.
- :param cls: an optional dict class to use. If this is not specified
- or `None` the default :class:`MultiDict` is used.
- :param silent: If set to False parsing errors will not be caught.
- """
-
- def __init__(
- self,
- stream_factory=None,
- charset="utf-8",
- errors="replace",
- max_form_memory_size=None,
- max_content_length=None,
- cls=None,
- silent=True,
- ):
- if stream_factory is None:
- stream_factory = default_stream_factory
- self.stream_factory = stream_factory
- self.charset = charset
- self.errors = errors
- self.max_form_memory_size = max_form_memory_size
- self.max_content_length = max_content_length
- if cls is None:
- cls = MultiDict
- self.cls = cls
- self.silent = silent
-
- def get_parse_func(self, mimetype, options):
- return self.parse_functions.get(mimetype)
-
- def parse_from_environ(self, environ):
- """Parses the information from the environment as form data.
-
- :param environ: the WSGI environment to be used for parsing.
- :return: A tuple in the form ``(stream, form, files)``.
- """
- content_type = environ.get("CONTENT_TYPE", "")
- content_length = get_content_length(environ)
- mimetype, options = parse_options_header(content_type)
- return self.parse(get_input_stream(environ), mimetype, content_length, options)
-
- def parse(self, stream, mimetype, content_length, options=None):
- """Parses the information from the given stream, mimetype,
- content length and mimetype parameters.
-
- :param stream: an input stream
- :param mimetype: the mimetype of the data
- :param content_length: the content length of the incoming data
- :param options: optional mimetype parameters (used for
- the multipart boundary for instance)
- :return: A tuple in the form ``(stream, form, files)``.
- """
- if (
- self.max_content_length is not None
- and content_length is not None
- and content_length > self.max_content_length
- ):
- raise exceptions.RequestEntityTooLarge()
- if options is None:
- options = {}
-
- parse_func = self.get_parse_func(mimetype, options)
- if parse_func is not None:
- try:
- return parse_func(self, stream, mimetype, content_length, options)
- except ValueError:
- if not self.silent:
- raise
-
- return stream, self.cls(), self.cls()
-
- @exhaust_stream
- def _parse_multipart(self, stream, mimetype, content_length, options):
- parser = MultiPartParser(
- self.stream_factory,
- self.charset,
- self.errors,
- max_form_memory_size=self.max_form_memory_size,
- cls=self.cls,
- )
- boundary = options.get("boundary")
- if boundary is None:
- raise ValueError("Missing boundary")
- if isinstance(boundary, text_type):
- boundary = boundary.encode("ascii")
- form, files = parser.parse(stream, boundary, content_length)
- return stream, form, files
-
- @exhaust_stream
- def _parse_urlencoded(self, stream, mimetype, content_length, options):
- if (
- self.max_form_memory_size is not None
- and content_length is not None
- and content_length > self.max_form_memory_size
- ):
- raise exceptions.RequestEntityTooLarge()
- form = url_decode_stream(stream, self.charset, errors=self.errors, cls=self.cls)
- return stream, form, self.cls()
-
- #: mapping of mimetypes to parsing functions
- parse_functions = {
- "multipart/form-data": _parse_multipart,
- "application/x-www-form-urlencoded": _parse_urlencoded,
- "application/x-url-encoded": _parse_urlencoded,
- }
-
-
-def is_valid_multipart_boundary(boundary):
- """Checks if the string given is a valid multipart boundary."""
- return _multipart_boundary_re.match(boundary) is not None
-
-
-def _line_parse(line):
- """Removes line ending characters and returns a tuple (`stripped_line`,
- `is_terminated`).
- """
- if line[-2:] in ["\r\n", b"\r\n"]:
- return line[:-2], True
- elif line[-1:] in ["\r", "\n", b"\r", b"\n"]:
- return line[:-1], True
- return line, False
-
-
-def parse_multipart_headers(iterable):
- """Parses multipart headers from an iterable that yields lines (including
- the trailing newline symbol). The iterable has to be newline terminated.
-
- The iterable will stop at the line where the headers ended so it can be
- further consumed.
-
- :param iterable: iterable of strings that are newline terminated
- """
- result = []
- for line in iterable:
- line = to_native(line)
- line, line_terminated = _line_parse(line)
- if not line_terminated:
- raise ValueError("unexpected end of line in multipart header")
- if not line:
- break
- elif line[0] in " \t" and result:
- key, value = result[-1]
- result[-1] = (key, value + "\n " + line[1:])
- else:
- parts = line.split(":", 1)
- if len(parts) == 2:
- result.append((parts[0].strip(), parts[1].strip()))
-
- # we link the list to the headers, no need to create a copy, the
- # list was not shared anyways.
- return Headers(result)
-
-
-_begin_form = "begin_form"
-_begin_file = "begin_file"
-_cont = "cont"
-_end = "end"
-
-
-class MultiPartParser(object):
- def __init__(
- self,
- stream_factory=None,
- charset="utf-8",
- errors="replace",
- max_form_memory_size=None,
- cls=None,
- buffer_size=64 * 1024,
- ):
- self.charset = charset
- self.errors = errors
- self.max_form_memory_size = max_form_memory_size
- self.stream_factory = (
- default_stream_factory if stream_factory is None else stream_factory
- )
- self.cls = MultiDict if cls is None else cls
-
- # make sure the buffer size is divisible by four so that we can base64
- # decode chunk by chunk
- assert buffer_size % 4 == 0, "buffer size has to be divisible by 4"
- # also the buffer size has to be at least 1024 bytes long or long headers
- # will freak out the system
- assert buffer_size >= 1024, "buffer size has to be at least 1KB"
-
- self.buffer_size = buffer_size
-
- def _fix_ie_filename(self, filename):
- """Internet Explorer 6 transmits the full file name if a file is
- uploaded. This function strips the full path if it thinks the
- filename is Windows-like absolute.
- """
- if filename[1:3] == ":\\" or filename[:2] == "\\\\":
- return filename.split("\\")[-1]
- return filename
-
- def _find_terminator(self, iterator):
- """The terminator might have some additional newlines before it.
- There is at least one application that sends additional newlines
- before headers (the python setuptools package).
- """
- for line in iterator:
- if not line:
- break
- line = line.strip()
- if line:
- return line
- return b""
-
- def fail(self, message):
- raise ValueError(message)
-
- def get_part_encoding(self, headers):
- transfer_encoding = headers.get("content-transfer-encoding")
- if (
- transfer_encoding is not None
- and transfer_encoding in _supported_multipart_encodings
- ):
- return transfer_encoding
-
- def get_part_charset(self, headers):
- # Figure out input charset for current part
- content_type = headers.get("content-type")
- if content_type:
- mimetype, ct_params = parse_options_header(content_type)
- return ct_params.get("charset", self.charset)
- return self.charset
-
- def start_file_streaming(self, filename, headers, total_content_length):
- if isinstance(filename, bytes):
- filename = filename.decode(self.charset, self.errors)
- filename = self._fix_ie_filename(filename)
- content_type = headers.get("content-type")
- try:
- content_length = int(headers["content-length"])
- except (KeyError, ValueError):
- content_length = 0
- container = self.stream_factory(
- total_content_length=total_content_length,
- filename=filename,
- content_type=content_type,
- content_length=content_length,
- )
- return filename, container
-
- def in_memory_threshold_reached(self, bytes):
- raise exceptions.RequestEntityTooLarge()
-
- def validate_boundary(self, boundary):
- if not boundary:
- self.fail("Missing boundary")
- if not is_valid_multipart_boundary(boundary):
- self.fail("Invalid boundary: %s" % boundary)
- if len(boundary) > self.buffer_size: # pragma: no cover
- # this should never happen because we check for a minimum size
- # of 1024 and boundaries may not be longer than 200. The only
- # situation when this happens is for non debug builds where
- # the assert is skipped.
- self.fail("Boundary longer than buffer size")
-
- def parse_lines(self, file, boundary, content_length, cap_at_buffer=True):
- """Generate parts of
- ``('begin_form', (headers, name))``
- ``('begin_file', (headers, name, filename))``
- ``('cont', bytestring)``
- ``('end', None)``
-
- Always obeys the grammar
- parts = ( begin_form cont* end |
- begin_file cont* end )*
- """
- next_part = b"--" + boundary
- last_part = next_part + b"--"
-
- iterator = chain(
- make_line_iter(
- file,
- limit=content_length,
- buffer_size=self.buffer_size,
- cap_at_buffer=cap_at_buffer,
- ),
- _empty_string_iter,
- )
-
- terminator = self._find_terminator(iterator)
-
- if terminator == last_part:
- return
- elif terminator != next_part:
- self.fail("Expected boundary at start of multipart data")
-
- while terminator != last_part:
- headers = parse_multipart_headers(iterator)
-
- disposition = headers.get("content-disposition")
- if disposition is None:
- self.fail("Missing Content-Disposition header")
- disposition, extra = parse_options_header(disposition)
- transfer_encoding = self.get_part_encoding(headers)
- name = extra.get("name")
- filename = extra.get("filename")
-
- # if no content type is given we stream into memory. A list is
- # used as a temporary container.
- if filename is None:
- yield _begin_form, (headers, name)
-
- # otherwise we parse the rest of the headers and ask the stream
- # factory for something we can write in.
- else:
- yield _begin_file, (headers, name, filename)
-
- buf = b""
- for line in iterator:
- if not line:
- self.fail("unexpected end of stream")
-
- if line[:2] == b"--":
- terminator = line.rstrip()
- if terminator in (next_part, last_part):
- break
-
- if transfer_encoding is not None:
- if transfer_encoding == "base64":
- transfer_encoding = "base64_codec"
- try:
- line = codecs.decode(line, transfer_encoding)
- except Exception:
- self.fail("could not decode transfer encoded chunk")
-
- # we have something in the buffer from the last iteration.
- # this is usually a newline delimiter.
- if buf:
- yield _cont, buf
- buf = b""
-
- # If the line ends with windows CRLF we write everything except
- # the last two bytes. In all other cases however we write
- # everything except the last byte. If it was a newline, that's
- # fine, otherwise it does not matter because we will write it
- # the next iteration. this ensures we do not write the
- # final newline into the stream. That way we do not have to
- # truncate the stream. However we do have to make sure that
- # if something else than a newline is in there we write it
- # out.
- if line[-2:] == b"\r\n":
- buf = b"\r\n"
- cutoff = -2
- else:
- buf = line[-1:]
- cutoff = -1
- yield _cont, line[:cutoff]
-
- else: # pragma: no cover
- raise ValueError("unexpected end of part")
-
- # if we have a leftover in the buffer that is not a newline
- # character we have to flush it, otherwise we will chop of
- # certain values.
- if buf not in (b"", b"\r", b"\n", b"\r\n"):
- yield _cont, buf
-
- yield _end, None
-
- def parse_parts(self, file, boundary, content_length):
- """Generate ``('file', (name, val))`` and
- ``('form', (name, val))`` parts.
- """
- in_memory = 0
-
- for ellt, ell in self.parse_lines(file, boundary, content_length):
- if ellt == _begin_file:
- headers, name, filename = ell
- is_file = True
- guard_memory = False
- filename, container = self.start_file_streaming(
- filename, headers, content_length
- )
- _write = container.write
-
- elif ellt == _begin_form:
- headers, name = ell
- is_file = False
- container = []
- _write = container.append
- guard_memory = self.max_form_memory_size is not None
-
- elif ellt == _cont:
- _write(ell)
- # if we write into memory and there is a memory size limit we
- # count the number of bytes in memory and raise an exception if
- # there is too much data in memory.
- if guard_memory:
- in_memory += len(ell)
- if in_memory > self.max_form_memory_size:
- self.in_memory_threshold_reached(in_memory)
-
- elif ellt == _end:
- if is_file:
- container.seek(0)
- yield (
- "file",
- (name, FileStorage(container, filename, name, headers=headers)),
- )
- else:
- part_charset = self.get_part_charset(headers)
- yield (
- "form",
- (name, b"".join(container).decode(part_charset, self.errors)),
- )
-
- def parse(self, file, boundary, content_length):
- formstream, filestream = tee(
- self.parse_parts(file, boundary, content_length), 2
- )
- form = (p[1] for p in formstream if p[0] == "form")
- files = (p[1] for p in filestream if p[0] == "file")
- return self.cls(form), self.cls(files)
-
-
-from . import exceptions
diff --git a/python/werkzeug/http.py b/python/werkzeug/http.py
deleted file mode 100644
index af32007..0000000
--- a/python/werkzeug/http.py
+++ /dev/null
@@ -1,1303 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.http
- ~~~~~~~~~~~~~
-
- Werkzeug comes with a bunch of utilities that help Werkzeug to deal with
- HTTP data. Most of the classes and functions provided by this module are
- used by the wrappers, but they are useful on their own, too, especially if
- the response and request objects are not used.
-
- This covers some of the more HTTP centric features of WSGI, some other
- utilities such as cookie handling are documented in the `werkzeug.utils`
- module.
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import base64
-import re
-import warnings
-from datetime import datetime
-from datetime import timedelta
-from hashlib import md5
-from time import gmtime
-from time import time
-
-from ._compat import integer_types
-from ._compat import iteritems
-from ._compat import PY2
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import to_bytes
-from ._compat import to_unicode
-from ._compat import try_coerce_native
-from ._internal import _cookie_parse_impl
-from ._internal import _cookie_quote
-from ._internal import _make_cookie_domain
-
-try:
- from email.utils import parsedate_tz
-except ImportError:
- from email.Utils import parsedate_tz
-
-try:
- from urllib.request import parse_http_list as _parse_list_header
- from urllib.parse import unquote_to_bytes as _unquote
-except ImportError:
- from urllib2 import parse_http_list as _parse_list_header
- from urllib2 import unquote as _unquote
-
-_cookie_charset = "latin1"
-_basic_auth_charset = "utf-8"
-# for explanation of "media-range", etc. see Sections 5.3.{1,2} of RFC 7231
-_accept_re = re.compile(
- r"""
- ( # media-range capturing-parenthesis
- [^\s;,]+ # type/subtype
- (?:[ \t]*;[ \t]* # ";"
- (?: # parameter non-capturing-parenthesis
- [^\s;,q][^\s;,]* # token that doesn't start with "q"
- | # or
- q[^\s;,=][^\s;,]* # token that is more than just "q"
- )
- )* # zero or more parameters
- ) # end of media-range
- (?:[ \t]*;[ \t]*q= # weight is a "q" parameter
- (\d*(?:\.\d+)?) # qvalue capturing-parentheses
- [^,]* # "extension" accept params: who cares?
- )? # accept params are optional
- """,
- re.VERBOSE,
-)
-_token_chars = frozenset(
- "!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz|~"
-)
-_etag_re = re.compile(r'([Ww]/)?(?:"(.*?)"|(.*?))(?:\s*,\s*|$)')
-_unsafe_header_chars = set('()<>@,;:"/[]?={} \t')
-_option_header_piece_re = re.compile(
- r"""
- ;\s*,?\s* # newlines were replaced with commas
- (?P<key>
- "[^"\\]*(?:\\.[^"\\]*)*" # quoted string
- |
- [^\s;,=*]+ # token
- )
- (?:\*(?P<count>\d+))? # *1, optional continuation index
- \s*
- (?: # optionally followed by =value
- (?: # equals sign, possibly with encoding
- \*\s*=\s* # * indicates extended notation
- (?: # optional encoding
- (?P<encoding>[^\s]+?)
- '(?P<language>[^\s]*?)'
- )?
- |
- =\s* # basic notation
- )
- (?P<value>
- "[^"\\]*(?:\\.[^"\\]*)*" # quoted string
- |
- [^;,]+ # token
- )?
- )?
- \s*
- """,
- flags=re.VERBOSE,
-)
-_option_header_start_mime_type = re.compile(r",\s*([^;,\s]+)([;,]\s*.+)?")
-
-_entity_headers = frozenset(
- [
- "allow",
- "content-encoding",
- "content-language",
- "content-length",
- "content-location",
- "content-md5",
- "content-range",
- "content-type",
- "expires",
- "last-modified",
- ]
-)
-_hop_by_hop_headers = frozenset(
- [
- "connection",
- "keep-alive",
- "proxy-authenticate",
- "proxy-authorization",
- "te",
- "trailer",
- "transfer-encoding",
- "upgrade",
- ]
-)
-
-
-HTTP_STATUS_CODES = {
- 100: "Continue",
- 101: "Switching Protocols",
- 102: "Processing",
- 200: "OK",
- 201: "Created",
- 202: "Accepted",
- 203: "Non Authoritative Information",
- 204: "No Content",
- 205: "Reset Content",
- 206: "Partial Content",
- 207: "Multi Status",
- 226: "IM Used", # see RFC 3229
- 300: "Multiple Choices",
- 301: "Moved Permanently",
- 302: "Found",
- 303: "See Other",
- 304: "Not Modified",
- 305: "Use Proxy",
- 307: "Temporary Redirect",
- 308: "Permanent Redirect",
- 400: "Bad Request",
- 401: "Unauthorized",
- 402: "Payment Required", # unused
- 403: "Forbidden",
- 404: "Not Found",
- 405: "Method Not Allowed",
- 406: "Not Acceptable",
- 407: "Proxy Authentication Required",
- 408: "Request Timeout",
- 409: "Conflict",
- 410: "Gone",
- 411: "Length Required",
- 412: "Precondition Failed",
- 413: "Request Entity Too Large",
- 414: "Request URI Too Long",
- 415: "Unsupported Media Type",
- 416: "Requested Range Not Satisfiable",
- 417: "Expectation Failed",
- 418: "I'm a teapot", # see RFC 2324
- 421: "Misdirected Request", # see RFC 7540
- 422: "Unprocessable Entity",
- 423: "Locked",
- 424: "Failed Dependency",
- 426: "Upgrade Required",
- 428: "Precondition Required", # see RFC 6585
- 429: "Too Many Requests",
- 431: "Request Header Fields Too Large",
- 449: "Retry With", # proprietary MS extension
- 451: "Unavailable For Legal Reasons",
- 500: "Internal Server Error",
- 501: "Not Implemented",
- 502: "Bad Gateway",
- 503: "Service Unavailable",
- 504: "Gateway Timeout",
- 505: "HTTP Version Not Supported",
- 507: "Insufficient Storage",
- 510: "Not Extended",
-}
-
-
-def wsgi_to_bytes(data):
- """coerce wsgi unicode represented bytes to real ones"""
- if isinstance(data, bytes):
- return data
- return data.encode("latin1") # XXX: utf8 fallback?
-
-
-def bytes_to_wsgi(data):
- assert isinstance(data, bytes), "data must be bytes"
- if isinstance(data, str):
- return data
- else:
- return data.decode("latin1")
-
-
-def quote_header_value(value, extra_chars="", allow_token=True):
- """Quote a header value if necessary.
-
- .. versionadded:: 0.5
-
- :param value: the value to quote.
- :param extra_chars: a list of extra characters to skip quoting.
- :param allow_token: if this is enabled token values are returned
- unchanged.
- """
- if isinstance(value, bytes):
- value = bytes_to_wsgi(value)
- value = str(value)
- if allow_token:
- token_chars = _token_chars | set(extra_chars)
- if set(value).issubset(token_chars):
- return value
- return '"%s"' % value.replace("\\", "\\\\").replace('"', '\\"')
-
-
-def unquote_header_value(value, is_filename=False):
- r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
- This does not use the real unquoting but what browsers are actually
- using for quoting.
-
- .. versionadded:: 0.5
-
- :param value: the header value to unquote.
- """
- if value and value[0] == value[-1] == '"':
- # this is not the real unquoting, but fixing this so that the
- # RFC is met will result in bugs with internet explorer and
- # probably some other browsers as well. IE for example is
- # uploading files with "C:\foo\bar.txt" as filename
- value = value[1:-1]
-
- # if this is a filename and the starting characters look like
- # a UNC path, then just return the value without quotes. Using the
- # replace sequence below on a UNC path has the effect of turning
- # the leading double slash into a single slash and then
- # _fix_ie_filename() doesn't work correctly. See #458.
- if not is_filename or value[:2] != "\\\\":
- return value.replace("\\\\", "\\").replace('\\"', '"')
- return value
-
-
-def dump_options_header(header, options):
- """The reverse function to :func:`parse_options_header`.
-
- :param header: the header to dump
- :param options: a dict of options to append.
- """
- segments = []
- if header is not None:
- segments.append(header)
- for key, value in iteritems(options):
- if value is None:
- segments.append(key)
- else:
- segments.append("%s=%s" % (key, quote_header_value(value)))
- return "; ".join(segments)
-
-
-def dump_header(iterable, allow_token=True):
- """Dump an HTTP header again. This is the reversal of
- :func:`parse_list_header`, :func:`parse_set_header` and
- :func:`parse_dict_header`. This also quotes strings that include an
- equals sign unless you pass it as dict of key, value pairs.
-
- >>> dump_header({'foo': 'bar baz'})
- 'foo="bar baz"'
- >>> dump_header(('foo', 'bar baz'))
- 'foo, "bar baz"'
-
- :param iterable: the iterable or dict of values to quote.
- :param allow_token: if set to `False` tokens as values are disallowed.
- See :func:`quote_header_value` for more details.
- """
- if isinstance(iterable, dict):
- items = []
- for key, value in iteritems(iterable):
- if value is None:
- items.append(key)
- else:
- items.append(
- "%s=%s" % (key, quote_header_value(value, allow_token=allow_token))
- )
- else:
- items = [quote_header_value(x, allow_token=allow_token) for x in iterable]
- return ", ".join(items)
-
-
-def parse_list_header(value):
- """Parse lists as described by RFC 2068 Section 2.
-
- In particular, parse comma-separated lists where the elements of
- the list may include quoted-strings. A quoted-string could
- contain a comma. A non-quoted string could have quotes in the
- middle. Quotes are removed automatically after parsing.
-
- It basically works like :func:`parse_set_header` just that items
- may appear multiple times and case sensitivity is preserved.
-
- The return value is a standard :class:`list`:
-
- >>> parse_list_header('token, "quoted value"')
- ['token', 'quoted value']
-
- To create a header from the :class:`list` again, use the
- :func:`dump_header` function.
-
- :param value: a string with a list header.
- :return: :class:`list`
- """
- result = []
- for item in _parse_list_header(value):
- if item[:1] == item[-1:] == '"':
- item = unquote_header_value(item[1:-1])
- result.append(item)
- return result
-
-
-def parse_dict_header(value, cls=dict):
- """Parse lists of key, value pairs as described by RFC 2068 Section 2 and
- convert them into a python dict (or any other mapping object created from
- the type with a dict like interface provided by the `cls` argument):
-
- >>> d = parse_dict_header('foo="is a fish", bar="as well"')
- >>> type(d) is dict
- True
- >>> sorted(d.items())
- [('bar', 'as well'), ('foo', 'is a fish')]
-
- If there is no value for a key it will be `None`:
-
- >>> parse_dict_header('key_without_value')
- {'key_without_value': None}
-
- To create a header from the :class:`dict` again, use the
- :func:`dump_header` function.
-
- .. versionchanged:: 0.9
- Added support for `cls` argument.
-
- :param value: a string with a dict header.
- :param cls: callable to use for storage of parsed results.
- :return: an instance of `cls`
- """
- result = cls()
- if not isinstance(value, text_type):
- # XXX: validate
- value = bytes_to_wsgi(value)
- for item in _parse_list_header(value):
- if "=" not in item:
- result[item] = None
- continue
- name, value = item.split("=", 1)
- if value[:1] == value[-1:] == '"':
- value = unquote_header_value(value[1:-1])
- result[name] = value
- return result
-
-
-def parse_options_header(value, multiple=False):
- """Parse a ``Content-Type`` like header into a tuple with the content
- type and the options:
-
- >>> parse_options_header('text/html; charset=utf8')
- ('text/html', {'charset': 'utf8'})
-
- This should not be used to parse ``Cache-Control`` like headers that use
- a slightly different format. For these headers use the
- :func:`parse_dict_header` function.
-
- .. versionchanged:: 0.15
- :rfc:`2231` parameter continuations are handled.
-
- .. versionadded:: 0.5
-
- :param value: the header to parse.
- :param multiple: Whether try to parse and return multiple MIME types
- :return: (mimetype, options) or (mimetype, options, mimetype, options, …)
- if multiple=True
- """
- if not value:
- return "", {}
-
- result = []
-
- value = "," + value.replace("\n", ",")
- while value:
- match = _option_header_start_mime_type.match(value)
- if not match:
- break
- result.append(match.group(1)) # mimetype
- options = {}
- # Parse options
- rest = match.group(2)
- continued_encoding = None
- while rest:
- optmatch = _option_header_piece_re.match(rest)
- if not optmatch:
- break
- option, count, encoding, language, option_value = optmatch.groups()
- # Continuations don't have to supply the encoding after the
- # first line. If we're in a continuation, track the current
- # encoding to use for subsequent lines. Reset it when the
- # continuation ends.
- if not count:
- continued_encoding = None
- else:
- if not encoding:
- encoding = continued_encoding
- continued_encoding = encoding
- option = unquote_header_value(option)
- if option_value is not None:
- option_value = unquote_header_value(option_value, option == "filename")
- if encoding is not None:
- option_value = _unquote(option_value).decode(encoding)
- if count:
- # Continuations append to the existing value. For
- # simplicity, this ignores the possibility of
- # out-of-order indices, which shouldn't happen anyway.
- options[option] = options.get(option, "") + option_value
- else:
- options[option] = option_value
- rest = rest[optmatch.end() :]
- result.append(options)
- if multiple is False:
- return tuple(result)
- value = rest
-
- return tuple(result) if result else ("", {})
-
-
-def parse_accept_header(value, cls=None):
- """Parses an HTTP Accept-* header. This does not implement a complete
- valid algorithm but one that supports at least value and quality
- extraction.
-
- Returns a new :class:`Accept` object (basically a list of ``(value, quality)``
- tuples sorted by the quality with some additional accessor methods).
-
- The second parameter can be a subclass of :class:`Accept` that is created
- with the parsed values and returned.
-
- :param value: the accept header string to be parsed.
- :param cls: the wrapper class for the return value (can be
- :class:`Accept` or a subclass thereof)
- :return: an instance of `cls`.
- """
- if cls is None:
- cls = Accept
-
- if not value:
- return cls(None)
-
- result = []
- for match in _accept_re.finditer(value):
- quality = match.group(2)
- if not quality:
- quality = 1
- else:
- quality = max(min(float(quality), 1), 0)
- result.append((match.group(1), quality))
- return cls(result)
-
-
-def parse_cache_control_header(value, on_update=None, cls=None):
- """Parse a cache control header. The RFC differs between response and
- request cache control, this method does not. It's your responsibility
- to not use the wrong control statements.
-
- .. versionadded:: 0.5
- The `cls` was added. If not specified an immutable
- :class:`~werkzeug.datastructures.RequestCacheControl` is returned.
-
- :param value: a cache control header to be parsed.
- :param on_update: an optional callable that is called every time a value
- on the :class:`~werkzeug.datastructures.CacheControl`
- object is changed.
- :param cls: the class for the returned object. By default
- :class:`~werkzeug.datastructures.RequestCacheControl` is used.
- :return: a `cls` object.
- """
- if cls is None:
- cls = RequestCacheControl
- if not value:
- return cls(None, on_update)
- return cls(parse_dict_header(value), on_update)
-
-
-def parse_set_header(value, on_update=None):
- """Parse a set-like header and return a
- :class:`~werkzeug.datastructures.HeaderSet` object:
-
- >>> hs = parse_set_header('token, "quoted value"')
-
- The return value is an object that treats the items case-insensitively
- and keeps the order of the items:
-
- >>> 'TOKEN' in hs
- True
- >>> hs.index('quoted value')
- 1
- >>> hs
- HeaderSet(['token', 'quoted value'])
-
- To create a header from the :class:`HeaderSet` again, use the
- :func:`dump_header` function.
-
- :param value: a set header to be parsed.
- :param on_update: an optional callable that is called every time a
- value on the :class:`~werkzeug.datastructures.HeaderSet`
- object is changed.
- :return: a :class:`~werkzeug.datastructures.HeaderSet`
- """
- if not value:
- return HeaderSet(None, on_update)
- return HeaderSet(parse_list_header(value), on_update)
-
-
-def parse_authorization_header(value):
- """Parse an HTTP basic/digest authorization header transmitted by the web
- browser. The return value is either `None` if the header was invalid or
- not given, otherwise an :class:`~werkzeug.datastructures.Authorization`
- object.
-
- :param value: the authorization header to parse.
- :return: a :class:`~werkzeug.datastructures.Authorization` object or `None`.
- """
- if not value:
- return
- value = wsgi_to_bytes(value)
- try:
- auth_type, auth_info = value.split(None, 1)
- auth_type = auth_type.lower()
- except ValueError:
- return
- if auth_type == b"basic":
- try:
- username, password = base64.b64decode(auth_info).split(b":", 1)
- except Exception:
- return
- return Authorization(
- "basic",
- {
- "username": to_unicode(username, _basic_auth_charset),
- "password": to_unicode(password, _basic_auth_charset),
- },
- )
- elif auth_type == b"digest":
- auth_map = parse_dict_header(auth_info)
- for key in "username", "realm", "nonce", "uri", "response":
- if key not in auth_map:
- return
- if "qop" in auth_map:
- if not auth_map.get("nc") or not auth_map.get("cnonce"):
- return
- return Authorization("digest", auth_map)
-
-
-def parse_www_authenticate_header(value, on_update=None):
- """Parse an HTTP WWW-Authenticate header into a
- :class:`~werkzeug.datastructures.WWWAuthenticate` object.
-
- :param value: a WWW-Authenticate header to parse.
- :param on_update: an optional callable that is called every time a value
- on the :class:`~werkzeug.datastructures.WWWAuthenticate`
- object is changed.
- :return: a :class:`~werkzeug.datastructures.WWWAuthenticate` object.
- """
- if not value:
- return WWWAuthenticate(on_update=on_update)
- try:
- auth_type, auth_info = value.split(None, 1)
- auth_type = auth_type.lower()
- except (ValueError, AttributeError):
- return WWWAuthenticate(value.strip().lower(), on_update=on_update)
- return WWWAuthenticate(auth_type, parse_dict_header(auth_info), on_update)
-
-
-def parse_if_range_header(value):
- """Parses an if-range header which can be an etag or a date. Returns
- a :class:`~werkzeug.datastructures.IfRange` object.
-
- .. versionadded:: 0.7
- """
- if not value:
- return IfRange()
- date = parse_date(value)
- if date is not None:
- return IfRange(date=date)
- # drop weakness information
- return IfRange(unquote_etag(value)[0])
-
-
-def parse_range_header(value, make_inclusive=True):
- """Parses a range header into a :class:`~werkzeug.datastructures.Range`
- object. If the header is missing or malformed `None` is returned.
- `ranges` is a list of ``(start, stop)`` tuples where the ranges are
- non-inclusive.
-
- .. versionadded:: 0.7
- """
- if not value or "=" not in value:
- return None
-
- ranges = []
- last_end = 0
- units, rng = value.split("=", 1)
- units = units.strip().lower()
-
- for item in rng.split(","):
- item = item.strip()
- if "-" not in item:
- return None
- if item.startswith("-"):
- if last_end < 0:
- return None
- try:
- begin = int(item)
- except ValueError:
- return None
- end = None
- last_end = -1
- elif "-" in item:
- begin, end = item.split("-", 1)
- begin = begin.strip()
- end = end.strip()
- if not begin.isdigit():
- return None
- begin = int(begin)
- if begin < last_end or last_end < 0:
- return None
- if end:
- if not end.isdigit():
- return None
- end = int(end) + 1
- if begin >= end:
- return None
- else:
- end = None
- last_end = end
- ranges.append((begin, end))
-
- return Range(units, ranges)
-
-
-def parse_content_range_header(value, on_update=None):
- """Parses a range header into a
- :class:`~werkzeug.datastructures.ContentRange` object or `None` if
- parsing is not possible.
-
- .. versionadded:: 0.7
-
- :param value: a content range header to be parsed.
- :param on_update: an optional callable that is called every time a value
- on the :class:`~werkzeug.datastructures.ContentRange`
- object is changed.
- """
- if value is None:
- return None
- try:
- units, rangedef = (value or "").strip().split(None, 1)
- except ValueError:
- return None
-
- if "/" not in rangedef:
- return None
- rng, length = rangedef.split("/", 1)
- if length == "*":
- length = None
- elif length.isdigit():
- length = int(length)
- else:
- return None
-
- if rng == "*":
- return ContentRange(units, None, None, length, on_update=on_update)
- elif "-" not in rng:
- return None
-
- start, stop = rng.split("-", 1)
- try:
- start = int(start)
- stop = int(stop) + 1
- except ValueError:
- return None
-
- if is_byte_range_valid(start, stop, length):
- return ContentRange(units, start, stop, length, on_update=on_update)
-
-
-def quote_etag(etag, weak=False):
- """Quote an etag.
-
- :param etag: the etag to quote.
- :param weak: set to `True` to tag it "weak".
- """
- if '"' in etag:
- raise ValueError("invalid etag")
- etag = '"%s"' % etag
- if weak:
- etag = "W/" + etag
- return etag
-
-
-def unquote_etag(etag):
- """Unquote a single etag:
-
- >>> unquote_etag('W/"bar"')
- ('bar', True)
- >>> unquote_etag('"bar"')
- ('bar', False)
-
- :param etag: the etag identifier to unquote.
- :return: a ``(etag, weak)`` tuple.
- """
- if not etag:
- return None, None
- etag = etag.strip()
- weak = False
- if etag.startswith(("W/", "w/")):
- weak = True
- etag = etag[2:]
- if etag[:1] == etag[-1:] == '"':
- etag = etag[1:-1]
- return etag, weak
-
-
-def parse_etags(value):
- """Parse an etag header.
-
- :param value: the tag header to parse
- :return: an :class:`~werkzeug.datastructures.ETags` object.
- """
- if not value:
- return ETags()
- strong = []
- weak = []
- end = len(value)
- pos = 0
- while pos < end:
- match = _etag_re.match(value, pos)
- if match is None:
- break
- is_weak, quoted, raw = match.groups()
- if raw == "*":
- return ETags(star_tag=True)
- elif quoted:
- raw = quoted
- if is_weak:
- weak.append(raw)
- else:
- strong.append(raw)
- pos = match.end()
- return ETags(strong, weak)
-
-
-def generate_etag(data):
- """Generate an etag for some data."""
- return md5(data).hexdigest()
-
-
-def parse_date(value):
- """Parse one of the following date formats into a datetime object:
-
- .. sourcecode:: text
-
- Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
- Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
-
- If parsing fails the return value is `None`.
-
- :param value: a string with a supported date format.
- :return: a :class:`datetime.datetime` object.
- """
- if value:
- t = parsedate_tz(value.strip())
- if t is not None:
- try:
- year = t[0]
- # unfortunately that function does not tell us if two digit
- # years were part of the string, or if they were prefixed
- # with two zeroes. So what we do is to assume that 69-99
- # refer to 1900, and everything below to 2000
- if year >= 0 and year <= 68:
- year += 2000
- elif year >= 69 and year <= 99:
- year += 1900
- return datetime(*((year,) + t[1:7])) - timedelta(seconds=t[-1] or 0)
- except (ValueError, OverflowError):
- return None
-
-
-def _dump_date(d, delim):
- """Used for `http_date` and `cookie_date`."""
- if d is None:
- d = gmtime()
- elif isinstance(d, datetime):
- d = d.utctimetuple()
- elif isinstance(d, (integer_types, float)):
- d = gmtime(d)
- return "%s, %02d%s%s%s%s %02d:%02d:%02d GMT" % (
- ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[d.tm_wday],
- d.tm_mday,
- delim,
- (
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
- )[d.tm_mon - 1],
- delim,
- str(d.tm_year),
- d.tm_hour,
- d.tm_min,
- d.tm_sec,
- )
-
-
-def cookie_date(expires=None):
- """Formats the time to ensure compatibility with Netscape's cookie
- standard.
-
- Accepts a floating point number expressed in seconds since the epoch in, a
- datetime object or a timetuple. All times in UTC. The :func:`parse_date`
- function can be used to parse such a date.
-
- Outputs a string in the format ``Wdy, DD-Mon-YYYY HH:MM:SS GMT``.
-
- :param expires: If provided that date is used, otherwise the current.
- """
- return _dump_date(expires, "-")
-
-
-def http_date(timestamp=None):
- """Formats the time to match the RFC1123 date format.
-
- Accepts a floating point number expressed in seconds since the epoch in, a
- datetime object or a timetuple. All times in UTC. The :func:`parse_date`
- function can be used to parse such a date.
-
- Outputs a string in the format ``Wdy, DD Mon YYYY HH:MM:SS GMT``.
-
- :param timestamp: If provided that date is used, otherwise the current.
- """
- return _dump_date(timestamp, " ")
-
-
-def parse_age(value=None):
- """Parses a base-10 integer count of seconds into a timedelta.
-
- If parsing fails, the return value is `None`.
-
- :param value: a string consisting of an integer represented in base-10
- :return: a :class:`datetime.timedelta` object or `None`.
- """
- if not value:
- return None
- try:
- seconds = int(value)
- except ValueError:
- return None
- if seconds < 0:
- return None
- try:
- return timedelta(seconds=seconds)
- except OverflowError:
- return None
-
-
-def dump_age(age=None):
- """Formats the duration as a base-10 integer.
-
- :param age: should be an integer number of seconds,
- a :class:`datetime.timedelta` object, or,
- if the age is unknown, `None` (default).
- """
- if age is None:
- return
- if isinstance(age, timedelta):
- # do the equivalent of Python 2.7's timedelta.total_seconds(),
- # but disregarding fractional seconds
- age = age.seconds + (age.days * 24 * 3600)
-
- age = int(age)
- if age < 0:
- raise ValueError("age cannot be negative")
-
- return str(age)
-
-
-def is_resource_modified(
- environ, etag=None, data=None, last_modified=None, ignore_if_range=True
-):
- """Convenience method for conditional requests.
-
- :param environ: the WSGI environment of the request to be checked.
- :param etag: the etag for the response for comparison.
- :param data: or alternatively the data of the response to automatically
- generate an etag using :func:`generate_etag`.
- :param last_modified: an optional date of the last modification.
- :param ignore_if_range: If `False`, `If-Range` header will be taken into
- account.
- :return: `True` if the resource was modified, otherwise `False`.
- """
- if etag is None and data is not None:
- etag = generate_etag(data)
- elif data is not None:
- raise TypeError("both data and etag given")
- if environ["REQUEST_METHOD"] not in ("GET", "HEAD"):
- return False
-
- unmodified = False
- if isinstance(last_modified, string_types):
- last_modified = parse_date(last_modified)
-
- # ensure that microsecond is zero because the HTTP spec does not transmit
- # that either and we might have some false positives. See issue #39
- if last_modified is not None:
- last_modified = last_modified.replace(microsecond=0)
-
- if_range = None
- if not ignore_if_range and "HTTP_RANGE" in environ:
- # https://tools.ietf.org/html/rfc7233#section-3.2
- # A server MUST ignore an If-Range header field received in a request
- # that does not contain a Range header field.
- if_range = parse_if_range_header(environ.get("HTTP_IF_RANGE"))
-
- if if_range is not None and if_range.date is not None:
- modified_since = if_range.date
- else:
- modified_since = parse_date(environ.get("HTTP_IF_MODIFIED_SINCE"))
-
- if modified_since and last_modified and last_modified <= modified_since:
- unmodified = True
-
- if etag:
- etag, _ = unquote_etag(etag)
- if if_range is not None and if_range.etag is not None:
- unmodified = parse_etags(if_range.etag).contains(etag)
- else:
- if_none_match = parse_etags(environ.get("HTTP_IF_NONE_MATCH"))
- if if_none_match:
- # https://tools.ietf.org/html/rfc7232#section-3.2
- # "A recipient MUST use the weak comparison function when comparing
- # entity-tags for If-None-Match"
- unmodified = if_none_match.contains_weak(etag)
-
- # https://tools.ietf.org/html/rfc7232#section-3.1
- # "Origin server MUST use the strong comparison function when
- # comparing entity-tags for If-Match"
- if_match = parse_etags(environ.get("HTTP_IF_MATCH"))
- if if_match:
- unmodified = not if_match.is_strong(etag)
-
- return not unmodified
-
-
-def remove_entity_headers(headers, allowed=("expires", "content-location")):
- """Remove all entity headers from a list or :class:`Headers` object. This
- operation works in-place. `Expires` and `Content-Location` headers are
- by default not removed. The reason for this is :rfc:`2616` section
- 10.3.5 which specifies some entity headers that should be sent.
-
- .. versionchanged:: 0.5
- added `allowed` parameter.
-
- :param headers: a list or :class:`Headers` object.
- :param allowed: a list of headers that should still be allowed even though
- they are entity headers.
- """
- allowed = set(x.lower() for x in allowed)
- headers[:] = [
- (key, value)
- for key, value in headers
- if not is_entity_header(key) or key.lower() in allowed
- ]
-
-
-def remove_hop_by_hop_headers(headers):
- """Remove all HTTP/1.1 "Hop-by-Hop" headers from a list or
- :class:`Headers` object. This operation works in-place.
-
- .. versionadded:: 0.5
-
- :param headers: a list or :class:`Headers` object.
- """
- headers[:] = [
- (key, value) for key, value in headers if not is_hop_by_hop_header(key)
- ]
-
-
-def is_entity_header(header):
- """Check if a header is an entity header.
-
- .. versionadded:: 0.5
-
- :param header: the header to test.
- :return: `True` if it's an entity header, `False` otherwise.
- """
- return header.lower() in _entity_headers
-
-
-def is_hop_by_hop_header(header):
- """Check if a header is an HTTP/1.1 "Hop-by-Hop" header.
-
- .. versionadded:: 0.5
-
- :param header: the header to test.
- :return: `True` if it's an HTTP/1.1 "Hop-by-Hop" header, `False` otherwise.
- """
- return header.lower() in _hop_by_hop_headers
-
-
-def parse_cookie(header, charset="utf-8", errors="replace", cls=None):
- """Parse a cookie. Either from a string or WSGI environ.
-
- Per default encoding errors are ignored. If you want a different behavior
- you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a
- :exc:`HTTPUnicodeError` is raised.
-
- .. versionchanged:: 0.5
- This function now returns a :class:`TypeConversionDict` instead of a
- regular dict. The `cls` parameter was added.
-
- :param header: the header to be used to parse the cookie. Alternatively
- this can be a WSGI environment.
- :param charset: the charset for the cookie values.
- :param errors: the error behavior for the charset decoding.
- :param cls: an optional dict class to use. If this is not specified
- or `None` the default :class:`TypeConversionDict` is
- used.
- """
- if isinstance(header, dict):
- header = header.get("HTTP_COOKIE", "")
- elif header is None:
- header = ""
-
- # If the value is an unicode string it's mangled through latin1. This
- # is done because on PEP 3333 on Python 3 all headers are assumed latin1
- # which however is incorrect for cookies, which are sent in page encoding.
- # As a result we
- if isinstance(header, text_type):
- header = header.encode("latin1", "replace")
-
- if cls is None:
- cls = TypeConversionDict
-
- def _parse_pairs():
- for key, val in _cookie_parse_impl(header):
- key = to_unicode(key, charset, errors, allow_none_charset=True)
- if not key:
- continue
- val = to_unicode(val, charset, errors, allow_none_charset=True)
- yield try_coerce_native(key), val
-
- return cls(_parse_pairs())
-
-
-def dump_cookie(
- key,
- value="",
- max_age=None,
- expires=None,
- path="/",
- domain=None,
- secure=False,
- httponly=False,
- charset="utf-8",
- sync_expires=True,
- max_size=4093,
- samesite=None,
-):
- """Creates a new Set-Cookie header without the ``Set-Cookie`` prefix
- The parameters are the same as in the cookie Morsel object in the
- Python standard library but it accepts unicode data, too.
-
- On Python 3 the return value of this function will be a unicode
- string, on Python 2 it will be a native string. In both cases the
- return value is usually restricted to ascii as the vast majority of
- values are properly escaped, but that is no guarantee. If a unicode
- string is returned it's tunneled through latin1 as required by
- PEP 3333.
-
- The return value is not ASCII safe if the key contains unicode
- characters. This is technically against the specification but
- happens in the wild. It's strongly recommended to not use
- non-ASCII values for the keys.
-
- :param max_age: should be a number of seconds, or `None` (default) if
- the cookie should last only as long as the client's
- browser session. Additionally `timedelta` objects
- are accepted, too.
- :param expires: should be a `datetime` object or unix timestamp.
- :param path: limits the cookie to a given path, per default it will
- span the whole domain.
- :param domain: Use this if you want to set a cross-domain cookie. For
- example, ``domain=".example.com"`` will set a cookie
- that is readable by the domain ``www.example.com``,
- ``foo.example.com`` etc. Otherwise, a cookie will only
- be readable by the domain that set it.
- :param secure: The cookie will only be available via HTTPS
- :param httponly: disallow JavaScript to access the cookie. This is an
- extension to the cookie standard and probably not
- supported by all browsers.
- :param charset: the encoding for unicode values.
- :param sync_expires: automatically set expires if max_age is defined
- but expires not.
- :param max_size: Warn if the final header value exceeds this size. The
- default, 4093, should be safely `supported by most browsers
- <cookie_>`_. Set to 0 to disable this check.
- :param samesite: Limits the scope of the cookie such that it will only
- be attached to requests if those requests are "same-site".
-
- .. _`cookie`: http://browsercookielimits.squawky.net/
- """
- key = to_bytes(key, charset)
- value = to_bytes(value, charset)
-
- if path is not None:
- path = iri_to_uri(path, charset)
- domain = _make_cookie_domain(domain)
- if isinstance(max_age, timedelta):
- max_age = (max_age.days * 60 * 60 * 24) + max_age.seconds
- if expires is not None:
- if not isinstance(expires, string_types):
- expires = cookie_date(expires)
- elif max_age is not None and sync_expires:
- expires = to_bytes(cookie_date(time() + max_age))
-
- samesite = samesite.title() if samesite else None
- if samesite not in ("Strict", "Lax", None):
- raise ValueError("invalid SameSite value; must be 'Strict', 'Lax' or None")
-
- buf = [key + b"=" + _cookie_quote(value)]
-
- # XXX: In theory all of these parameters that are not marked with `None`
- # should be quoted. Because stdlib did not quote it before I did not
- # want to introduce quoting there now.
- for k, v, q in (
- (b"Domain", domain, True),
- (b"Expires", expires, False),
- (b"Max-Age", max_age, False),
- (b"Secure", secure, None),
- (b"HttpOnly", httponly, None),
- (b"Path", path, False),
- (b"SameSite", samesite, False),
- ):
- if q is None:
- if v:
- buf.append(k)
- continue
-
- if v is None:
- continue
-
- tmp = bytearray(k)
- if not isinstance(v, (bytes, bytearray)):
- v = to_bytes(text_type(v), charset)
- if q:
- v = _cookie_quote(v)
- tmp += b"=" + v
- buf.append(bytes(tmp))
-
- # The return value will be an incorrectly encoded latin1 header on
- # Python 3 for consistency with the headers object and a bytestring
- # on Python 2 because that's how the API makes more sense.
- rv = b"; ".join(buf)
- if not PY2:
- rv = rv.decode("latin1")
-
- # Warn if the final value of the cookie is less than the limit. If the
- # cookie is too large, then it may be silently ignored, which can be quite
- # hard to debug.
- cookie_size = len(rv)
-
- if max_size and cookie_size > max_size:
- value_size = len(value)
- warnings.warn(
- 'The "{key}" cookie is too large: the value was {value_size} bytes'
- " but the header required {extra_size} extra bytes. The final size"
- " was {cookie_size} bytes but the limit is {max_size} bytes."
- " Browsers may silently ignore cookies larger than this.".format(
- key=key,
- value_size=value_size,
- extra_size=cookie_size - value_size,
- cookie_size=cookie_size,
- max_size=max_size,
- ),
- stacklevel=2,
- )
-
- return rv
-
-
-def is_byte_range_valid(start, stop, length):
- """Checks if a given byte content range is valid for the given length.
-
- .. versionadded:: 0.7
- """
- if (start is None) != (stop is None):
- return False
- elif start is None:
- return length is None or length >= 0
- elif length is None:
- return 0 <= start < stop
- elif start >= stop:
- return False
- return 0 <= start < length
-
-
-# circular dependency fun
-from .datastructures import Accept
-from .datastructures import Authorization
-from .datastructures import ContentRange
-from .datastructures import ETags
-from .datastructures import HeaderSet
-from .datastructures import IfRange
-from .datastructures import Range
-from .datastructures import RequestCacheControl
-from .datastructures import TypeConversionDict
-from .datastructures import WWWAuthenticate
-from .urls import iri_to_uri
-
-# DEPRECATED
-from .datastructures import CharsetAccept as _CharsetAccept
-from .datastructures import Headers as _Headers
-from .datastructures import LanguageAccept as _LanguageAccept
-from .datastructures import MIMEAccept as _MIMEAccept
-
-
-class MIMEAccept(_MIMEAccept):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.http.MIMEAccept' has moved to 'werkzeug"
- ".datastructures.MIMEAccept' as of version 0.5. This old"
- " import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(MIMEAccept, self).__init__(*args, **kwargs)
-
-
-class CharsetAccept(_CharsetAccept):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.http.CharsetAccept' has moved to 'werkzeug"
- ".datastructures.CharsetAccept' as of version 0.5. This old"
- " import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(CharsetAccept, self).__init__(*args, **kwargs)
-
-
-class LanguageAccept(_LanguageAccept):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.http.LanguageAccept' has moved to 'werkzeug"
- ".datastructures.LanguageAccept' as of version 0.5. This"
- " old import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(LanguageAccept, self).__init__(*args, **kwargs)
-
-
-class Headers(_Headers):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.http.Headers' has moved to 'werkzeug"
- ".datastructures.Headers' as of version 0.5. This old"
- " import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(Headers, self).__init__(*args, **kwargs)
diff --git a/python/werkzeug/local.py b/python/werkzeug/local.py
deleted file mode 100644
index 9a6088c..0000000
--- a/python/werkzeug/local.py
+++ /dev/null
@@ -1,421 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.local
- ~~~~~~~~~~~~~~
-
- This module implements context-local objects.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import copy
-from functools import update_wrapper
-
-from ._compat import implements_bool
-from ._compat import PY2
-from .wsgi import ClosingIterator
-
-# since each thread has its own greenlet we can just use those as identifiers
-# for the context. If greenlets are not available we fall back to the
-# current thread ident depending on where it is.
-try:
- from greenlet import getcurrent as get_ident
-except ImportError:
- try:
- from thread import get_ident
- except ImportError:
- from _thread import get_ident
-
-
-def release_local(local):
- """Releases the contents of the local for the current context.
- This makes it possible to use locals without a manager.
-
- Example::
-
- >>> loc = Local()
- >>> loc.foo = 42
- >>> release_local(loc)
- >>> hasattr(loc, 'foo')
- False
-
- With this function one can release :class:`Local` objects as well
- as :class:`LocalStack` objects. However it is not possible to
- release data held by proxies that way, one always has to retain
- a reference to the underlying local object in order to be able
- to release it.
-
- .. versionadded:: 0.6.1
- """
- local.__release_local__()
-
-
-class Local(object):
- __slots__ = ("__storage__", "__ident_func__")
-
- def __init__(self):
- object.__setattr__(self, "__storage__", {})
- object.__setattr__(self, "__ident_func__", get_ident)
-
- def __iter__(self):
- return iter(self.__storage__.items())
-
- def __call__(self, proxy):
- """Create a proxy for a name."""
- return LocalProxy(self, proxy)
-
- def __release_local__(self):
- self.__storage__.pop(self.__ident_func__(), None)
-
- def __getattr__(self, name):
- try:
- return self.__storage__[self.__ident_func__()][name]
- except KeyError:
- raise AttributeError(name)
-
- def __setattr__(self, name, value):
- ident = self.__ident_func__()
- storage = self.__storage__
- try:
- storage[ident][name] = value
- except KeyError:
- storage[ident] = {name: value}
-
- def __delattr__(self, name):
- try:
- del self.__storage__[self.__ident_func__()][name]
- except KeyError:
- raise AttributeError(name)
-
-
-class LocalStack(object):
- """This class works similar to a :class:`Local` but keeps a stack
- of objects instead. This is best explained with an example::
-
- >>> ls = LocalStack()
- >>> ls.push(42)
- >>> ls.top
- 42
- >>> ls.push(23)
- >>> ls.top
- 23
- >>> ls.pop()
- 23
- >>> ls.top
- 42
-
- They can be force released by using a :class:`LocalManager` or with
- the :func:`release_local` function but the correct way is to pop the
- item from the stack after using. When the stack is empty it will
- no longer be bound to the current context (and as such released).
-
- By calling the stack without arguments it returns a proxy that resolves to
- the topmost item on the stack.
-
- .. versionadded:: 0.6.1
- """
-
- def __init__(self):
- self._local = Local()
-
- def __release_local__(self):
- self._local.__release_local__()
-
- def _get__ident_func__(self):
- return self._local.__ident_func__
-
- def _set__ident_func__(self, value):
- object.__setattr__(self._local, "__ident_func__", value)
-
- __ident_func__ = property(_get__ident_func__, _set__ident_func__)
- del _get__ident_func__, _set__ident_func__
-
- def __call__(self):
- def _lookup():
- rv = self.top
- if rv is None:
- raise RuntimeError("object unbound")
- return rv
-
- return LocalProxy(_lookup)
-
- def push(self, obj):
- """Pushes a new item to the stack"""
- rv = getattr(self._local, "stack", None)
- if rv is None:
- self._local.stack = rv = []
- rv.append(obj)
- return rv
-
- def pop(self):
- """Removes the topmost item from the stack, will return the
- old value or `None` if the stack was already empty.
- """
- stack = getattr(self._local, "stack", None)
- if stack is None:
- return None
- elif len(stack) == 1:
- release_local(self._local)
- return stack[-1]
- else:
- return stack.pop()
-
- @property
- def top(self):
- """The topmost item on the stack. If the stack is empty,
- `None` is returned.
- """
- try:
- return self._local.stack[-1]
- except (AttributeError, IndexError):
- return None
-
-
-class LocalManager(object):
- """Local objects cannot manage themselves. For that you need a local
- manager. You can pass a local manager multiple locals or add them later
- by appending them to `manager.locals`. Every time the manager cleans up,
- it will clean up all the data left in the locals for this context.
-
- The `ident_func` parameter can be added to override the default ident
- function for the wrapped locals.
-
- .. versionchanged:: 0.6.1
- Instead of a manager the :func:`release_local` function can be used
- as well.
-
- .. versionchanged:: 0.7
- `ident_func` was added.
- """
-
- def __init__(self, locals=None, ident_func=None):
- if locals is None:
- self.locals = []
- elif isinstance(locals, Local):
- self.locals = [locals]
- else:
- self.locals = list(locals)
- if ident_func is not None:
- self.ident_func = ident_func
- for local in self.locals:
- object.__setattr__(local, "__ident_func__", ident_func)
- else:
- self.ident_func = get_ident
-
- def get_ident(self):
- """Return the context identifier the local objects use internally for
- this context. You cannot override this method to change the behavior
- but use it to link other context local objects (such as SQLAlchemy's
- scoped sessions) to the Werkzeug locals.
-
- .. versionchanged:: 0.7
- You can pass a different ident function to the local manager that
- will then be propagated to all the locals passed to the
- constructor.
- """
- return self.ident_func()
-
- def cleanup(self):
- """Manually clean up the data in the locals for this context. Call
- this at the end of the request or use `make_middleware()`.
- """
- for local in self.locals:
- release_local(local)
-
- def make_middleware(self, app):
- """Wrap a WSGI application so that cleaning up happens after
- request end.
- """
-
- def application(environ, start_response):
- return ClosingIterator(app(environ, start_response), self.cleanup)
-
- return application
-
- def middleware(self, func):
- """Like `make_middleware` but for decorating functions.
-
- Example usage::
-
- @manager.middleware
- def application(environ, start_response):
- ...
-
- The difference to `make_middleware` is that the function passed
- will have all the arguments copied from the inner application
- (name, docstring, module).
- """
- return update_wrapper(self.make_middleware(func), func)
-
- def __repr__(self):
- return "<%s storages: %d>" % (self.__class__.__name__, len(self.locals))
-
-
-@implements_bool
-class LocalProxy(object):
- """Acts as a proxy for a werkzeug local. Forwards all operations to
- a proxied object. The only operations not supported for forwarding
- are right handed operands and any kind of assignment.
-
- Example usage::
-
- from werkzeug.local import Local
- l = Local()
-
- # these are proxies
- request = l('request')
- user = l('user')
-
-
- from werkzeug.local import LocalStack
- _response_local = LocalStack()
-
- # this is a proxy
- response = _response_local()
-
- Whenever something is bound to l.user / l.request the proxy objects
- will forward all operations. If no object is bound a :exc:`RuntimeError`
- will be raised.
-
- To create proxies to :class:`Local` or :class:`LocalStack` objects,
- call the object as shown above. If you want to have a proxy to an
- object looked up by a function, you can (as of Werkzeug 0.6.1) pass
- a function to the :class:`LocalProxy` constructor::
-
- session = LocalProxy(lambda: get_current_request().session)
-
- .. versionchanged:: 0.6.1
- The class can be instantiated with a callable as well now.
- """
-
- __slots__ = ("__local", "__dict__", "__name__", "__wrapped__")
-
- def __init__(self, local, name=None):
- object.__setattr__(self, "_LocalProxy__local", local)
- object.__setattr__(self, "__name__", name)
- if callable(local) and not hasattr(local, "__release_local__"):
- # "local" is a callable that is not an instance of Local or
- # LocalManager: mark it as a wrapped function.
- object.__setattr__(self, "__wrapped__", local)
-
- def _get_current_object(self):
- """Return the current object. This is useful if you want the real
- object behind the proxy at a time for performance reasons or because
- you want to pass the object into a different context.
- """
- if not hasattr(self.__local, "__release_local__"):
- return self.__local()
- try:
- return getattr(self.__local, self.__name__)
- except AttributeError:
- raise RuntimeError("no object bound to %s" % self.__name__)
-
- @property
- def __dict__(self):
- try:
- return self._get_current_object().__dict__
- except RuntimeError:
- raise AttributeError("__dict__")
-
- def __repr__(self):
- try:
- obj = self._get_current_object()
- except RuntimeError:
- return "<%s unbound>" % self.__class__.__name__
- return repr(obj)
-
- def __bool__(self):
- try:
- return bool(self._get_current_object())
- except RuntimeError:
- return False
-
- def __unicode__(self):
- try:
- return unicode(self._get_current_object()) # noqa
- except RuntimeError:
- return repr(self)
-
- def __dir__(self):
- try:
- return dir(self._get_current_object())
- except RuntimeError:
- return []
-
- def __getattr__(self, name):
- if name == "__members__":
- return dir(self._get_current_object())
- return getattr(self._get_current_object(), name)
-
- def __setitem__(self, key, value):
- self._get_current_object()[key] = value
-
- def __delitem__(self, key):
- del self._get_current_object()[key]
-
- if PY2:
- __getslice__ = lambda x, i, j: x._get_current_object()[i:j]
-
- def __setslice__(self, i, j, seq):
- self._get_current_object()[i:j] = seq
-
- def __delslice__(self, i, j):
- del self._get_current_object()[i:j]
-
- __setattr__ = lambda x, n, v: setattr(x._get_current_object(), n, v)
- __delattr__ = lambda x, n: delattr(x._get_current_object(), n)
- __str__ = lambda x: str(x._get_current_object())
- __lt__ = lambda x, o: x._get_current_object() < o
- __le__ = lambda x, o: x._get_current_object() <= o
- __eq__ = lambda x, o: x._get_current_object() == o
- __ne__ = lambda x, o: x._get_current_object() != o
- __gt__ = lambda x, o: x._get_current_object() > o
- __ge__ = lambda x, o: x._get_current_object() >= o
- __cmp__ = lambda x, o: cmp(x._get_current_object(), o) # noqa
- __hash__ = lambda x: hash(x._get_current_object())
- __call__ = lambda x, *a, **kw: x._get_current_object()(*a, **kw)
- __len__ = lambda x: len(x._get_current_object())
- __getitem__ = lambda x, i: x._get_current_object()[i]
- __iter__ = lambda x: iter(x._get_current_object())
- __contains__ = lambda x, i: i in x._get_current_object()
- __add__ = lambda x, o: x._get_current_object() + o
- __sub__ = lambda x, o: x._get_current_object() - o
- __mul__ = lambda x, o: x._get_current_object() * o
- __floordiv__ = lambda x, o: x._get_current_object() // o
- __mod__ = lambda x, o: x._get_current_object() % o
- __divmod__ = lambda x, o: x._get_current_object().__divmod__(o)
- __pow__ = lambda x, o: x._get_current_object() ** o
- __lshift__ = lambda x, o: x._get_current_object() << o
- __rshift__ = lambda x, o: x._get_current_object() >> o
- __and__ = lambda x, o: x._get_current_object() & o
- __xor__ = lambda x, o: x._get_current_object() ^ o
- __or__ = lambda x, o: x._get_current_object() | o
- __div__ = lambda x, o: x._get_current_object().__div__(o)
- __truediv__ = lambda x, o: x._get_current_object().__truediv__(o)
- __neg__ = lambda x: -(x._get_current_object())
- __pos__ = lambda x: +(x._get_current_object())
- __abs__ = lambda x: abs(x._get_current_object())
- __invert__ = lambda x: ~(x._get_current_object())
- __complex__ = lambda x: complex(x._get_current_object())
- __int__ = lambda x: int(x._get_current_object())
- __long__ = lambda x: long(x._get_current_object()) # noqa
- __float__ = lambda x: float(x._get_current_object())
- __oct__ = lambda x: oct(x._get_current_object())
- __hex__ = lambda x: hex(x._get_current_object())
- __index__ = lambda x: x._get_current_object().__index__()
- __coerce__ = lambda x, o: x._get_current_object().__coerce__(x, o)
- __enter__ = lambda x: x._get_current_object().__enter__()
- __exit__ = lambda x, *a, **kw: x._get_current_object().__exit__(*a, **kw)
- __radd__ = lambda x, o: o + x._get_current_object()
- __rsub__ = lambda x, o: o - x._get_current_object()
- __rmul__ = lambda x, o: o * x._get_current_object()
- __rdiv__ = lambda x, o: o / x._get_current_object()
- if PY2:
- __rtruediv__ = lambda x, o: x._get_current_object().__rtruediv__(o)
- else:
- __rtruediv__ = __rdiv__
- __rfloordiv__ = lambda x, o: o // x._get_current_object()
- __rmod__ = lambda x, o: o % x._get_current_object()
- __rdivmod__ = lambda x, o: x._get_current_object().__rdivmod__(o)
- __copy__ = lambda x: copy.copy(x._get_current_object())
- __deepcopy__ = lambda x, memo: copy.deepcopy(x._get_current_object(), memo)
diff --git a/python/werkzeug/middleware/__init__.py b/python/werkzeug/middleware/__init__.py
deleted file mode 100644
index 5e049f5..0000000
--- a/python/werkzeug/middleware/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-"""
-Middleware
-==========
-
-A WSGI middleware is a WSGI application that wraps another application
-in order to observe or change its behavior. Werkzeug provides some
-middleware for common use cases.
-
-.. toctree::
- :maxdepth: 1
-
- proxy_fix
- shared_data
- dispatcher
- http_proxy
- lint
- profiler
-
-The :doc:`interactive debugger </debug>` is also a middleware that can
-be applied manually, although it is typically used automatically with
-the :doc:`development server </serving>`.
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
diff --git a/python/werkzeug/middleware/dispatcher.py b/python/werkzeug/middleware/dispatcher.py
deleted file mode 100644
index 2eb173e..0000000
--- a/python/werkzeug/middleware/dispatcher.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
-Application Dispatcher
-======================
-
-This middleware creates a single WSGI application that dispatches to
-multiple other WSGI applications mounted at different URL paths.
-
-A common example is writing a Single Page Application, where you have a
-backend API and a frontend written in JavaScript that does the routing
-in the browser rather than requesting different pages from the server.
-The frontend is a single HTML and JS file that should be served for any
-path besides "/api".
-
-This example dispatches to an API app under "/api", an admin app
-under "/admin", and an app that serves frontend files for all other
-requests::
-
- app = DispatcherMiddleware(serve_frontend, {
- '/api': api_app,
- '/admin': admin_app,
- })
-
-In production, you might instead handle this at the HTTP server level,
-serving files or proxying to application servers based on location. The
-API and admin apps would each be deployed with a separate WSGI server,
-and the static files would be served directly by the HTTP server.
-
-.. autoclass:: DispatcherMiddleware
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-
-
-class DispatcherMiddleware(object):
- """Combine multiple applications as a single WSGI application.
- Requests are dispatched to an application based on the path it is
- mounted under.
-
- :param app: The WSGI application to dispatch to if the request
- doesn't match a mounted path.
- :param mounts: Maps path prefixes to applications for dispatching.
- """
-
- def __init__(self, app, mounts=None):
- self.app = app
- self.mounts = mounts or {}
-
- def __call__(self, environ, start_response):
- script = environ.get("PATH_INFO", "")
- path_info = ""
-
- while "/" in script:
- if script in self.mounts:
- app = self.mounts[script]
- break
-
- script, last_item = script.rsplit("/", 1)
- path_info = "/%s%s" % (last_item, path_info)
- else:
- app = self.mounts.get(script, self.app)
-
- original_script_name = environ.get("SCRIPT_NAME", "")
- environ["SCRIPT_NAME"] = original_script_name + script
- environ["PATH_INFO"] = path_info
- return app(environ, start_response)
diff --git a/python/werkzeug/middleware/http_proxy.py b/python/werkzeug/middleware/http_proxy.py
deleted file mode 100644
index bfdc071..0000000
--- a/python/werkzeug/middleware/http_proxy.py
+++ /dev/null
@@ -1,219 +0,0 @@
-"""
-Basic HTTP Proxy
-================
-
-.. autoclass:: ProxyMiddleware
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-import socket
-
-from ..datastructures import EnvironHeaders
-from ..http import is_hop_by_hop_header
-from ..urls import url_parse
-from ..urls import url_quote
-from ..wsgi import get_input_stream
-
-try:
- from http import client
-except ImportError:
- import httplib as client
-
-
-class ProxyMiddleware(object):
- """Proxy requests under a path to an external server, routing other
- requests to the app.
-
- This middleware can only proxy HTTP requests, as that is the only
- protocol handled by the WSGI server. Other protocols, such as
- websocket requests, cannot be proxied at this layer. This should
- only be used for development, in production a real proxying server
- should be used.
-
- The middleware takes a dict that maps a path prefix to a dict
- describing the host to be proxied to::
-
- app = ProxyMiddleware(app, {
- "/static/": {
- "target": "http://127.0.0.1:5001/",
- }
- })
-
- Each host has the following options:
-
- ``target``:
- The target URL to dispatch to. This is required.
- ``remove_prefix``:
- Whether to remove the prefix from the URL before dispatching it
- to the target. The default is ``False``.
- ``host``:
- ``"<auto>"`` (default):
- The host header is automatically rewritten to the URL of the
- target.
- ``None``:
- The host header is unmodified from the client request.
- Any other value:
- The host header is overwritten with the value.
- ``headers``:
- A dictionary of headers to be sent with the request to the
- target. The default is ``{}``.
- ``ssl_context``:
- A :class:`ssl.SSLContext` defining how to verify requests if the
- target is HTTPS. The default is ``None``.
-
- In the example above, everything under ``"/static/"`` is proxied to
- the server on port 5001. The host header is rewritten to the target,
- and the ``"/static/"`` prefix is removed from the URLs.
-
- :param app: The WSGI application to wrap.
- :param targets: Proxy target configurations. See description above.
- :param chunk_size: Size of chunks to read from input stream and
- write to target.
- :param timeout: Seconds before an operation to a target fails.
-
- .. versionadded:: 0.14
- """
-
- def __init__(self, app, targets, chunk_size=2 << 13, timeout=10):
- def _set_defaults(opts):
- opts.setdefault("remove_prefix", False)
- opts.setdefault("host", "<auto>")
- opts.setdefault("headers", {})
- opts.setdefault("ssl_context", None)
- return opts
-
- self.app = app
- self.targets = dict(
- ("/%s/" % k.strip("/"), _set_defaults(v)) for k, v in targets.items()
- )
- self.chunk_size = chunk_size
- self.timeout = timeout
-
- def proxy_to(self, opts, path, prefix):
- target = url_parse(opts["target"])
-
- def application(environ, start_response):
- headers = list(EnvironHeaders(environ).items())
- headers[:] = [
- (k, v)
- for k, v in headers
- if not is_hop_by_hop_header(k)
- and k.lower() not in ("content-length", "host")
- ]
- headers.append(("Connection", "close"))
-
- if opts["host"] == "<auto>":
- headers.append(("Host", target.ascii_host))
- elif opts["host"] is None:
- headers.append(("Host", environ["HTTP_HOST"]))
- else:
- headers.append(("Host", opts["host"]))
-
- headers.extend(opts["headers"].items())
- remote_path = path
-
- if opts["remove_prefix"]:
- remote_path = "%s/%s" % (
- target.path.rstrip("/"),
- remote_path[len(prefix) :].lstrip("/"),
- )
-
- content_length = environ.get("CONTENT_LENGTH")
- chunked = False
-
- if content_length not in ("", None):
- headers.append(("Content-Length", content_length))
- elif content_length is not None:
- headers.append(("Transfer-Encoding", "chunked"))
- chunked = True
-
- try:
- if target.scheme == "http":
- con = client.HTTPConnection(
- target.ascii_host, target.port or 80, timeout=self.timeout
- )
- elif target.scheme == "https":
- con = client.HTTPSConnection(
- target.ascii_host,
- target.port or 443,
- timeout=self.timeout,
- context=opts["ssl_context"],
- )
- else:
- raise RuntimeError(
- "Target scheme must be 'http' or 'https', got '{}'.".format(
- target.scheme
- )
- )
-
- con.connect()
- remote_url = url_quote(remote_path)
- querystring = environ["QUERY_STRING"]
-
- if querystring:
- remote_url = remote_url + "?" + querystring
-
- con.putrequest(environ["REQUEST_METHOD"], remote_url, skip_host=True)
-
- for k, v in headers:
- if k.lower() == "connection":
- v = "close"
-
- con.putheader(k, v)
-
- con.endheaders()
- stream = get_input_stream(environ)
-
- while 1:
- data = stream.read(self.chunk_size)
-
- if not data:
- break
-
- if chunked:
- con.send(b"%x\r\n%s\r\n" % (len(data), data))
- else:
- con.send(data)
-
- resp = con.getresponse()
- except socket.error:
- from ..exceptions import BadGateway
-
- return BadGateway()(environ, start_response)
-
- start_response(
- "%d %s" % (resp.status, resp.reason),
- [
- (k.title(), v)
- for k, v in resp.getheaders()
- if not is_hop_by_hop_header(k)
- ],
- )
-
- def read():
- while 1:
- try:
- data = resp.read(self.chunk_size)
- except socket.error:
- break
-
- if not data:
- break
-
- yield data
-
- return read()
-
- return application
-
- def __call__(self, environ, start_response):
- path = environ["PATH_INFO"]
- app = self.app
-
- for prefix, opts in self.targets.items():
- if path.startswith(prefix):
- app = self.proxy_to(opts, path, prefix)
- break
-
- return app(environ, start_response)
diff --git a/python/werkzeug/middleware/lint.py b/python/werkzeug/middleware/lint.py
deleted file mode 100644
index 98f9581..0000000
--- a/python/werkzeug/middleware/lint.py
+++ /dev/null
@@ -1,408 +0,0 @@
-"""
-WSGI Protocol Linter
-====================
-
-This module provides a middleware that performs sanity checks on the
-behavior of the WSGI server and application. It checks that the
-:pep:`3333` WSGI spec is properly implemented. It also warns on some
-common HTTP errors such as non-empty responses for 304 status codes.
-
-.. autoclass:: LintMiddleware
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-from warnings import warn
-
-from .._compat import implements_iterator
-from .._compat import PY2
-from .._compat import string_types
-from ..datastructures import Headers
-from ..http import is_entity_header
-from ..wsgi import FileWrapper
-
-try:
- from urllib.parse import urlparse
-except ImportError:
- from urlparse import urlparse
-
-
-class WSGIWarning(Warning):
- """Warning class for WSGI warnings."""
-
-
-class HTTPWarning(Warning):
- """Warning class for HTTP warnings."""
-
-
-def check_string(context, obj, stacklevel=3):
- if type(obj) is not str:
- warn(
- "'%s' requires strings, got '%s'" % (context, type(obj).__name__),
- WSGIWarning,
- )
-
-
-class InputStream(object):
- def __init__(self, stream):
- self._stream = stream
-
- def read(self, *args):
- if len(args) == 0:
- warn(
- "WSGI does not guarantee an EOF marker on the input stream, thus making"
- " calls to 'wsgi.input.read()' unsafe. Conforming servers may never"
- " return from this call.",
- WSGIWarning,
- stacklevel=2,
- )
- elif len(args) != 1:
- warn(
- "Too many parameters passed to 'wsgi.input.read()'.",
- WSGIWarning,
- stacklevel=2,
- )
- return self._stream.read(*args)
-
- def readline(self, *args):
- if len(args) == 0:
- warn(
- "Calls to 'wsgi.input.readline()' without arguments are unsafe. Use"
- " 'wsgi.input.read()' instead.",
- WSGIWarning,
- stacklevel=2,
- )
- elif len(args) == 1:
- warn(
- "'wsgi.input.readline()' was called with a size hint. WSGI does not"
- " support this, although it's available on all major servers.",
- WSGIWarning,
- stacklevel=2,
- )
- else:
- raise TypeError("Too many arguments passed to 'wsgi.input.readline()'.")
- return self._stream.readline(*args)
-
- def __iter__(self):
- try:
- return iter(self._stream)
- except TypeError:
- warn("'wsgi.input' is not iterable.", WSGIWarning, stacklevel=2)
- return iter(())
-
- def close(self):
- warn("The application closed the input stream!", WSGIWarning, stacklevel=2)
- self._stream.close()
-
-
-class ErrorStream(object):
- def __init__(self, stream):
- self._stream = stream
-
- def write(self, s):
- check_string("wsgi.error.write()", s)
- self._stream.write(s)
-
- def flush(self):
- self._stream.flush()
-
- def writelines(self, seq):
- for line in seq:
- self.write(line)
-
- def close(self):
- warn("The application closed the error stream!", WSGIWarning, stacklevel=2)
- self._stream.close()
-
-
-class GuardedWrite(object):
- def __init__(self, write, chunks):
- self._write = write
- self._chunks = chunks
-
- def __call__(self, s):
- check_string("write()", s)
- self._write.write(s)
- self._chunks.append(len(s))
-
-
-@implements_iterator
-class GuardedIterator(object):
- def __init__(self, iterator, headers_set, chunks):
- self._iterator = iterator
- if PY2:
- self._next = iter(iterator).next
- else:
- self._next = iter(iterator).__next__
- self.closed = False
- self.headers_set = headers_set
- self.chunks = chunks
-
- def __iter__(self):
- return self
-
- def __next__(self):
- if self.closed:
- warn("Iterated over closed 'app_iter'.", WSGIWarning, stacklevel=2)
-
- rv = self._next()
-
- if not self.headers_set:
- warn(
- "The application returned before it started the response.",
- WSGIWarning,
- stacklevel=2,
- )
-
- check_string("application iterator items", rv)
- self.chunks.append(len(rv))
- return rv
-
- def close(self):
- self.closed = True
-
- if hasattr(self._iterator, "close"):
- self._iterator.close()
-
- if self.headers_set:
- status_code, headers = self.headers_set
- bytes_sent = sum(self.chunks)
- content_length = headers.get("content-length", type=int)
-
- if status_code == 304:
- for key, _value in headers:
- key = key.lower()
- if key not in ("expires", "content-location") and is_entity_header(
- key
- ):
- warn(
- "Entity header %r found in 304 response." % key, HTTPWarning
- )
- if bytes_sent:
- warn("304 responses must not have a body.", HTTPWarning)
- elif 100 <= status_code < 200 or status_code == 204:
- if content_length != 0:
- warn(
- "%r responses must have an empty content length." % status_code,
- HTTPWarning,
- )
- if bytes_sent:
- warn(
- "%r responses must not have a body." % status_code, HTTPWarning
- )
- elif content_length is not None and content_length != bytes_sent:
- warn(
- "Content-Length and the number of bytes sent to the client do not"
- " match.",
- WSGIWarning,
- )
-
- def __del__(self):
- if not self.closed:
- try:
- warn(
- "Iterator was garbage collected before it was closed.", WSGIWarning
- )
- except Exception:
- pass
-
-
-class LintMiddleware(object):
- """Warns about common errors in the WSGI and HTTP behavior of the
- server and wrapped application. Some of the issues it check are:
-
- - invalid status codes
- - non-bytestrings sent to the WSGI server
- - strings returned from the WSGI application
- - non-empty conditional responses
- - unquoted etags
- - relative URLs in the Location header
- - unsafe calls to wsgi.input
- - unclosed iterators
-
- Error information is emitted using the :mod:`warnings` module.
-
- :param app: The WSGI application to wrap.
-
- .. code-block:: python
-
- from werkzeug.middleware.lint import LintMiddleware
- app = LintMiddleware(app)
- """
-
- def __init__(self, app):
- self.app = app
-
- def check_environ(self, environ):
- if type(environ) is not dict:
- warn(
- "WSGI environment is not a standard Python dict.",
- WSGIWarning,
- stacklevel=4,
- )
- for key in (
- "REQUEST_METHOD",
- "SERVER_NAME",
- "SERVER_PORT",
- "wsgi.version",
- "wsgi.input",
- "wsgi.errors",
- "wsgi.multithread",
- "wsgi.multiprocess",
- "wsgi.run_once",
- ):
- if key not in environ:
- warn(
- "Required environment key %r not found" % key,
- WSGIWarning,
- stacklevel=3,
- )
- if environ["wsgi.version"] != (1, 0):
- warn("Environ is not a WSGI 1.0 environ.", WSGIWarning, stacklevel=3)
-
- script_name = environ.get("SCRIPT_NAME", "")
- path_info = environ.get("PATH_INFO", "")
-
- if script_name and script_name[0] != "/":
- warn(
- "'SCRIPT_NAME' does not start with a slash: %r" % script_name,
- WSGIWarning,
- stacklevel=3,
- )
-
- if path_info and path_info[0] != "/":
- warn(
- "'PATH_INFO' does not start with a slash: %r" % path_info,
- WSGIWarning,
- stacklevel=3,
- )
-
- def check_start_response(self, status, headers, exc_info):
- check_string("status", status)
- status_code = status.split(None, 1)[0]
-
- if len(status_code) != 3 or not status_code.isdigit():
- warn(WSGIWarning("Status code must be three digits"), stacklevel=3)
-
- if len(status) < 4 or status[3] != " ":
- warn(
- WSGIWarning(
- "Invalid value for status %r. Valid "
- "status strings are three digits, a space "
- "and a status explanation"
- ),
- stacklevel=3,
- )
-
- status_code = int(status_code)
-
- if status_code < 100:
- warn(WSGIWarning("status code < 100 detected"), stacklevel=3)
-
- if type(headers) is not list:
- warn(WSGIWarning("header list is not a list"), stacklevel=3)
-
- for item in headers:
- if type(item) is not tuple or len(item) != 2:
- warn(WSGIWarning("Headers must tuple 2-item tuples"), stacklevel=3)
- name, value = item
- if type(name) is not str or type(value) is not str:
- warn(WSGIWarning("header items must be strings"), stacklevel=3)
- if name.lower() == "status":
- warn(
- WSGIWarning(
- "The status header is not supported due to "
- "conflicts with the CGI spec."
- ),
- stacklevel=3,
- )
-
- if exc_info is not None and not isinstance(exc_info, tuple):
- warn(WSGIWarning("invalid value for exc_info"), stacklevel=3)
-
- headers = Headers(headers)
- self.check_headers(headers)
-
- return status_code, headers
-
- def check_headers(self, headers):
- etag = headers.get("etag")
-
- if etag is not None:
- if etag.startswith(("W/", "w/")):
- if etag.startswith("w/"):
- warn(
- HTTPWarning("weak etag indicator should be upcase."),
- stacklevel=4,
- )
-
- etag = etag[2:]
-
- if not (etag[:1] == etag[-1:] == '"'):
- warn(HTTPWarning("unquoted etag emitted."), stacklevel=4)
-
- location = headers.get("location")
-
- if location is not None:
- if not urlparse(location).netloc:
- warn(
- HTTPWarning("absolute URLs required for location header"),
- stacklevel=4,
- )
-
- def check_iterator(self, app_iter):
- if isinstance(app_iter, string_types):
- warn(
- "The application returned astring. The response will send one character"
- " at a time to the client, which will kill performance. Return a list"
- " or iterable instead.",
- WSGIWarning,
- stacklevel=3,
- )
-
- def __call__(self, *args, **kwargs):
- if len(args) != 2:
- warn("A WSGI app takes two arguments.", WSGIWarning, stacklevel=2)
-
- if kwargs:
- warn(
- "A WSGI app does not take keyword arguments.", WSGIWarning, stacklevel=2
- )
-
- environ, start_response = args
-
- self.check_environ(environ)
- environ["wsgi.input"] = InputStream(environ["wsgi.input"])
- environ["wsgi.errors"] = ErrorStream(environ["wsgi.errors"])
-
- # Hook our own file wrapper in so that applications will always
- # iterate to the end and we can check the content length.
- environ["wsgi.file_wrapper"] = FileWrapper
-
- headers_set = []
- chunks = []
-
- def checking_start_response(*args, **kwargs):
- if len(args) not in (2, 3):
- warn(
- "Invalid number of arguments: %s, expected 2 or 3." % len(args),
- WSGIWarning,
- stacklevel=2,
- )
-
- if kwargs:
- warn("'start_response' does not take keyword arguments.", WSGIWarning)
-
- status, headers = args[:2]
-
- if len(args) == 3:
- exc_info = args[2]
- else:
- exc_info = None
-
- headers_set[:] = self.check_start_response(status, headers, exc_info)
- return GuardedWrite(start_response(status, headers, exc_info), chunks)
-
- app_iter = self.app(environ, checking_start_response)
- self.check_iterator(app_iter)
- return GuardedIterator(app_iter, headers_set, chunks)
diff --git a/python/werkzeug/middleware/profiler.py b/python/werkzeug/middleware/profiler.py
deleted file mode 100644
index 32a14d9..0000000
--- a/python/werkzeug/middleware/profiler.py
+++ /dev/null
@@ -1,132 +0,0 @@
-"""
-Application Profiler
-====================
-
-This module provides a middleware that profiles each request with the
-:mod:`cProfile` module. This can help identify bottlenecks in your code
-that may be slowing down your application.
-
-.. autoclass:: ProfilerMiddleware
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-from __future__ import print_function
-
-import os.path
-import sys
-import time
-from pstats import Stats
-
-try:
- from cProfile import Profile
-except ImportError:
- from profile import Profile
-
-
-class ProfilerMiddleware(object):
- """Wrap a WSGI application and profile the execution of each
- request. Responses are buffered so that timings are more exact.
-
- If ``stream`` is given, :class:`pstats.Stats` are written to it
- after each request. If ``profile_dir`` is given, :mod:`cProfile`
- data files are saved to that directory, one file per request.
-
- The filename can be customized by passing ``filename_format``. If
- it is a string, it will be formatted using :meth:`str.format` with
- the following fields available:
-
- - ``{method}`` - The request method; GET, POST, etc.
- - ``{path}`` - The request path or 'root' should one not exist.
- - ``{elapsed}`` - The elapsed time of the request.
- - ``{time}`` - The time of the request.
-
- If it is a callable, it will be called with the WSGI ``environ``
- dict and should return a filename.
-
- :param app: The WSGI application to wrap.
- :param stream: Write stats to this stream. Disable with ``None``.
- :param sort_by: A tuple of columns to sort stats by. See
- :meth:`pstats.Stats.sort_stats`.
- :param restrictions: A tuple of restrictions to filter stats by. See
- :meth:`pstats.Stats.print_stats`.
- :param profile_dir: Save profile data files to this directory.
- :param filename_format: Format string for profile data file names,
- or a callable returning a name. See explanation above.
-
- .. code-block:: python
-
- from werkzeug.middleware.profiler import ProfilerMiddleware
- app = ProfilerMiddleware(app)
-
- .. versionchanged:: 0.15
- Stats are written even if ``profile_dir`` is given, and can be
- disable by passing ``stream=None``.
-
- .. versionadded:: 0.15
- Added ``filename_format``.
-
- .. versionadded:: 0.9
- Added ``restrictions`` and ``profile_dir``.
- """
-
- def __init__(
- self,
- app,
- stream=sys.stdout,
- sort_by=("time", "calls"),
- restrictions=(),
- profile_dir=None,
- filename_format="{method}.{path}.{elapsed:.0f}ms.{time:.0f}.prof",
- ):
- self._app = app
- self._stream = stream
- self._sort_by = sort_by
- self._restrictions = restrictions
- self._profile_dir = profile_dir
- self._filename_format = filename_format
-
- def __call__(self, environ, start_response):
- response_body = []
-
- def catching_start_response(status, headers, exc_info=None):
- start_response(status, headers, exc_info)
- return response_body.append
-
- def runapp():
- app_iter = self._app(environ, catching_start_response)
- response_body.extend(app_iter)
-
- if hasattr(app_iter, "close"):
- app_iter.close()
-
- profile = Profile()
- start = time.time()
- profile.runcall(runapp)
- body = b"".join(response_body)
- elapsed = time.time() - start
-
- if self._profile_dir is not None:
- if callable(self._filename_format):
- filename = self._filename_format(environ)
- else:
- filename = self._filename_format.format(
- method=environ["REQUEST_METHOD"],
- path=(
- environ.get("PATH_INFO").strip("/").replace("/", ".") or "root"
- ),
- elapsed=elapsed * 1000.0,
- time=time.time(),
- )
- filename = os.path.join(self._profile_dir, filename)
- profile.dump_stats(filename)
-
- if self._stream is not None:
- stats = Stats(profile, stream=self._stream)
- stats.sort_stats(*self._sort_by)
- print("-" * 80, file=self._stream)
- print("PATH: {!r}".format(environ.get("PATH_INFO", "")), file=self._stream)
- stats.print_stats(*self._restrictions)
- print("-" * 80 + "\n", file=self._stream)
-
- return [body]
diff --git a/python/werkzeug/middleware/proxy_fix.py b/python/werkzeug/middleware/proxy_fix.py
deleted file mode 100644
index dc1dacc..0000000
--- a/python/werkzeug/middleware/proxy_fix.py
+++ /dev/null
@@ -1,228 +0,0 @@
-"""
-X-Forwarded-For Proxy Fix
-=========================
-
-This module provides a middleware that adjusts the WSGI environ based on
-``X-Forwarded-`` headers that proxies in front of an application may
-set.
-
-When an application is running behind a proxy server, WSGI may see the
-request as coming from that server rather than the real client. Proxies
-set various headers to track where the request actually came from.
-
-This middleware should only be applied if the application is actually
-behind such a proxy, and should be configured with the number of proxies
-that are chained in front of it. Not all proxies set all the headers.
-Since incoming headers can be faked, you must set how many proxies are
-setting each header so the middleware knows what to trust.
-
-.. autoclass:: ProxyFix
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-import warnings
-
-
-class ProxyFix(object):
- """Adjust the WSGI environ based on ``X-Forwarded-`` that proxies in
- front of the application may set.
-
- - ``X-Forwarded-For`` sets ``REMOTE_ADDR``.
- - ``X-Forwarded-Proto`` sets ``wsgi.url_scheme``.
- - ``X-Forwarded-Host`` sets ``HTTP_HOST``, ``SERVER_NAME``, and
- ``SERVER_PORT``.
- - ``X-Forwarded-Port`` sets ``HTTP_HOST`` and ``SERVER_PORT``.
- - ``X-Forwarded-Prefix`` sets ``SCRIPT_NAME``.
-
- You must tell the middleware how many proxies set each header so it
- knows what values to trust. It is a security issue to trust values
- that came from the client rather than a proxy.
-
- The original values of the headers are stored in the WSGI
- environ as ``werkzeug.proxy_fix.orig``, a dict.
-
- :param app: The WSGI application to wrap.
- :param x_for: Number of values to trust for ``X-Forwarded-For``.
- :param x_proto: Number of values to trust for ``X-Forwarded-Proto``.
- :param x_host: Number of values to trust for ``X-Forwarded-Host``.
- :param x_port: Number of values to trust for ``X-Forwarded-Port``.
- :param x_prefix: Number of values to trust for
- ``X-Forwarded-Prefix``.
- :param num_proxies: Deprecated, use ``x_for`` instead.
-
- .. code-block:: python
-
- from werkzeug.middleware.proxy_fix import ProxyFix
- # App is behind one proxy that sets the -For and -Host headers.
- app = ProxyFix(app, x_for=1, x_host=1)
-
- .. versionchanged:: 0.15
- All headers support multiple values. The ``num_proxies``
- argument is deprecated. Each header is configured with a
- separate number of trusted proxies.
-
- .. versionchanged:: 0.15
- Original WSGI environ values are stored in the
- ``werkzeug.proxy_fix.orig`` dict. ``orig_remote_addr``,
- ``orig_wsgi_url_scheme``, and ``orig_http_host`` are deprecated
- and will be removed in 1.0.
-
- .. versionchanged:: 0.15
- Support ``X-Forwarded-Port`` and ``X-Forwarded-Prefix``.
-
- .. versionchanged:: 0.15
- ``X-Fowarded-Host`` and ``X-Forwarded-Port`` modify
- ``SERVER_NAME`` and ``SERVER_PORT``.
- """
-
- def __init__(
- self, app, num_proxies=None, x_for=1, x_proto=0, x_host=0, x_port=0, x_prefix=0
- ):
- self.app = app
- self.x_for = x_for
- self.x_proto = x_proto
- self.x_host = x_host
- self.x_port = x_port
- self.x_prefix = x_prefix
- self.num_proxies = num_proxies
-
- @property
- def num_proxies(self):
- """The number of proxies setting ``X-Forwarded-For`` in front
- of the application.
-
- .. deprecated:: 0.15
- A separate number of trusted proxies is configured for each
- header. ``num_proxies`` maps to ``x_for``. This method will
- be removed in 1.0.
-
- :internal:
- """
- warnings.warn(
- "'num_proxies' is deprecated as of version 0.15 and will be"
- " removed in version 1.0. Use 'x_for' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.x_for
-
- @num_proxies.setter
- def num_proxies(self, value):
- if value is not None:
- warnings.warn(
- "'num_proxies' is deprecated as of version 0.15 and"
- " will be removed in version 1.0. Use 'x_for' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- self.x_for = value
-
- def get_remote_addr(self, forwarded_for):
- """Get the real ``remote_addr`` by looking backwards ``x_for``
- number of values in the ``X-Forwarded-For`` header.
-
- :param forwarded_for: List of values parsed from the
- ``X-Forwarded-For`` header.
- :return: The real ``remote_addr``, or ``None`` if there were not
- at least ``x_for`` values.
-
- .. deprecated:: 0.15
- This is handled internally for each header. This method will
- be removed in 1.0.
-
- .. versionchanged:: 0.9
- Use ``num_proxies`` instead of always picking the first
- value.
-
- .. versionadded:: 0.8
- """
- warnings.warn(
- "'get_remote_addr' is deprecated as of version 0.15 and"
- " will be removed in version 1.0. It is now handled"
- " internally for each header.",
- DeprecationWarning,
- )
- return self._get_trusted_comma(self.x_for, ",".join(forwarded_for))
-
- def _get_trusted_comma(self, trusted, value):
- """Get the real value from a comma-separated header based on the
- configured number of trusted proxies.
-
- :param trusted: Number of values to trust in the header.
- :param value: Header value to parse.
- :return: The real value, or ``None`` if there are fewer values
- than the number of trusted proxies.
-
- .. versionadded:: 0.15
- """
- if not (trusted and value):
- return
- values = [x.strip() for x in value.split(",")]
- if len(values) >= trusted:
- return values[-trusted]
-
- def __call__(self, environ, start_response):
- """Modify the WSGI environ based on the various ``Forwarded``
- headers before calling the wrapped application. Store the
- original environ values in ``werkzeug.proxy_fix.orig_{key}``.
- """
- environ_get = environ.get
- orig_remote_addr = environ_get("REMOTE_ADDR")
- orig_wsgi_url_scheme = environ_get("wsgi.url_scheme")
- orig_http_host = environ_get("HTTP_HOST")
- environ.update(
- {
- "werkzeug.proxy_fix.orig": {
- "REMOTE_ADDR": orig_remote_addr,
- "wsgi.url_scheme": orig_wsgi_url_scheme,
- "HTTP_HOST": orig_http_host,
- "SERVER_NAME": environ_get("SERVER_NAME"),
- "SERVER_PORT": environ_get("SERVER_PORT"),
- "SCRIPT_NAME": environ_get("SCRIPT_NAME"),
- },
- # todo: remove deprecated keys
- "werkzeug.proxy_fix.orig_remote_addr": orig_remote_addr,
- "werkzeug.proxy_fix.orig_wsgi_url_scheme": orig_wsgi_url_scheme,
- "werkzeug.proxy_fix.orig_http_host": orig_http_host,
- }
- )
-
- x_for = self._get_trusted_comma(self.x_for, environ_get("HTTP_X_FORWARDED_FOR"))
- if x_for:
- environ["REMOTE_ADDR"] = x_for
-
- x_proto = self._get_trusted_comma(
- self.x_proto, environ_get("HTTP_X_FORWARDED_PROTO")
- )
- if x_proto:
- environ["wsgi.url_scheme"] = x_proto
-
- x_host = self._get_trusted_comma(
- self.x_host, environ_get("HTTP_X_FORWARDED_HOST")
- )
- if x_host:
- environ["HTTP_HOST"] = x_host
- parts = x_host.split(":", 1)
- environ["SERVER_NAME"] = parts[0]
- if len(parts) == 2:
- environ["SERVER_PORT"] = parts[1]
-
- x_port = self._get_trusted_comma(
- self.x_port, environ_get("HTTP_X_FORWARDED_PORT")
- )
- if x_port:
- host = environ.get("HTTP_HOST")
- if host:
- parts = host.split(":", 1)
- host = parts[0] if len(parts) == 2 else host
- environ["HTTP_HOST"] = "%s:%s" % (host, x_port)
- environ["SERVER_PORT"] = x_port
-
- x_prefix = self._get_trusted_comma(
- self.x_prefix, environ_get("HTTP_X_FORWARDED_PREFIX")
- )
- if x_prefix:
- environ["SCRIPT_NAME"] = x_prefix
-
- return self.app(environ, start_response)
diff --git a/python/werkzeug/middleware/shared_data.py b/python/werkzeug/middleware/shared_data.py
deleted file mode 100644
index a902281..0000000
--- a/python/werkzeug/middleware/shared_data.py
+++ /dev/null
@@ -1,260 +0,0 @@
-"""
-Serve Shared Static Files
-=========================
-
-.. autoclass:: SharedDataMiddleware
- :members: is_allowed
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-import mimetypes
-import os
-import posixpath
-from datetime import datetime
-from io import BytesIO
-from time import mktime
-from time import time
-from zlib import adler32
-
-from .._compat import PY2
-from .._compat import string_types
-from ..filesystem import get_filesystem_encoding
-from ..http import http_date
-from ..http import is_resource_modified
-from ..wsgi import get_path_info
-from ..wsgi import wrap_file
-
-
-class SharedDataMiddleware(object):
-
- """A WSGI middleware that provides static content for development
- environments or simple server setups. Usage is quite simple::
-
- import os
- from werkzeug.wsgi import SharedDataMiddleware
-
- app = SharedDataMiddleware(app, {
- '/static': os.path.join(os.path.dirname(__file__), 'static')
- })
-
- The contents of the folder ``./shared`` will now be available on
- ``http://example.com/shared/``. This is pretty useful during development
- because a standalone media server is not required. One can also mount
- files on the root folder and still continue to use the application because
- the shared data middleware forwards all unhandled requests to the
- application, even if the requests are below one of the shared folders.
-
- If `pkg_resources` is available you can also tell the middleware to serve
- files from package data::
-
- app = SharedDataMiddleware(app, {
- '/static': ('myapplication', 'static')
- })
-
- This will then serve the ``static`` folder in the `myapplication`
- Python package.
-
- The optional `disallow` parameter can be a list of :func:`~fnmatch.fnmatch`
- rules for files that are not accessible from the web. If `cache` is set to
- `False` no caching headers are sent.
-
- Currently the middleware does not support non ASCII filenames. If the
- encoding on the file system happens to be the encoding of the URI it may
- work but this could also be by accident. We strongly suggest using ASCII
- only file names for static files.
-
- The middleware will guess the mimetype using the Python `mimetype`
- module. If it's unable to figure out the charset it will fall back
- to `fallback_mimetype`.
-
- .. versionchanged:: 0.5
- The cache timeout is configurable now.
-
- .. versionadded:: 0.6
- The `fallback_mimetype` parameter was added.
-
- :param app: the application to wrap. If you don't want to wrap an
- application you can pass it :exc:`NotFound`.
- :param exports: a list or dict of exported files and folders.
- :param disallow: a list of :func:`~fnmatch.fnmatch` rules.
- :param fallback_mimetype: the fallback mimetype for unknown files.
- :param cache: enable or disable caching headers.
- :param cache_timeout: the cache timeout in seconds for the headers.
- """
-
- def __init__(
- self,
- app,
- exports,
- disallow=None,
- cache=True,
- cache_timeout=60 * 60 * 12,
- fallback_mimetype="text/plain",
- ):
- self.app = app
- self.exports = []
- self.cache = cache
- self.cache_timeout = cache_timeout
-
- if hasattr(exports, "items"):
- exports = exports.items()
-
- for key, value in exports:
- if isinstance(value, tuple):
- loader = self.get_package_loader(*value)
- elif isinstance(value, string_types):
- if os.path.isfile(value):
- loader = self.get_file_loader(value)
- else:
- loader = self.get_directory_loader(value)
- else:
- raise TypeError("unknown def %r" % value)
-
- self.exports.append((key, loader))
-
- if disallow is not None:
- from fnmatch import fnmatch
-
- self.is_allowed = lambda x: not fnmatch(x, disallow)
-
- self.fallback_mimetype = fallback_mimetype
-
- def is_allowed(self, filename):
- """Subclasses can override this method to disallow the access to
- certain files. However by providing `disallow` in the constructor
- this method is overwritten.
- """
- return True
-
- def _opener(self, filename):
- return lambda: (
- open(filename, "rb"),
- datetime.utcfromtimestamp(os.path.getmtime(filename)),
- int(os.path.getsize(filename)),
- )
-
- def get_file_loader(self, filename):
- return lambda x: (os.path.basename(filename), self._opener(filename))
-
- def get_package_loader(self, package, package_path):
- from pkg_resources import DefaultProvider, ResourceManager, get_provider
-
- loadtime = datetime.utcnow()
- provider = get_provider(package)
- manager = ResourceManager()
- filesystem_bound = isinstance(provider, DefaultProvider)
-
- def loader(path):
- if path is None:
- return None, None
-
- path = posixpath.join(package_path, path)
-
- if not provider.has_resource(path):
- return None, None
-
- basename = posixpath.basename(path)
-
- if filesystem_bound:
- return (
- basename,
- self._opener(provider.get_resource_filename(manager, path)),
- )
-
- s = provider.get_resource_string(manager, path)
- return basename, lambda: (BytesIO(s), loadtime, len(s))
-
- return loader
-
- def get_directory_loader(self, directory):
- def loader(path):
- if path is not None:
- path = os.path.join(directory, path)
- else:
- path = directory
-
- if os.path.isfile(path):
- return os.path.basename(path), self._opener(path)
-
- return None, None
-
- return loader
-
- def generate_etag(self, mtime, file_size, real_filename):
- if not isinstance(real_filename, bytes):
- real_filename = real_filename.encode(get_filesystem_encoding())
-
- return "wzsdm-%d-%s-%s" % (
- mktime(mtime.timetuple()),
- file_size,
- adler32(real_filename) & 0xFFFFFFFF,
- )
-
- def __call__(self, environ, start_response):
- cleaned_path = get_path_info(environ)
-
- if PY2:
- cleaned_path = cleaned_path.encode(get_filesystem_encoding())
-
- # sanitize the path for non unix systems
- cleaned_path = cleaned_path.strip("/")
-
- for sep in os.sep, os.altsep:
- if sep and sep != "/":
- cleaned_path = cleaned_path.replace(sep, "/")
-
- path = "/" + "/".join(x for x in cleaned_path.split("/") if x and x != "..")
- file_loader = None
-
- for search_path, loader in self.exports:
- if search_path == path:
- real_filename, file_loader = loader(None)
-
- if file_loader is not None:
- break
-
- if not search_path.endswith("/"):
- search_path += "/"
-
- if path.startswith(search_path):
- real_filename, file_loader = loader(path[len(search_path) :])
-
- if file_loader is not None:
- break
-
- if file_loader is None or not self.is_allowed(real_filename):
- return self.app(environ, start_response)
-
- guessed_type = mimetypes.guess_type(real_filename)
- mime_type = guessed_type[0] or self.fallback_mimetype
- f, mtime, file_size = file_loader()
-
- headers = [("Date", http_date())]
-
- if self.cache:
- timeout = self.cache_timeout
- etag = self.generate_etag(mtime, file_size, real_filename)
- headers += [
- ("Etag", '"%s"' % etag),
- ("Cache-Control", "max-age=%d, public" % timeout),
- ]
-
- if not is_resource_modified(environ, etag, last_modified=mtime):
- f.close()
- start_response("304 Not Modified", headers)
- return []
-
- headers.append(("Expires", http_date(time() + timeout)))
- else:
- headers.append(("Cache-Control", "public"))
-
- headers.extend(
- (
- ("Content-Type", mime_type),
- ("Content-Length", str(file_size)),
- ("Last-Modified", http_date(mtime)),
- )
- )
- start_response("200 OK", headers)
- return wrap_file(environ, f)
diff --git a/python/werkzeug/posixemulation.py b/python/werkzeug/posixemulation.py
deleted file mode 100644
index 696b456..0000000
--- a/python/werkzeug/posixemulation.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- coding: utf-8 -*-
-r"""
- werkzeug.posixemulation
- ~~~~~~~~~~~~~~~~~~~~~~~
-
- Provides a POSIX emulation for some features that are relevant to
- web applications. The main purpose is to simplify support for
- systems such as Windows NT that are not 100% POSIX compatible.
-
- Currently this only implements a :func:`rename` function that
- follows POSIX semantics. Eg: if the target file already exists it
- will be replaced without asking.
-
- This module was introduced in 0.6.1 and is not a public interface.
- It might become one in later versions of Werkzeug.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import errno
-import os
-import random
-import sys
-import time
-
-from ._compat import to_unicode
-from .filesystem import get_filesystem_encoding
-
-can_rename_open_file = False
-
-if os.name == "nt":
- try:
- import ctypes
-
- _MOVEFILE_REPLACE_EXISTING = 0x1
- _MOVEFILE_WRITE_THROUGH = 0x8
- _MoveFileEx = ctypes.windll.kernel32.MoveFileExW
-
- def _rename(src, dst):
- src = to_unicode(src, get_filesystem_encoding())
- dst = to_unicode(dst, get_filesystem_encoding())
- if _rename_atomic(src, dst):
- return True
- retry = 0
- rv = False
- while not rv and retry < 100:
- rv = _MoveFileEx(
- src, dst, _MOVEFILE_REPLACE_EXISTING | _MOVEFILE_WRITE_THROUGH
- )
- if not rv:
- time.sleep(0.001)
- retry += 1
- return rv
-
- # new in Vista and Windows Server 2008
- _CreateTransaction = ctypes.windll.ktmw32.CreateTransaction
- _CommitTransaction = ctypes.windll.ktmw32.CommitTransaction
- _MoveFileTransacted = ctypes.windll.kernel32.MoveFileTransactedW
- _CloseHandle = ctypes.windll.kernel32.CloseHandle
- can_rename_open_file = True
-
- def _rename_atomic(src, dst):
- ta = _CreateTransaction(None, 0, 0, 0, 0, 1000, "Werkzeug rename")
- if ta == -1:
- return False
- try:
- retry = 0
- rv = False
- while not rv and retry < 100:
- rv = _MoveFileTransacted(
- src,
- dst,
- None,
- None,
- _MOVEFILE_REPLACE_EXISTING | _MOVEFILE_WRITE_THROUGH,
- ta,
- )
- if rv:
- rv = _CommitTransaction(ta)
- break
- else:
- time.sleep(0.001)
- retry += 1
- return rv
- finally:
- _CloseHandle(ta)
-
- except Exception:
-
- def _rename(src, dst):
- return False
-
- def _rename_atomic(src, dst):
- return False
-
- def rename(src, dst):
- # Try atomic or pseudo-atomic rename
- if _rename(src, dst):
- return
- # Fall back to "move away and replace"
- try:
- os.rename(src, dst)
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise
- old = "%s-%08x" % (dst, random.randint(0, sys.maxsize))
- os.rename(dst, old)
- os.rename(src, dst)
- try:
- os.unlink(old)
- except Exception:
- pass
-
-
-else:
- rename = os.rename
- can_rename_open_file = True
diff --git a/python/werkzeug/routing.py b/python/werkzeug/routing.py
deleted file mode 100644
index 6b1dd98..0000000
--- a/python/werkzeug/routing.py
+++ /dev/null
@@ -1,2026 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.routing
- ~~~~~~~~~~~~~~~~
-
- When it comes to combining multiple controller or view functions (however
- you want to call them) you need a dispatcher. A simple way would be
- applying regular expression tests on the ``PATH_INFO`` and calling
- registered callback functions that return the value then.
-
- This module implements a much more powerful system than simple regular
- expression matching because it can also convert values in the URLs and
- build URLs.
-
- Here a simple example that creates an URL map for an application with
- two subdomains (www and kb) and some URL rules:
-
- >>> m = Map([
- ... # Static URLs
- ... Rule('/', endpoint='static/index'),
- ... Rule('/about', endpoint='static/about'),
- ... Rule('/help', endpoint='static/help'),
- ... # Knowledge Base
- ... Subdomain('kb', [
- ... Rule('/', endpoint='kb/index'),
- ... Rule('/browse/', endpoint='kb/browse'),
- ... Rule('/browse/<int:id>/', endpoint='kb/browse'),
- ... Rule('/browse/<int:id>/<int:page>', endpoint='kb/browse')
- ... ])
- ... ], default_subdomain='www')
-
- If the application doesn't use subdomains it's perfectly fine to not set
- the default subdomain and not use the `Subdomain` rule factory. The endpoint
- in the rules can be anything, for example import paths or unique
- identifiers. The WSGI application can use those endpoints to get the
- handler for that URL. It doesn't have to be a string at all but it's
- recommended.
-
- Now it's possible to create a URL adapter for one of the subdomains and
- build URLs:
-
- >>> c = m.bind('example.com')
- >>> c.build("kb/browse", dict(id=42))
- 'http://kb.example.com/browse/42/'
- >>> c.build("kb/browse", dict())
- 'http://kb.example.com/browse/'
- >>> c.build("kb/browse", dict(id=42, page=3))
- 'http://kb.example.com/browse/42/3'
- >>> c.build("static/about")
- '/about'
- >>> c.build("static/index", force_external=True)
- 'http://www.example.com/'
-
- >>> c = m.bind('example.com', subdomain='kb')
- >>> c.build("static/about")
- 'http://www.example.com/about'
-
- The first argument to bind is the server name *without* the subdomain.
- Per default it will assume that the script is mounted on the root, but
- often that's not the case so you can provide the real mount point as
- second argument:
-
- >>> c = m.bind('example.com', '/applications/example')
-
- The third argument can be the subdomain, if not given the default
- subdomain is used. For more details about binding have a look at the
- documentation of the `MapAdapter`.
-
- And here is how you can match URLs:
-
- >>> c = m.bind('example.com')
- >>> c.match("/")
- ('static/index', {})
- >>> c.match("/about")
- ('static/about', {})
- >>> c = m.bind('example.com', '/', 'kb')
- >>> c.match("/")
- ('kb/index', {})
- >>> c.match("/browse/42/23")
- ('kb/browse', {'id': 42, 'page': 23})
-
- If matching fails you get a `NotFound` exception, if the rule thinks
- it's a good idea to redirect (for example because the URL was defined
- to have a slash at the end but the request was missing that slash) it
- will raise a `RequestRedirect` exception. Both are subclasses of the
- `HTTPException` so you can use those errors as responses in the
- application.
-
- If matching succeeded but the URL rule was incompatible to the given
- method (for example there were only rules for `GET` and `HEAD` and
- routing system tried to match a `POST` request) a `MethodNotAllowed`
- exception is raised.
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import ast
-import difflib
-import posixpath
-import re
-import uuid
-from pprint import pformat
-from threading import Lock
-
-from ._compat import implements_to_string
-from ._compat import iteritems
-from ._compat import itervalues
-from ._compat import native_string_result
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import to_bytes
-from ._compat import to_unicode
-from ._compat import wsgi_decoding_dance
-from ._internal import _encode_idna
-from ._internal import _get_environ
-from .datastructures import ImmutableDict
-from .datastructures import MultiDict
-from .exceptions import BadHost
-from .exceptions import HTTPException
-from .exceptions import MethodNotAllowed
-from .exceptions import NotFound
-from .urls import _fast_url_quote
-from .urls import url_encode
-from .urls import url_join
-from .urls import url_quote
-from .utils import cached_property
-from .utils import format_string
-from .utils import redirect
-from .wsgi import get_host
-
-_rule_re = re.compile(
- r"""
- (?P<static>[^<]*) # static rule data
- <
- (?:
- (?P<converter>[a-zA-Z_][a-zA-Z0-9_]*) # converter name
- (?:\((?P<args>.*?)\))? # converter arguments
- \: # variable delimiter
- )?
- (?P<variable>[a-zA-Z_][a-zA-Z0-9_]*) # variable name
- >
- """,
- re.VERBOSE,
-)
-_simple_rule_re = re.compile(r"<([^>]+)>")
-_converter_args_re = re.compile(
- r"""
- ((?P<name>\w+)\s*=\s*)?
- (?P<value>
- True|False|
- \d+.\d+|
- \d+.|
- \d+|
- [\w\d_.]+|
- [urUR]?(?P<stringval>"[^"]*?"|'[^']*')
- )\s*,
- """,
- re.VERBOSE | re.UNICODE,
-)
-
-
-_PYTHON_CONSTANTS = {"None": None, "True": True, "False": False}
-
-
-def _pythonize(value):
- if value in _PYTHON_CONSTANTS:
- return _PYTHON_CONSTANTS[value]
- for convert in int, float:
- try:
- return convert(value)
- except ValueError:
- pass
- if value[:1] == value[-1:] and value[0] in "\"'":
- value = value[1:-1]
- return text_type(value)
-
-
-def parse_converter_args(argstr):
- argstr += ","
- args = []
- kwargs = {}
-
- for item in _converter_args_re.finditer(argstr):
- value = item.group("stringval")
- if value is None:
- value = item.group("value")
- value = _pythonize(value)
- if not item.group("name"):
- args.append(value)
- else:
- name = item.group("name")
- kwargs[name] = value
-
- return tuple(args), kwargs
-
-
-def parse_rule(rule):
- """Parse a rule and return it as generator. Each iteration yields tuples
- in the form ``(converter, arguments, variable)``. If the converter is
- `None` it's a static url part, otherwise it's a dynamic one.
-
- :internal:
- """
- pos = 0
- end = len(rule)
- do_match = _rule_re.match
- used_names = set()
- while pos < end:
- m = do_match(rule, pos)
- if m is None:
- break
- data = m.groupdict()
- if data["static"]:
- yield None, None, data["static"]
- variable = data["variable"]
- converter = data["converter"] or "default"
- if variable in used_names:
- raise ValueError("variable name %r used twice." % variable)
- used_names.add(variable)
- yield converter, data["args"] or None, variable
- pos = m.end()
- if pos < end:
- remaining = rule[pos:]
- if ">" in remaining or "<" in remaining:
- raise ValueError("malformed url rule: %r" % rule)
- yield None, None, remaining
-
-
-class RoutingException(Exception):
- """Special exceptions that require the application to redirect, notifying
- about missing urls, etc.
-
- :internal:
- """
-
-
-class RequestRedirect(HTTPException, RoutingException):
- """Raise if the map requests a redirect. This is for example the case if
- `strict_slashes` are activated and an url that requires a trailing slash.
-
- The attribute `new_url` contains the absolute destination url.
- """
-
- code = 308
-
- def __init__(self, new_url):
- RoutingException.__init__(self, new_url)
- self.new_url = new_url
-
- def get_response(self, environ):
- return redirect(self.new_url, self.code)
-
-
-class RequestSlash(RoutingException):
- """Internal exception."""
-
-
-class RequestAliasRedirect(RoutingException): # noqa: B903
- """This rule is an alias and wants to redirect to the canonical URL."""
-
- def __init__(self, matched_values):
- self.matched_values = matched_values
-
-
-@implements_to_string
-class BuildError(RoutingException, LookupError):
- """Raised if the build system cannot find a URL for an endpoint with the
- values provided.
- """
-
- def __init__(self, endpoint, values, method, adapter=None):
- LookupError.__init__(self, endpoint, values, method)
- self.endpoint = endpoint
- self.values = values
- self.method = method
- self.adapter = adapter
-
- @cached_property
- def suggested(self):
- return self.closest_rule(self.adapter)
-
- def closest_rule(self, adapter):
- def _score_rule(rule):
- return sum(
- [
- 0.98
- * difflib.SequenceMatcher(
- None, rule.endpoint, self.endpoint
- ).ratio(),
- 0.01 * bool(set(self.values or ()).issubset(rule.arguments)),
- 0.01 * bool(rule.methods and self.method in rule.methods),
- ]
- )
-
- if adapter and adapter.map._rules:
- return max(adapter.map._rules, key=_score_rule)
-
- def __str__(self):
- message = []
- message.append("Could not build url for endpoint %r" % self.endpoint)
- if self.method:
- message.append(" (%r)" % self.method)
- if self.values:
- message.append(" with values %r" % sorted(self.values.keys()))
- message.append(".")
- if self.suggested:
- if self.endpoint == self.suggested.endpoint:
- if self.method and self.method not in self.suggested.methods:
- message.append(
- " Did you mean to use methods %r?"
- % sorted(self.suggested.methods)
- )
- missing_values = self.suggested.arguments.union(
- set(self.suggested.defaults or ())
- ) - set(self.values.keys())
- if missing_values:
- message.append(
- " Did you forget to specify values %r?" % sorted(missing_values)
- )
- else:
- message.append(" Did you mean %r instead?" % self.suggested.endpoint)
- return u"".join(message)
-
-
-class ValidationError(ValueError):
- """Validation error. If a rule converter raises this exception the rule
- does not match the current URL and the next URL is tried.
- """
-
-
-class RuleFactory(object):
- """As soon as you have more complex URL setups it's a good idea to use rule
- factories to avoid repetitive tasks. Some of them are builtin, others can
- be added by subclassing `RuleFactory` and overriding `get_rules`.
- """
-
- def get_rules(self, map):
- """Subclasses of `RuleFactory` have to override this method and return
- an iterable of rules."""
- raise NotImplementedError()
-
-
-class Subdomain(RuleFactory):
- """All URLs provided by this factory have the subdomain set to a
- specific domain. For example if you want to use the subdomain for
- the current language this can be a good setup::
-
- url_map = Map([
- Rule('/', endpoint='#select_language'),
- Subdomain('<string(length=2):lang_code>', [
- Rule('/', endpoint='index'),
- Rule('/about', endpoint='about'),
- Rule('/help', endpoint='help')
- ])
- ])
-
- All the rules except for the ``'#select_language'`` endpoint will now
- listen on a two letter long subdomain that holds the language code
- for the current request.
- """
-
- def __init__(self, subdomain, rules):
- self.subdomain = subdomain
- self.rules = rules
-
- def get_rules(self, map):
- for rulefactory in self.rules:
- for rule in rulefactory.get_rules(map):
- rule = rule.empty()
- rule.subdomain = self.subdomain
- yield rule
-
-
-class Submount(RuleFactory):
- """Like `Subdomain` but prefixes the URL rule with a given string::
-
- url_map = Map([
- Rule('/', endpoint='index'),
- Submount('/blog', [
- Rule('/', endpoint='blog/index'),
- Rule('/entry/<entry_slug>', endpoint='blog/show')
- ])
- ])
-
- Now the rule ``'blog/show'`` matches ``/blog/entry/<entry_slug>``.
- """
-
- def __init__(self, path, rules):
- self.path = path.rstrip("/")
- self.rules = rules
-
- def get_rules(self, map):
- for rulefactory in self.rules:
- for rule in rulefactory.get_rules(map):
- rule = rule.empty()
- rule.rule = self.path + rule.rule
- yield rule
-
-
-class EndpointPrefix(RuleFactory):
- """Prefixes all endpoints (which must be strings for this factory) with
- another string. This can be useful for sub applications::
-
- url_map = Map([
- Rule('/', endpoint='index'),
- EndpointPrefix('blog/', [Submount('/blog', [
- Rule('/', endpoint='index'),
- Rule('/entry/<entry_slug>', endpoint='show')
- ])])
- ])
- """
-
- def __init__(self, prefix, rules):
- self.prefix = prefix
- self.rules = rules
-
- def get_rules(self, map):
- for rulefactory in self.rules:
- for rule in rulefactory.get_rules(map):
- rule = rule.empty()
- rule.endpoint = self.prefix + rule.endpoint
- yield rule
-
-
-class RuleTemplate(object):
- """Returns copies of the rules wrapped and expands string templates in
- the endpoint, rule, defaults or subdomain sections.
-
- Here a small example for such a rule template::
-
- from werkzeug.routing import Map, Rule, RuleTemplate
-
- resource = RuleTemplate([
- Rule('/$name/', endpoint='$name.list'),
- Rule('/$name/<int:id>', endpoint='$name.show')
- ])
-
- url_map = Map([resource(name='user'), resource(name='page')])
-
- When a rule template is called the keyword arguments are used to
- replace the placeholders in all the string parameters.
- """
-
- def __init__(self, rules):
- self.rules = list(rules)
-
- def __call__(self, *args, **kwargs):
- return RuleTemplateFactory(self.rules, dict(*args, **kwargs))
-
-
-class RuleTemplateFactory(RuleFactory):
- """A factory that fills in template variables into rules. Used by
- `RuleTemplate` internally.
-
- :internal:
- """
-
- def __init__(self, rules, context):
- self.rules = rules
- self.context = context
-
- def get_rules(self, map):
- for rulefactory in self.rules:
- for rule in rulefactory.get_rules(map):
- new_defaults = subdomain = None
- if rule.defaults:
- new_defaults = {}
- for key, value in iteritems(rule.defaults):
- if isinstance(value, string_types):
- value = format_string(value, self.context)
- new_defaults[key] = value
- if rule.subdomain is not None:
- subdomain = format_string(rule.subdomain, self.context)
- new_endpoint = rule.endpoint
- if isinstance(new_endpoint, string_types):
- new_endpoint = format_string(new_endpoint, self.context)
- yield Rule(
- format_string(rule.rule, self.context),
- new_defaults,
- subdomain,
- rule.methods,
- rule.build_only,
- new_endpoint,
- rule.strict_slashes,
- )
-
-
-def _prefix_names(src):
- """ast parse and prefix names with `.` to avoid collision with user vars"""
- tree = ast.parse(src).body[0]
- if isinstance(tree, ast.Expr):
- tree = tree.value
- for node in ast.walk(tree):
- if isinstance(node, ast.Name):
- node.id = "." + node.id
- return tree
-
-
-_CALL_CONVERTER_CODE_FMT = "self._converters[{elem!r}].to_url()"
-_IF_KWARGS_URL_ENCODE_CODE = """\
-if kwargs:
- q = '?'
- params = self._encode_query_vars(kwargs)
-else:
- q = params = ''
-"""
-_IF_KWARGS_URL_ENCODE_AST = _prefix_names(_IF_KWARGS_URL_ENCODE_CODE)
-_URL_ENCODE_AST_NAMES = (_prefix_names("q"), _prefix_names("params"))
-
-
-@implements_to_string
-class Rule(RuleFactory):
- """A Rule represents one URL pattern. There are some options for `Rule`
- that change the way it behaves and are passed to the `Rule` constructor.
- Note that besides the rule-string all arguments *must* be keyword arguments
- in order to not break the application on Werkzeug upgrades.
-
- `string`
- Rule strings basically are just normal URL paths with placeholders in
- the format ``<converter(arguments):name>`` where the converter and the
- arguments are optional. If no converter is defined the `default`
- converter is used which means `string` in the normal configuration.
-
- URL rules that end with a slash are branch URLs, others are leaves.
- If you have `strict_slashes` enabled (which is the default), all
- branch URLs that are matched without a trailing slash will trigger a
- redirect to the same URL with the missing slash appended.
-
- The converters are defined on the `Map`.
-
- `endpoint`
- The endpoint for this rule. This can be anything. A reference to a
- function, a string, a number etc. The preferred way is using a string
- because the endpoint is used for URL generation.
-
- `defaults`
- An optional dict with defaults for other rules with the same endpoint.
- This is a bit tricky but useful if you want to have unique URLs::
-
- url_map = Map([
- Rule('/all/', defaults={'page': 1}, endpoint='all_entries'),
- Rule('/all/page/<int:page>', endpoint='all_entries')
- ])
-
- If a user now visits ``http://example.com/all/page/1`` he will be
- redirected to ``http://example.com/all/``. If `redirect_defaults` is
- disabled on the `Map` instance this will only affect the URL
- generation.
-
- `subdomain`
- The subdomain rule string for this rule. If not specified the rule
- only matches for the `default_subdomain` of the map. If the map is
- not bound to a subdomain this feature is disabled.
-
- Can be useful if you want to have user profiles on different subdomains
- and all subdomains are forwarded to your application::
-
- url_map = Map([
- Rule('/', subdomain='<username>', endpoint='user/homepage'),
- Rule('/stats', subdomain='<username>', endpoint='user/stats')
- ])
-
- `methods`
- A sequence of http methods this rule applies to. If not specified, all
- methods are allowed. For example this can be useful if you want different
- endpoints for `POST` and `GET`. If methods are defined and the path
- matches but the method matched against is not in this list or in the
- list of another rule for that path the error raised is of the type
- `MethodNotAllowed` rather than `NotFound`. If `GET` is present in the
- list of methods and `HEAD` is not, `HEAD` is added automatically.
-
- .. versionchanged:: 0.6.1
- `HEAD` is now automatically added to the methods if `GET` is
- present. The reason for this is that existing code often did not
- work properly in servers not rewriting `HEAD` to `GET`
- automatically and it was not documented how `HEAD` should be
- treated. This was considered a bug in Werkzeug because of that.
-
- `strict_slashes`
- Override the `Map` setting for `strict_slashes` only for this rule. If
- not specified the `Map` setting is used.
-
- `build_only`
- Set this to True and the rule will never match but will create a URL
- that can be build. This is useful if you have resources on a subdomain
- or folder that are not handled by the WSGI application (like static data)
-
- `redirect_to`
- If given this must be either a string or callable. In case of a
- callable it's called with the url adapter that triggered the match and
- the values of the URL as keyword arguments and has to return the target
- for the redirect, otherwise it has to be a string with placeholders in
- rule syntax::
-
- def foo_with_slug(adapter, id):
- # ask the database for the slug for the old id. this of
- # course has nothing to do with werkzeug.
- return 'foo/' + Foo.get_slug_for_id(id)
-
- url_map = Map([
- Rule('/foo/<slug>', endpoint='foo'),
- Rule('/some/old/url/<slug>', redirect_to='foo/<slug>'),
- Rule('/other/old/url/<int:id>', redirect_to=foo_with_slug)
- ])
-
- When the rule is matched the routing system will raise a
- `RequestRedirect` exception with the target for the redirect.
-
- Keep in mind that the URL will be joined against the URL root of the
- script so don't use a leading slash on the target URL unless you
- really mean root of that domain.
-
- `alias`
- If enabled this rule serves as an alias for another rule with the same
- endpoint and arguments.
-
- `host`
- If provided and the URL map has host matching enabled this can be
- used to provide a match rule for the whole host. This also means
- that the subdomain feature is disabled.
-
- .. versionadded:: 0.7
- The `alias` and `host` parameters were added.
- """
-
- def __init__(
- self,
- string,
- defaults=None,
- subdomain=None,
- methods=None,
- build_only=False,
- endpoint=None,
- strict_slashes=None,
- redirect_to=None,
- alias=False,
- host=None,
- ):
- if not string.startswith("/"):
- raise ValueError("urls must start with a leading slash")
- self.rule = string
- self.is_leaf = not string.endswith("/")
-
- self.map = None
- self.strict_slashes = strict_slashes
- self.subdomain = subdomain
- self.host = host
- self.defaults = defaults
- self.build_only = build_only
- self.alias = alias
- if methods is None:
- self.methods = None
- else:
- if isinstance(methods, str):
- raise TypeError("param `methods` should be `Iterable[str]`, not `str`")
- self.methods = set([x.upper() for x in methods])
- if "HEAD" not in self.methods and "GET" in self.methods:
- self.methods.add("HEAD")
- self.endpoint = endpoint
- self.redirect_to = redirect_to
-
- if defaults:
- self.arguments = set(map(str, defaults))
- else:
- self.arguments = set()
- self._trace = self._converters = self._regex = self._argument_weights = None
-
- def empty(self):
- """
- Return an unbound copy of this rule.
-
- This can be useful if want to reuse an already bound URL for another
- map. See ``get_empty_kwargs`` to override what keyword arguments are
- provided to the new copy.
- """
- return type(self)(self.rule, **self.get_empty_kwargs())
-
- def get_empty_kwargs(self):
- """
- Provides kwargs for instantiating empty copy with empty()
-
- Use this method to provide custom keyword arguments to the subclass of
- ``Rule`` when calling ``some_rule.empty()``. Helpful when the subclass
- has custom keyword arguments that are needed at instantiation.
-
- Must return a ``dict`` that will be provided as kwargs to the new
- instance of ``Rule``, following the initial ``self.rule`` value which
- is always provided as the first, required positional argument.
- """
- defaults = None
- if self.defaults:
- defaults = dict(self.defaults)
- return dict(
- defaults=defaults,
- subdomain=self.subdomain,
- methods=self.methods,
- build_only=self.build_only,
- endpoint=self.endpoint,
- strict_slashes=self.strict_slashes,
- redirect_to=self.redirect_to,
- alias=self.alias,
- host=self.host,
- )
-
- def get_rules(self, map):
- yield self
-
- def refresh(self):
- """Rebinds and refreshes the URL. Call this if you modified the
- rule in place.
-
- :internal:
- """
- self.bind(self.map, rebind=True)
-
- def bind(self, map, rebind=False):
- """Bind the url to a map and create a regular expression based on
- the information from the rule itself and the defaults from the map.
-
- :internal:
- """
- if self.map is not None and not rebind:
- raise RuntimeError("url rule %r already bound to map %r" % (self, self.map))
- self.map = map
- if self.strict_slashes is None:
- self.strict_slashes = map.strict_slashes
- if self.subdomain is None:
- self.subdomain = map.default_subdomain
- self.compile()
-
- def get_converter(self, variable_name, converter_name, args, kwargs):
- """Looks up the converter for the given parameter.
-
- .. versionadded:: 0.9
- """
- if converter_name not in self.map.converters:
- raise LookupError("the converter %r does not exist" % converter_name)
- return self.map.converters[converter_name](self.map, *args, **kwargs)
-
- def _encode_query_vars(self, query_vars):
- return url_encode(
- query_vars,
- charset=self.map.charset,
- sort=self.map.sort_parameters,
- key=self.map.sort_key,
- )
-
- def compile(self):
- """Compiles the regular expression and stores it."""
- assert self.map is not None, "rule not bound"
-
- if self.map.host_matching:
- domain_rule = self.host or ""
- else:
- domain_rule = self.subdomain or ""
-
- self._trace = []
- self._converters = {}
- self._static_weights = []
- self._argument_weights = []
- regex_parts = []
-
- def _build_regex(rule):
- index = 0
- for converter, arguments, variable in parse_rule(rule):
- if converter is None:
- regex_parts.append(re.escape(variable))
- self._trace.append((False, variable))
- for part in variable.split("/"):
- if part:
- self._static_weights.append((index, -len(part)))
- else:
- if arguments:
- c_args, c_kwargs = parse_converter_args(arguments)
- else:
- c_args = ()
- c_kwargs = {}
- convobj = self.get_converter(variable, converter, c_args, c_kwargs)
- regex_parts.append("(?P<%s>%s)" % (variable, convobj.regex))
- self._converters[variable] = convobj
- self._trace.append((True, variable))
- self._argument_weights.append(convobj.weight)
- self.arguments.add(str(variable))
- index = index + 1
-
- _build_regex(domain_rule)
- regex_parts.append("\\|")
- self._trace.append((False, "|"))
- _build_regex(self.rule if self.is_leaf else self.rule.rstrip("/"))
- if not self.is_leaf:
- self._trace.append((False, "/"))
-
- self._build = self._compile_builder(False).__get__(self, None)
- self._build_unknown = self._compile_builder(True).__get__(self, None)
-
- if self.build_only:
- return
- regex = r"^%s%s$" % (
- u"".join(regex_parts),
- (not self.is_leaf or not self.strict_slashes)
- and "(?<!/)(?P<__suffix__>/?)"
- or "",
- )
- self._regex = re.compile(regex, re.UNICODE)
-
- def match(self, path, method=None):
- """Check if the rule matches a given path. Path is a string in the
- form ``"subdomain|/path"`` and is assembled by the map. If
- the map is doing host matching the subdomain part will be the host
- instead.
-
- If the rule matches a dict with the converted values is returned,
- otherwise the return value is `None`.
-
- :internal:
- """
- if not self.build_only:
- m = self._regex.search(path)
- if m is not None:
- groups = m.groupdict()
- # we have a folder like part of the url without a trailing
- # slash and strict slashes enabled. raise an exception that
- # tells the map to redirect to the same url but with a
- # trailing slash
- if (
- self.strict_slashes
- and not self.is_leaf
- and not groups.pop("__suffix__")
- and (
- method is None or self.methods is None or method in self.methods
- )
- ):
- raise RequestSlash()
- # if we are not in strict slashes mode we have to remove
- # a __suffix__
- elif not self.strict_slashes:
- del groups["__suffix__"]
-
- result = {}
- for name, value in iteritems(groups):
- try:
- value = self._converters[name].to_python(value)
- except ValidationError:
- return
- result[str(name)] = value
- if self.defaults:
- result.update(self.defaults)
-
- if self.alias and self.map.redirect_defaults:
- raise RequestAliasRedirect(result)
-
- return result
-
- @staticmethod
- def _get_func_code(code, name):
- globs, locs = {}, {}
- exec(code, globs, locs)
- return locs[name]
-
- def _compile_builder(self, append_unknown=True):
- defaults = self.defaults or {}
- dom_ops = []
- url_ops = []
-
- opl = dom_ops
- for is_dynamic, data in self._trace:
- if data == "|" and opl is dom_ops:
- opl = url_ops
- continue
- # this seems like a silly case to ever come up but:
- # if a default is given for a value that appears in the rule,
- # resolve it to a constant ahead of time
- if is_dynamic and data in defaults:
- data = self._converters[data].to_url(defaults[data])
- opl.append((False, data))
- elif not is_dynamic:
- opl.append(
- (False, url_quote(to_bytes(data, self.map.charset), safe="/:|+"))
- )
- else:
- opl.append((True, data))
-
- def _convert(elem):
- ret = _prefix_names(_CALL_CONVERTER_CODE_FMT.format(elem=elem))
- ret.args = [ast.Name(str(elem), ast.Load())] # str for py2
- return ret
-
- def _parts(ops):
- parts = [
- _convert(elem) if is_dynamic else ast.Str(s=elem)
- for is_dynamic, elem in ops
- ]
- parts = parts or [ast.Str("")]
- # constant fold
- ret = [parts[0]]
- for p in parts[1:]:
- if isinstance(p, ast.Str) and isinstance(ret[-1], ast.Str):
- ret[-1] = ast.Str(ret[-1].s + p.s)
- else:
- ret.append(p)
- return ret
-
- dom_parts = _parts(dom_ops)
- url_parts = _parts(url_ops)
- if not append_unknown:
- body = []
- else:
- body = [_IF_KWARGS_URL_ENCODE_AST]
- url_parts.extend(_URL_ENCODE_AST_NAMES)
-
- def _join(parts):
- if len(parts) == 1: # shortcut
- return parts[0]
- elif hasattr(ast, "JoinedStr"): # py36+
- return ast.JoinedStr(parts)
- else:
- call = _prefix_names('"".join()')
- call.args = [ast.Tuple(parts, ast.Load())]
- return call
-
- body.append(
- ast.Return(ast.Tuple([_join(dom_parts), _join(url_parts)], ast.Load()))
- )
-
- # str is necessary for python2
- pargs = [
- str(elem)
- for is_dynamic, elem in dom_ops + url_ops
- if is_dynamic and elem not in defaults
- ]
- kargs = [str(k) for k in defaults]
-
- func_ast = _prefix_names("def _(): pass")
- func_ast.name = "<builder:{!r}>".format(self.rule)
- if hasattr(ast, "arg"): # py3
- func_ast.args.args.append(ast.arg(".self", None))
- for arg in pargs + kargs:
- func_ast.args.args.append(ast.arg(arg, None))
- func_ast.args.kwarg = ast.arg(".kwargs", None)
- else:
- func_ast.args.args.append(ast.Name(".self", ast.Load()))
- for arg in pargs + kargs:
- func_ast.args.args.append(ast.Name(arg, ast.Load()))
- func_ast.args.kwarg = ".kwargs"
- for _ in kargs:
- func_ast.args.defaults.append(ast.Str(""))
- func_ast.body = body
-
- module = ast.fix_missing_locations(ast.Module([func_ast]))
- code = compile(module, "<werkzeug routing>", "exec")
- return self._get_func_code(code, func_ast.name)
-
- def build(self, values, append_unknown=True):
- """Assembles the relative url for that rule and the subdomain.
- If building doesn't work for some reasons `None` is returned.
-
- :internal:
- """
- try:
- if append_unknown:
- return self._build_unknown(**values)
- else:
- return self._build(**values)
- except ValidationError:
- return None
-
- def provides_defaults_for(self, rule):
- """Check if this rule has defaults for a given rule.
-
- :internal:
- """
- return (
- not self.build_only
- and self.defaults
- and self.endpoint == rule.endpoint
- and self != rule
- and self.arguments == rule.arguments
- )
-
- def suitable_for(self, values, method=None):
- """Check if the dict of values has enough data for url generation.
-
- :internal:
- """
- # if a method was given explicitly and that method is not supported
- # by this rule, this rule is not suitable.
- if (
- method is not None
- and self.methods is not None
- and method not in self.methods
- ):
- return False
-
- defaults = self.defaults or ()
-
- # all arguments required must be either in the defaults dict or
- # the value dictionary otherwise it's not suitable
- for key in self.arguments:
- if key not in defaults and key not in values:
- return False
-
- # in case defaults are given we ensure that either the value was
- # skipped or the value is the same as the default value.
- if defaults:
- for key, value in iteritems(defaults):
- if key in values and value != values[key]:
- return False
-
- return True
-
- def match_compare_key(self):
- """The match compare key for sorting.
-
- Current implementation:
-
- 1. rules without any arguments come first for performance
- reasons only as we expect them to match faster and some
- common ones usually don't have any arguments (index pages etc.)
- 2. rules with more static parts come first so the second argument
- is the negative length of the number of the static weights.
- 3. we order by static weights, which is a combination of index
- and length
- 4. The more complex rules come first so the next argument is the
- negative length of the number of argument weights.
- 5. lastly we order by the actual argument weights.
-
- :internal:
- """
- return (
- bool(self.arguments),
- -len(self._static_weights),
- self._static_weights,
- -len(self._argument_weights),
- self._argument_weights,
- )
-
- def build_compare_key(self):
- """The build compare key for sorting.
-
- :internal:
- """
- return 1 if self.alias else 0, -len(self.arguments), -len(self.defaults or ())
-
- def __eq__(self, other):
- return self.__class__ is other.__class__ and self._trace == other._trace
-
- __hash__ = None
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.rule
-
- @native_string_result
- def __repr__(self):
- if self.map is None:
- return u"<%s (unbound)>" % self.__class__.__name__
- tmp = []
- for is_dynamic, data in self._trace:
- if is_dynamic:
- tmp.append(u"<%s>" % data)
- else:
- tmp.append(data)
- return u"<%s %s%s -> %s>" % (
- self.__class__.__name__,
- repr((u"".join(tmp)).lstrip(u"|")).lstrip(u"u"),
- self.methods is not None and u" (%s)" % u", ".join(self.methods) or u"",
- self.endpoint,
- )
-
-
-class BaseConverter(object):
- """Base class for all converters."""
-
- regex = "[^/]+"
- weight = 100
-
- def __init__(self, map):
- self.map = map
-
- def to_python(self, value):
- return value
-
- def to_url(self, value):
- if isinstance(value, (bytes, bytearray)):
- return _fast_url_quote(value)
- return _fast_url_quote(text_type(value).encode(self.map.charset))
-
-
-class UnicodeConverter(BaseConverter):
- """This converter is the default converter and accepts any string but
- only one path segment. Thus the string can not include a slash.
-
- This is the default validator.
-
- Example::
-
- Rule('/pages/<page>'),
- Rule('/<string(length=2):lang_code>')
-
- :param map: the :class:`Map`.
- :param minlength: the minimum length of the string. Must be greater
- or equal 1.
- :param maxlength: the maximum length of the string.
- :param length: the exact length of the string.
- """
-
- def __init__(self, map, minlength=1, maxlength=None, length=None):
- BaseConverter.__init__(self, map)
- if length is not None:
- length = "{%d}" % int(length)
- else:
- if maxlength is None:
- maxlength = ""
- else:
- maxlength = int(maxlength)
- length = "{%s,%s}" % (int(minlength), maxlength)
- self.regex = "[^/]" + length
-
-
-class AnyConverter(BaseConverter):
- """Matches one of the items provided. Items can either be Python
- identifiers or strings::
-
- Rule('/<any(about, help, imprint, class, "foo,bar"):page_name>')
-
- :param map: the :class:`Map`.
- :param items: this function accepts the possible items as positional
- arguments.
- """
-
- def __init__(self, map, *items):
- BaseConverter.__init__(self, map)
- self.regex = "(?:%s)" % "|".join([re.escape(x) for x in items])
-
-
-class PathConverter(BaseConverter):
- """Like the default :class:`UnicodeConverter`, but it also matches
- slashes. This is useful for wikis and similar applications::
-
- Rule('/<path:wikipage>')
- Rule('/<path:wikipage>/edit')
-
- :param map: the :class:`Map`.
- """
-
- regex = "[^/].*?"
- weight = 200
-
-
-class NumberConverter(BaseConverter):
- """Baseclass for `IntegerConverter` and `FloatConverter`.
-
- :internal:
- """
-
- weight = 50
-
- def __init__(self, map, fixed_digits=0, min=None, max=None, signed=False):
- if signed:
- self.regex = self.signed_regex
- BaseConverter.__init__(self, map)
- self.fixed_digits = fixed_digits
- self.min = min
- self.max = max
- self.signed = signed
-
- def to_python(self, value):
- if self.fixed_digits and len(value) != self.fixed_digits:
- raise ValidationError()
- value = self.num_convert(value)
- if (self.min is not None and value < self.min) or (
- self.max is not None and value > self.max
- ):
- raise ValidationError()
- return value
-
- def to_url(self, value):
- value = self.num_convert(value)
- if self.fixed_digits:
- value = ("%%0%sd" % self.fixed_digits) % value
- return str(value)
-
- @property
- def signed_regex(self):
- return r"-?" + self.regex
-
-
-class IntegerConverter(NumberConverter):
- """This converter only accepts integer values::
-
- Rule("/page/<int:page>")
-
- By default it only accepts unsigned, positive values. The ``signed``
- parameter will enable signed, negative values. ::
-
- Rule("/page/<int(signed=True):page>")
-
- :param map: The :class:`Map`.
- :param fixed_digits: The number of fixed digits in the URL. If you
- set this to ``4`` for example, the rule will only match if the
- URL looks like ``/0001/``. The default is variable length.
- :param min: The minimal value.
- :param max: The maximal value.
- :param signed: Allow signed (negative) values.
-
- .. versionadded:: 0.15
- The ``signed`` parameter.
- """
-
- regex = r"\d+"
- num_convert = int
-
-
-class FloatConverter(NumberConverter):
- """This converter only accepts floating point values::
-
- Rule("/probability/<float:probability>")
-
- By default it only accepts unsigned, positive values. The ``signed``
- parameter will enable signed, negative values. ::
-
- Rule("/offset/<float(signed=True):offset>")
-
- :param map: The :class:`Map`.
- :param min: The minimal value.
- :param max: The maximal value.
- :param signed: Allow signed (negative) values.
-
- .. versionadded:: 0.15
- The ``signed`` parameter.
- """
-
- regex = r"\d+\.\d+"
- num_convert = float
-
- def __init__(self, map, min=None, max=None, signed=False):
- NumberConverter.__init__(self, map, min=min, max=max, signed=signed)
-
-
-class UUIDConverter(BaseConverter):
- """This converter only accepts UUID strings::
-
- Rule('/object/<uuid:identifier>')
-
- .. versionadded:: 0.10
-
- :param map: the :class:`Map`.
- """
-
- regex = (
- r"[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-"
- r"[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"
- )
-
- def to_python(self, value):
- return uuid.UUID(value)
-
- def to_url(self, value):
- return str(value)
-
-
-#: the default converter mapping for the map.
-DEFAULT_CONVERTERS = {
- "default": UnicodeConverter,
- "string": UnicodeConverter,
- "any": AnyConverter,
- "path": PathConverter,
- "int": IntegerConverter,
- "float": FloatConverter,
- "uuid": UUIDConverter,
-}
-
-
-class Map(object):
- """The map class stores all the URL rules and some configuration
- parameters. Some of the configuration values are only stored on the
- `Map` instance since those affect all rules, others are just defaults
- and can be overridden for each rule. Note that you have to specify all
- arguments besides the `rules` as keyword arguments!
-
- :param rules: sequence of url rules for this map.
- :param default_subdomain: The default subdomain for rules without a
- subdomain defined.
- :param charset: charset of the url. defaults to ``"utf-8"``
- :param strict_slashes: Take care of trailing slashes.
- :param redirect_defaults: This will redirect to the default rule if it
- wasn't visited that way. This helps creating
- unique URLs.
- :param converters: A dict of converters that adds additional converters
- to the list of converters. If you redefine one
- converter this will override the original one.
- :param sort_parameters: If set to `True` the url parameters are sorted.
- See `url_encode` for more details.
- :param sort_key: The sort key function for `url_encode`.
- :param encoding_errors: the error method to use for decoding
- :param host_matching: if set to `True` it enables the host matching
- feature and disables the subdomain one. If
- enabled the `host` parameter to rules is used
- instead of the `subdomain` one.
-
- .. versionadded:: 0.5
- `sort_parameters` and `sort_key` was added.
-
- .. versionadded:: 0.7
- `encoding_errors` and `host_matching` was added.
- """
-
- #: A dict of default converters to be used.
- default_converters = ImmutableDict(DEFAULT_CONVERTERS)
-
- def __init__(
- self,
- rules=None,
- default_subdomain="",
- charset="utf-8",
- strict_slashes=True,
- redirect_defaults=True,
- converters=None,
- sort_parameters=False,
- sort_key=None,
- encoding_errors="replace",
- host_matching=False,
- ):
- self._rules = []
- self._rules_by_endpoint = {}
- self._remap = True
- self._remap_lock = Lock()
-
- self.default_subdomain = default_subdomain
- self.charset = charset
- self.encoding_errors = encoding_errors
- self.strict_slashes = strict_slashes
- self.redirect_defaults = redirect_defaults
- self.host_matching = host_matching
-
- self.converters = self.default_converters.copy()
- if converters:
- self.converters.update(converters)
-
- self.sort_parameters = sort_parameters
- self.sort_key = sort_key
-
- for rulefactory in rules or ():
- self.add(rulefactory)
-
- def is_endpoint_expecting(self, endpoint, *arguments):
- """Iterate over all rules and check if the endpoint expects
- the arguments provided. This is for example useful if you have
- some URLs that expect a language code and others that do not and
- you want to wrap the builder a bit so that the current language
- code is automatically added if not provided but endpoints expect
- it.
-
- :param endpoint: the endpoint to check.
- :param arguments: this function accepts one or more arguments
- as positional arguments. Each one of them is
- checked.
- """
- self.update()
- arguments = set(arguments)
- for rule in self._rules_by_endpoint[endpoint]:
- if arguments.issubset(rule.arguments):
- return True
- return False
-
- def iter_rules(self, endpoint=None):
- """Iterate over all rules or the rules of an endpoint.
-
- :param endpoint: if provided only the rules for that endpoint
- are returned.
- :return: an iterator
- """
- self.update()
- if endpoint is not None:
- return iter(self._rules_by_endpoint[endpoint])
- return iter(self._rules)
-
- def add(self, rulefactory):
- """Add a new rule or factory to the map and bind it. Requires that the
- rule is not bound to another map.
-
- :param rulefactory: a :class:`Rule` or :class:`RuleFactory`
- """
- for rule in rulefactory.get_rules(self):
- rule.bind(self)
- self._rules.append(rule)
- self._rules_by_endpoint.setdefault(rule.endpoint, []).append(rule)
- self._remap = True
-
- def bind(
- self,
- server_name,
- script_name=None,
- subdomain=None,
- url_scheme="http",
- default_method="GET",
- path_info=None,
- query_args=None,
- ):
- """Return a new :class:`MapAdapter` with the details specified to the
- call. Note that `script_name` will default to ``'/'`` if not further
- specified or `None`. The `server_name` at least is a requirement
- because the HTTP RFC requires absolute URLs for redirects and so all
- redirect exceptions raised by Werkzeug will contain the full canonical
- URL.
-
- If no path_info is passed to :meth:`match` it will use the default path
- info passed to bind. While this doesn't really make sense for
- manual bind calls, it's useful if you bind a map to a WSGI
- environment which already contains the path info.
-
- `subdomain` will default to the `default_subdomain` for this map if
- no defined. If there is no `default_subdomain` you cannot use the
- subdomain feature.
-
- .. versionadded:: 0.7
- `query_args` added
-
- .. versionadded:: 0.8
- `query_args` can now also be a string.
-
- .. versionchanged:: 0.15
- ``path_info`` defaults to ``'/'`` if ``None``.
- """
- server_name = server_name.lower()
- if self.host_matching:
- if subdomain is not None:
- raise RuntimeError("host matching enabled and a subdomain was provided")
- elif subdomain is None:
- subdomain = self.default_subdomain
- if script_name is None:
- script_name = "/"
- if path_info is None:
- path_info = "/"
- try:
- server_name = _encode_idna(server_name)
- except UnicodeError:
- raise BadHost()
- return MapAdapter(
- self,
- server_name,
- script_name,
- subdomain,
- url_scheme,
- path_info,
- default_method,
- query_args,
- )
-
- def bind_to_environ(self, environ, server_name=None, subdomain=None):
- """Like :meth:`bind` but you can pass it an WSGI environment and it
- will fetch the information from that dictionary. Note that because of
- limitations in the protocol there is no way to get the current
- subdomain and real `server_name` from the environment. If you don't
- provide it, Werkzeug will use `SERVER_NAME` and `SERVER_PORT` (or
- `HTTP_HOST` if provided) as used `server_name` with disabled subdomain
- feature.
-
- If `subdomain` is `None` but an environment and a server name is
- provided it will calculate the current subdomain automatically.
- Example: `server_name` is ``'example.com'`` and the `SERVER_NAME`
- in the wsgi `environ` is ``'staging.dev.example.com'`` the calculated
- subdomain will be ``'staging.dev'``.
-
- If the object passed as environ has an environ attribute, the value of
- this attribute is used instead. This allows you to pass request
- objects. Additionally `PATH_INFO` added as a default of the
- :class:`MapAdapter` so that you don't have to pass the path info to
- the match method.
-
- .. versionchanged:: 0.5
- previously this method accepted a bogus `calculate_subdomain`
- parameter that did not have any effect. It was removed because
- of that.
-
- .. versionchanged:: 0.8
- This will no longer raise a ValueError when an unexpected server
- name was passed.
-
- :param environ: a WSGI environment.
- :param server_name: an optional server name hint (see above).
- :param subdomain: optionally the current subdomain (see above).
- """
- environ = _get_environ(environ)
-
- wsgi_server_name = get_host(environ).lower()
-
- if server_name is None:
- server_name = wsgi_server_name
- else:
- server_name = server_name.lower()
-
- if subdomain is None and not self.host_matching:
- cur_server_name = wsgi_server_name.split(".")
- real_server_name = server_name.split(".")
- offset = -len(real_server_name)
- if cur_server_name[offset:] != real_server_name:
- # This can happen even with valid configs if the server was
- # accesssed directly by IP address under some situations.
- # Instead of raising an exception like in Werkzeug 0.7 or
- # earlier we go by an invalid subdomain which will result
- # in a 404 error on matching.
- subdomain = "<invalid>"
- else:
- subdomain = ".".join(filter(None, cur_server_name[:offset]))
-
- def _get_wsgi_string(name):
- val = environ.get(name)
- if val is not None:
- return wsgi_decoding_dance(val, self.charset)
-
- script_name = _get_wsgi_string("SCRIPT_NAME")
- path_info = _get_wsgi_string("PATH_INFO")
- query_args = _get_wsgi_string("QUERY_STRING")
- return Map.bind(
- self,
- server_name,
- script_name,
- subdomain,
- environ["wsgi.url_scheme"],
- environ["REQUEST_METHOD"],
- path_info,
- query_args=query_args,
- )
-
- def update(self):
- """Called before matching and building to keep the compiled rules
- in the correct order after things changed.
- """
- if not self._remap:
- return
-
- with self._remap_lock:
- if not self._remap:
- return
-
- self._rules.sort(key=lambda x: x.match_compare_key())
- for rules in itervalues(self._rules_by_endpoint):
- rules.sort(key=lambda x: x.build_compare_key())
- self._remap = False
-
- def __repr__(self):
- rules = self.iter_rules()
- return "%s(%s)" % (self.__class__.__name__, pformat(list(rules)))
-
-
-class MapAdapter(object):
-
- """Returned by :meth:`Map.bind` or :meth:`Map.bind_to_environ` and does
- the URL matching and building based on runtime information.
- """
-
- def __init__(
- self,
- map,
- server_name,
- script_name,
- subdomain,
- url_scheme,
- path_info,
- default_method,
- query_args=None,
- ):
- self.map = map
- self.server_name = to_unicode(server_name)
- script_name = to_unicode(script_name)
- if not script_name.endswith(u"/"):
- script_name += u"/"
- self.script_name = script_name
- self.subdomain = to_unicode(subdomain)
- self.url_scheme = to_unicode(url_scheme)
- self.path_info = to_unicode(path_info)
- self.default_method = to_unicode(default_method)
- self.query_args = query_args
-
- def dispatch(
- self, view_func, path_info=None, method=None, catch_http_exceptions=False
- ):
- """Does the complete dispatching process. `view_func` is called with
- the endpoint and a dict with the values for the view. It should
- look up the view function, call it, and return a response object
- or WSGI application. http exceptions are not caught by default
- so that applications can display nicer error messages by just
- catching them by hand. If you want to stick with the default
- error messages you can pass it ``catch_http_exceptions=True`` and
- it will catch the http exceptions.
-
- Here a small example for the dispatch usage::
-
- from werkzeug.wrappers import Request, Response
- from werkzeug.wsgi import responder
- from werkzeug.routing import Map, Rule
-
- def on_index(request):
- return Response('Hello from the index')
-
- url_map = Map([Rule('/', endpoint='index')])
- views = {'index': on_index}
-
- @responder
- def application(environ, start_response):
- request = Request(environ)
- urls = url_map.bind_to_environ(environ)
- return urls.dispatch(lambda e, v: views[e](request, **v),
- catch_http_exceptions=True)
-
- Keep in mind that this method might return exception objects, too, so
- use :class:`Response.force_type` to get a response object.
-
- :param view_func: a function that is called with the endpoint as
- first argument and the value dict as second. Has
- to dispatch to the actual view function with this
- information. (see above)
- :param path_info: the path info to use for matching. Overrides the
- path info specified on binding.
- :param method: the HTTP method used for matching. Overrides the
- method specified on binding.
- :param catch_http_exceptions: set to `True` to catch any of the
- werkzeug :class:`HTTPException`\\s.
- """
- try:
- try:
- endpoint, args = self.match(path_info, method)
- except RequestRedirect as e:
- return e
- return view_func(endpoint, args)
- except HTTPException as e:
- if catch_http_exceptions:
- return e
- raise
-
- def match(self, path_info=None, method=None, return_rule=False, query_args=None):
- """The usage is simple: you just pass the match method the current
- path info as well as the method (which defaults to `GET`). The
- following things can then happen:
-
- - you receive a `NotFound` exception that indicates that no URL is
- matching. A `NotFound` exception is also a WSGI application you
- can call to get a default page not found page (happens to be the
- same object as `werkzeug.exceptions.NotFound`)
-
- - you receive a `MethodNotAllowed` exception that indicates that there
- is a match for this URL but not for the current request method.
- This is useful for RESTful applications.
-
- - you receive a `RequestRedirect` exception with a `new_url`
- attribute. This exception is used to notify you about a request
- Werkzeug requests from your WSGI application. This is for example the
- case if you request ``/foo`` although the correct URL is ``/foo/``
- You can use the `RequestRedirect` instance as response-like object
- similar to all other subclasses of `HTTPException`.
-
- - you get a tuple in the form ``(endpoint, arguments)`` if there is
- a match (unless `return_rule` is True, in which case you get a tuple
- in the form ``(rule, arguments)``)
-
- If the path info is not passed to the match method the default path
- info of the map is used (defaults to the root URL if not defined
- explicitly).
-
- All of the exceptions raised are subclasses of `HTTPException` so they
- can be used as WSGI responses. They will all render generic error or
- redirect pages.
-
- Here is a small example for matching:
-
- >>> m = Map([
- ... Rule('/', endpoint='index'),
- ... Rule('/downloads/', endpoint='downloads/index'),
- ... Rule('/downloads/<int:id>', endpoint='downloads/show')
- ... ])
- >>> urls = m.bind("example.com", "/")
- >>> urls.match("/", "GET")
- ('index', {})
- >>> urls.match("/downloads/42")
- ('downloads/show', {'id': 42})
-
- And here is what happens on redirect and missing URLs:
-
- >>> urls.match("/downloads")
- Traceback (most recent call last):
- ...
- RequestRedirect: http://example.com/downloads/
- >>> urls.match("/missing")
- Traceback (most recent call last):
- ...
- NotFound: 404 Not Found
-
- :param path_info: the path info to use for matching. Overrides the
- path info specified on binding.
- :param method: the HTTP method used for matching. Overrides the
- method specified on binding.
- :param return_rule: return the rule that matched instead of just the
- endpoint (defaults to `False`).
- :param query_args: optional query arguments that are used for
- automatic redirects as string or dictionary. It's
- currently not possible to use the query arguments
- for URL matching.
-
- .. versionadded:: 0.6
- `return_rule` was added.
-
- .. versionadded:: 0.7
- `query_args` was added.
-
- .. versionchanged:: 0.8
- `query_args` can now also be a string.
- """
- self.map.update()
- if path_info is None:
- path_info = self.path_info
- else:
- path_info = to_unicode(path_info, self.map.charset)
- if query_args is None:
- query_args = self.query_args
- method = (method or self.default_method).upper()
-
- path = u"%s|%s" % (
- self.map.host_matching and self.server_name or self.subdomain,
- path_info and "/%s" % path_info.lstrip("/"),
- )
-
- have_match_for = set()
- for rule in self.map._rules:
- try:
- rv = rule.match(path, method)
- except RequestSlash:
- raise RequestRedirect(
- self.make_redirect_url(
- url_quote(path_info, self.map.charset, safe="/:|+") + "/",
- query_args,
- )
- )
- except RequestAliasRedirect as e:
- raise RequestRedirect(
- self.make_alias_redirect_url(
- path, rule.endpoint, e.matched_values, method, query_args
- )
- )
- if rv is None:
- continue
- if rule.methods is not None and method not in rule.methods:
- have_match_for.update(rule.methods)
- continue
-
- if self.map.redirect_defaults:
- redirect_url = self.get_default_redirect(rule, method, rv, query_args)
- if redirect_url is not None:
- raise RequestRedirect(redirect_url)
-
- if rule.redirect_to is not None:
- if isinstance(rule.redirect_to, string_types):
-
- def _handle_match(match):
- value = rv[match.group(1)]
- return rule._converters[match.group(1)].to_url(value)
-
- redirect_url = _simple_rule_re.sub(_handle_match, rule.redirect_to)
- else:
- redirect_url = rule.redirect_to(self, **rv)
- raise RequestRedirect(
- str(
- url_join(
- "%s://%s%s%s"
- % (
- self.url_scheme or "http",
- self.subdomain + "." if self.subdomain else "",
- self.server_name,
- self.script_name,
- ),
- redirect_url,
- )
- )
- )
-
- if return_rule:
- return rule, rv
- else:
- return rule.endpoint, rv
-
- if have_match_for:
- raise MethodNotAllowed(valid_methods=list(have_match_for))
- raise NotFound()
-
- def test(self, path_info=None, method=None):
- """Test if a rule would match. Works like `match` but returns `True`
- if the URL matches, or `False` if it does not exist.
-
- :param path_info: the path info to use for matching. Overrides the
- path info specified on binding.
- :param method: the HTTP method used for matching. Overrides the
- method specified on binding.
- """
- try:
- self.match(path_info, method)
- except RequestRedirect:
- pass
- except HTTPException:
- return False
- return True
-
- def allowed_methods(self, path_info=None):
- """Returns the valid methods that match for a given path.
-
- .. versionadded:: 0.7
- """
- try:
- self.match(path_info, method="--")
- except MethodNotAllowed as e:
- return e.valid_methods
- except HTTPException:
- pass
- return []
-
- def get_host(self, domain_part):
- """Figures out the full host name for the given domain part. The
- domain part is a subdomain in case host matching is disabled or
- a full host name.
- """
- if self.map.host_matching:
- if domain_part is None:
- return self.server_name
- return to_unicode(domain_part, "ascii")
- subdomain = domain_part
- if subdomain is None:
- subdomain = self.subdomain
- else:
- subdomain = to_unicode(subdomain, "ascii")
- return (subdomain + u"." if subdomain else u"") + self.server_name
-
- def get_default_redirect(self, rule, method, values, query_args):
- """A helper that returns the URL to redirect to if it finds one.
- This is used for default redirecting only.
-
- :internal:
- """
- assert self.map.redirect_defaults
- for r in self.map._rules_by_endpoint[rule.endpoint]:
- # every rule that comes after this one, including ourself
- # has a lower priority for the defaults. We order the ones
- # with the highest priority up for building.
- if r is rule:
- break
- if r.provides_defaults_for(rule) and r.suitable_for(values, method):
- values.update(r.defaults)
- domain_part, path = r.build(values)
- return self.make_redirect_url(path, query_args, domain_part=domain_part)
-
- def encode_query_args(self, query_args):
- if not isinstance(query_args, string_types):
- query_args = url_encode(query_args, self.map.charset)
- return query_args
-
- def make_redirect_url(self, path_info, query_args=None, domain_part=None):
- """Creates a redirect URL.
-
- :internal:
- """
- suffix = ""
- if query_args:
- suffix = "?" + self.encode_query_args(query_args)
- return str(
- "%s://%s/%s%s"
- % (
- self.url_scheme or "http",
- self.get_host(domain_part),
- posixpath.join(
- self.script_name[:-1].lstrip("/"), path_info.lstrip("/")
- ),
- suffix,
- )
- )
-
- def make_alias_redirect_url(self, path, endpoint, values, method, query_args):
- """Internally called to make an alias redirect URL."""
- url = self.build(
- endpoint, values, method, append_unknown=False, force_external=True
- )
- if query_args:
- url += "?" + self.encode_query_args(query_args)
- assert url != path, "detected invalid alias setting. No canonical URL found"
- return url
-
- def _partial_build(self, endpoint, values, method, append_unknown):
- """Helper for :meth:`build`. Returns subdomain and path for the
- rule that accepts this endpoint, values and method.
-
- :internal:
- """
- # in case the method is none, try with the default method first
- if method is None:
- rv = self._partial_build(
- endpoint, values, self.default_method, append_unknown
- )
- if rv is not None:
- return rv
-
- # default method did not match or a specific method is passed,
- # check all and go with first result.
- for rule in self.map._rules_by_endpoint.get(endpoint, ()):
- if rule.suitable_for(values, method):
- rv = rule.build(values, append_unknown)
- if rv is not None:
- return rv
-
- def build(
- self,
- endpoint,
- values=None,
- method=None,
- force_external=False,
- append_unknown=True,
- ):
- """Building URLs works pretty much the other way round. Instead of
- `match` you call `build` and pass it the endpoint and a dict of
- arguments for the placeholders.
-
- The `build` function also accepts an argument called `force_external`
- which, if you set it to `True` will force external URLs. Per default
- external URLs (include the server name) will only be used if the
- target URL is on a different subdomain.
-
- >>> m = Map([
- ... Rule('/', endpoint='index'),
- ... Rule('/downloads/', endpoint='downloads/index'),
- ... Rule('/downloads/<int:id>', endpoint='downloads/show')
- ... ])
- >>> urls = m.bind("example.com", "/")
- >>> urls.build("index", {})
- '/'
- >>> urls.build("downloads/show", {'id': 42})
- '/downloads/42'
- >>> urls.build("downloads/show", {'id': 42}, force_external=True)
- 'http://example.com/downloads/42'
-
- Because URLs cannot contain non ASCII data you will always get
- bytestrings back. Non ASCII characters are urlencoded with the
- charset defined on the map instance.
-
- Additional values are converted to unicode and appended to the URL as
- URL querystring parameters:
-
- >>> urls.build("index", {'q': 'My Searchstring'})
- '/?q=My+Searchstring'
-
- When processing those additional values, lists are furthermore
- interpreted as multiple values (as per
- :py:class:`werkzeug.datastructures.MultiDict`):
-
- >>> urls.build("index", {'q': ['a', 'b', 'c']})
- '/?q=a&q=b&q=c'
-
- Passing a ``MultiDict`` will also add multiple values:
-
- >>> urls.build("index", MultiDict((('p', 'z'), ('q', 'a'), ('q', 'b'))))
- '/?p=z&q=a&q=b'
-
- If a rule does not exist when building a `BuildError` exception is
- raised.
-
- The build method accepts an argument called `method` which allows you
- to specify the method you want to have an URL built for if you have
- different methods for the same endpoint specified.
-
- .. versionadded:: 0.6
- the `append_unknown` parameter was added.
-
- :param endpoint: the endpoint of the URL to build.
- :param values: the values for the URL to build. Unhandled values are
- appended to the URL as query parameters.
- :param method: the HTTP method for the rule if there are different
- URLs for different methods on the same endpoint.
- :param force_external: enforce full canonical external URLs. If the URL
- scheme is not provided, this will generate
- a protocol-relative URL.
- :param append_unknown: unknown parameters are appended to the generated
- URL as query string argument. Disable this
- if you want the builder to ignore those.
- """
- self.map.update()
-
- if values:
- if isinstance(values, MultiDict):
- temp_values = {}
- # iteritems(dict, values) is like `values.lists()`
- # without the call or `list()` coercion overhead.
- for key, value in iteritems(dict, values):
- if not value:
- continue
- if len(value) == 1: # flatten single item lists
- value = value[0]
- if value is None: # drop None
- continue
- temp_values[key] = value
- values = temp_values
- else:
- # drop None
- values = dict(i for i in iteritems(values) if i[1] is not None)
- else:
- values = {}
-
- rv = self._partial_build(endpoint, values, method, append_unknown)
- if rv is None:
- raise BuildError(endpoint, values, method, self)
- domain_part, path = rv
-
- host = self.get_host(domain_part)
-
- # shortcut this.
- if not force_external and (
- (self.map.host_matching and host == self.server_name)
- or (not self.map.host_matching and domain_part == self.subdomain)
- ):
- return "%s/%s" % (self.script_name.rstrip("/"), path.lstrip("/"))
- return str(
- "%s//%s%s/%s"
- % (
- self.url_scheme + ":" if self.url_scheme else "",
- host,
- self.script_name[:-1],
- path.lstrip("/"),
- )
- )
diff --git a/python/werkzeug/security.py b/python/werkzeug/security.py
deleted file mode 100644
index 1842afd..0000000
--- a/python/werkzeug/security.py
+++ /dev/null
@@ -1,241 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.security
- ~~~~~~~~~~~~~~~~~
-
- Security related helpers such as secure password hashing tools.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import hashlib
-import hmac
-import os
-import posixpath
-from random import SystemRandom
-from struct import Struct
-
-from ._compat import izip
-from ._compat import PY2
-from ._compat import range_type
-from ._compat import text_type
-from ._compat import to_bytes
-from ._compat import to_native
-
-SALT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
-DEFAULT_PBKDF2_ITERATIONS = 150000
-
-_pack_int = Struct(">I").pack
-_builtin_safe_str_cmp = getattr(hmac, "compare_digest", None)
-_sys_rng = SystemRandom()
-_os_alt_seps = list(
- sep for sep in [os.path.sep, os.path.altsep] if sep not in (None, "/")
-)
-
-
-def pbkdf2_hex(
- data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None
-):
- """Like :func:`pbkdf2_bin`, but returns a hex-encoded string.
-
- .. versionadded:: 0.9
-
- :param data: the data to derive.
- :param salt: the salt for the derivation.
- :param iterations: the number of iterations.
- :param keylen: the length of the resulting key. If not provided,
- the digest size will be used.
- :param hashfunc: the hash function to use. This can either be the
- string name of a known hash function, or a function
- from the hashlib module. Defaults to sha256.
- """
- rv = pbkdf2_bin(data, salt, iterations, keylen, hashfunc)
- return to_native(codecs.encode(rv, "hex_codec"))
-
-
-def pbkdf2_bin(
- data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None
-):
- """Returns a binary digest for the PBKDF2 hash algorithm of `data`
- with the given `salt`. It iterates `iterations` times and produces a
- key of `keylen` bytes. By default, SHA-256 is used as hash function;
- a different hashlib `hashfunc` can be provided.
-
- .. versionadded:: 0.9
-
- :param data: the data to derive.
- :param salt: the salt for the derivation.
- :param iterations: the number of iterations.
- :param keylen: the length of the resulting key. If not provided
- the digest size will be used.
- :param hashfunc: the hash function to use. This can either be the
- string name of a known hash function or a function
- from the hashlib module. Defaults to sha256.
- """
- if not hashfunc:
- hashfunc = "sha256"
-
- data = to_bytes(data)
- salt = to_bytes(salt)
-
- if callable(hashfunc):
- _test_hash = hashfunc()
- hash_name = getattr(_test_hash, "name", None)
- else:
- hash_name = hashfunc
- return hashlib.pbkdf2_hmac(hash_name, data, salt, iterations, keylen)
-
-
-def safe_str_cmp(a, b):
- """This function compares strings in somewhat constant time. This
- requires that the length of at least one string is known in advance.
-
- Returns `True` if the two strings are equal, or `False` if they are not.
-
- .. versionadded:: 0.7
- """
- if isinstance(a, text_type):
- a = a.encode("utf-8")
- if isinstance(b, text_type):
- b = b.encode("utf-8")
-
- if _builtin_safe_str_cmp is not None:
- return _builtin_safe_str_cmp(a, b)
-
- if len(a) != len(b):
- return False
-
- rv = 0
- if PY2:
- for x, y in izip(a, b):
- rv |= ord(x) ^ ord(y)
- else:
- for x, y in izip(a, b):
- rv |= x ^ y
-
- return rv == 0
-
-
-def gen_salt(length):
- """Generate a random string of SALT_CHARS with specified ``length``."""
- if length <= 0:
- raise ValueError("Salt length must be positive")
- return "".join(_sys_rng.choice(SALT_CHARS) for _ in range_type(length))
-
-
-def _hash_internal(method, salt, password):
- """Internal password hash helper. Supports plaintext without salt,
- unsalted and salted passwords. In case salted passwords are used
- hmac is used.
- """
- if method == "plain":
- return password, method
-
- if isinstance(password, text_type):
- password = password.encode("utf-8")
-
- if method.startswith("pbkdf2:"):
- args = method[7:].split(":")
- if len(args) not in (1, 2):
- raise ValueError("Invalid number of arguments for PBKDF2")
- method = args.pop(0)
- iterations = args and int(args[0] or 0) or DEFAULT_PBKDF2_ITERATIONS
- is_pbkdf2 = True
- actual_method = "pbkdf2:%s:%d" % (method, iterations)
- else:
- is_pbkdf2 = False
- actual_method = method
-
- if is_pbkdf2:
- if not salt:
- raise ValueError("Salt is required for PBKDF2")
- rv = pbkdf2_hex(password, salt, iterations, hashfunc=method)
- elif salt:
- if isinstance(salt, text_type):
- salt = salt.encode("utf-8")
- mac = _create_mac(salt, password, method)
- rv = mac.hexdigest()
- else:
- rv = hashlib.new(method, password).hexdigest()
- return rv, actual_method
-
-
-def _create_mac(key, msg, method):
- if callable(method):
- return hmac.HMAC(key, msg, method)
-
- def hashfunc(d=b""):
- return hashlib.new(method, d)
-
- # Python 2.7 used ``hasattr(digestmod, '__call__')``
- # to detect if hashfunc is callable
- hashfunc.__call__ = hashfunc
- return hmac.HMAC(key, msg, hashfunc)
-
-
-def generate_password_hash(password, method="pbkdf2:sha256", salt_length=8):
- """Hash a password with the given method and salt with a string of
- the given length. The format of the string returned includes the method
- that was used so that :func:`check_password_hash` can check the hash.
-
- The format for the hashed string looks like this::
-
- method$salt$hash
-
- This method can **not** generate unsalted passwords but it is possible
- to set param method='plain' in order to enforce plaintext passwords.
- If a salt is used, hmac is used internally to salt the password.
-
- If PBKDF2 is wanted it can be enabled by setting the method to
- ``pbkdf2:method:iterations`` where iterations is optional::
-
- pbkdf2:sha256:80000$salt$hash
- pbkdf2:sha256$salt$hash
-
- :param password: the password to hash.
- :param method: the hash method to use (one that hashlib supports). Can
- optionally be in the format ``pbkdf2:<method>[:iterations]``
- to enable PBKDF2.
- :param salt_length: the length of the salt in letters.
- """
- salt = gen_salt(salt_length) if method != "plain" else ""
- h, actual_method = _hash_internal(method, salt, password)
- return "%s$%s$%s" % (actual_method, salt, h)
-
-
-def check_password_hash(pwhash, password):
- """check a password against a given salted and hashed password value.
- In order to support unsalted legacy passwords this method supports
- plain text passwords, md5 and sha1 hashes (both salted and unsalted).
-
- Returns `True` if the password matched, `False` otherwise.
-
- :param pwhash: a hashed string like returned by
- :func:`generate_password_hash`.
- :param password: the plaintext password to compare against the hash.
- """
- if pwhash.count("$") < 2:
- return False
- method, salt, hashval = pwhash.split("$", 2)
- return safe_str_cmp(_hash_internal(method, salt, password)[0], hashval)
-
-
-def safe_join(directory, *pathnames):
- """Safely join `directory` and one or more untrusted `pathnames`. If this
- cannot be done, this function returns ``None``.
-
- :param directory: the base directory.
- :param pathnames: the untrusted pathnames relative to that directory.
- """
- parts = [directory]
- for filename in pathnames:
- if filename != "":
- filename = posixpath.normpath(filename)
- for sep in _os_alt_seps:
- if sep in filename:
- return None
- if os.path.isabs(filename) or filename == ".." or filename.startswith("../"):
- return None
- parts.append(filename)
- return posixpath.join(*parts)
diff --git a/python/werkzeug/serving.py b/python/werkzeug/serving.py
deleted file mode 100644
index ff9f880..0000000
--- a/python/werkzeug/serving.py
+++ /dev/null
@@ -1,1074 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.serving
- ~~~~~~~~~~~~~~~~
-
- There are many ways to serve a WSGI application. While you're developing
- it you usually don't want a full blown webserver like Apache but a simple
- standalone one. From Python 2.5 onwards there is the `wsgiref`_ server in
- the standard library. If you're using older versions of Python you can
- download the package from the cheeseshop.
-
- However there are some caveats. Sourcecode won't reload itself when
- changed and each time you kill the server using ``^C`` you get an
- `KeyboardInterrupt` error. While the latter is easy to solve the first
- one can be a pain in the ass in some situations.
-
- The easiest way is creating a small ``start-myproject.py`` that runs the
- application::
-
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from myproject import make_app
- from werkzeug.serving import run_simple
-
- app = make_app(...)
- run_simple('localhost', 8080, app, use_reloader=True)
-
- You can also pass it a `extra_files` keyword argument with a list of
- additional files (like configuration files) you want to observe.
-
- For bigger applications you should consider using `click`
- (http://click.pocoo.org) instead of a simple start file.
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import io
-import os
-import signal
-import socket
-import sys
-
-import werkzeug
-from ._compat import PY2
-from ._compat import reraise
-from ._compat import WIN
-from ._compat import wsgi_encoding_dance
-from ._internal import _log
-from .exceptions import InternalServerError
-from .urls import uri_to_iri
-from .urls import url_parse
-from .urls import url_unquote
-
-try:
- import socketserver
- from http.server import BaseHTTPRequestHandler
- from http.server import HTTPServer
-except ImportError:
- import SocketServer as socketserver
- from BaseHTTPServer import HTTPServer
- from BaseHTTPServer import BaseHTTPRequestHandler
-
-try:
- import ssl
-except ImportError:
-
- class _SslDummy(object):
- def __getattr__(self, name):
- raise RuntimeError("SSL support unavailable")
-
- ssl = _SslDummy()
-
-try:
- import termcolor
-except ImportError:
- termcolor = None
-
-
-def _get_openssl_crypto_module():
- try:
- from OpenSSL import crypto
- except ImportError:
- raise TypeError("Using ad-hoc certificates requires the pyOpenSSL library.")
- else:
- return crypto
-
-
-ThreadingMixIn = socketserver.ThreadingMixIn
-can_fork = hasattr(os, "fork")
-
-if can_fork:
- ForkingMixIn = socketserver.ForkingMixIn
-else:
-
- class ForkingMixIn(object):
- pass
-
-
-try:
- af_unix = socket.AF_UNIX
-except AttributeError:
- af_unix = None
-
-
-LISTEN_QUEUE = 128
-can_open_by_fd = not WIN and hasattr(socket, "fromfd")
-
-# On Python 3, ConnectionError represents the same errnos as
-# socket.error from Python 2, while socket.error is an alias for the
-# more generic OSError.
-if PY2:
- _ConnectionError = socket.error
-else:
- _ConnectionError = ConnectionError
-
-
-class DechunkedInput(io.RawIOBase):
- """An input stream that handles Transfer-Encoding 'chunked'"""
-
- def __init__(self, rfile):
- self._rfile = rfile
- self._done = False
- self._len = 0
-
- def readable(self):
- return True
-
- def read_chunk_len(self):
- try:
- line = self._rfile.readline().decode("latin1")
- _len = int(line.strip(), 16)
- except ValueError:
- raise IOError("Invalid chunk header")
- if _len < 0:
- raise IOError("Negative chunk length not allowed")
- return _len
-
- def readinto(self, buf):
- read = 0
- while not self._done and read < len(buf):
- if self._len == 0:
- # This is the first chunk or we fully consumed the previous
- # one. Read the next length of the next chunk
- self._len = self.read_chunk_len()
-
- if self._len == 0:
- # Found the final chunk of size 0. The stream is now exhausted,
- # but there is still a final newline that should be consumed
- self._done = True
-
- if self._len > 0:
- # There is data (left) in this chunk, so append it to the
- # buffer. If this operation fully consumes the chunk, this will
- # reset self._len to 0.
- n = min(len(buf), self._len)
- buf[read : read + n] = self._rfile.read(n)
- self._len -= n
- read += n
-
- if self._len == 0:
- # Skip the terminating newline of a chunk that has been fully
- # consumed. This also applies to the 0-sized final chunk
- terminator = self._rfile.readline()
- if terminator not in (b"\n", b"\r\n", b"\r"):
- raise IOError("Missing chunk terminating newline")
-
- return read
-
-
-class WSGIRequestHandler(BaseHTTPRequestHandler, object):
-
- """A request handler that implements WSGI dispatching."""
-
- @property
- def server_version(self):
- return "Werkzeug/" + werkzeug.__version__
-
- def make_environ(self):
- request_url = url_parse(self.path)
-
- def shutdown_server():
- self.server.shutdown_signal = True
-
- url_scheme = "http" if self.server.ssl_context is None else "https"
- if not self.client_address:
- self.client_address = "<local>"
- if isinstance(self.client_address, str):
- self.client_address = (self.client_address, 0)
- else:
- pass
- path_info = url_unquote(request_url.path)
-
- environ = {
- "wsgi.version": (1, 0),
- "wsgi.url_scheme": url_scheme,
- "wsgi.input": self.rfile,
- "wsgi.errors": sys.stderr,
- "wsgi.multithread": self.server.multithread,
- "wsgi.multiprocess": self.server.multiprocess,
- "wsgi.run_once": False,
- "werkzeug.server.shutdown": shutdown_server,
- "SERVER_SOFTWARE": self.server_version,
- "REQUEST_METHOD": self.command,
- "SCRIPT_NAME": "",
- "PATH_INFO": wsgi_encoding_dance(path_info),
- "QUERY_STRING": wsgi_encoding_dance(request_url.query),
- # Non-standard, added by mod_wsgi, uWSGI
- "REQUEST_URI": wsgi_encoding_dance(self.path),
- # Non-standard, added by gunicorn
- "RAW_URI": wsgi_encoding_dance(self.path),
- "REMOTE_ADDR": self.address_string(),
- "REMOTE_PORT": self.port_integer(),
- "SERVER_NAME": self.server.server_address[0],
- "SERVER_PORT": str(self.server.server_address[1]),
- "SERVER_PROTOCOL": self.request_version,
- }
-
- for key, value in self.get_header_items():
- key = key.upper().replace("-", "_")
- value = value.replace("\r\n", "")
- if key not in ("CONTENT_TYPE", "CONTENT_LENGTH"):
- key = "HTTP_" + key
- if key in environ:
- value = "{},{}".format(environ[key], value)
- environ[key] = value
-
- if environ.get("HTTP_TRANSFER_ENCODING", "").strip().lower() == "chunked":
- environ["wsgi.input_terminated"] = True
- environ["wsgi.input"] = DechunkedInput(environ["wsgi.input"])
-
- if request_url.scheme and request_url.netloc:
- environ["HTTP_HOST"] = request_url.netloc
-
- return environ
-
- def run_wsgi(self):
- if self.headers.get("Expect", "").lower().strip() == "100-continue":
- self.wfile.write(b"HTTP/1.1 100 Continue\r\n\r\n")
-
- self.environ = environ = self.make_environ()
- headers_set = []
- headers_sent = []
-
- def write(data):
- assert headers_set, "write() before start_response"
- if not headers_sent:
- status, response_headers = headers_sent[:] = headers_set
- try:
- code, msg = status.split(None, 1)
- except ValueError:
- code, msg = status, ""
- code = int(code)
- self.send_response(code, msg)
- header_keys = set()
- for key, value in response_headers:
- self.send_header(key, value)
- key = key.lower()
- header_keys.add(key)
- if not (
- "content-length" in header_keys
- or environ["REQUEST_METHOD"] == "HEAD"
- or code < 200
- or code in (204, 304)
- ):
- self.close_connection = True
- self.send_header("Connection", "close")
- if "server" not in header_keys:
- self.send_header("Server", self.version_string())
- if "date" not in header_keys:
- self.send_header("Date", self.date_time_string())
- self.end_headers()
-
- assert isinstance(data, bytes), "applications must write bytes"
- self.wfile.write(data)
- self.wfile.flush()
-
- def start_response(status, response_headers, exc_info=None):
- if exc_info:
- try:
- if headers_sent:
- reraise(*exc_info)
- finally:
- exc_info = None
- elif headers_set:
- raise AssertionError("Headers already set")
- headers_set[:] = [status, response_headers]
- return write
-
- def execute(app):
- application_iter = app(environ, start_response)
- try:
- for data in application_iter:
- write(data)
- if not headers_sent:
- write(b"")
- finally:
- if hasattr(application_iter, "close"):
- application_iter.close()
- application_iter = None
-
- try:
- execute(self.server.app)
- except (_ConnectionError, socket.timeout) as e:
- self.connection_dropped(e, environ)
- except Exception:
- if self.server.passthrough_errors:
- raise
- from .debug.tbtools import get_current_traceback
-
- traceback = get_current_traceback(ignore_system_exceptions=True)
- try:
- # if we haven't yet sent the headers but they are set
- # we roll back to be able to set them again.
- if not headers_sent:
- del headers_set[:]
- execute(InternalServerError())
- except Exception:
- pass
- self.server.log("error", "Error on request:\n%s", traceback.plaintext)
-
- def handle(self):
- """Handles a request ignoring dropped connections."""
- rv = None
- try:
- rv = BaseHTTPRequestHandler.handle(self)
- except (_ConnectionError, socket.timeout) as e:
- self.connection_dropped(e)
- except Exception as e:
- if self.server.ssl_context is None or not is_ssl_error(e):
- raise
- if self.server.shutdown_signal:
- self.initiate_shutdown()
- return rv
-
- def initiate_shutdown(self):
- """A horrible, horrible way to kill the server for Python 2.6 and
- later. It's the best we can do.
- """
- # Windows does not provide SIGKILL, go with SIGTERM then.
- sig = getattr(signal, "SIGKILL", signal.SIGTERM)
- # reloader active
- if is_running_from_reloader():
- os.kill(os.getpid(), sig)
- # python 2.7
- self.server._BaseServer__shutdown_request = True
- # python 2.6
- self.server._BaseServer__serving = False
-
- def connection_dropped(self, error, environ=None):
- """Called if the connection was closed by the client. By default
- nothing happens.
- """
-
- def handle_one_request(self):
- """Handle a single HTTP request."""
- self.raw_requestline = self.rfile.readline()
- if not self.raw_requestline:
- self.close_connection = 1
- elif self.parse_request():
- return self.run_wsgi()
-
- def send_response(self, code, message=None):
- """Send the response header and log the response code."""
- self.log_request(code)
- if message is None:
- message = code in self.responses and self.responses[code][0] or ""
- if self.request_version != "HTTP/0.9":
- hdr = "%s %d %s\r\n" % (self.protocol_version, code, message)
- self.wfile.write(hdr.encode("ascii"))
-
- def version_string(self):
- return BaseHTTPRequestHandler.version_string(self).strip()
-
- def address_string(self):
- if getattr(self, "environ", None):
- return self.environ["REMOTE_ADDR"]
- elif not self.client_address:
- return "<local>"
- elif isinstance(self.client_address, str):
- return self.client_address
- else:
- return self.client_address[0]
-
- def port_integer(self):
- return self.client_address[1]
-
- def log_request(self, code="-", size="-"):
- try:
- path = uri_to_iri(self.path)
- msg = "%s %s %s" % (self.command, path, self.request_version)
- except AttributeError:
- # path isn't set if the requestline was bad
- msg = self.requestline
-
- code = str(code)
-
- if termcolor:
- color = termcolor.colored
-
- if code[0] == "1": # 1xx - Informational
- msg = color(msg, attrs=["bold"])
- elif code[0] == "2": # 2xx - Success
- msg = color(msg, color="white")
- elif code == "304": # 304 - Resource Not Modified
- msg = color(msg, color="cyan")
- elif code[0] == "3": # 3xx - Redirection
- msg = color(msg, color="green")
- elif code == "404": # 404 - Resource Not Found
- msg = color(msg, color="yellow")
- elif code[0] == "4": # 4xx - Client Error
- msg = color(msg, color="red", attrs=["bold"])
- else: # 5xx, or any other response
- msg = color(msg, color="magenta", attrs=["bold"])
-
- self.log("info", '"%s" %s %s', msg, code, size)
-
- def log_error(self, *args):
- self.log("error", *args)
-
- def log_message(self, format, *args):
- self.log("info", format, *args)
-
- def log(self, type, message, *args):
- _log(
- type,
- "%s - - [%s] %s\n"
- % (self.address_string(), self.log_date_time_string(), message % args),
- )
-
- def get_header_items(self):
- """
- Get an iterable list of key/value pairs representing headers.
-
- This function provides Python 2/3 compatibility as related to the
- parsing of request headers. Python 2.7 is not compliant with
- RFC 3875 Section 4.1.18 which requires multiple values for headers
- to be provided or RFC 2616 which allows for folding of multi-line
- headers. This function will return a matching list regardless
- of Python version. It can be removed once Python 2.7 support
- is dropped.
-
- :return: List of tuples containing header hey/value pairs
- """
- if PY2:
- # For Python 2, process the headers manually according to
- # W3C RFC 2616 Section 4.2.
- items = []
- for header in self.headers.headers:
- # Remove "\r\n" from the header and split on ":" to get
- # the field name and value.
- try:
- key, value = header[0:-2].split(":", 1)
- except ValueError:
- # If header could not be slit with : but starts with white
- # space and it follows an existing header, it's a folded
- # header.
- if header[0] in ("\t", " ") and items:
- # Pop off the last header
- key, value = items.pop()
- # Append the current header to the value of the last
- # header which will be placed back on the end of the
- # list
- value = value + header
- # Otherwise it's just a bad header and should error
- else:
- # Re-raise the value error
- raise
-
- # Add the key and the value once stripped of leading
- # white space. The specification allows for stripping
- # trailing white space but the Python 3 code does not
- # strip trailing white space. Therefore, trailing space
- # will be left as is to match the Python 3 behavior.
- items.append((key, value.lstrip()))
- else:
- items = self.headers.items()
-
- return items
-
-
-#: backwards compatible name if someone is subclassing it
-BaseRequestHandler = WSGIRequestHandler
-
-
-def generate_adhoc_ssl_pair(cn=None):
- from random import random
-
- crypto = _get_openssl_crypto_module()
-
- # pretty damn sure that this is not actually accepted by anyone
- if cn is None:
- cn = "*"
-
- cert = crypto.X509()
- cert.set_serial_number(int(random() * sys.maxsize))
- cert.gmtime_adj_notBefore(0)
- cert.gmtime_adj_notAfter(60 * 60 * 24 * 365)
-
- subject = cert.get_subject()
- subject.CN = cn
- subject.O = "Dummy Certificate" # noqa: E741
-
- issuer = cert.get_issuer()
- issuer.CN = subject.CN
- issuer.O = subject.O # noqa: E741
-
- pkey = crypto.PKey()
- pkey.generate_key(crypto.TYPE_RSA, 2048)
- cert.set_pubkey(pkey)
- cert.sign(pkey, "sha256")
-
- return cert, pkey
-
-
-def make_ssl_devcert(base_path, host=None, cn=None):
- """Creates an SSL key for development. This should be used instead of
- the ``'adhoc'`` key which generates a new cert on each server start.
- It accepts a path for where it should store the key and cert and
- either a host or CN. If a host is given it will use the CN
- ``*.host/CN=host``.
-
- For more information see :func:`run_simple`.
-
- .. versionadded:: 0.9
-
- :param base_path: the path to the certificate and key. The extension
- ``.crt`` is added for the certificate, ``.key`` is
- added for the key.
- :param host: the name of the host. This can be used as an alternative
- for the `cn`.
- :param cn: the `CN` to use.
- """
- from OpenSSL import crypto
-
- if host is not None:
- cn = "*.%s/CN=%s" % (host, host)
- cert, pkey = generate_adhoc_ssl_pair(cn=cn)
-
- cert_file = base_path + ".crt"
- pkey_file = base_path + ".key"
-
- with open(cert_file, "wb") as f:
- f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
- with open(pkey_file, "wb") as f:
- f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
-
- return cert_file, pkey_file
-
-
-def generate_adhoc_ssl_context():
- """Generates an adhoc SSL context for the development server."""
- crypto = _get_openssl_crypto_module()
- import tempfile
- import atexit
-
- cert, pkey = generate_adhoc_ssl_pair()
- cert_handle, cert_file = tempfile.mkstemp()
- pkey_handle, pkey_file = tempfile.mkstemp()
- atexit.register(os.remove, pkey_file)
- atexit.register(os.remove, cert_file)
-
- os.write(cert_handle, crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
- os.write(pkey_handle, crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
- os.close(cert_handle)
- os.close(pkey_handle)
- ctx = load_ssl_context(cert_file, pkey_file)
- return ctx
-
-
-def load_ssl_context(cert_file, pkey_file=None, protocol=None):
- """Loads SSL context from cert/private key files and optional protocol.
- Many parameters are directly taken from the API of
- :py:class:`ssl.SSLContext`.
-
- :param cert_file: Path of the certificate to use.
- :param pkey_file: Path of the private key to use. If not given, the key
- will be obtained from the certificate file.
- :param protocol: One of the ``PROTOCOL_*`` constants in the stdlib ``ssl``
- module. Defaults to ``PROTOCOL_SSLv23``.
- """
- if protocol is None:
- protocol = ssl.PROTOCOL_SSLv23
- ctx = _SSLContext(protocol)
- ctx.load_cert_chain(cert_file, pkey_file)
- return ctx
-
-
-class _SSLContext(object):
-
- """A dummy class with a small subset of Python3's ``ssl.SSLContext``, only
- intended to be used with and by Werkzeug."""
-
- def __init__(self, protocol):
- self._protocol = protocol
- self._certfile = None
- self._keyfile = None
- self._password = None
-
- def load_cert_chain(self, certfile, keyfile=None, password=None):
- self._certfile = certfile
- self._keyfile = keyfile or certfile
- self._password = password
-
- def wrap_socket(self, sock, **kwargs):
- return ssl.wrap_socket(
- sock,
- keyfile=self._keyfile,
- certfile=self._certfile,
- ssl_version=self._protocol,
- **kwargs
- )
-
-
-def is_ssl_error(error=None):
- """Checks if the given error (or the current one) is an SSL error."""
- exc_types = (ssl.SSLError,)
- try:
- from OpenSSL.SSL import Error
-
- exc_types += (Error,)
- except ImportError:
- pass
-
- if error is None:
- error = sys.exc_info()[1]
- return isinstance(error, exc_types)
-
-
-def select_address_family(host, port):
- """Return ``AF_INET4``, ``AF_INET6``, or ``AF_UNIX`` depending on
- the host and port."""
- # disabled due to problems with current ipv6 implementations
- # and various operating systems. Probably this code also is
- # not supposed to work, but I can't come up with any other
- # ways to implement this.
- # try:
- # info = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
- # socket.SOCK_STREAM, 0,
- # socket.AI_PASSIVE)
- # if info:
- # return info[0][0]
- # except socket.gaierror:
- # pass
- if host.startswith("unix://"):
- return socket.AF_UNIX
- elif ":" in host and hasattr(socket, "AF_INET6"):
- return socket.AF_INET6
- return socket.AF_INET
-
-
-def get_sockaddr(host, port, family):
- """Return a fully qualified socket address that can be passed to
- :func:`socket.bind`."""
- if family == af_unix:
- return host.split("://", 1)[1]
- try:
- res = socket.getaddrinfo(
- host, port, family, socket.SOCK_STREAM, socket.IPPROTO_TCP
- )
- except socket.gaierror:
- return host, port
- return res[0][4]
-
-
-class BaseWSGIServer(HTTPServer, object):
-
- """Simple single-threaded, single-process WSGI server."""
-
- multithread = False
- multiprocess = False
- request_queue_size = LISTEN_QUEUE
-
- def __init__(
- self,
- host,
- port,
- app,
- handler=None,
- passthrough_errors=False,
- ssl_context=None,
- fd=None,
- ):
- if handler is None:
- handler = WSGIRequestHandler
-
- self.address_family = select_address_family(host, port)
-
- if fd is not None:
- real_sock = socket.fromfd(fd, self.address_family, socket.SOCK_STREAM)
- port = 0
-
- server_address = get_sockaddr(host, int(port), self.address_family)
-
- # remove socket file if it already exists
- if self.address_family == af_unix and os.path.exists(server_address):
- os.unlink(server_address)
- HTTPServer.__init__(self, server_address, handler)
-
- self.app = app
- self.passthrough_errors = passthrough_errors
- self.shutdown_signal = False
- self.host = host
- self.port = self.socket.getsockname()[1]
-
- # Patch in the original socket.
- if fd is not None:
- self.socket.close()
- self.socket = real_sock
- self.server_address = self.socket.getsockname()
-
- if ssl_context is not None:
- if isinstance(ssl_context, tuple):
- ssl_context = load_ssl_context(*ssl_context)
- if ssl_context == "adhoc":
- ssl_context = generate_adhoc_ssl_context()
- # If we are on Python 2 the return value from socket.fromfd
- # is an internal socket object but what we need for ssl wrap
- # is the wrapper around it :(
- sock = self.socket
- if PY2 and not isinstance(sock, socket.socket):
- sock = socket.socket(sock.family, sock.type, sock.proto, sock)
- self.socket = ssl_context.wrap_socket(sock, server_side=True)
- self.ssl_context = ssl_context
- else:
- self.ssl_context = None
-
- def log(self, type, message, *args):
- _log(type, message, *args)
-
- def serve_forever(self):
- self.shutdown_signal = False
- try:
- HTTPServer.serve_forever(self)
- except KeyboardInterrupt:
- pass
- finally:
- self.server_close()
-
- def handle_error(self, request, client_address):
- if self.passthrough_errors:
- raise
- # Python 2 still causes a socket.error after the earlier
- # handling, so silence it here.
- if isinstance(sys.exc_info()[1], _ConnectionError):
- return
- return HTTPServer.handle_error(self, request, client_address)
-
- def get_request(self):
- con, info = self.socket.accept()
- return con, info
-
-
-class ThreadedWSGIServer(ThreadingMixIn, BaseWSGIServer):
-
- """A WSGI server that does threading."""
-
- multithread = True
- daemon_threads = True
-
-
-class ForkingWSGIServer(ForkingMixIn, BaseWSGIServer):
-
- """A WSGI server that does forking."""
-
- multiprocess = True
-
- def __init__(
- self,
- host,
- port,
- app,
- processes=40,
- handler=None,
- passthrough_errors=False,
- ssl_context=None,
- fd=None,
- ):
- if not can_fork:
- raise ValueError("Your platform does not support forking.")
- BaseWSGIServer.__init__(
- self, host, port, app, handler, passthrough_errors, ssl_context, fd
- )
- self.max_children = processes
-
-
-def make_server(
- host=None,
- port=None,
- app=None,
- threaded=False,
- processes=1,
- request_handler=None,
- passthrough_errors=False,
- ssl_context=None,
- fd=None,
-):
- """Create a new server instance that is either threaded, or forks
- or just processes one request after another.
- """
- if threaded and processes > 1:
- raise ValueError("cannot have a multithreaded and multi process server.")
- elif threaded:
- return ThreadedWSGIServer(
- host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
- )
- elif processes > 1:
- return ForkingWSGIServer(
- host,
- port,
- app,
- processes,
- request_handler,
- passthrough_errors,
- ssl_context,
- fd=fd,
- )
- else:
- return BaseWSGIServer(
- host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
- )
-
-
-def is_running_from_reloader():
- """Checks if the application is running from within the Werkzeug
- reloader subprocess.
-
- .. versionadded:: 0.10
- """
- return os.environ.get("WERKZEUG_RUN_MAIN") == "true"
-
-
-def run_simple(
- hostname,
- port,
- application,
- use_reloader=False,
- use_debugger=False,
- use_evalex=True,
- extra_files=None,
- reloader_interval=1,
- reloader_type="auto",
- threaded=False,
- processes=1,
- request_handler=None,
- static_files=None,
- passthrough_errors=False,
- ssl_context=None,
-):
- """Start a WSGI application. Optional features include a reloader,
- multithreading and fork support.
-
- This function has a command-line interface too::
-
- python -m werkzeug.serving --help
-
- .. versionadded:: 0.5
- `static_files` was added to simplify serving of static files as well
- as `passthrough_errors`.
-
- .. versionadded:: 0.6
- support for SSL was added.
-
- .. versionadded:: 0.8
- Added support for automatically loading a SSL context from certificate
- file and private key.
-
- .. versionadded:: 0.9
- Added command-line interface.
-
- .. versionadded:: 0.10
- Improved the reloader and added support for changing the backend
- through the `reloader_type` parameter. See :ref:`reloader`
- for more information.
-
- .. versionchanged:: 0.15
- Bind to a Unix socket by passing a path that starts with
- ``unix://`` as the ``hostname``.
-
- :param hostname: The host to bind to, for example ``'localhost'``.
- If the value is a path that starts with ``unix://`` it will bind
- to a Unix socket instead of a TCP socket..
- :param port: The port for the server. eg: ``8080``
- :param application: the WSGI application to execute
- :param use_reloader: should the server automatically restart the python
- process if modules were changed?
- :param use_debugger: should the werkzeug debugging system be used?
- :param use_evalex: should the exception evaluation feature be enabled?
- :param extra_files: a list of files the reloader should watch
- additionally to the modules. For example configuration
- files.
- :param reloader_interval: the interval for the reloader in seconds.
- :param reloader_type: the type of reloader to use. The default is
- auto detection. Valid values are ``'stat'`` and
- ``'watchdog'``. See :ref:`reloader` for more
- information.
- :param threaded: should the process handle each request in a separate
- thread?
- :param processes: if greater than 1 then handle each request in a new process
- up to this maximum number of concurrent processes.
- :param request_handler: optional parameter that can be used to replace
- the default one. You can use this to replace it
- with a different
- :class:`~BaseHTTPServer.BaseHTTPRequestHandler`
- subclass.
- :param static_files: a list or dict of paths for static files. This works
- exactly like :class:`SharedDataMiddleware`, it's actually
- just wrapping the application in that middleware before
- serving.
- :param passthrough_errors: set this to `True` to disable the error catching.
- This means that the server will die on errors but
- it can be useful to hook debuggers in (pdb etc.)
- :param ssl_context: an SSL context for the connection. Either an
- :class:`ssl.SSLContext`, a tuple in the form
- ``(cert_file, pkey_file)``, the string ``'adhoc'`` if
- the server should automatically create one, or ``None``
- to disable SSL (which is the default).
- """
- if not isinstance(port, int):
- raise TypeError("port must be an integer")
- if use_debugger:
- from .debug import DebuggedApplication
-
- application = DebuggedApplication(application, use_evalex)
- if static_files:
- from .middleware.shared_data import SharedDataMiddleware
-
- application = SharedDataMiddleware(application, static_files)
-
- def log_startup(sock):
- display_hostname = hostname if hostname not in ("", "*") else "localhost"
- quit_msg = "(Press CTRL+C to quit)"
- if sock.family == af_unix:
- _log("info", " * Running on %s %s", display_hostname, quit_msg)
- else:
- if ":" in display_hostname:
- display_hostname = "[%s]" % display_hostname
- port = sock.getsockname()[1]
- _log(
- "info",
- " * Running on %s://%s:%d/ %s",
- "http" if ssl_context is None else "https",
- display_hostname,
- port,
- quit_msg,
- )
-
- def inner():
- try:
- fd = int(os.environ["WERKZEUG_SERVER_FD"])
- except (LookupError, ValueError):
- fd = None
- srv = make_server(
- hostname,
- port,
- application,
- threaded,
- processes,
- request_handler,
- passthrough_errors,
- ssl_context,
- fd=fd,
- )
- if fd is None:
- log_startup(srv.socket)
- srv.serve_forever()
-
- if use_reloader:
- # If we're not running already in the subprocess that is the
- # reloader we want to open up a socket early to make sure the
- # port is actually available.
- if not is_running_from_reloader():
- if port == 0 and not can_open_by_fd:
- raise ValueError(
- "Cannot bind to a random port with enabled "
- "reloader if the Python interpreter does "
- "not support socket opening by fd."
- )
-
- # Create and destroy a socket so that any exceptions are
- # raised before we spawn a separate Python interpreter and
- # lose this ability.
- address_family = select_address_family(hostname, port)
- server_address = get_sockaddr(hostname, port, address_family)
- s = socket.socket(address_family, socket.SOCK_STREAM)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.bind(server_address)
- if hasattr(s, "set_inheritable"):
- s.set_inheritable(True)
-
- # If we can open the socket by file descriptor, then we can just
- # reuse this one and our socket will survive the restarts.
- if can_open_by_fd:
- os.environ["WERKZEUG_SERVER_FD"] = str(s.fileno())
- s.listen(LISTEN_QUEUE)
- log_startup(s)
- else:
- s.close()
- if address_family == af_unix:
- _log("info", "Unlinking %s" % server_address)
- os.unlink(server_address)
-
- # Do not use relative imports, otherwise "python -m werkzeug.serving"
- # breaks.
- from ._reloader import run_with_reloader
-
- run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
- else:
- inner()
-
-
-def run_with_reloader(*args, **kwargs):
- # People keep using undocumented APIs. Do not use this function
- # please, we do not guarantee that it continues working.
- from ._reloader import run_with_reloader
-
- return run_with_reloader(*args, **kwargs)
-
-
-def main():
- """A simple command-line interface for :py:func:`run_simple`."""
-
- # in contrast to argparse, this works at least under Python < 2.7
- import optparse
- from .utils import import_string
-
- parser = optparse.OptionParser(usage="Usage: %prog [options] app_module:app_object")
- parser.add_option(
- "-b",
- "--bind",
- dest="address",
- help="The hostname:port the app should listen on.",
- )
- parser.add_option(
- "-d",
- "--debug",
- dest="use_debugger",
- action="store_true",
- default=False,
- help="Use Werkzeug's debugger.",
- )
- parser.add_option(
- "-r",
- "--reload",
- dest="use_reloader",
- action="store_true",
- default=False,
- help="Reload Python process if modules change.",
- )
- options, args = parser.parse_args()
-
- hostname, port = None, None
- if options.address:
- address = options.address.split(":")
- hostname = address[0]
- if len(address) > 1:
- port = address[1]
-
- if len(args) != 1:
- sys.stdout.write("No application supplied, or too much. See --help\n")
- sys.exit(1)
- app = import_string(args[0])
-
- run_simple(
- hostname=(hostname or "127.0.0.1"),
- port=int(port or 5000),
- application=app,
- use_reloader=options.use_reloader,
- use_debugger=options.use_debugger,
- )
-
-
-if __name__ == "__main__":
- main()
diff --git a/python/werkzeug/test.py b/python/werkzeug/test.py
deleted file mode 100644
index 6148665..0000000
--- a/python/werkzeug/test.py
+++ /dev/null
@@ -1,1146 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.test
- ~~~~~~~~~~~~~
-
- This module implements a client to WSGI applications for testing.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import mimetypes
-import sys
-from io import BytesIO
-from itertools import chain
-from random import random
-from tempfile import TemporaryFile
-from time import time
-
-from ._compat import iteritems
-from ._compat import iterlists
-from ._compat import itervalues
-from ._compat import make_literal_wrapper
-from ._compat import reraise
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import to_bytes
-from ._compat import wsgi_encoding_dance
-from ._internal import _get_environ
-from .datastructures import CallbackDict
-from .datastructures import CombinedMultiDict
-from .datastructures import EnvironHeaders
-from .datastructures import FileMultiDict
-from .datastructures import FileStorage
-from .datastructures import Headers
-from .datastructures import MultiDict
-from .http import dump_cookie
-from .http import dump_options_header
-from .http import parse_options_header
-from .urls import iri_to_uri
-from .urls import url_encode
-from .urls import url_fix
-from .urls import url_parse
-from .urls import url_unparse
-from .urls import url_unquote
-from .utils import get_content_type
-from .wrappers import BaseRequest
-from .wsgi import ClosingIterator
-from .wsgi import get_current_url
-
-try:
- from urllib.request import Request as U2Request
-except ImportError:
- from urllib2 import Request as U2Request
-
-try:
- from http.cookiejar import CookieJar
-except ImportError:
- from cookielib import CookieJar
-
-
-def stream_encode_multipart(
- values, use_tempfile=True, threshold=1024 * 500, boundary=None, charset="utf-8"
-):
- """Encode a dict of values (either strings or file descriptors or
- :class:`FileStorage` objects.) into a multipart encoded string stored
- in a file descriptor.
- """
- if boundary is None:
- boundary = "---------------WerkzeugFormPart_%s%s" % (time(), random())
- _closure = [BytesIO(), 0, False]
-
- if use_tempfile:
-
- def write_binary(string):
- stream, total_length, on_disk = _closure
- if on_disk:
- stream.write(string)
- else:
- length = len(string)
- if length + _closure[1] <= threshold:
- stream.write(string)
- else:
- new_stream = TemporaryFile("wb+")
- new_stream.write(stream.getvalue())
- new_stream.write(string)
- _closure[0] = new_stream
- _closure[2] = True
- _closure[1] = total_length + length
-
- else:
- write_binary = _closure[0].write
-
- def write(string):
- write_binary(string.encode(charset))
-
- if not isinstance(values, MultiDict):
- values = MultiDict(values)
-
- for key, values in iterlists(values):
- for value in values:
- write('--%s\r\nContent-Disposition: form-data; name="%s"' % (boundary, key))
- reader = getattr(value, "read", None)
- if reader is not None:
- filename = getattr(value, "filename", getattr(value, "name", None))
- content_type = getattr(value, "content_type", None)
- if content_type is None:
- content_type = (
- filename
- and mimetypes.guess_type(filename)[0]
- or "application/octet-stream"
- )
- if filename is not None:
- write('; filename="%s"\r\n' % filename)
- else:
- write("\r\n")
- write("Content-Type: %s\r\n\r\n" % content_type)
- while 1:
- chunk = reader(16384)
- if not chunk:
- break
- write_binary(chunk)
- else:
- if not isinstance(value, string_types):
- value = str(value)
-
- value = to_bytes(value, charset)
- write("\r\n\r\n")
- write_binary(value)
- write("\r\n")
- write("--%s--\r\n" % boundary)
-
- length = int(_closure[0].tell())
- _closure[0].seek(0)
- return _closure[0], length, boundary
-
-
-def encode_multipart(values, boundary=None, charset="utf-8"):
- """Like `stream_encode_multipart` but returns a tuple in the form
- (``boundary``, ``data``) where data is a bytestring.
- """
- stream, length, boundary = stream_encode_multipart(
- values, use_tempfile=False, boundary=boundary, charset=charset
- )
- return boundary, stream.read()
-
-
-def File(fd, filename=None, mimetype=None):
- """Backwards compat.
-
- .. deprecated:: 0.5
- """
- from warnings import warn
-
- warn(
- "'werkzeug.test.File' is deprecated as of version 0.5 and will"
- " be removed in version 1.0. Use 'EnvironBuilder' or"
- " 'FileStorage' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return FileStorage(fd, filename=filename, content_type=mimetype)
-
-
-class _TestCookieHeaders(object):
-
- """A headers adapter for cookielib
- """
-
- def __init__(self, headers):
- self.headers = headers
-
- def getheaders(self, name):
- headers = []
- name = name.lower()
- for k, v in self.headers:
- if k.lower() == name:
- headers.append(v)
- return headers
-
- def get_all(self, name, default=None):
- rv = []
- for k, v in self.headers:
- if k.lower() == name.lower():
- rv.append(v)
- return rv or default or []
-
-
-class _TestCookieResponse(object):
-
- """Something that looks like a httplib.HTTPResponse, but is actually just an
- adapter for our test responses to make them available for cookielib.
- """
-
- def __init__(self, headers):
- self.headers = _TestCookieHeaders(headers)
-
- def info(self):
- return self.headers
-
-
-class _TestCookieJar(CookieJar):
-
- """A cookielib.CookieJar modified to inject and read cookie headers from
- and to wsgi environments, and wsgi application responses.
- """
-
- def inject_wsgi(self, environ):
- """Inject the cookies as client headers into the server's wsgi
- environment.
- """
- cvals = ["%s=%s" % (c.name, c.value) for c in self]
-
- if cvals:
- environ["HTTP_COOKIE"] = "; ".join(cvals)
- else:
- environ.pop("HTTP_COOKIE", None)
-
- def extract_wsgi(self, environ, headers):
- """Extract the server's set-cookie headers as cookies into the
- cookie jar.
- """
- self.extract_cookies(
- _TestCookieResponse(headers), U2Request(get_current_url(environ))
- )
-
-
-def _iter_data(data):
- """Iterates over a `dict` or :class:`MultiDict` yielding all keys and
- values.
- This is used to iterate over the data passed to the
- :class:`EnvironBuilder`.
- """
- if isinstance(data, MultiDict):
- for key, values in iterlists(data):
- for value in values:
- yield key, value
- else:
- for key, values in iteritems(data):
- if isinstance(values, list):
- for value in values:
- yield key, value
- else:
- yield key, values
-
-
-class EnvironBuilder(object):
- """This class can be used to conveniently create a WSGI environment
- for testing purposes. It can be used to quickly create WSGI environments
- or request objects from arbitrary data.
-
- The signature of this class is also used in some other places as of
- Werkzeug 0.5 (:func:`create_environ`, :meth:`BaseResponse.from_values`,
- :meth:`Client.open`). Because of this most of the functionality is
- available through the constructor alone.
-
- Files and regular form data can be manipulated independently of each
- other with the :attr:`form` and :attr:`files` attributes, but are
- passed with the same argument to the constructor: `data`.
-
- `data` can be any of these values:
-
- - a `str` or `bytes` object: The object is converted into an
- :attr:`input_stream`, the :attr:`content_length` is set and you have to
- provide a :attr:`content_type`.
- - a `dict` or :class:`MultiDict`: The keys have to be strings. The values
- have to be either any of the following objects, or a list of any of the
- following objects:
-
- - a :class:`file`-like object: These are converted into
- :class:`FileStorage` objects automatically.
- - a `tuple`: The :meth:`~FileMultiDict.add_file` method is called
- with the key and the unpacked `tuple` items as positional
- arguments.
- - a `str`: The string is set as form data for the associated key.
- - a file-like object: The object content is loaded in memory and then
- handled like a regular `str` or a `bytes`.
-
- :param path: the path of the request. In the WSGI environment this will
- end up as `PATH_INFO`. If the `query_string` is not defined
- and there is a question mark in the `path` everything after
- it is used as query string.
- :param base_url: the base URL is a URL that is used to extract the WSGI
- URL scheme, host (server name + server port) and the
- script root (`SCRIPT_NAME`).
- :param query_string: an optional string or dict with URL parameters.
- :param method: the HTTP method to use, defaults to `GET`.
- :param input_stream: an optional input stream. Do not specify this and
- `data`. As soon as an input stream is set you can't
- modify :attr:`args` and :attr:`files` unless you
- set the :attr:`input_stream` to `None` again.
- :param content_type: The content type for the request. As of 0.5 you
- don't have to provide this when specifying files
- and form data via `data`.
- :param content_length: The content length for the request. You don't
- have to specify this when providing data via
- `data`.
- :param errors_stream: an optional error stream that is used for
- `wsgi.errors`. Defaults to :data:`stderr`.
- :param multithread: controls `wsgi.multithread`. Defaults to `False`.
- :param multiprocess: controls `wsgi.multiprocess`. Defaults to `False`.
- :param run_once: controls `wsgi.run_once`. Defaults to `False`.
- :param headers: an optional list or :class:`Headers` object of headers.
- :param data: a string or dict of form data or a file-object.
- See explanation above.
- :param json: An object to be serialized and assigned to ``data``.
- Defaults the content type to ``"application/json"``.
- Serialized with the function assigned to :attr:`json_dumps`.
- :param environ_base: an optional dict of environment defaults.
- :param environ_overrides: an optional dict of environment overrides.
- :param charset: the charset used to encode unicode data.
-
- .. versionadded:: 0.15
- The ``json`` param and :meth:`json_dumps` method.
-
- .. versionadded:: 0.15
- The environ has keys ``REQUEST_URI`` and ``RAW_URI`` containing
- the path before perecent-decoding. This is not part of the WSGI
- PEP, but many WSGI servers include it.
-
- .. versionchanged:: 0.6
- ``path`` and ``base_url`` can now be unicode strings that are
- encoded with :func:`iri_to_uri`.
- """
-
- #: the server protocol to use. defaults to HTTP/1.1
- server_protocol = "HTTP/1.1"
-
- #: the wsgi version to use. defaults to (1, 0)
- wsgi_version = (1, 0)
-
- #: the default request class for :meth:`get_request`
- request_class = BaseRequest
-
- import json
-
- #: The serialization function used when ``json`` is passed.
- json_dumps = staticmethod(json.dumps)
- del json
-
- def __init__(
- self,
- path="/",
- base_url=None,
- query_string=None,
- method="GET",
- input_stream=None,
- content_type=None,
- content_length=None,
- errors_stream=None,
- multithread=False,
- multiprocess=False,
- run_once=False,
- headers=None,
- data=None,
- environ_base=None,
- environ_overrides=None,
- charset="utf-8",
- mimetype=None,
- json=None,
- ):
- path_s = make_literal_wrapper(path)
- if query_string is not None and path_s("?") in path:
- raise ValueError("Query string is defined in the path and as an argument")
- if query_string is None and path_s("?") in path:
- path, query_string = path.split(path_s("?"), 1)
- self.charset = charset
- self.path = iri_to_uri(path)
- if base_url is not None:
- base_url = url_fix(iri_to_uri(base_url, charset), charset)
- self.base_url = base_url
- if isinstance(query_string, (bytes, text_type)):
- self.query_string = query_string
- else:
- if query_string is None:
- query_string = MultiDict()
- elif not isinstance(query_string, MultiDict):
- query_string = MultiDict(query_string)
- self.args = query_string
- self.method = method
- if headers is None:
- headers = Headers()
- elif not isinstance(headers, Headers):
- headers = Headers(headers)
- self.headers = headers
- if content_type is not None:
- self.content_type = content_type
- if errors_stream is None:
- errors_stream = sys.stderr
- self.errors_stream = errors_stream
- self.multithread = multithread
- self.multiprocess = multiprocess
- self.run_once = run_once
- self.environ_base = environ_base
- self.environ_overrides = environ_overrides
- self.input_stream = input_stream
- self.content_length = content_length
- self.closed = False
-
- if json is not None:
- if data is not None:
- raise TypeError("can't provide both json and data")
-
- data = self.json_dumps(json)
-
- if self.content_type is None:
- self.content_type = "application/json"
-
- if data:
- if input_stream is not None:
- raise TypeError("can't provide input stream and data")
- if hasattr(data, "read"):
- data = data.read()
- if isinstance(data, text_type):
- data = data.encode(self.charset)
- if isinstance(data, bytes):
- self.input_stream = BytesIO(data)
- if self.content_length is None:
- self.content_length = len(data)
- else:
- for key, value in _iter_data(data):
- if isinstance(value, (tuple, dict)) or hasattr(value, "read"):
- self._add_file_from_data(key, value)
- else:
- self.form.setlistdefault(key).append(value)
-
- if mimetype is not None:
- self.mimetype = mimetype
-
- @classmethod
- def from_environ(cls, environ, **kwargs):
- """Turn an environ dict back into a builder. Any extra kwargs
- override the args extracted from the environ.
-
- .. versionadded:: 0.15
- """
- headers = Headers(EnvironHeaders(environ))
- out = {
- "path": environ["PATH_INFO"],
- "base_url": cls._make_base_url(
- environ["wsgi.url_scheme"], headers.pop("Host"), environ["SCRIPT_NAME"]
- ),
- "query_string": environ["QUERY_STRING"],
- "method": environ["REQUEST_METHOD"],
- "input_stream": environ["wsgi.input"],
- "content_type": headers.pop("Content-Type", None),
- "content_length": headers.pop("Content-Length", None),
- "errors_stream": environ["wsgi.errors"],
- "multithread": environ["wsgi.multithread"],
- "multiprocess": environ["wsgi.multiprocess"],
- "run_once": environ["wsgi.run_once"],
- "headers": headers,
- }
- out.update(kwargs)
- return cls(**out)
-
- def _add_file_from_data(self, key, value):
- """Called in the EnvironBuilder to add files from the data dict."""
- if isinstance(value, tuple):
- self.files.add_file(key, *value)
- elif isinstance(value, dict):
- from warnings import warn
-
- warn(
- "Passing a dict as file data is deprecated as of"
- " version 0.5 and will be removed in version 1.0. Use"
- " a tuple or 'FileStorage' object instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- value = dict(value)
- mimetype = value.pop("mimetype", None)
- if mimetype is not None:
- value["content_type"] = mimetype
- self.files.add_file(key, **value)
- else:
- self.files.add_file(key, value)
-
- @staticmethod
- def _make_base_url(scheme, host, script_root):
- return url_unparse((scheme, host, script_root, "", "")).rstrip("/") + "/"
-
- @property
- def base_url(self):
- """The base URL is used to extract the URL scheme, host name,
- port, and root path.
- """
- return self._make_base_url(self.url_scheme, self.host, self.script_root)
-
- @base_url.setter
- def base_url(self, value):
- if value is None:
- scheme = "http"
- netloc = "localhost"
- script_root = ""
- else:
- scheme, netloc, script_root, qs, anchor = url_parse(value)
- if qs or anchor:
- raise ValueError("base url must not contain a query string or fragment")
- self.script_root = script_root.rstrip("/")
- self.host = netloc
- self.url_scheme = scheme
-
- def _get_content_type(self):
- ct = self.headers.get("Content-Type")
- if ct is None and not self._input_stream:
- if self._files:
- return "multipart/form-data"
- elif self._form:
- return "application/x-www-form-urlencoded"
- return None
- return ct
-
- def _set_content_type(self, value):
- if value is None:
- self.headers.pop("Content-Type", None)
- else:
- self.headers["Content-Type"] = value
-
- content_type = property(
- _get_content_type,
- _set_content_type,
- doc="""The content type for the request. Reflected from and to
- the :attr:`headers`. Do not set if you set :attr:`files` or
- :attr:`form` for auto detection.""",
- )
- del _get_content_type, _set_content_type
-
- def _get_content_length(self):
- return self.headers.get("Content-Length", type=int)
-
- def _get_mimetype(self):
- ct = self.content_type
- if ct:
- return ct.split(";")[0].strip()
-
- def _set_mimetype(self, value):
- self.content_type = get_content_type(value, self.charset)
-
- def _get_mimetype_params(self):
- def on_update(d):
- self.headers["Content-Type"] = dump_options_header(self.mimetype, d)
-
- d = parse_options_header(self.headers.get("content-type", ""))[1]
- return CallbackDict(d, on_update)
-
- mimetype = property(
- _get_mimetype,
- _set_mimetype,
- doc="""The mimetype (content type without charset etc.)
-
- .. versionadded:: 0.14
- """,
- )
- mimetype_params = property(
- _get_mimetype_params,
- doc=""" The mimetype parameters as dict. For example if the
- content type is ``text/html; charset=utf-8`` the params would be
- ``{'charset': 'utf-8'}``.
-
- .. versionadded:: 0.14
- """,
- )
- del _get_mimetype, _set_mimetype, _get_mimetype_params
-
- def _set_content_length(self, value):
- if value is None:
- self.headers.pop("Content-Length", None)
- else:
- self.headers["Content-Length"] = str(value)
-
- content_length = property(
- _get_content_length,
- _set_content_length,
- doc="""The content length as integer. Reflected from and to the
- :attr:`headers`. Do not set if you set :attr:`files` or
- :attr:`form` for auto detection.""",
- )
- del _get_content_length, _set_content_length
-
- def form_property(name, storage, doc): # noqa: B902
- key = "_" + name
-
- def getter(self):
- if self._input_stream is not None:
- raise AttributeError("an input stream is defined")
- rv = getattr(self, key)
- if rv is None:
- rv = storage()
- setattr(self, key, rv)
-
- return rv
-
- def setter(self, value):
- self._input_stream = None
- setattr(self, key, value)
-
- return property(getter, setter, doc=doc)
-
- form = form_property("form", MultiDict, doc="A :class:`MultiDict` of form values.")
- files = form_property(
- "files",
- FileMultiDict,
- doc="""A :class:`FileMultiDict` of uploaded files. You can use
- the :meth:`~FileMultiDict.add_file` method to add new files to
- the dict.""",
- )
- del form_property
-
- def _get_input_stream(self):
- return self._input_stream
-
- def _set_input_stream(self, value):
- self._input_stream = value
- self._form = self._files = None
-
- input_stream = property(
- _get_input_stream,
- _set_input_stream,
- doc="""An optional input stream. If you set this it will clear
- :attr:`form` and :attr:`files`.""",
- )
- del _get_input_stream, _set_input_stream
-
- def _get_query_string(self):
- if self._query_string is None:
- if self._args is not None:
- return url_encode(self._args, charset=self.charset)
- return ""
- return self._query_string
-
- def _set_query_string(self, value):
- self._query_string = value
- self._args = None
-
- query_string = property(
- _get_query_string,
- _set_query_string,
- doc="""The query string. If you set this to a string
- :attr:`args` will no longer be available.""",
- )
- del _get_query_string, _set_query_string
-
- def _get_args(self):
- if self._query_string is not None:
- raise AttributeError("a query string is defined")
- if self._args is None:
- self._args = MultiDict()
- return self._args
-
- def _set_args(self, value):
- self._query_string = None
- self._args = value
-
- args = property(
- _get_args, _set_args, doc="The URL arguments as :class:`MultiDict`."
- )
- del _get_args, _set_args
-
- @property
- def server_name(self):
- """The server name (read-only, use :attr:`host` to set)"""
- return self.host.split(":", 1)[0]
-
- @property
- def server_port(self):
- """The server port as integer (read-only, use :attr:`host` to set)"""
- pieces = self.host.split(":", 1)
- if len(pieces) == 2 and pieces[1].isdigit():
- return int(pieces[1])
- elif self.url_scheme == "https":
- return 443
- return 80
-
- def __del__(self):
- try:
- self.close()
- except Exception:
- pass
-
- def close(self):
- """Closes all files. If you put real :class:`file` objects into the
- :attr:`files` dict you can call this method to automatically close
- them all in one go.
- """
- if self.closed:
- return
- try:
- files = itervalues(self.files)
- except AttributeError:
- files = ()
- for f in files:
- try:
- f.close()
- except Exception:
- pass
- self.closed = True
-
- def get_environ(self):
- """Return the built environ.
-
- .. versionchanged:: 0.15
- The content type and length headers are set based on
- input stream detection. Previously this only set the WSGI
- keys.
- """
- input_stream = self.input_stream
- content_length = self.content_length
-
- mimetype = self.mimetype
- content_type = self.content_type
-
- if input_stream is not None:
- start_pos = input_stream.tell()
- input_stream.seek(0, 2)
- end_pos = input_stream.tell()
- input_stream.seek(start_pos)
- content_length = end_pos - start_pos
- elif mimetype == "multipart/form-data":
- values = CombinedMultiDict([self.form, self.files])
- input_stream, content_length, boundary = stream_encode_multipart(
- values, charset=self.charset
- )
- content_type = mimetype + '; boundary="%s"' % boundary
- elif mimetype == "application/x-www-form-urlencoded":
- # XXX: py2v3 review
- values = url_encode(self.form, charset=self.charset)
- values = values.encode("ascii")
- content_length = len(values)
- input_stream = BytesIO(values)
- else:
- input_stream = BytesIO()
-
- result = {}
- if self.environ_base:
- result.update(self.environ_base)
-
- def _path_encode(x):
- return wsgi_encoding_dance(url_unquote(x, self.charset), self.charset)
-
- qs = wsgi_encoding_dance(self.query_string)
-
- result.update(
- {
- "REQUEST_METHOD": self.method,
- "SCRIPT_NAME": _path_encode(self.script_root),
- "PATH_INFO": _path_encode(self.path),
- "QUERY_STRING": qs,
- # Non-standard, added by mod_wsgi, uWSGI
- "REQUEST_URI": wsgi_encoding_dance(self.path),
- # Non-standard, added by gunicorn
- "RAW_URI": wsgi_encoding_dance(self.path),
- "SERVER_NAME": self.server_name,
- "SERVER_PORT": str(self.server_port),
- "HTTP_HOST": self.host,
- "SERVER_PROTOCOL": self.server_protocol,
- "wsgi.version": self.wsgi_version,
- "wsgi.url_scheme": self.url_scheme,
- "wsgi.input": input_stream,
- "wsgi.errors": self.errors_stream,
- "wsgi.multithread": self.multithread,
- "wsgi.multiprocess": self.multiprocess,
- "wsgi.run_once": self.run_once,
- }
- )
-
- headers = self.headers.copy()
-
- if content_type is not None:
- result["CONTENT_TYPE"] = content_type
- headers.set("Content-Type", content_type)
-
- if content_length is not None:
- result["CONTENT_LENGTH"] = str(content_length)
- headers.set("Content-Length", content_length)
-
- for key, value in headers.to_wsgi_list():
- result["HTTP_%s" % key.upper().replace("-", "_")] = value
-
- if self.environ_overrides:
- result.update(self.environ_overrides)
-
- return result
-
- def get_request(self, cls=None):
- """Returns a request with the data. If the request class is not
- specified :attr:`request_class` is used.
-
- :param cls: The request wrapper to use.
- """
- if cls is None:
- cls = self.request_class
- return cls(self.get_environ())
-
-
-class ClientRedirectError(Exception):
- """If a redirect loop is detected when using follow_redirects=True with
- the :cls:`Client`, then this exception is raised.
- """
-
-
-class Client(object):
- """This class allows you to send requests to a wrapped application.
-
- The response wrapper can be a class or factory function that takes
- three arguments: app_iter, status and headers. The default response
- wrapper just returns a tuple.
-
- Example::
-
- class ClientResponse(BaseResponse):
- ...
-
- client = Client(MyApplication(), response_wrapper=ClientResponse)
-
- The use_cookies parameter indicates whether cookies should be stored and
- sent for subsequent requests. This is True by default, but passing False
- will disable this behaviour.
-
- If you want to request some subdomain of your application you may set
- `allow_subdomain_redirects` to `True` as if not no external redirects
- are allowed.
-
- .. versionadded:: 0.5
- `use_cookies` is new in this version. Older versions did not provide
- builtin cookie support.
-
- .. versionadded:: 0.14
- The `mimetype` parameter was added.
-
- .. versionadded:: 0.15
- The ``json`` parameter.
- """
-
- def __init__(
- self,
- application,
- response_wrapper=None,
- use_cookies=True,
- allow_subdomain_redirects=False,
- ):
- self.application = application
- self.response_wrapper = response_wrapper
- if use_cookies:
- self.cookie_jar = _TestCookieJar()
- else:
- self.cookie_jar = None
- self.allow_subdomain_redirects = allow_subdomain_redirects
-
- def set_cookie(
- self,
- server_name,
- key,
- value="",
- max_age=None,
- expires=None,
- path="/",
- domain=None,
- secure=None,
- httponly=False,
- charset="utf-8",
- ):
- """Sets a cookie in the client's cookie jar. The server name
- is required and has to match the one that is also passed to
- the open call.
- """
- assert self.cookie_jar is not None, "cookies disabled"
- header = dump_cookie(
- key, value, max_age, expires, path, domain, secure, httponly, charset
- )
- environ = create_environ(path, base_url="http://" + server_name)
- headers = [("Set-Cookie", header)]
- self.cookie_jar.extract_wsgi(environ, headers)
-
- def delete_cookie(self, server_name, key, path="/", domain=None):
- """Deletes a cookie in the test client."""
- self.set_cookie(
- server_name, key, expires=0, max_age=0, path=path, domain=domain
- )
-
- def run_wsgi_app(self, environ, buffered=False):
- """Runs the wrapped WSGI app with the given environment."""
- if self.cookie_jar is not None:
- self.cookie_jar.inject_wsgi(environ)
- rv = run_wsgi_app(self.application, environ, buffered=buffered)
- if self.cookie_jar is not None:
- self.cookie_jar.extract_wsgi(environ, rv[2])
- return rv
-
- def resolve_redirect(self, response, new_location, environ, buffered=False):
- """Perform a new request to the location given by the redirect
- response to the previous request.
- """
- scheme, netloc, path, qs, anchor = url_parse(new_location)
- builder = EnvironBuilder.from_environ(environ, query_string=qs)
-
- to_name_parts = netloc.split(":", 1)[0].split(".")
- from_name_parts = builder.server_name.split(".")
-
- if to_name_parts != [""]:
- # The new location has a host, use it for the base URL.
- builder.url_scheme = scheme
- builder.host = netloc
- else:
- # A local redirect with autocorrect_location_header=False
- # doesn't have a host, so use the request's host.
- to_name_parts = from_name_parts
-
- # Explain why a redirect to a different server name won't be followed.
- if to_name_parts != from_name_parts:
- if to_name_parts[-len(from_name_parts) :] == from_name_parts:
- if not self.allow_subdomain_redirects:
- raise RuntimeError("Following subdomain redirects is not enabled.")
- else:
- raise RuntimeError("Following external redirects is not supported.")
-
- path_parts = path.split("/")
- root_parts = builder.script_root.split("/")
-
- if path_parts[: len(root_parts)] == root_parts:
- # Strip the script root from the path.
- builder.path = path[len(builder.script_root) :]
- else:
- # The new location is not under the script root, so use the
- # whole path and clear the previous root.
- builder.path = path
- builder.script_root = ""
-
- status_code = int(response[1].split(None, 1)[0])
-
- # Only 307 and 308 preserve all of the original request.
- if status_code not in {307, 308}:
- # HEAD is preserved, everything else becomes GET.
- if builder.method != "HEAD":
- builder.method = "GET"
-
- # Clear the body and the headers that describe it.
- builder.input_stream = None
- builder.content_type = None
- builder.content_length = None
- builder.headers.pop("Transfer-Encoding", None)
-
- # Disable the response wrapper while handling redirects. Not
- # thread safe, but the client should not be shared anyway.
- old_response_wrapper = self.response_wrapper
- self.response_wrapper = None
-
- try:
- return self.open(builder, as_tuple=True, buffered=buffered)
- finally:
- self.response_wrapper = old_response_wrapper
-
- def open(self, *args, **kwargs):
- """Takes the same arguments as the :class:`EnvironBuilder` class with
- some additions: You can provide a :class:`EnvironBuilder` or a WSGI
- environment as only argument instead of the :class:`EnvironBuilder`
- arguments and two optional keyword arguments (`as_tuple`, `buffered`)
- that change the type of the return value or the way the application is
- executed.
-
- .. versionchanged:: 0.5
- If a dict is provided as file in the dict for the `data` parameter
- the content type has to be called `content_type` now instead of
- `mimetype`. This change was made for consistency with
- :class:`werkzeug.FileWrapper`.
-
- The `follow_redirects` parameter was added to :func:`open`.
-
- Additional parameters:
-
- :param as_tuple: Returns a tuple in the form ``(environ, result)``
- :param buffered: Set this to True to buffer the application run.
- This will automatically close the application for
- you as well.
- :param follow_redirects: Set this to True if the `Client` should
- follow HTTP redirects.
- """
- as_tuple = kwargs.pop("as_tuple", False)
- buffered = kwargs.pop("buffered", False)
- follow_redirects = kwargs.pop("follow_redirects", False)
- environ = None
- if not kwargs and len(args) == 1:
- if isinstance(args[0], EnvironBuilder):
- environ = args[0].get_environ()
- elif isinstance(args[0], dict):
- environ = args[0]
- if environ is None:
- builder = EnvironBuilder(*args, **kwargs)
- try:
- environ = builder.get_environ()
- finally:
- builder.close()
-
- response = self.run_wsgi_app(environ.copy(), buffered=buffered)
-
- # handle redirects
- redirect_chain = []
- while 1:
- status_code = int(response[1].split(None, 1)[0])
- if (
- status_code not in {301, 302, 303, 305, 307, 308}
- or not follow_redirects
- ):
- break
-
- # Exhaust intermediate response bodies to ensure middleware
- # that returns an iterator runs any cleanup code.
- if not buffered:
- for _ in response[0]:
- pass
-
- new_location = response[2]["location"]
- new_redirect_entry = (new_location, status_code)
- if new_redirect_entry in redirect_chain:
- raise ClientRedirectError("loop detected")
- redirect_chain.append(new_redirect_entry)
- environ, response = self.resolve_redirect(
- response, new_location, environ, buffered=buffered
- )
-
- if self.response_wrapper is not None:
- response = self.response_wrapper(*response)
- if as_tuple:
- return environ, response
- return response
-
- def get(self, *args, **kw):
- """Like open but method is enforced to GET."""
- kw["method"] = "GET"
- return self.open(*args, **kw)
-
- def patch(self, *args, **kw):
- """Like open but method is enforced to PATCH."""
- kw["method"] = "PATCH"
- return self.open(*args, **kw)
-
- def post(self, *args, **kw):
- """Like open but method is enforced to POST."""
- kw["method"] = "POST"
- return self.open(*args, **kw)
-
- def head(self, *args, **kw):
- """Like open but method is enforced to HEAD."""
- kw["method"] = "HEAD"
- return self.open(*args, **kw)
-
- def put(self, *args, **kw):
- """Like open but method is enforced to PUT."""
- kw["method"] = "PUT"
- return self.open(*args, **kw)
-
- def delete(self, *args, **kw):
- """Like open but method is enforced to DELETE."""
- kw["method"] = "DELETE"
- return self.open(*args, **kw)
-
- def options(self, *args, **kw):
- """Like open but method is enforced to OPTIONS."""
- kw["method"] = "OPTIONS"
- return self.open(*args, **kw)
-
- def trace(self, *args, **kw):
- """Like open but method is enforced to TRACE."""
- kw["method"] = "TRACE"
- return self.open(*args, **kw)
-
- def __repr__(self):
- return "<%s %r>" % (self.__class__.__name__, self.application)
-
-
-def create_environ(*args, **kwargs):
- """Create a new WSGI environ dict based on the values passed. The first
- parameter should be the path of the request which defaults to '/'. The
- second one can either be an absolute path (in that case the host is
- localhost:80) or a full path to the request with scheme, netloc port and
- the path to the script.
-
- This accepts the same arguments as the :class:`EnvironBuilder`
- constructor.
-
- .. versionchanged:: 0.5
- This function is now a thin wrapper over :class:`EnvironBuilder` which
- was added in 0.5. The `headers`, `environ_base`, `environ_overrides`
- and `charset` parameters were added.
- """
- builder = EnvironBuilder(*args, **kwargs)
- try:
- return builder.get_environ()
- finally:
- builder.close()
-
-
-def run_wsgi_app(app, environ, buffered=False):
- """Return a tuple in the form (app_iter, status, headers) of the
- application output. This works best if you pass it an application that
- returns an iterator all the time.
-
- Sometimes applications may use the `write()` callable returned
- by the `start_response` function. This tries to resolve such edge
- cases automatically. But if you don't get the expected output you
- should set `buffered` to `True` which enforces buffering.
-
- If passed an invalid WSGI application the behavior of this function is
- undefined. Never pass non-conforming WSGI applications to this function.
-
- :param app: the application to execute.
- :param buffered: set to `True` to enforce buffering.
- :return: tuple in the form ``(app_iter, status, headers)``
- """
- environ = _get_environ(environ)
- response = []
- buffer = []
-
- def start_response(status, headers, exc_info=None):
- if exc_info is not None:
- reraise(*exc_info)
- response[:] = [status, headers]
- return buffer.append
-
- app_rv = app(environ, start_response)
- close_func = getattr(app_rv, "close", None)
- app_iter = iter(app_rv)
-
- # when buffering we emit the close call early and convert the
- # application iterator into a regular list
- if buffered:
- try:
- app_iter = list(app_iter)
- finally:
- if close_func is not None:
- close_func()
-
- # otherwise we iterate the application iter until we have a response, chain
- # the already received data with the already collected data and wrap it in
- # a new `ClosingIterator` if we need to restore a `close` callable from the
- # original return value.
- else:
- for item in app_iter:
- buffer.append(item)
- if response:
- break
- if buffer:
- app_iter = chain(buffer, app_iter)
- if close_func is not None and app_iter is not app_rv:
- app_iter = ClosingIterator(app_iter, close_func)
-
- return app_iter, response[0], Headers(response[1])
diff --git a/python/werkzeug/testapp.py b/python/werkzeug/testapp.py
deleted file mode 100644
index 8ea23be..0000000
--- a/python/werkzeug/testapp.py
+++ /dev/null
@@ -1,241 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.testapp
- ~~~~~~~~~~~~~~~~
-
- Provide a small test application that can be used to test a WSGI server
- and check it for WSGI compliance.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import base64
-import os
-import sys
-from textwrap import wrap
-
-import werkzeug
-from .utils import escape
-from .wrappers import BaseRequest as Request
-from .wrappers import BaseResponse as Response
-
-logo = Response(
- base64.b64decode(
- """
-R0lGODlhoACgAOMIAAEDACwpAEpCAGdgAJaKAM28AOnVAP3rAP/////////
-//////////////////////yH5BAEKAAgALAAAAACgAKAAAAT+EMlJq704680R+F0ojmRpnuj0rWnrv
-nB8rbRs33gu0bzu/0AObxgsGn3D5HHJbCUFyqZ0ukkSDlAidctNFg7gbI9LZlrBaHGtzAae0eloe25
-7w9EDOX2fst/xenyCIn5/gFqDiVVDV4aGeYiKkhSFjnCQY5OTlZaXgZp8nJ2ekaB0SQOjqphrpnOiq
-ncEn65UsLGytLVmQ6m4sQazpbtLqL/HwpnER8bHyLrLOc3Oz8PRONPU1crXN9na263dMt/g4SzjMeX
-m5yDpLqgG7OzJ4u8lT/P69ej3JPn69kHzN2OIAHkB9RUYSFCFQYQJFTIkCDBiwoXWGnowaLEjRm7+G
-p9A7Hhx4rUkAUaSLJlxHMqVMD/aSycSZkyTplCqtGnRAM5NQ1Ly5OmzZc6gO4d6DGAUKA+hSocWYAo
-SlM6oUWX2O/o0KdaVU5vuSQLAa0ADwQgMEMB2AIECZhVSnTno6spgbtXmHcBUrQACcc2FrTrWS8wAf
-78cMFBgwIBgbN+qvTt3ayikRBk7BoyGAGABAdYyfdzRQGV3l4coxrqQ84GpUBmrdR3xNIDUPAKDBSA
-ADIGDhhqTZIWaDcrVX8EsbNzbkvCOxG8bN5w8ly9H8jyTJHC6DFndQydbguh2e/ctZJFXRxMAqqPVA
-tQH5E64SPr1f0zz7sQYjAHg0In+JQ11+N2B0XXBeeYZgBZFx4tqBToiTCPv0YBgQv8JqA6BEf6RhXx
-w1ENhRBnWV8ctEX4Ul2zc3aVGcQNC2KElyTDYyYUWvShdjDyMOGMuFjqnII45aogPhz/CodUHFwaDx
-lTgsaOjNyhGWJQd+lFoAGk8ObghI0kawg+EV5blH3dr+digkYuAGSaQZFHFz2P/cTaLmhF52QeSb45
-Jwxd+uSVGHlqOZpOeJpCFZ5J+rkAkFjQ0N1tah7JJSZUFNsrkeJUJMIBi8jyaEKIhKPomnC91Uo+NB
-yyaJ5umnnpInIFh4t6ZSpGaAVmizqjpByDegYl8tPE0phCYrhcMWSv+uAqHfgH88ak5UXZmlKLVJhd
-dj78s1Fxnzo6yUCrV6rrDOkluG+QzCAUTbCwf9SrmMLzK6p+OPHx7DF+bsfMRq7Ec61Av9i6GLw23r
-idnZ+/OO0a99pbIrJkproCQMA17OPG6suq3cca5ruDfXCCDoS7BEdvmJn5otdqscn+uogRHHXs8cbh
-EIfYaDY1AkrC0cqwcZpnM6ludx72x0p7Fo/hZAcpJDjax0UdHavMKAbiKltMWCF3xxh9k25N/Viud8
-ba78iCvUkt+V6BpwMlErmcgc502x+u1nSxJSJP9Mi52awD1V4yB/QHONsnU3L+A/zR4VL/indx/y64
-gqcj+qgTeweM86f0Qy1QVbvmWH1D9h+alqg254QD8HJXHvjQaGOqEqC22M54PcftZVKVSQG9jhkv7C
-JyTyDoAJfPdu8v7DRZAxsP/ky9MJ3OL36DJfCFPASC3/aXlfLOOON9vGZZHydGf8LnxYJuuVIbl83y
-Az5n/RPz07E+9+zw2A2ahz4HxHo9Kt79HTMx1Q7ma7zAzHgHqYH0SoZWyTuOLMiHwSfZDAQTn0ajk9
-YQqodnUYjByQZhZak9Wu4gYQsMyEpIOAOQKze8CmEF45KuAHTvIDOfHJNipwoHMuGHBnJElUoDmAyX
-c2Qm/R8Ah/iILCCJOEokGowdhDYc/yoL+vpRGwyVSCWFYZNljkhEirGXsalWcAgOdeAdoXcktF2udb
-qbUhjWyMQxYO01o6KYKOr6iK3fE4MaS+DsvBsGOBaMb0Y6IxADaJhFICaOLmiWTlDAnY1KzDG4ambL
-cWBA8mUzjJsN2KjSaSXGqMCVXYpYkj33mcIApyhQf6YqgeNAmNvuC0t4CsDbSshZJkCS1eNisKqlyG
-cF8G2JeiDX6tO6Mv0SmjCa3MFb0bJaGPMU0X7c8XcpvMaOQmCajwSeY9G0WqbBmKv34DsMIEztU6Y2
-KiDlFdt6jnCSqx7Dmt6XnqSKaFFHNO5+FmODxMCWBEaco77lNDGXBM0ECYB/+s7nKFdwSF5hgXumQe
-EZ7amRg39RHy3zIjyRCykQh8Zo2iviRKyTDn/zx6EefptJj2Cw+Ep2FSc01U5ry4KLPYsTyWnVGnvb
-UpyGlhjBUljyjHhWpf8OFaXwhp9O4T1gU9UeyPPa8A2l0p1kNqPXEVRm1AOs1oAGZU596t6SOR2mcB
-Oco1srWtkaVrMUzIErrKri85keKqRQYX9VX0/eAUK1hrSu6HMEX3Qh2sCh0q0D2CtnUqS4hj62sE/z
-aDs2Sg7MBS6xnQeooc2R2tC9YrKpEi9pLXfYXp20tDCpSP8rKlrD4axprb9u1Df5hSbz9QU0cRpfgn
-kiIzwKucd0wsEHlLpe5yHXuc6FrNelOl7pY2+11kTWx7VpRu97dXA3DO1vbkhcb4zyvERYajQgAADs
-="""
- ),
- mimetype="image/png",
-)
-
-
-TEMPLATE = u"""\
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<title>WSGI Information</title>
-<style type="text/css">
- @import url(https://fonts.googleapis.com/css?family=Ubuntu);
-
- body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
- 'Verdana', sans-serif; background-color: white; color: #000;
- font-size: 15px; text-align: center; }
- #logo { float: right; padding: 0 0 10px 10px; }
- div.box { text-align: left; width: 45em; margin: auto; padding: 50px 0;
- background-color: white; }
- h1, h2 { font-family: 'Ubuntu', 'Lucida Grande', 'Lucida Sans Unicode',
- 'Geneva', 'Verdana', sans-serif; font-weight: normal; }
- h1 { margin: 0 0 30px 0; }
- h2 { font-size: 1.4em; margin: 1em 0 0.5em 0; }
- table { width: 100%%; border-collapse: collapse; border: 1px solid #AFC5C9 }
- table th { background-color: #AFC1C4; color: white; font-size: 0.72em;
- font-weight: normal; width: 18em; vertical-align: top;
- padding: 0.5em 0 0.1em 0.5em; }
- table td { border: 1px solid #AFC5C9; padding: 0.1em 0 0.1em 0.5em; }
- code { font-family: 'Consolas', 'Monaco', 'Bitstream Vera Sans Mono',
- monospace; font-size: 0.7em; }
- ul li { line-height: 1.5em; }
- ul.path { font-size: 0.7em; margin: 0 -30px; padding: 8px 30px;
- list-style: none; background: #E8EFF0; }
- ul.path li { line-height: 1.6em; }
- li.virtual { color: #999; text-decoration: underline; }
- li.exp { background: white; }
-</style>
-<div class="box">
- <img src="?resource=logo" id="logo" alt="[The Werkzeug Logo]" />
- <h1>WSGI Information</h1>
- <p>
- This page displays all available information about the WSGI server and
- the underlying Python interpreter.
- <h2 id="python-interpreter">Python Interpreter</h2>
- <table>
- <tr>
- <th>Python Version
- <td>%(python_version)s
- <tr>
- <th>Platform
- <td>%(platform)s [%(os)s]
- <tr>
- <th>API Version
- <td>%(api_version)s
- <tr>
- <th>Byteorder
- <td>%(byteorder)s
- <tr>
- <th>Werkzeug Version
- <td>%(werkzeug_version)s
- </table>
- <h2 id="wsgi-environment">WSGI Environment</h2>
- <table>%(wsgi_env)s</table>
- <h2 id="installed-eggs">Installed Eggs</h2>
- <p>
- The following python packages were installed on the system as
- Python eggs:
- <ul>%(python_eggs)s</ul>
- <h2 id="sys-path">System Path</h2>
- <p>
- The following paths are the current contents of the load path. The
- following entries are looked up for Python packages. Note that not
- all items in this path are folders. Gray and underlined items are
- entries pointing to invalid resources or used by custom import hooks
- such as the zip importer.
- <p>
- Items with a bright background were expanded for display from a relative
- path. If you encounter such paths in the output you might want to check
- your setup as relative paths are usually problematic in multithreaded
- environments.
- <ul class="path">%(sys_path)s</ul>
-</div>
-"""
-
-
-def iter_sys_path():
- if os.name == "posix":
-
- def strip(x):
- prefix = os.path.expanduser("~")
- if x.startswith(prefix):
- x = "~" + x[len(prefix) :]
- return x
-
- else:
-
- def strip(x):
- return x
-
- cwd = os.path.abspath(os.getcwd())
- for item in sys.path:
- path = os.path.join(cwd, item or os.path.curdir)
- yield strip(os.path.normpath(path)), not os.path.isdir(path), path != item
-
-
-def render_testapp(req):
- try:
- import pkg_resources
- except ImportError:
- eggs = ()
- else:
- eggs = sorted(pkg_resources.working_set, key=lambda x: x.project_name.lower())
- python_eggs = []
- for egg in eggs:
- try:
- version = egg.version
- except (ValueError, AttributeError):
- version = "unknown"
- python_eggs.append(
- "<li>%s <small>[%s]</small>" % (escape(egg.project_name), escape(version))
- )
-
- wsgi_env = []
- sorted_environ = sorted(req.environ.items(), key=lambda x: repr(x[0]).lower())
- for key, value in sorted_environ:
- wsgi_env.append(
- "<tr><th>%s<td><code>%s</code>"
- % (escape(str(key)), " ".join(wrap(escape(repr(value)))))
- )
-
- sys_path = []
- for item, virtual, expanded in iter_sys_path():
- class_ = []
- if virtual:
- class_.append("virtual")
- if expanded:
- class_.append("exp")
- sys_path.append(
- "<li%s>%s"
- % (' class="%s"' % " ".join(class_) if class_ else "", escape(item))
- )
-
- return (
- TEMPLATE
- % {
- "python_version": "<br>".join(escape(sys.version).splitlines()),
- "platform": escape(sys.platform),
- "os": escape(os.name),
- "api_version": sys.api_version,
- "byteorder": sys.byteorder,
- "werkzeug_version": werkzeug.__version__,
- "python_eggs": "\n".join(python_eggs),
- "wsgi_env": "\n".join(wsgi_env),
- "sys_path": "\n".join(sys_path),
- }
- ).encode("utf-8")
-
-
-def test_app(environ, start_response):
- """Simple test application that dumps the environment. You can use
- it to check if Werkzeug is working properly:
-
- .. sourcecode:: pycon
-
- >>> from werkzeug.serving import run_simple
- >>> from werkzeug.testapp import test_app
- >>> run_simple('localhost', 3000, test_app)
- * Running on http://localhost:3000/
-
- The application displays important information from the WSGI environment,
- the Python interpreter and the installed libraries.
- """
- req = Request(environ, populate_request=False)
- if req.args.get("resource") == "logo":
- response = logo
- else:
- response = Response(render_testapp(req), mimetype="text/html")
- return response(environ, start_response)
-
-
-if __name__ == "__main__":
- from .serving import run_simple
-
- run_simple("localhost", 5000, test_app, use_reloader=True)
diff --git a/python/werkzeug/urls.py b/python/werkzeug/urls.py
deleted file mode 100644
index 38e9e5a..0000000
--- a/python/werkzeug/urls.py
+++ /dev/null
@@ -1,1134 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.urls
- ~~~~~~~~~~~~~
-
- ``werkzeug.urls`` used to provide several wrapper functions for Python 2
- urlparse, whose main purpose were to work around the behavior of the Py2
- stdlib and its lack of unicode support. While this was already a somewhat
- inconvenient situation, it got even more complicated because Python 3's
- ``urllib.parse`` actually does handle unicode properly. In other words,
- this module would wrap two libraries with completely different behavior. So
- now this module contains a 2-and-3-compatible backport of Python 3's
- ``urllib.parse``, which is mostly API-compatible.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import os
-import re
-from collections import namedtuple
-
-from ._compat import fix_tuple_repr
-from ._compat import implements_to_string
-from ._compat import make_literal_wrapper
-from ._compat import normalize_string_tuple
-from ._compat import PY2
-from ._compat import text_type
-from ._compat import to_native
-from ._compat import to_unicode
-from ._compat import try_coerce_native
-from ._internal import _decode_idna
-from ._internal import _encode_idna
-from .datastructures import iter_multi_items
-from .datastructures import MultiDict
-
-# A regular expression for what a valid schema looks like
-_scheme_re = re.compile(r"^[a-zA-Z0-9+-.]+$")
-
-# Characters that are safe in any part of an URL.
-_always_safe = frozenset(
- bytearray(
- b"abcdefghijklmnopqrstuvwxyz"
- b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- b"0123456789"
- b"-._~"
- )
-)
-
-_hexdigits = "0123456789ABCDEFabcdef"
-_hextobyte = dict(
- ((a + b).encode(), int(a + b, 16)) for a in _hexdigits for b in _hexdigits
-)
-_bytetohex = [("%%%02X" % char).encode("ascii") for char in range(256)]
-
-
-_URLTuple = fix_tuple_repr(
- namedtuple("_URLTuple", ["scheme", "netloc", "path", "query", "fragment"])
-)
-
-
-class BaseURL(_URLTuple):
- """Superclass of :py:class:`URL` and :py:class:`BytesURL`."""
-
- __slots__ = ()
-
- def replace(self, **kwargs):
- """Return an URL with the same values, except for those parameters
- given new values by whichever keyword arguments are specified."""
- return self._replace(**kwargs)
-
- @property
- def host(self):
- """The host part of the URL if available, otherwise `None`. The
- host is either the hostname or the IP address mentioned in the
- URL. It will not contain the port.
- """
- return self._split_host()[0]
-
- @property
- def ascii_host(self):
- """Works exactly like :attr:`host` but will return a result that
- is restricted to ASCII. If it finds a netloc that is not ASCII
- it will attempt to idna decode it. This is useful for socket
- operations when the URL might include internationalized characters.
- """
- rv = self.host
- if rv is not None and isinstance(rv, text_type):
- try:
- rv = _encode_idna(rv)
- except UnicodeError:
- rv = rv.encode("ascii", "ignore")
- return to_native(rv, "ascii", "ignore")
-
- @property
- def port(self):
- """The port in the URL as an integer if it was present, `None`
- otherwise. This does not fill in default ports.
- """
- try:
- rv = int(to_native(self._split_host()[1]))
- if 0 <= rv <= 65535:
- return rv
- except (ValueError, TypeError):
- pass
-
- @property
- def auth(self):
- """The authentication part in the URL if available, `None`
- otherwise.
- """
- return self._split_netloc()[0]
-
- @property
- def username(self):
- """The username if it was part of the URL, `None` otherwise.
- This undergoes URL decoding and will always be a unicode string.
- """
- rv = self._split_auth()[0]
- if rv is not None:
- return _url_unquote_legacy(rv)
-
- @property
- def raw_username(self):
- """The username if it was part of the URL, `None` otherwise.
- Unlike :attr:`username` this one is not being decoded.
- """
- return self._split_auth()[0]
-
- @property
- def password(self):
- """The password if it was part of the URL, `None` otherwise.
- This undergoes URL decoding and will always be a unicode string.
- """
- rv = self._split_auth()[1]
- if rv is not None:
- return _url_unquote_legacy(rv)
-
- @property
- def raw_password(self):
- """The password if it was part of the URL, `None` otherwise.
- Unlike :attr:`password` this one is not being decoded.
- """
- return self._split_auth()[1]
-
- def decode_query(self, *args, **kwargs):
- """Decodes the query part of the URL. Ths is a shortcut for
- calling :func:`url_decode` on the query argument. The arguments and
- keyword arguments are forwarded to :func:`url_decode` unchanged.
- """
- return url_decode(self.query, *args, **kwargs)
-
- def join(self, *args, **kwargs):
- """Joins this URL with another one. This is just a convenience
- function for calling into :meth:`url_join` and then parsing the
- return value again.
- """
- return url_parse(url_join(self, *args, **kwargs))
-
- def to_url(self):
- """Returns a URL string or bytes depending on the type of the
- information stored. This is just a convenience function
- for calling :meth:`url_unparse` for this URL.
- """
- return url_unparse(self)
-
- def decode_netloc(self):
- """Decodes the netloc part into a string."""
- rv = _decode_idna(self.host or "")
-
- if ":" in rv:
- rv = "[%s]" % rv
- port = self.port
- if port is not None:
- rv = "%s:%d" % (rv, port)
- auth = ":".join(
- filter(
- None,
- [
- _url_unquote_legacy(self.raw_username or "", "/:%@"),
- _url_unquote_legacy(self.raw_password or "", "/:%@"),
- ],
- )
- )
- if auth:
- rv = "%s@%s" % (auth, rv)
- return rv
-
- def to_uri_tuple(self):
- """Returns a :class:`BytesURL` tuple that holds a URI. This will
- encode all the information in the URL properly to ASCII using the
- rules a web browser would follow.
-
- It's usually more interesting to directly call :meth:`iri_to_uri` which
- will return a string.
- """
- return url_parse(iri_to_uri(self).encode("ascii"))
-
- def to_iri_tuple(self):
- """Returns a :class:`URL` tuple that holds a IRI. This will try
- to decode as much information as possible in the URL without
- losing information similar to how a web browser does it for the
- URL bar.
-
- It's usually more interesting to directly call :meth:`uri_to_iri` which
- will return a string.
- """
- return url_parse(uri_to_iri(self))
-
- def get_file_location(self, pathformat=None):
- """Returns a tuple with the location of the file in the form
- ``(server, location)``. If the netloc is empty in the URL or
- points to localhost, it's represented as ``None``.
-
- The `pathformat` by default is autodetection but needs to be set
- when working with URLs of a specific system. The supported values
- are ``'windows'`` when working with Windows or DOS paths and
- ``'posix'`` when working with posix paths.
-
- If the URL does not point to a local file, the server and location
- are both represented as ``None``.
-
- :param pathformat: The expected format of the path component.
- Currently ``'windows'`` and ``'posix'`` are
- supported. Defaults to ``None`` which is
- autodetect.
- """
- if self.scheme != "file":
- return None, None
-
- path = url_unquote(self.path)
- host = self.netloc or None
-
- if pathformat is None:
- if os.name == "nt":
- pathformat = "windows"
- else:
- pathformat = "posix"
-
- if pathformat == "windows":
- if path[:1] == "/" and path[1:2].isalpha() and path[2:3] in "|:":
- path = path[1:2] + ":" + path[3:]
- windows_share = path[:3] in ("\\" * 3, "/" * 3)
- import ntpath
-
- path = ntpath.normpath(path)
- # Windows shared drives are represented as ``\\host\\directory``.
- # That results in a URL like ``file://///host/directory``, and a
- # path like ``///host/directory``. We need to special-case this
- # because the path contains the hostname.
- if windows_share and host is None:
- parts = path.lstrip("\\").split("\\", 1)
- if len(parts) == 2:
- host, path = parts
- else:
- host = parts[0]
- path = ""
- elif pathformat == "posix":
- import posixpath
-
- path = posixpath.normpath(path)
- else:
- raise TypeError("Invalid path format %s" % repr(pathformat))
-
- if host in ("127.0.0.1", "::1", "localhost"):
- host = None
-
- return host, path
-
- def _split_netloc(self):
- if self._at in self.netloc:
- return self.netloc.split(self._at, 1)
- return None, self.netloc
-
- def _split_auth(self):
- auth = self._split_netloc()[0]
- if not auth:
- return None, None
- if self._colon not in auth:
- return auth, None
- return auth.split(self._colon, 1)
-
- def _split_host(self):
- rv = self._split_netloc()[1]
- if not rv:
- return None, None
-
- if not rv.startswith(self._lbracket):
- if self._colon in rv:
- return rv.split(self._colon, 1)
- return rv, None
-
- idx = rv.find(self._rbracket)
- if idx < 0:
- return rv, None
-
- host = rv[1:idx]
- rest = rv[idx + 1 :]
- if rest.startswith(self._colon):
- return host, rest[1:]
- return host, None
-
-
-@implements_to_string
-class URL(BaseURL):
- """Represents a parsed URL. This behaves like a regular tuple but
- also has some extra attributes that give further insight into the
- URL.
- """
-
- __slots__ = ()
- _at = "@"
- _colon = ":"
- _lbracket = "["
- _rbracket = "]"
-
- def __str__(self):
- return self.to_url()
-
- def encode_netloc(self):
- """Encodes the netloc part to an ASCII safe URL as bytes."""
- rv = self.ascii_host or ""
- if ":" in rv:
- rv = "[%s]" % rv
- port = self.port
- if port is not None:
- rv = "%s:%d" % (rv, port)
- auth = ":".join(
- filter(
- None,
- [
- url_quote(self.raw_username or "", "utf-8", "strict", "/:%"),
- url_quote(self.raw_password or "", "utf-8", "strict", "/:%"),
- ],
- )
- )
- if auth:
- rv = "%s@%s" % (auth, rv)
- return to_native(rv)
-
- def encode(self, charset="utf-8", errors="replace"):
- """Encodes the URL to a tuple made out of bytes. The charset is
- only being used for the path, query and fragment.
- """
- return BytesURL(
- self.scheme.encode("ascii"),
- self.encode_netloc(),
- self.path.encode(charset, errors),
- self.query.encode(charset, errors),
- self.fragment.encode(charset, errors),
- )
-
-
-class BytesURL(BaseURL):
- """Represents a parsed URL in bytes."""
-
- __slots__ = ()
- _at = b"@"
- _colon = b":"
- _lbracket = b"["
- _rbracket = b"]"
-
- def __str__(self):
- return self.to_url().decode("utf-8", "replace")
-
- def encode_netloc(self):
- """Returns the netloc unchanged as bytes."""
- return self.netloc
-
- def decode(self, charset="utf-8", errors="replace"):
- """Decodes the URL to a tuple made out of strings. The charset is
- only being used for the path, query and fragment.
- """
- return URL(
- self.scheme.decode("ascii"),
- self.decode_netloc(),
- self.path.decode(charset, errors),
- self.query.decode(charset, errors),
- self.fragment.decode(charset, errors),
- )
-
-
-_unquote_maps = {frozenset(): _hextobyte}
-
-
-def _unquote_to_bytes(string, unsafe=""):
- if isinstance(string, text_type):
- string = string.encode("utf-8")
-
- if isinstance(unsafe, text_type):
- unsafe = unsafe.encode("utf-8")
-
- unsafe = frozenset(bytearray(unsafe))
- groups = iter(string.split(b"%"))
- result = bytearray(next(groups, b""))
-
- try:
- hex_to_byte = _unquote_maps[unsafe]
- except KeyError:
- hex_to_byte = _unquote_maps[unsafe] = {
- h: b for h, b in _hextobyte.items() if b not in unsafe
- }
-
- for group in groups:
- code = group[:2]
-
- if code in hex_to_byte:
- result.append(hex_to_byte[code])
- result.extend(group[2:])
- else:
- result.append(37) # %
- result.extend(group)
-
- return bytes(result)
-
-
-def _url_encode_impl(obj, charset, encode_keys, sort, key):
- iterable = iter_multi_items(obj)
- if sort:
- iterable = sorted(iterable, key=key)
- for key, value in iterable:
- if value is None:
- continue
- if not isinstance(key, bytes):
- key = text_type(key).encode(charset)
- if not isinstance(value, bytes):
- value = text_type(value).encode(charset)
- yield _fast_url_quote_plus(key) + "=" + _fast_url_quote_plus(value)
-
-
-def _url_unquote_legacy(value, unsafe=""):
- try:
- return url_unquote(value, charset="utf-8", errors="strict", unsafe=unsafe)
- except UnicodeError:
- return url_unquote(value, charset="latin1", unsafe=unsafe)
-
-
-def url_parse(url, scheme=None, allow_fragments=True):
- """Parses a URL from a string into a :class:`URL` tuple. If the URL
- is lacking a scheme it can be provided as second argument. Otherwise,
- it is ignored. Optionally fragments can be stripped from the URL
- by setting `allow_fragments` to `False`.
-
- The inverse of this function is :func:`url_unparse`.
-
- :param url: the URL to parse.
- :param scheme: the default schema to use if the URL is schemaless.
- :param allow_fragments: if set to `False` a fragment will be removed
- from the URL.
- """
- s = make_literal_wrapper(url)
- is_text_based = isinstance(url, text_type)
-
- if scheme is None:
- scheme = s("")
- netloc = query = fragment = s("")
- i = url.find(s(":"))
- if i > 0 and _scheme_re.match(to_native(url[:i], errors="replace")):
- # make sure "iri" is not actually a port number (in which case
- # "scheme" is really part of the path)
- rest = url[i + 1 :]
- if not rest or any(c not in s("0123456789") for c in rest):
- # not a port number
- scheme, url = url[:i].lower(), rest
-
- if url[:2] == s("//"):
- delim = len(url)
- for c in s("/?#"):
- wdelim = url.find(c, 2)
- if wdelim >= 0:
- delim = min(delim, wdelim)
- netloc, url = url[2:delim], url[delim:]
- if (s("[") in netloc and s("]") not in netloc) or (
- s("]") in netloc and s("[") not in netloc
- ):
- raise ValueError("Invalid IPv6 URL")
-
- if allow_fragments and s("#") in url:
- url, fragment = url.split(s("#"), 1)
- if s("?") in url:
- url, query = url.split(s("?"), 1)
-
- result_type = URL if is_text_based else BytesURL
- return result_type(scheme, netloc, url, query, fragment)
-
-
-def _make_fast_url_quote(charset="utf-8", errors="strict", safe="/:", unsafe=""):
- """Precompile the translation table for a URL encoding function.
-
- Unlike :func:`url_quote`, the generated function only takes the
- string to quote.
-
- :param charset: The charset to encode the result with.
- :param errors: How to handle encoding errors.
- :param safe: An optional sequence of safe characters to never encode.
- :param unsafe: An optional sequence of unsafe characters to always encode.
- """
- if isinstance(safe, text_type):
- safe = safe.encode(charset, errors)
-
- if isinstance(unsafe, text_type):
- unsafe = unsafe.encode(charset, errors)
-
- safe = (frozenset(bytearray(safe)) | _always_safe) - frozenset(bytearray(unsafe))
- table = [chr(c) if c in safe else "%%%02X" % c for c in range(256)]
-
- if not PY2:
-
- def quote(string):
- return "".join([table[c] for c in string])
-
- else:
-
- def quote(string):
- return "".join([table[c] for c in bytearray(string)])
-
- return quote
-
-
-_fast_url_quote = _make_fast_url_quote()
-_fast_quote_plus = _make_fast_url_quote(safe=" ", unsafe="+")
-
-
-def _fast_url_quote_plus(string):
- return _fast_quote_plus(string).replace(" ", "+")
-
-
-def url_quote(string, charset="utf-8", errors="strict", safe="/:", unsafe=""):
- """URL encode a single string with a given encoding.
-
- :param s: the string to quote.
- :param charset: the charset to be used.
- :param safe: an optional sequence of safe characters.
- :param unsafe: an optional sequence of unsafe characters.
-
- .. versionadded:: 0.9.2
- The `unsafe` parameter was added.
- """
- if not isinstance(string, (text_type, bytes, bytearray)):
- string = text_type(string)
- if isinstance(string, text_type):
- string = string.encode(charset, errors)
- if isinstance(safe, text_type):
- safe = safe.encode(charset, errors)
- if isinstance(unsafe, text_type):
- unsafe = unsafe.encode(charset, errors)
- safe = (frozenset(bytearray(safe)) | _always_safe) - frozenset(bytearray(unsafe))
- rv = bytearray()
- for char in bytearray(string):
- if char in safe:
- rv.append(char)
- else:
- rv.extend(_bytetohex[char])
- return to_native(bytes(rv))
-
-
-def url_quote_plus(string, charset="utf-8", errors="strict", safe=""):
- """URL encode a single string with the given encoding and convert
- whitespace to "+".
-
- :param s: The string to quote.
- :param charset: The charset to be used.
- :param safe: An optional sequence of safe characters.
- """
- return url_quote(string, charset, errors, safe + " ", "+").replace(" ", "+")
-
-
-def url_unparse(components):
- """The reverse operation to :meth:`url_parse`. This accepts arbitrary
- as well as :class:`URL` tuples and returns a URL as a string.
-
- :param components: the parsed URL as tuple which should be converted
- into a URL string.
- """
- scheme, netloc, path, query, fragment = normalize_string_tuple(components)
- s = make_literal_wrapper(scheme)
- url = s("")
-
- # We generally treat file:///x and file:/x the same which is also
- # what browsers seem to do. This also allows us to ignore a schema
- # register for netloc utilization or having to differenciate between
- # empty and missing netloc.
- if netloc or (scheme and path.startswith(s("/"))):
- if path and path[:1] != s("/"):
- path = s("/") + path
- url = s("//") + (netloc or s("")) + path
- elif path:
- url += path
- if scheme:
- url = scheme + s(":") + url
- if query:
- url = url + s("?") + query
- if fragment:
- url = url + s("#") + fragment
- return url
-
-
-def url_unquote(string, charset="utf-8", errors="replace", unsafe=""):
- """URL decode a single string with a given encoding. If the charset
- is set to `None` no unicode decoding is performed and raw bytes
- are returned.
-
- :param s: the string to unquote.
- :param charset: the charset of the query string. If set to `None`
- no unicode decoding will take place.
- :param errors: the error handling for the charset decoding.
- """
- rv = _unquote_to_bytes(string, unsafe)
- if charset is not None:
- rv = rv.decode(charset, errors)
- return rv
-
-
-def url_unquote_plus(s, charset="utf-8", errors="replace"):
- """URL decode a single string with the given `charset` and decode "+" to
- whitespace.
-
- Per default encoding errors are ignored. If you want a different behavior
- you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a
- :exc:`HTTPUnicodeError` is raised.
-
- :param s: The string to unquote.
- :param charset: the charset of the query string. If set to `None`
- no unicode decoding will take place.
- :param errors: The error handling for the `charset` decoding.
- """
- if isinstance(s, text_type):
- s = s.replace(u"+", u" ")
- else:
- s = s.replace(b"+", b" ")
- return url_unquote(s, charset, errors)
-
-
-def url_fix(s, charset="utf-8"):
- r"""Sometimes you get an URL by a user that just isn't a real URL because
- it contains unsafe characters like ' ' and so on. This function can fix
- some of the problems in a similar way browsers handle data entered by the
- user:
-
- >>> url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
- 'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'
-
- :param s: the string with the URL to fix.
- :param charset: The target charset for the URL if the url was given as
- unicode string.
- """
- # First step is to switch to unicode processing and to convert
- # backslashes (which are invalid in URLs anyways) to slashes. This is
- # consistent with what Chrome does.
- s = to_unicode(s, charset, "replace").replace("\\", "/")
-
- # For the specific case that we look like a malformed windows URL
- # we want to fix this up manually:
- if s.startswith("file://") and s[7:8].isalpha() and s[8:10] in (":/", "|/"):
- s = "file:///" + s[7:]
-
- url = url_parse(s)
- path = url_quote(url.path, charset, safe="/%+$!*'(),")
- qs = url_quote_plus(url.query, charset, safe=":&%=+$!*'(),")
- anchor = url_quote_plus(url.fragment, charset, safe=":&%=+$!*'(),")
- return to_native(url_unparse((url.scheme, url.encode_netloc(), path, qs, anchor)))
-
-
-# not-unreserved characters remain quoted when unquoting to IRI
-_to_iri_unsafe = "".join([chr(c) for c in range(128) if c not in _always_safe])
-
-
-def _codec_error_url_quote(e):
- """Used in :func:`uri_to_iri` after unquoting to re-quote any
- invalid bytes.
- """
- out = _fast_url_quote(e.object[e.start : e.end])
-
- if PY2:
- out = out.decode("utf-8")
-
- return out, e.end
-
-
-codecs.register_error("werkzeug.url_quote", _codec_error_url_quote)
-
-
-def uri_to_iri(uri, charset="utf-8", errors="werkzeug.url_quote"):
- """Convert a URI to an IRI. All valid UTF-8 characters are unquoted,
- leaving all reserved and invalid characters quoted. If the URL has
- a domain, it is decoded from Punycode.
-
- >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF")
- 'http://\\u2603.net/p\\xe5th?q=\\xe8ry%DF'
-
- :param uri: The URI to convert.
- :param charset: The encoding to encode unquoted bytes with.
- :param errors: Error handler to use during ``bytes.encode``. By
- default, invalid bytes are left quoted.
-
- .. versionchanged:: 0.15
- All reserved and invalid characters remain quoted. Previously,
- only some reserved characters were preserved, and invalid bytes
- were replaced instead of left quoted.
-
- .. versionadded:: 0.6
- """
- if isinstance(uri, tuple):
- uri = url_unparse(uri)
-
- uri = url_parse(to_unicode(uri, charset))
- path = url_unquote(uri.path, charset, errors, _to_iri_unsafe)
- query = url_unquote(uri.query, charset, errors, _to_iri_unsafe)
- fragment = url_unquote(uri.fragment, charset, errors, _to_iri_unsafe)
- return url_unparse((uri.scheme, uri.decode_netloc(), path, query, fragment))
-
-
-# reserved characters remain unquoted when quoting to URI
-_to_uri_safe = ":/?#[]@!$&'()*+,;=%"
-
-
-def iri_to_uri(iri, charset="utf-8", errors="strict", safe_conversion=False):
- """Convert an IRI to a URI. All non-ASCII and unsafe characters are
- quoted. If the URL has a domain, it is encoded to Punycode.
-
- >>> iri_to_uri('http://\\u2603.net/p\\xe5th?q=\\xe8ry%DF')
- 'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'
-
- :param iri: The IRI to convert.
- :param charset: The encoding of the IRI.
- :param errors: Error handler to use during ``bytes.encode``.
- :param safe_conversion: Return the URL unchanged if it only contains
- ASCII characters and no whitespace. See the explanation below.
-
- There is a general problem with IRI conversion with some protocols
- that are in violation of the URI specification. Consider the
- following two IRIs::
-
- magnet:?xt=uri:whatever
- itms-services://?action=download-manifest
-
- After parsing, we don't know if the scheme requires the ``//``,
- which is dropped if empty, but conveys different meanings in the
- final URL if it's present or not. In this case, you can use
- ``safe_conversion``, which will return the URL unchanged if it only
- contains ASCII characters and no whitespace. This can result in a
- URI with unquoted characters if it was not already quoted correctly,
- but preserves the URL's semantics. Werkzeug uses this for the
- ``Location`` header for redirects.
-
- .. versionchanged:: 0.15
- All reserved characters remain unquoted. Previously, only some
- reserved characters were left unquoted.
-
- .. versionchanged:: 0.9.6
- The ``safe_conversion`` parameter was added.
-
- .. versionadded:: 0.6
- """
- if isinstance(iri, tuple):
- iri = url_unparse(iri)
-
- if safe_conversion:
- # If we're not sure if it's safe to convert the URL, and it only
- # contains ASCII characters, return it unconverted.
- try:
- native_iri = to_native(iri)
- ascii_iri = native_iri.encode("ascii")
-
- # Only return if it doesn't have whitespace. (Why?)
- if len(ascii_iri.split()) == 1:
- return native_iri
- except UnicodeError:
- pass
-
- iri = url_parse(to_unicode(iri, charset, errors))
- path = url_quote(iri.path, charset, errors, _to_uri_safe)
- query = url_quote(iri.query, charset, errors, _to_uri_safe)
- fragment = url_quote(iri.fragment, charset, errors, _to_uri_safe)
- return to_native(
- url_unparse((iri.scheme, iri.encode_netloc(), path, query, fragment))
- )
-
-
-def url_decode(
- s,
- charset="utf-8",
- decode_keys=False,
- include_empty=True,
- errors="replace",
- separator="&",
- cls=None,
-):
- """
- Parse a querystring and return it as :class:`MultiDict`. There is a
- difference in key decoding on different Python versions. On Python 3
- keys will always be fully decoded whereas on Python 2, keys will
- remain bytestrings if they fit into ASCII. On 2.x keys can be forced
- to be unicode by setting `decode_keys` to `True`.
-
- If the charset is set to `None` no unicode decoding will happen and
- raw bytes will be returned.
-
- Per default a missing value for a key will default to an empty key. If
- you don't want that behavior you can set `include_empty` to `False`.
-
- Per default encoding errors are ignored. If you want a different behavior
- you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a
- `HTTPUnicodeError` is raised.
-
- .. versionchanged:: 0.5
- In previous versions ";" and "&" could be used for url decoding.
- This changed in 0.5 where only "&" is supported. If you want to
- use ";" instead a different `separator` can be provided.
-
- The `cls` parameter was added.
-
- :param s: a string with the query string to decode.
- :param charset: the charset of the query string. If set to `None`
- no unicode decoding will take place.
- :param decode_keys: Used on Python 2.x to control whether keys should
- be forced to be unicode objects. If set to `True`
- then keys will be unicode in all cases. Otherwise,
- they remain `str` if they fit into ASCII.
- :param include_empty: Set to `False` if you don't want empty values to
- appear in the dict.
- :param errors: the decoding error behavior.
- :param separator: the pair separator to be used, defaults to ``&``
- :param cls: an optional dict class to use. If this is not specified
- or `None` the default :class:`MultiDict` is used.
- """
- if cls is None:
- cls = MultiDict
- if isinstance(s, text_type) and not isinstance(separator, text_type):
- separator = separator.decode(charset or "ascii")
- elif isinstance(s, bytes) and not isinstance(separator, bytes):
- separator = separator.encode(charset or "ascii")
- return cls(
- _url_decode_impl(
- s.split(separator), charset, decode_keys, include_empty, errors
- )
- )
-
-
-def url_decode_stream(
- stream,
- charset="utf-8",
- decode_keys=False,
- include_empty=True,
- errors="replace",
- separator="&",
- cls=None,
- limit=None,
- return_iterator=False,
-):
- """Works like :func:`url_decode` but decodes a stream. The behavior
- of stream and limit follows functions like
- :func:`~werkzeug.wsgi.make_line_iter`. The generator of pairs is
- directly fed to the `cls` so you can consume the data while it's
- parsed.
-
- .. versionadded:: 0.8
-
- :param stream: a stream with the encoded querystring
- :param charset: the charset of the query string. If set to `None`
- no unicode decoding will take place.
- :param decode_keys: Used on Python 2.x to control whether keys should
- be forced to be unicode objects. If set to `True`,
- keys will be unicode in all cases. Otherwise, they
- remain `str` if they fit into ASCII.
- :param include_empty: Set to `False` if you don't want empty values to
- appear in the dict.
- :param errors: the decoding error behavior.
- :param separator: the pair separator to be used, defaults to ``&``
- :param cls: an optional dict class to use. If this is not specified
- or `None` the default :class:`MultiDict` is used.
- :param limit: the content length of the URL data. Not necessary if
- a limited stream is provided.
- :param return_iterator: if set to `True` the `cls` argument is ignored
- and an iterator over all decoded pairs is
- returned
- """
- from .wsgi import make_chunk_iter
-
- pair_iter = make_chunk_iter(stream, separator, limit)
- decoder = _url_decode_impl(pair_iter, charset, decode_keys, include_empty, errors)
-
- if return_iterator:
- return decoder
-
- if cls is None:
- cls = MultiDict
-
- return cls(decoder)
-
-
-def _url_decode_impl(pair_iter, charset, decode_keys, include_empty, errors):
- for pair in pair_iter:
- if not pair:
- continue
- s = make_literal_wrapper(pair)
- equal = s("=")
- if equal in pair:
- key, value = pair.split(equal, 1)
- else:
- if not include_empty:
- continue
- key = pair
- value = s("")
- key = url_unquote_plus(key, charset, errors)
- if charset is not None and PY2 and not decode_keys:
- key = try_coerce_native(key)
- yield key, url_unquote_plus(value, charset, errors)
-
-
-def url_encode(
- obj, charset="utf-8", encode_keys=False, sort=False, key=None, separator=b"&"
-):
- """URL encode a dict/`MultiDict`. If a value is `None` it will not appear
- in the result string. Per default only values are encoded into the target
- charset strings. If `encode_keys` is set to ``True`` unicode keys are
- supported too.
-
- If `sort` is set to `True` the items are sorted by `key` or the default
- sorting algorithm.
-
- .. versionadded:: 0.5
- `sort`, `key`, and `separator` were added.
-
- :param obj: the object to encode into a query string.
- :param charset: the charset of the query string.
- :param encode_keys: set to `True` if you have unicode keys. (Ignored on
- Python 3.x)
- :param sort: set to `True` if you want parameters to be sorted by `key`.
- :param separator: the separator to be used for the pairs.
- :param key: an optional function to be used for sorting. For more details
- check out the :func:`sorted` documentation.
- """
- separator = to_native(separator, "ascii")
- return separator.join(_url_encode_impl(obj, charset, encode_keys, sort, key))
-
-
-def url_encode_stream(
- obj,
- stream=None,
- charset="utf-8",
- encode_keys=False,
- sort=False,
- key=None,
- separator=b"&",
-):
- """Like :meth:`url_encode` but writes the results to a stream
- object. If the stream is `None` a generator over all encoded
- pairs is returned.
-
- .. versionadded:: 0.8
-
- :param obj: the object to encode into a query string.
- :param stream: a stream to write the encoded object into or `None` if
- an iterator over the encoded pairs should be returned. In
- that case the separator argument is ignored.
- :param charset: the charset of the query string.
- :param encode_keys: set to `True` if you have unicode keys. (Ignored on
- Python 3.x)
- :param sort: set to `True` if you want parameters to be sorted by `key`.
- :param separator: the separator to be used for the pairs.
- :param key: an optional function to be used for sorting. For more details
- check out the :func:`sorted` documentation.
- """
- separator = to_native(separator, "ascii")
- gen = _url_encode_impl(obj, charset, encode_keys, sort, key)
- if stream is None:
- return gen
- for idx, chunk in enumerate(gen):
- if idx:
- stream.write(separator)
- stream.write(chunk)
-
-
-def url_join(base, url, allow_fragments=True):
- """Join a base URL and a possibly relative URL to form an absolute
- interpretation of the latter.
-
- :param base: the base URL for the join operation.
- :param url: the URL to join.
- :param allow_fragments: indicates whether fragments should be allowed.
- """
- if isinstance(base, tuple):
- base = url_unparse(base)
- if isinstance(url, tuple):
- url = url_unparse(url)
-
- base, url = normalize_string_tuple((base, url))
- s = make_literal_wrapper(base)
-
- if not base:
- return url
- if not url:
- return base
-
- bscheme, bnetloc, bpath, bquery, bfragment = url_parse(
- base, allow_fragments=allow_fragments
- )
- scheme, netloc, path, query, fragment = url_parse(url, bscheme, allow_fragments)
- if scheme != bscheme:
- return url
- if netloc:
- return url_unparse((scheme, netloc, path, query, fragment))
- netloc = bnetloc
-
- if path[:1] == s("/"):
- segments = path.split(s("/"))
- elif not path:
- segments = bpath.split(s("/"))
- if not query:
- query = bquery
- else:
- segments = bpath.split(s("/"))[:-1] + path.split(s("/"))
-
- # If the rightmost part is "./" we want to keep the slash but
- # remove the dot.
- if segments[-1] == s("."):
- segments[-1] = s("")
-
- # Resolve ".." and "."
- segments = [segment for segment in segments if segment != s(".")]
- while 1:
- i = 1
- n = len(segments) - 1
- while i < n:
- if segments[i] == s("..") and segments[i - 1] not in (s(""), s("..")):
- del segments[i - 1 : i + 1]
- break
- i += 1
- else:
- break
-
- # Remove trailing ".." if the URL is absolute
- unwanted_marker = [s(""), s("..")]
- while segments[:2] == unwanted_marker:
- del segments[1]
-
- path = s("/").join(segments)
- return url_unparse((scheme, netloc, path, query, fragment))
-
-
-class Href(object):
- """Implements a callable that constructs URLs with the given base. The
- function can be called with any number of positional and keyword
- arguments which than are used to assemble the URL. Works with URLs
- and posix paths.
-
- Positional arguments are appended as individual segments to
- the path of the URL:
-
- >>> href = Href('/foo')
- >>> href('bar', 23)
- '/foo/bar/23'
- >>> href('foo', bar=23)
- '/foo/foo?bar=23'
-
- If any of the arguments (positional or keyword) evaluates to `None` it
- will be skipped. If no keyword arguments are given the last argument
- can be a :class:`dict` or :class:`MultiDict` (or any other dict subclass),
- otherwise the keyword arguments are used for the query parameters, cutting
- off the first trailing underscore of the parameter name:
-
- >>> href(is_=42)
- '/foo?is=42'
- >>> href({'foo': 'bar'})
- '/foo?foo=bar'
-
- Combining of both methods is not allowed:
-
- >>> href({'foo': 'bar'}, bar=42)
- Traceback (most recent call last):
- ...
- TypeError: keyword arguments and query-dicts can't be combined
-
- Accessing attributes on the href object creates a new href object with
- the attribute name as prefix:
-
- >>> bar_href = href.bar
- >>> bar_href("blub")
- '/foo/bar/blub'
-
- If `sort` is set to `True` the items are sorted by `key` or the default
- sorting algorithm:
-
- >>> href = Href("/", sort=True)
- >>> href(a=1, b=2, c=3)
- '/?a=1&b=2&c=3'
-
- .. versionadded:: 0.5
- `sort` and `key` were added.
- """
-
- def __init__(self, base="./", charset="utf-8", sort=False, key=None):
- if not base:
- base = "./"
- self.base = base
- self.charset = charset
- self.sort = sort
- self.key = key
-
- def __getattr__(self, name):
- if name[:2] == "__":
- raise AttributeError(name)
- base = self.base
- if base[-1:] != "/":
- base += "/"
- return Href(url_join(base, name), self.charset, self.sort, self.key)
-
- def __call__(self, *path, **query):
- if path and isinstance(path[-1], dict):
- if query:
- raise TypeError("keyword arguments and query-dicts can't be combined")
- query, path = path[-1], path[:-1]
- elif query:
- query = dict(
- [(k.endswith("_") and k[:-1] or k, v) for k, v in query.items()]
- )
- path = "/".join(
- [
- to_unicode(url_quote(x, self.charset), "ascii")
- for x in path
- if x is not None
- ]
- ).lstrip("/")
- rv = self.base
- if path:
- if not rv.endswith("/"):
- rv += "/"
- rv = url_join(rv, "./" + path)
- if query:
- rv += "?" + to_unicode(
- url_encode(query, self.charset, sort=self.sort, key=self.key), "ascii"
- )
- return to_native(rv)
diff --git a/python/werkzeug/useragents.py b/python/werkzeug/useragents.py
deleted file mode 100644
index e265e09..0000000
--- a/python/werkzeug/useragents.py
+++ /dev/null
@@ -1,220 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.useragents
- ~~~~~~~~~~~~~~~~~~~
-
- This module provides a helper to inspect user agent strings. This module
- is far from complete but should work for most of the currently available
- browsers.
-
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import re
-import warnings
-
-
-class UserAgentParser(object):
- """A simple user agent parser. Used by the `UserAgent`."""
-
- platforms = (
- ("cros", "chromeos"),
- ("iphone|ios", "iphone"),
- ("ipad", "ipad"),
- (r"darwin|mac|os\s*x", "macos"),
- ("win", "windows"),
- (r"android", "android"),
- ("netbsd", "netbsd"),
- ("openbsd", "openbsd"),
- ("freebsd", "freebsd"),
- ("dragonfly", "dragonflybsd"),
- ("(sun|i86)os", "solaris"),
- (r"x11|lin(\b|ux)?", "linux"),
- (r"nintendo\s+wii", "wii"),
- ("irix", "irix"),
- ("hp-?ux", "hpux"),
- ("aix", "aix"),
- ("sco|unix_sv", "sco"),
- ("bsd", "bsd"),
- ("amiga", "amiga"),
- ("blackberry|playbook", "blackberry"),
- ("symbian", "symbian"),
- )
- browsers = (
- ("googlebot", "google"),
- ("msnbot", "msn"),
- ("yahoo", "yahoo"),
- ("ask jeeves", "ask"),
- (r"aol|america\s+online\s+browser", "aol"),
- ("opera", "opera"),
- ("edge", "edge"),
- ("chrome|crios", "chrome"),
- ("seamonkey", "seamonkey"),
- ("firefox|firebird|phoenix|iceweasel", "firefox"),
- ("galeon", "galeon"),
- ("safari|version", "safari"),
- ("webkit", "webkit"),
- ("camino", "camino"),
- ("konqueror", "konqueror"),
- ("k-meleon", "kmeleon"),
- ("netscape", "netscape"),
- (r"msie|microsoft\s+internet\s+explorer|trident/.+? rv:", "msie"),
- ("lynx", "lynx"),
- ("links", "links"),
- ("Baiduspider", "baidu"),
- ("bingbot", "bing"),
- ("mozilla", "mozilla"),
- )
-
- _browser_version_re = r"(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?"
- _language_re = re.compile(
- r"(?:;\s*|\s+)(\b\w{2}\b(?:-\b\w{2}\b)?)\s*;|"
- r"(?:\(|\[|;)\s*(\b\w{2}\b(?:-\b\w{2}\b)?)\s*(?:\]|\)|;)"
- )
-
- def __init__(self):
- self.platforms = [(b, re.compile(a, re.I)) for a, b in self.platforms]
- self.browsers = [
- (b, re.compile(self._browser_version_re % a, re.I))
- for a, b in self.browsers
- ]
-
- def __call__(self, user_agent):
- for platform, regex in self.platforms: # noqa: B007
- match = regex.search(user_agent)
- if match is not None:
- break
- else:
- platform = None
- for browser, regex in self.browsers: # noqa: B007
- match = regex.search(user_agent)
- if match is not None:
- version = match.group(1)
- break
- else:
- browser = version = None
- match = self._language_re.search(user_agent)
- if match is not None:
- language = match.group(1) or match.group(2)
- else:
- language = None
- return platform, browser, version, language
-
-
-class UserAgent(object):
- """Represents a user agent. Pass it a WSGI environment or a user agent
- string and you can inspect some of the details from the user agent
- string via the attributes. The following attributes exist:
-
- .. attribute:: string
-
- the raw user agent string
-
- .. attribute:: platform
-
- the browser platform. The following platforms are currently
- recognized:
-
- - `aix`
- - `amiga`
- - `android`
- - `blackberry`
- - `bsd`
- - `chromeos`
- - `dragonflybsd`
- - `freebsd`
- - `hpux`
- - `ipad`
- - `iphone`
- - `irix`
- - `linux`
- - `macos`
- - `netbsd`
- - `openbsd`
- - `sco`
- - `solaris`
- - `symbian`
- - `wii`
- - `windows`
-
- .. attribute:: browser
-
- the name of the browser. The following browsers are currently
- recognized:
-
- - `aol` *
- - `ask` *
- - `baidu` *
- - `bing` *
- - `camino`
- - `chrome`
- - `edge`
- - `firefox`
- - `galeon`
- - `google` *
- - `kmeleon`
- - `konqueror`
- - `links`
- - `lynx`
- - `mozilla`
- - `msie`
- - `msn`
- - `netscape`
- - `opera`
- - `safari`
- - `seamonkey`
- - `webkit`
- - `yahoo` *
-
- (Browsers marked with a star (``*``) are crawlers.)
-
- .. attribute:: version
-
- the version of the browser
-
- .. attribute:: language
-
- the language of the browser
- """
-
- _parser = UserAgentParser()
-
- def __init__(self, environ_or_string):
- if isinstance(environ_or_string, dict):
- environ_or_string = environ_or_string.get("HTTP_USER_AGENT", "")
- self.string = environ_or_string
- self.platform, self.browser, self.version, self.language = self._parser(
- environ_or_string
- )
-
- def to_header(self):
- return self.string
-
- def __str__(self):
- return self.string
-
- def __nonzero__(self):
- return bool(self.browser)
-
- __bool__ = __nonzero__
-
- def __repr__(self):
- return "<%s %r/%s>" % (self.__class__.__name__, self.browser, self.version)
-
-
-# DEPRECATED
-from .wrappers import UserAgentMixin as _UserAgentMixin
-
-
-class UserAgentMixin(_UserAgentMixin):
- @property
- def user_agent(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.useragents.UserAgentMixin' should be imported"
- " from 'werkzeug.wrappers.UserAgentMixin'. This old import"
- " will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- return super(_UserAgentMixin, self).user_agent
diff --git a/python/werkzeug/utils.py b/python/werkzeug/utils.py
deleted file mode 100644
index 2062057..0000000
--- a/python/werkzeug/utils.py
+++ /dev/null
@@ -1,836 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.utils
- ~~~~~~~~~~~~~~
-
- This module implements various utilities for WSGI applications. Most of
- them are used by the request and response wrappers but especially for
- middleware development it makes sense to use them without the wrappers.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import codecs
-import os
-import pkgutil
-import re
-import sys
-import warnings
-
-from ._compat import iteritems
-from ._compat import PY2
-from ._compat import reraise
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import unichr
-from ._internal import _DictAccessorProperty
-from ._internal import _missing
-from ._internal import _parse_signature
-
-try:
- from html.entities import name2codepoint
-except ImportError:
- from htmlentitydefs import name2codepoint
-
-
-_format_re = re.compile(r"\$(?:(%s)|\{(%s)\})" % (("[a-zA-Z_][a-zA-Z0-9_]*",) * 2))
-_entity_re = re.compile(r"&([^;]+);")
-_filename_ascii_strip_re = re.compile(r"[^A-Za-z0-9_.-]")
-_windows_device_files = (
- "CON",
- "AUX",
- "COM1",
- "COM2",
- "COM3",
- "COM4",
- "LPT1",
- "LPT2",
- "LPT3",
- "PRN",
- "NUL",
-)
-
-
-class cached_property(property):
- """A decorator that converts a function into a lazy property. The
- function wrapped is called the first time to retrieve the result
- and then that calculated result is used the next time you access
- the value::
-
- class Foo(object):
-
- @cached_property
- def foo(self):
- # calculate something important here
- return 42
-
- The class has to have a `__dict__` in order for this property to
- work.
- """
-
- # implementation detail: A subclass of python's builtin property
- # decorator, we override __get__ to check for a cached value. If one
- # chooses to invoke __get__ by hand the property will still work as
- # expected because the lookup logic is replicated in __get__ for
- # manual invocation.
-
- def __init__(self, func, name=None, doc=None):
- self.__name__ = name or func.__name__
- self.__module__ = func.__module__
- self.__doc__ = doc or func.__doc__
- self.func = func
-
- def __set__(self, obj, value):
- obj.__dict__[self.__name__] = value
-
- def __get__(self, obj, type=None):
- if obj is None:
- return self
- value = obj.__dict__.get(self.__name__, _missing)
- if value is _missing:
- value = self.func(obj)
- obj.__dict__[self.__name__] = value
- return value
-
-
-class environ_property(_DictAccessorProperty):
- """Maps request attributes to environment variables. This works not only
- for the Werzeug request object, but also any other class with an
- environ attribute:
-
- >>> class Test(object):
- ... environ = {'key': 'value'}
- ... test = environ_property('key')
- >>> var = Test()
- >>> var.test
- 'value'
-
- If you pass it a second value it's used as default if the key does not
- exist, the third one can be a converter that takes a value and converts
- it. If it raises :exc:`ValueError` or :exc:`TypeError` the default value
- is used. If no default value is provided `None` is used.
-
- Per default the property is read only. You have to explicitly enable it
- by passing ``read_only=False`` to the constructor.
- """
-
- read_only = True
-
- def lookup(self, obj):
- return obj.environ
-
-
-class header_property(_DictAccessorProperty):
- """Like `environ_property` but for headers."""
-
- def lookup(self, obj):
- return obj.headers
-
-
-class HTMLBuilder(object):
- """Helper object for HTML generation.
-
- Per default there are two instances of that class. The `html` one, and
- the `xhtml` one for those two dialects. The class uses keyword parameters
- and positional parameters to generate small snippets of HTML.
-
- Keyword parameters are converted to XML/SGML attributes, positional
- arguments are used as children. Because Python accepts positional
- arguments before keyword arguments it's a good idea to use a list with the
- star-syntax for some children:
-
- >>> html.p(class_='foo', *[html.a('foo', href='foo.html'), ' ',
- ... html.a('bar', href='bar.html')])
- u'<p class="foo"><a href="foo.html">foo</a> <a href="bar.html">bar</a></p>'
-
- This class works around some browser limitations and can not be used for
- arbitrary SGML/XML generation. For that purpose lxml and similar
- libraries exist.
-
- Calling the builder escapes the string passed:
-
- >>> html.p(html("<foo>"))
- u'<p>&lt;foo&gt;</p>'
- """
-
- _entity_re = re.compile(r"&([^;]+);")
- _entities = name2codepoint.copy()
- _entities["apos"] = 39
- _empty_elements = {
- "area",
- "base",
- "basefont",
- "br",
- "col",
- "command",
- "embed",
- "frame",
- "hr",
- "img",
- "input",
- "keygen",
- "isindex",
- "link",
- "meta",
- "param",
- "source",
- "wbr",
- }
- _boolean_attributes = {
- "selected",
- "checked",
- "compact",
- "declare",
- "defer",
- "disabled",
- "ismap",
- "multiple",
- "nohref",
- "noresize",
- "noshade",
- "nowrap",
- }
- _plaintext_elements = {"textarea"}
- _c_like_cdata = {"script", "style"}
-
- def __init__(self, dialect):
- self._dialect = dialect
-
- def __call__(self, s):
- return escape(s)
-
- def __getattr__(self, tag):
- if tag[:2] == "__":
- raise AttributeError(tag)
-
- def proxy(*children, **arguments):
- buffer = "<" + tag
- for key, value in iteritems(arguments):
- if value is None:
- continue
- if key[-1] == "_":
- key = key[:-1]
- if key in self._boolean_attributes:
- if not value:
- continue
- if self._dialect == "xhtml":
- value = '="' + key + '"'
- else:
- value = ""
- else:
- value = '="' + escape(value) + '"'
- buffer += " " + key + value
- if not children and tag in self._empty_elements:
- if self._dialect == "xhtml":
- buffer += " />"
- else:
- buffer += ">"
- return buffer
- buffer += ">"
-
- children_as_string = "".join(
- [text_type(x) for x in children if x is not None]
- )
-
- if children_as_string:
- if tag in self._plaintext_elements:
- children_as_string = escape(children_as_string)
- elif tag in self._c_like_cdata and self._dialect == "xhtml":
- children_as_string = (
- "/*<![CDATA[*/" + children_as_string + "/*]]>*/"
- )
- buffer += children_as_string + "</" + tag + ">"
- return buffer
-
- return proxy
-
- def __repr__(self):
- return "<%s for %r>" % (self.__class__.__name__, self._dialect)
-
-
-html = HTMLBuilder("html")
-xhtml = HTMLBuilder("xhtml")
-
-# https://cgit.freedesktop.org/xdg/shared-mime-info/tree/freedesktop.org.xml.in
-# https://www.iana.org/assignments/media-types/media-types.xhtml
-# Types listed in the XDG mime info that have a charset in the IANA registration.
-_charset_mimetypes = {
- "application/ecmascript",
- "application/javascript",
- "application/sql",
- "application/xml",
- "application/xml-dtd",
- "application/xml-external-parsed-entity",
-}
-
-
-def get_content_type(mimetype, charset):
- """Returns the full content type string with charset for a mimetype.
-
- If the mimetype represents text, the charset parameter will be
- appended, otherwise the mimetype is returned unchanged.
-
- :param mimetype: The mimetype to be used as content type.
- :param charset: The charset to be appended for text mimetypes.
- :return: The content type.
-
- .. verionchanged:: 0.15
- Any type that ends with ``+xml`` gets a charset, not just those
- that start with ``application/``. Known text types such as
- ``application/javascript`` are also given charsets.
- """
- if (
- mimetype.startswith("text/")
- or mimetype in _charset_mimetypes
- or mimetype.endswith("+xml")
- ):
- mimetype += "; charset=" + charset
-
- return mimetype
-
-
-def detect_utf_encoding(data):
- """Detect which UTF encoding was used to encode the given bytes.
-
- The latest JSON standard (:rfc:`8259`) suggests that only UTF-8 is
- accepted. Older documents allowed 8, 16, or 32. 16 and 32 can be big
- or little endian. Some editors or libraries may prepend a BOM.
-
- :internal:
-
- :param data: Bytes in unknown UTF encoding.
- :return: UTF encoding name
-
- .. versionadded:: 0.15
- """
- head = data[:4]
-
- if head[:3] == codecs.BOM_UTF8:
- return "utf-8-sig"
-
- if b"\x00" not in head:
- return "utf-8"
-
- if head in (codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE):
- return "utf-32"
-
- if head[:2] in (codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE):
- return "utf-16"
-
- if len(head) == 4:
- if head[:3] == b"\x00\x00\x00":
- return "utf-32-be"
-
- if head[::2] == b"\x00\x00":
- return "utf-16-be"
-
- if head[1:] == b"\x00\x00\x00":
- return "utf-32-le"
-
- if head[1::2] == b"\x00\x00":
- return "utf-16-le"
-
- if len(head) == 2:
- return "utf-16-be" if head.startswith(b"\x00") else "utf-16-le"
-
- return "utf-8"
-
-
-def format_string(string, context):
- """String-template format a string:
-
- >>> format_string('$foo and ${foo}s', dict(foo=42))
- '42 and 42s'
-
- This does not do any attribute lookup etc. For more advanced string
- formattings have a look at the `werkzeug.template` module.
-
- :param string: the format string.
- :param context: a dict with the variables to insert.
- """
-
- def lookup_arg(match):
- x = context[match.group(1) or match.group(2)]
- if not isinstance(x, string_types):
- x = type(string)(x)
- return x
-
- return _format_re.sub(lookup_arg, string)
-
-
-def secure_filename(filename):
- r"""Pass it a filename and it will return a secure version of it. This
- filename can then safely be stored on a regular file system and passed
- to :func:`os.path.join`. The filename returned is an ASCII only string
- for maximum portability.
-
- On windows systems the function also makes sure that the file is not
- named after one of the special device files.
-
- >>> secure_filename("My cool movie.mov")
- 'My_cool_movie.mov'
- >>> secure_filename("../../../etc/passwd")
- 'etc_passwd'
- >>> secure_filename(u'i contain cool \xfcml\xe4uts.txt')
- 'i_contain_cool_umlauts.txt'
-
- The function might return an empty filename. It's your responsibility
- to ensure that the filename is unique and that you abort or
- generate a random filename if the function returned an empty one.
-
- .. versionadded:: 0.5
-
- :param filename: the filename to secure
- """
- if isinstance(filename, text_type):
- from unicodedata import normalize
-
- filename = normalize("NFKD", filename).encode("ascii", "ignore")
- if not PY2:
- filename = filename.decode("ascii")
- for sep in os.path.sep, os.path.altsep:
- if sep:
- filename = filename.replace(sep, " ")
- filename = str(_filename_ascii_strip_re.sub("", "_".join(filename.split()))).strip(
- "._"
- )
-
- # on nt a couple of special files are present in each folder. We
- # have to ensure that the target file is not such a filename. In
- # this case we prepend an underline
- if (
- os.name == "nt"
- and filename
- and filename.split(".")[0].upper() in _windows_device_files
- ):
- filename = "_" + filename
-
- return filename
-
-
-def escape(s, quote=None):
- """Replace special characters "&", "<", ">" and (") to HTML-safe sequences.
-
- There is a special handling for `None` which escapes to an empty string.
-
- .. versionchanged:: 0.9
- `quote` is now implicitly on.
-
- :param s: the string to escape.
- :param quote: ignored.
- """
- if s is None:
- return ""
- elif hasattr(s, "__html__"):
- return text_type(s.__html__())
- elif not isinstance(s, string_types):
- s = text_type(s)
- if quote is not None:
- from warnings import warn
-
- warn(
- "The 'quote' parameter is no longer used as of version 0.9"
- " and will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- s = (
- s.replace("&", "&amp;")
- .replace("<", "&lt;")
- .replace(">", "&gt;")
- .replace('"', "&quot;")
- )
- return s
-
-
-def unescape(s):
- """The reverse function of `escape`. This unescapes all the HTML
- entities, not only the XML entities inserted by `escape`.
-
- :param s: the string to unescape.
- """
-
- def handle_match(m):
- name = m.group(1)
- if name in HTMLBuilder._entities:
- return unichr(HTMLBuilder._entities[name])
- try:
- if name[:2] in ("#x", "#X"):
- return unichr(int(name[2:], 16))
- elif name.startswith("#"):
- return unichr(int(name[1:]))
- except ValueError:
- pass
- return u""
-
- return _entity_re.sub(handle_match, s)
-
-
-def redirect(location, code=302, Response=None):
- """Returns a response object (a WSGI application) that, if called,
- redirects the client to the target location. Supported codes are
- 301, 302, 303, 305, 307, and 308. 300 is not supported because
- it's not a real redirect and 304 because it's the answer for a
- request with a request with defined If-Modified-Since headers.
-
- .. versionadded:: 0.6
- The location can now be a unicode string that is encoded using
- the :func:`iri_to_uri` function.
-
- .. versionadded:: 0.10
- The class used for the Response object can now be passed in.
-
- :param location: the location the response should redirect to.
- :param code: the redirect status code. defaults to 302.
- :param class Response: a Response class to use when instantiating a
- response. The default is :class:`werkzeug.wrappers.Response` if
- unspecified.
- """
- if Response is None:
- from .wrappers import Response
-
- display_location = escape(location)
- if isinstance(location, text_type):
- # Safe conversion is necessary here as we might redirect
- # to a broken URI scheme (for instance itms-services).
- from .urls import iri_to_uri
-
- location = iri_to_uri(location, safe_conversion=True)
- response = Response(
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
- "<title>Redirecting...</title>\n"
- "<h1>Redirecting...</h1>\n"
- "<p>You should be redirected automatically to target URL: "
- '<a href="%s">%s</a>. If not click the link.'
- % (escape(location), display_location),
- code,
- mimetype="text/html",
- )
- response.headers["Location"] = location
- return response
-
-
-def append_slash_redirect(environ, code=301):
- """Redirects to the same URL but with a slash appended. The behavior
- of this function is undefined if the path ends with a slash already.
-
- :param environ: the WSGI environment for the request that triggers
- the redirect.
- :param code: the status code for the redirect.
- """
- new_path = environ["PATH_INFO"].strip("/") + "/"
- query_string = environ.get("QUERY_STRING")
- if query_string:
- new_path += "?" + query_string
- return redirect(new_path, code)
-
-
-def import_string(import_name, silent=False):
- """Imports an object based on a string. This is useful if you want to
- use import paths as endpoints or something similar. An import path can
- be specified either in dotted notation (``xml.sax.saxutils.escape``)
- or with a colon as object delimiter (``xml.sax.saxutils:escape``).
-
- If `silent` is True the return value will be `None` if the import fails.
-
- :param import_name: the dotted name for the object to import.
- :param silent: if set to `True` import errors are ignored and
- `None` is returned instead.
- :return: imported object
- """
- # force the import name to automatically convert to strings
- # __import__ is not able to handle unicode strings in the fromlist
- # if the module is a package
- import_name = str(import_name).replace(":", ".")
- try:
- try:
- __import__(import_name)
- except ImportError:
- if "." not in import_name:
- raise
- else:
- return sys.modules[import_name]
-
- module_name, obj_name = import_name.rsplit(".", 1)
- module = __import__(module_name, globals(), locals(), [obj_name])
- try:
- return getattr(module, obj_name)
- except AttributeError as e:
- raise ImportError(e)
-
- except ImportError as e:
- if not silent:
- reraise(
- ImportStringError, ImportStringError(import_name, e), sys.exc_info()[2]
- )
-
-
-def find_modules(import_path, include_packages=False, recursive=False):
- """Finds all the modules below a package. This can be useful to
- automatically import all views / controllers so that their metaclasses /
- function decorators have a chance to register themselves on the
- application.
-
- Packages are not returned unless `include_packages` is `True`. This can
- also recursively list modules but in that case it will import all the
- packages to get the correct load path of that module.
-
- :param import_path: the dotted name for the package to find child modules.
- :param include_packages: set to `True` if packages should be returned, too.
- :param recursive: set to `True` if recursion should happen.
- :return: generator
- """
- module = import_string(import_path)
- path = getattr(module, "__path__", None)
- if path is None:
- raise ValueError("%r is not a package" % import_path)
- basename = module.__name__ + "."
- for _importer, modname, ispkg in pkgutil.iter_modules(path):
- modname = basename + modname
- if ispkg:
- if include_packages:
- yield modname
- if recursive:
- for item in find_modules(modname, include_packages, True):
- yield item
- else:
- yield modname
-
-
-def validate_arguments(func, args, kwargs, drop_extra=True):
- """Checks if the function accepts the arguments and keyword arguments.
- Returns a new ``(args, kwargs)`` tuple that can safely be passed to
- the function without causing a `TypeError` because the function signature
- is incompatible. If `drop_extra` is set to `True` (which is the default)
- any extra positional or keyword arguments are dropped automatically.
-
- The exception raised provides three attributes:
-
- `missing`
- A set of argument names that the function expected but where
- missing.
-
- `extra`
- A dict of keyword arguments that the function can not handle but
- where provided.
-
- `extra_positional`
- A list of values that where given by positional argument but the
- function cannot accept.
-
- This can be useful for decorators that forward user submitted data to
- a view function::
-
- from werkzeug.utils import ArgumentValidationError, validate_arguments
-
- def sanitize(f):
- def proxy(request):
- data = request.values.to_dict()
- try:
- args, kwargs = validate_arguments(f, (request,), data)
- except ArgumentValidationError:
- raise BadRequest('The browser failed to transmit all '
- 'the data expected.')
- return f(*args, **kwargs)
- return proxy
-
- :param func: the function the validation is performed against.
- :param args: a tuple of positional arguments.
- :param kwargs: a dict of keyword arguments.
- :param drop_extra: set to `False` if you don't want extra arguments
- to be silently dropped.
- :return: tuple in the form ``(args, kwargs)``.
- """
- parser = _parse_signature(func)
- args, kwargs, missing, extra, extra_positional = parser(args, kwargs)[:5]
- if missing:
- raise ArgumentValidationError(tuple(missing))
- elif (extra or extra_positional) and not drop_extra:
- raise ArgumentValidationError(None, extra, extra_positional)
- return tuple(args), kwargs
-
-
-def bind_arguments(func, args, kwargs):
- """Bind the arguments provided into a dict. When passed a function,
- a tuple of arguments and a dict of keyword arguments `bind_arguments`
- returns a dict of names as the function would see it. This can be useful
- to implement a cache decorator that uses the function arguments to build
- the cache key based on the values of the arguments.
-
- :param func: the function the arguments should be bound for.
- :param args: tuple of positional arguments.
- :param kwargs: a dict of keyword arguments.
- :return: a :class:`dict` of bound keyword arguments.
- """
- (
- args,
- kwargs,
- missing,
- extra,
- extra_positional,
- arg_spec,
- vararg_var,
- kwarg_var,
- ) = _parse_signature(func)(args, kwargs)
- values = {}
- for (name, _has_default, _default), value in zip(arg_spec, args):
- values[name] = value
- if vararg_var is not None:
- values[vararg_var] = tuple(extra_positional)
- elif extra_positional:
- raise TypeError("too many positional arguments")
- if kwarg_var is not None:
- multikw = set(extra) & set([x[0] for x in arg_spec])
- if multikw:
- raise TypeError(
- "got multiple values for keyword argument " + repr(next(iter(multikw)))
- )
- values[kwarg_var] = extra
- elif extra:
- raise TypeError("got unexpected keyword argument " + repr(next(iter(extra))))
- return values
-
-
-class ArgumentValidationError(ValueError):
-
- """Raised if :func:`validate_arguments` fails to validate"""
-
- def __init__(self, missing=None, extra=None, extra_positional=None):
- self.missing = set(missing or ())
- self.extra = extra or {}
- self.extra_positional = extra_positional or []
- ValueError.__init__(
- self,
- "function arguments invalid. (%d missing, %d additional)"
- % (len(self.missing), len(self.extra) + len(self.extra_positional)),
- )
-
-
-class ImportStringError(ImportError):
- """Provides information about a failed :func:`import_string` attempt."""
-
- #: String in dotted notation that failed to be imported.
- import_name = None
- #: Wrapped exception.
- exception = None
-
- def __init__(self, import_name, exception):
- self.import_name = import_name
- self.exception = exception
-
- msg = (
- "import_string() failed for %r. Possible reasons are:\n\n"
- "- missing __init__.py in a package;\n"
- "- package or module path not included in sys.path;\n"
- "- duplicated package or module name taking precedence in "
- "sys.path;\n"
- "- missing module, class, function or variable;\n\n"
- "Debugged import:\n\n%s\n\n"
- "Original exception:\n\n%s: %s"
- )
-
- name = ""
- tracked = []
- for part in import_name.replace(":", ".").split("."):
- name += (name and ".") + part
- imported = import_string(name, silent=True)
- if imported:
- tracked.append((name, getattr(imported, "__file__", None)))
- else:
- track = ["- %r found in %r." % (n, i) for n, i in tracked]
- track.append("- %r not found." % name)
- msg = msg % (
- import_name,
- "\n".join(track),
- exception.__class__.__name__,
- str(exception),
- )
- break
-
- ImportError.__init__(self, msg)
-
- def __repr__(self):
- return "<%s(%r, %r)>" % (
- self.__class__.__name__,
- self.import_name,
- self.exception,
- )
-
-
-# DEPRECATED
-from .datastructures import CombinedMultiDict as _CombinedMultiDict
-from .datastructures import EnvironHeaders as _EnvironHeaders
-from .datastructures import Headers as _Headers
-from .datastructures import MultiDict as _MultiDict
-from .http import dump_cookie as _dump_cookie
-from .http import parse_cookie as _parse_cookie
-
-
-class MultiDict(_MultiDict):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.MultiDict' has moved to 'werkzeug"
- ".datastructures.MultiDict' as of version 0.5. This old"
- " import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(MultiDict, self).__init__(*args, **kwargs)
-
-
-class CombinedMultiDict(_CombinedMultiDict):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.CombinedMultiDict' has moved to 'werkzeug"
- ".datastructures.CombinedMultiDict' as of version 0.5. This"
- " old import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(CombinedMultiDict, self).__init__(*args, **kwargs)
-
-
-class Headers(_Headers):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.Headers' has moved to 'werkzeug"
- ".datastructures.Headers' as of version 0.5. This old"
- " import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(Headers, self).__init__(*args, **kwargs)
-
-
-class EnvironHeaders(_EnvironHeaders):
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.EnvironHeaders' has moved to 'werkzeug"
- ".datastructures.EnvironHeaders' as of version 0.5. This"
- " old import will be removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(EnvironHeaders, self).__init__(*args, **kwargs)
-
-
-def parse_cookie(*args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.parse_cookie' as moved to 'werkzeug.http"
- ".parse_cookie' as of version 0.5. This old import will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- return _parse_cookie(*args, **kwargs)
-
-
-def dump_cookie(*args, **kwargs):
- warnings.warn(
- "'werkzeug.utils.dump_cookie' as moved to 'werkzeug.http"
- ".dump_cookie' as of version 0.5. This old import will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- return _dump_cookie(*args, **kwargs)
diff --git a/python/werkzeug/wrappers/__init__.py b/python/werkzeug/wrappers/__init__.py
deleted file mode 100644
index 56c764a..0000000
--- a/python/werkzeug/wrappers/__init__.py
+++ /dev/null
@@ -1,36 +0,0 @@
-"""
-werkzeug.wrappers
-~~~~~~~~~~~~~~~~~
-
-The wrappers are simple request and response objects which you can
-subclass to do whatever you want them to do. The request object contains
-the information transmitted by the client (webbrowser) and the response
-object contains all the information sent back to the browser.
-
-An important detail is that the request object is created with the WSGI
-environ and will act as high-level proxy whereas the response object is an
-actual WSGI application.
-
-Like everything else in Werkzeug these objects will work correctly with
-unicode data. Incoming form data parsed by the response object will be
-decoded into an unicode object if possible and if it makes sense.
-
-:copyright: 2007 Pallets
-:license: BSD-3-Clause
-"""
-from .accept import AcceptMixin
-from .auth import AuthorizationMixin
-from .auth import WWWAuthenticateMixin
-from .base_request import BaseRequest
-from .base_response import BaseResponse
-from .common_descriptors import CommonRequestDescriptorsMixin
-from .common_descriptors import CommonResponseDescriptorsMixin
-from .etag import ETagRequestMixin
-from .etag import ETagResponseMixin
-from .request import PlainRequest
-from .request import Request
-from .request import StreamOnlyMixin
-from .response import Response
-from .response import ResponseStream
-from .response import ResponseStreamMixin
-from .user_agent import UserAgentMixin
diff --git a/python/werkzeug/wrappers/accept.py b/python/werkzeug/wrappers/accept.py
deleted file mode 100644
index d0620a0..0000000
--- a/python/werkzeug/wrappers/accept.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from ..datastructures import CharsetAccept
-from ..datastructures import LanguageAccept
-from ..datastructures import MIMEAccept
-from ..http import parse_accept_header
-from ..utils import cached_property
-
-
-class AcceptMixin(object):
- """A mixin for classes with an :attr:`~BaseResponse.environ` attribute
- to get all the HTTP accept headers as
- :class:`~werkzeug.datastructures.Accept` objects (or subclasses
- thereof).
- """
-
- @cached_property
- def accept_mimetypes(self):
- """List of mimetypes this client supports as
- :class:`~werkzeug.datastructures.MIMEAccept` object.
- """
- return parse_accept_header(self.environ.get("HTTP_ACCEPT"), MIMEAccept)
-
- @cached_property
- def accept_charsets(self):
- """List of charsets this client supports as
- :class:`~werkzeug.datastructures.CharsetAccept` object.
- """
- return parse_accept_header(
- self.environ.get("HTTP_ACCEPT_CHARSET"), CharsetAccept
- )
-
- @cached_property
- def accept_encodings(self):
- """List of encodings this client accepts. Encodings in a HTTP term
- are compression encodings such as gzip. For charsets have a look at
- :attr:`accept_charset`.
- """
- return parse_accept_header(self.environ.get("HTTP_ACCEPT_ENCODING"))
-
- @cached_property
- def accept_languages(self):
- """List of languages this client accepts as
- :class:`~werkzeug.datastructures.LanguageAccept` object.
-
- .. versionchanged 0.5
- In previous versions this was a regular
- :class:`~werkzeug.datastructures.Accept` object.
- """
- return parse_accept_header(
- self.environ.get("HTTP_ACCEPT_LANGUAGE"), LanguageAccept
- )
diff --git a/python/werkzeug/wrappers/auth.py b/python/werkzeug/wrappers/auth.py
deleted file mode 100644
index 714f755..0000000
--- a/python/werkzeug/wrappers/auth.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from ..http import parse_authorization_header
-from ..http import parse_www_authenticate_header
-from ..utils import cached_property
-
-
-class AuthorizationMixin(object):
- """Adds an :attr:`authorization` property that represents the parsed
- value of the `Authorization` header as
- :class:`~werkzeug.datastructures.Authorization` object.
- """
-
- @cached_property
- def authorization(self):
- """The `Authorization` object in parsed form."""
- header = self.environ.get("HTTP_AUTHORIZATION")
- return parse_authorization_header(header)
-
-
-class WWWAuthenticateMixin(object):
- """Adds a :attr:`www_authenticate` property to a response object."""
-
- @property
- def www_authenticate(self):
- """The `WWW-Authenticate` header in a parsed form."""
-
- def on_update(www_auth):
- if not www_auth and "www-authenticate" in self.headers:
- del self.headers["www-authenticate"]
- elif www_auth:
- self.headers["WWW-Authenticate"] = www_auth.to_header()
-
- header = self.headers.get("www-authenticate")
- return parse_www_authenticate_header(header, on_update)
diff --git a/python/werkzeug/wrappers/base_request.py b/python/werkzeug/wrappers/base_request.py
deleted file mode 100644
index 41e8aad..0000000
--- a/python/werkzeug/wrappers/base_request.py
+++ /dev/null
@@ -1,693 +0,0 @@
-import warnings
-from functools import update_wrapper
-from io import BytesIO
-
-from .._compat import to_native
-from .._compat import to_unicode
-from .._compat import wsgi_decoding_dance
-from .._compat import wsgi_get_bytes
-from ..datastructures import CombinedMultiDict
-from ..datastructures import EnvironHeaders
-from ..datastructures import ImmutableList
-from ..datastructures import ImmutableMultiDict
-from ..datastructures import ImmutableTypeConversionDict
-from ..datastructures import iter_multi_items
-from ..datastructures import MultiDict
-from ..formparser import default_stream_factory
-from ..formparser import FormDataParser
-from ..http import parse_cookie
-from ..http import parse_options_header
-from ..urls import url_decode
-from ..utils import cached_property
-from ..utils import environ_property
-from ..wsgi import get_content_length
-from ..wsgi import get_current_url
-from ..wsgi import get_host
-from ..wsgi import get_input_stream
-
-
-class BaseRequest(object):
- """Very basic request object. This does not implement advanced stuff like
- entity tag parsing or cache controls. The request object is created with
- the WSGI environment as first argument and will add itself to the WSGI
- environment as ``'werkzeug.request'`` unless it's created with
- `populate_request` set to False.
-
- There are a couple of mixins available that add additional functionality
- to the request object, there is also a class called `Request` which
- subclasses `BaseRequest` and all the important mixins.
-
- It's a good idea to create a custom subclass of the :class:`BaseRequest`
- and add missing functionality either via mixins or direct implementation.
- Here an example for such subclasses::
-
- from werkzeug.wrappers import BaseRequest, ETagRequestMixin
-
- class Request(BaseRequest, ETagRequestMixin):
- pass
-
- Request objects are **read only**. As of 0.5 modifications are not
- allowed in any place. Unlike the lower level parsing functions the
- request object will use immutable objects everywhere possible.
-
- Per default the request object will assume all the text data is `utf-8`
- encoded. Please refer to :doc:`the unicode chapter </unicode>` for more
- details about customizing the behavior.
-
- Per default the request object will be added to the WSGI
- environment as `werkzeug.request` to support the debugging system.
- If you don't want that, set `populate_request` to `False`.
-
- If `shallow` is `True` the environment is initialized as shallow
- object around the environ. Every operation that would modify the
- environ in any way (such as consuming form data) raises an exception
- unless the `shallow` attribute is explicitly set to `False`. This
- is useful for middlewares where you don't want to consume the form
- data by accident. A shallow request is not populated to the WSGI
- environment.
-
- .. versionchanged:: 0.5
- read-only mode was enforced by using immutables classes for all
- data.
- """
-
- #: the charset for the request, defaults to utf-8
- charset = "utf-8"
-
- #: the error handling procedure for errors, defaults to 'replace'
- encoding_errors = "replace"
-
- #: the maximum content length. This is forwarded to the form data
- #: parsing function (:func:`parse_form_data`). When set and the
- #: :attr:`form` or :attr:`files` attribute is accessed and the
- #: parsing fails because more than the specified value is transmitted
- #: a :exc:`~werkzeug.exceptions.RequestEntityTooLarge` exception is raised.
- #:
- #: Have a look at :ref:`dealing-with-request-data` for more details.
- #:
- #: .. versionadded:: 0.5
- max_content_length = None
-
- #: the maximum form field size. This is forwarded to the form data
- #: parsing function (:func:`parse_form_data`). When set and the
- #: :attr:`form` or :attr:`files` attribute is accessed and the
- #: data in memory for post data is longer than the specified value a
- #: :exc:`~werkzeug.exceptions.RequestEntityTooLarge` exception is raised.
- #:
- #: Have a look at :ref:`dealing-with-request-data` for more details.
- #:
- #: .. versionadded:: 0.5
- max_form_memory_size = None
-
- #: the class to use for `args` and `form`. The default is an
- #: :class:`~werkzeug.datastructures.ImmutableMultiDict` which supports
- #: multiple values per key. alternatively it makes sense to use an
- #: :class:`~werkzeug.datastructures.ImmutableOrderedMultiDict` which
- #: preserves order or a :class:`~werkzeug.datastructures.ImmutableDict`
- #: which is the fastest but only remembers the last key. It is also
- #: possible to use mutable structures, but this is not recommended.
- #:
- #: .. versionadded:: 0.6
- parameter_storage_class = ImmutableMultiDict
-
- #: the type to be used for list values from the incoming WSGI environment.
- #: By default an :class:`~werkzeug.datastructures.ImmutableList` is used
- #: (for example for :attr:`access_list`).
- #:
- #: .. versionadded:: 0.6
- list_storage_class = ImmutableList
-
- #: the type to be used for dict values from the incoming WSGI environment.
- #: By default an
- #: :class:`~werkzeug.datastructures.ImmutableTypeConversionDict` is used
- #: (for example for :attr:`cookies`).
- #:
- #: .. versionadded:: 0.6
- dict_storage_class = ImmutableTypeConversionDict
-
- #: The form data parser that shoud be used. Can be replaced to customize
- #: the form date parsing.
- form_data_parser_class = FormDataParser
-
- #: Optionally a list of hosts that is trusted by this request. By default
- #: all hosts are trusted which means that whatever the client sends the
- #: host is will be accepted.
- #:
- #: Because `Host` and `X-Forwarded-Host` headers can be set to any value by
- #: a malicious client, it is recommended to either set this property or
- #: implement similar validation in the proxy (if application is being run
- #: behind one).
- #:
- #: .. versionadded:: 0.9
- trusted_hosts = None
-
- #: Indicates whether the data descriptor should be allowed to read and
- #: buffer up the input stream. By default it's enabled.
- #:
- #: .. versionadded:: 0.9
- disable_data_descriptor = False
-
- def __init__(self, environ, populate_request=True, shallow=False):
- self.environ = environ
- if populate_request and not shallow:
- self.environ["werkzeug.request"] = self
- self.shallow = shallow
-
- def __repr__(self):
- # make sure the __repr__ even works if the request was created
- # from an invalid WSGI environment. If we display the request
- # in a debug session we don't want the repr to blow up.
- args = []
- try:
- args.append("'%s'" % to_native(self.url, self.url_charset))
- args.append("[%s]" % self.method)
- except Exception:
- args.append("(invalid WSGI environ)")
-
- return "<%s %s>" % (self.__class__.__name__, " ".join(args))
-
- @property
- def url_charset(self):
- """The charset that is assumed for URLs. Defaults to the value
- of :attr:`charset`.
-
- .. versionadded:: 0.6
- """
- return self.charset
-
- @classmethod
- def from_values(cls, *args, **kwargs):
- """Create a new request object based on the values provided. If
- environ is given missing values are filled from there. This method is
- useful for small scripts when you need to simulate a request from an URL.
- Do not use this method for unittesting, there is a full featured client
- object (:class:`Client`) that allows to create multipart requests,
- support for cookies etc.
-
- This accepts the same options as the
- :class:`~werkzeug.test.EnvironBuilder`.
-
- .. versionchanged:: 0.5
- This method now accepts the same arguments as
- :class:`~werkzeug.test.EnvironBuilder`. Because of this the
- `environ` parameter is now called `environ_overrides`.
-
- :return: request object
- """
- from ..test import EnvironBuilder
-
- charset = kwargs.pop("charset", cls.charset)
- kwargs["charset"] = charset
- builder = EnvironBuilder(*args, **kwargs)
- try:
- return builder.get_request(cls)
- finally:
- builder.close()
-
- @classmethod
- def application(cls, f):
- """Decorate a function as responder that accepts the request as first
- argument. This works like the :func:`responder` decorator but the
- function is passed the request object as first argument and the
- request object will be closed automatically::
-
- @Request.application
- def my_wsgi_app(request):
- return Response('Hello World!')
-
- As of Werkzeug 0.14 HTTP exceptions are automatically caught and
- converted to responses instead of failing.
-
- :param f: the WSGI callable to decorate
- :return: a new WSGI callable
- """
- #: return a callable that wraps the -2nd argument with the request
- #: and calls the function with all the arguments up to that one and
- #: the request. The return value is then called with the latest
- #: two arguments. This makes it possible to use this decorator for
- #: both methods and standalone WSGI functions.
- from ..exceptions import HTTPException
-
- def application(*args):
- request = cls(args[-2])
- with request:
- try:
- resp = f(*args[:-2] + (request,))
- except HTTPException as e:
- resp = e.get_response(args[-2])
- return resp(*args[-2:])
-
- return update_wrapper(application, f)
-
- def _get_file_stream(
- self, total_content_length, content_type, filename=None, content_length=None
- ):
- """Called to get a stream for the file upload.
-
- This must provide a file-like class with `read()`, `readline()`
- and `seek()` methods that is both writeable and readable.
-
- The default implementation returns a temporary file if the total
- content length is higher than 500KB. Because many browsers do not
- provide a content length for the files only the total content
- length matters.
-
- :param total_content_length: the total content length of all the
- data in the request combined. This value
- is guaranteed to be there.
- :param content_type: the mimetype of the uploaded file.
- :param filename: the filename of the uploaded file. May be `None`.
- :param content_length: the length of this file. This value is usually
- not provided because webbrowsers do not provide
- this value.
- """
- return default_stream_factory(
- total_content_length=total_content_length,
- filename=filename,
- content_type=content_type,
- content_length=content_length,
- )
-
- @property
- def want_form_data_parsed(self):
- """Returns True if the request method carries content. As of
- Werkzeug 0.9 this will be the case if a content type is transmitted.
-
- .. versionadded:: 0.8
- """
- return bool(self.environ.get("CONTENT_TYPE"))
-
- def make_form_data_parser(self):
- """Creates the form data parser. Instantiates the
- :attr:`form_data_parser_class` with some parameters.
-
- .. versionadded:: 0.8
- """
- return self.form_data_parser_class(
- self._get_file_stream,
- self.charset,
- self.encoding_errors,
- self.max_form_memory_size,
- self.max_content_length,
- self.parameter_storage_class,
- )
-
- def _load_form_data(self):
- """Method used internally to retrieve submitted data. After calling
- this sets `form` and `files` on the request object to multi dicts
- filled with the incoming form data. As a matter of fact the input
- stream will be empty afterwards. You can also call this method to
- force the parsing of the form data.
-
- .. versionadded:: 0.8
- """
- # abort early if we have already consumed the stream
- if "form" in self.__dict__:
- return
-
- _assert_not_shallow(self)
-
- if self.want_form_data_parsed:
- content_type = self.environ.get("CONTENT_TYPE", "")
- content_length = get_content_length(self.environ)
- mimetype, options = parse_options_header(content_type)
- parser = self.make_form_data_parser()
- data = parser.parse(
- self._get_stream_for_parsing(), mimetype, content_length, options
- )
- else:
- data = (
- self.stream,
- self.parameter_storage_class(),
- self.parameter_storage_class(),
- )
-
- # inject the values into the instance dict so that we bypass
- # our cached_property non-data descriptor.
- d = self.__dict__
- d["stream"], d["form"], d["files"] = data
-
- def _get_stream_for_parsing(self):
- """This is the same as accessing :attr:`stream` with the difference
- that if it finds cached data from calling :meth:`get_data` first it
- will create a new stream out of the cached data.
-
- .. versionadded:: 0.9.3
- """
- cached_data = getattr(self, "_cached_data", None)
- if cached_data is not None:
- return BytesIO(cached_data)
- return self.stream
-
- def close(self):
- """Closes associated resources of this request object. This
- closes all file handles explicitly. You can also use the request
- object in a with statement which will automatically close it.
-
- .. versionadded:: 0.9
- """
- files = self.__dict__.get("files")
- for _key, value in iter_multi_items(files or ()):
- value.close()
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.close()
-
- @cached_property
- def stream(self):
- """
- If the incoming form data was not encoded with a known mimetype
- the data is stored unmodified in this stream for consumption. Most
- of the time it is a better idea to use :attr:`data` which will give
- you that data as a string. The stream only returns the data once.
-
- Unlike :attr:`input_stream` this stream is properly guarded that you
- can't accidentally read past the length of the input. Werkzeug will
- internally always refer to this stream to read data which makes it
- possible to wrap this object with a stream that does filtering.
-
- .. versionchanged:: 0.9
- This stream is now always available but might be consumed by the
- form parser later on. Previously the stream was only set if no
- parsing happened.
- """
- _assert_not_shallow(self)
- return get_input_stream(self.environ)
-
- input_stream = environ_property(
- "wsgi.input",
- """The WSGI input stream.
-
- In general it's a bad idea to use this one because you can
- easily read past the boundary. Use the :attr:`stream`
- instead.""",
- )
-
- @cached_property
- def args(self):
- """The parsed URL parameters (the part in the URL after the question
- mark).
-
- By default an
- :class:`~werkzeug.datastructures.ImmutableMultiDict`
- is returned from this function. This can be changed by setting
- :attr:`parameter_storage_class` to a different type. This might
- be necessary if the order of the form data is important.
- """
- return url_decode(
- wsgi_get_bytes(self.environ.get("QUERY_STRING", "")),
- self.url_charset,
- errors=self.encoding_errors,
- cls=self.parameter_storage_class,
- )
-
- @cached_property
- def data(self):
- """
- Contains the incoming request data as string in case it came with
- a mimetype Werkzeug does not handle.
- """
-
- if self.disable_data_descriptor:
- raise AttributeError("data descriptor is disabled")
- # XXX: this should eventually be deprecated.
-
- # We trigger form data parsing first which means that the descriptor
- # will not cache the data that would otherwise be .form or .files
- # data. This restores the behavior that was there in Werkzeug
- # before 0.9. New code should use :meth:`get_data` explicitly as
- # this will make behavior explicit.
- return self.get_data(parse_form_data=True)
-
- def get_data(self, cache=True, as_text=False, parse_form_data=False):
- """This reads the buffered incoming data from the client into one
- bytestring. By default this is cached but that behavior can be
- changed by setting `cache` to `False`.
-
- Usually it's a bad idea to call this method without checking the
- content length first as a client could send dozens of megabytes or more
- to cause memory problems on the server.
-
- Note that if the form data was already parsed this method will not
- return anything as form data parsing does not cache the data like
- this method does. To implicitly invoke form data parsing function
- set `parse_form_data` to `True`. When this is done the return value
- of this method will be an empty string if the form parser handles
- the data. This generally is not necessary as if the whole data is
- cached (which is the default) the form parser will used the cached
- data to parse the form data. Please be generally aware of checking
- the content length first in any case before calling this method
- to avoid exhausting server memory.
-
- If `as_text` is set to `True` the return value will be a decoded
- unicode string.
-
- .. versionadded:: 0.9
- """
- rv = getattr(self, "_cached_data", None)
- if rv is None:
- if parse_form_data:
- self._load_form_data()
- rv = self.stream.read()
- if cache:
- self._cached_data = rv
- if as_text:
- rv = rv.decode(self.charset, self.encoding_errors)
- return rv
-
- @cached_property
- def form(self):
- """The form parameters. By default an
- :class:`~werkzeug.datastructures.ImmutableMultiDict`
- is returned from this function. This can be changed by setting
- :attr:`parameter_storage_class` to a different type. This might
- be necessary if the order of the form data is important.
-
- Please keep in mind that file uploads will not end up here, but instead
- in the :attr:`files` attribute.
-
- .. versionchanged:: 0.9
-
- Previous to Werkzeug 0.9 this would only contain form data for POST
- and PUT requests.
- """
- self._load_form_data()
- return self.form
-
- @cached_property
- def values(self):
- """A :class:`werkzeug.datastructures.CombinedMultiDict` that combines
- :attr:`args` and :attr:`form`."""
- args = []
- for d in self.args, self.form:
- if not isinstance(d, MultiDict):
- d = MultiDict(d)
- args.append(d)
- return CombinedMultiDict(args)
-
- @cached_property
- def files(self):
- """:class:`~werkzeug.datastructures.MultiDict` object containing
- all uploaded files. Each key in :attr:`files` is the name from the
- ``<input type="file" name="">``. Each value in :attr:`files` is a
- Werkzeug :class:`~werkzeug.datastructures.FileStorage` object.
-
- It basically behaves like a standard file object you know from Python,
- with the difference that it also has a
- :meth:`~werkzeug.datastructures.FileStorage.save` function that can
- store the file on the filesystem.
-
- Note that :attr:`files` will only contain data if the request method was
- POST, PUT or PATCH and the ``<form>`` that posted to the request had
- ``enctype="multipart/form-data"``. It will be empty otherwise.
-
- See the :class:`~werkzeug.datastructures.MultiDict` /
- :class:`~werkzeug.datastructures.FileStorage` documentation for
- more details about the used data structure.
- """
- self._load_form_data()
- return self.files
-
- @cached_property
- def cookies(self):
- """A :class:`dict` with the contents of all cookies transmitted with
- the request."""
- return parse_cookie(
- self.environ,
- self.charset,
- self.encoding_errors,
- cls=self.dict_storage_class,
- )
-
- @cached_property
- def headers(self):
- """The headers from the WSGI environ as immutable
- :class:`~werkzeug.datastructures.EnvironHeaders`.
- """
- return EnvironHeaders(self.environ)
-
- @cached_property
- def path(self):
- """Requested path as unicode. This works a bit like the regular path
- info in the WSGI environment but will always include a leading slash,
- even if the URL root is accessed.
- """
- raw_path = wsgi_decoding_dance(
- self.environ.get("PATH_INFO") or "", self.charset, self.encoding_errors
- )
- return "/" + raw_path.lstrip("/")
-
- @cached_property
- def full_path(self):
- """Requested path as unicode, including the query string."""
- return self.path + u"?" + to_unicode(self.query_string, self.url_charset)
-
- @cached_property
- def script_root(self):
- """The root path of the script without the trailing slash."""
- raw_path = wsgi_decoding_dance(
- self.environ.get("SCRIPT_NAME") or "", self.charset, self.encoding_errors
- )
- return raw_path.rstrip("/")
-
- @cached_property
- def url(self):
- """The reconstructed current URL as IRI.
- See also: :attr:`trusted_hosts`.
- """
- return get_current_url(self.environ, trusted_hosts=self.trusted_hosts)
-
- @cached_property
- def base_url(self):
- """Like :attr:`url` but without the querystring
- See also: :attr:`trusted_hosts`.
- """
- return get_current_url(
- self.environ, strip_querystring=True, trusted_hosts=self.trusted_hosts
- )
-
- @cached_property
- def url_root(self):
- """The full URL root (with hostname), this is the application
- root as IRI.
- See also: :attr:`trusted_hosts`.
- """
- return get_current_url(self.environ, True, trusted_hosts=self.trusted_hosts)
-
- @cached_property
- def host_url(self):
- """Just the host with scheme as IRI.
- See also: :attr:`trusted_hosts`.
- """
- return get_current_url(
- self.environ, host_only=True, trusted_hosts=self.trusted_hosts
- )
-
- @cached_property
- def host(self):
- """Just the host including the port if available.
- See also: :attr:`trusted_hosts`.
- """
- return get_host(self.environ, trusted_hosts=self.trusted_hosts)
-
- query_string = environ_property(
- "QUERY_STRING",
- "",
- read_only=True,
- load_func=wsgi_get_bytes,
- doc="The URL parameters as raw bytestring.",
- )
- method = environ_property(
- "REQUEST_METHOD",
- "GET",
- read_only=True,
- load_func=lambda x: x.upper(),
- doc="The request method. (For example ``'GET'`` or ``'POST'``).",
- )
-
- @cached_property
- def access_route(self):
- """If a forwarded header exists this is a list of all ip addresses
- from the client ip to the last proxy server.
- """
- if "HTTP_X_FORWARDED_FOR" in self.environ:
- addr = self.environ["HTTP_X_FORWARDED_FOR"].split(",")
- return self.list_storage_class([x.strip() for x in addr])
- elif "REMOTE_ADDR" in self.environ:
- return self.list_storage_class([self.environ["REMOTE_ADDR"]])
- return self.list_storage_class()
-
- @property
- def remote_addr(self):
- """The remote address of the client."""
- return self.environ.get("REMOTE_ADDR")
-
- remote_user = environ_property(
- "REMOTE_USER",
- doc="""If the server supports user authentication, and the
- script is protected, this attribute contains the username the
- user has authenticated as.""",
- )
-
- scheme = environ_property(
- "wsgi.url_scheme",
- doc="""
- URL scheme (http or https).
-
- .. versionadded:: 0.7""",
- )
-
- @property
- def is_xhr(self):
- """True if the request was triggered via a JavaScript XMLHttpRequest.
- This only works with libraries that support the ``X-Requested-With``
- header and set it to "XMLHttpRequest". Libraries that do that are
- prototype, jQuery and Mochikit and probably some more.
-
- .. deprecated:: 0.13
- ``X-Requested-With`` is not standard and is unreliable. You
- may be able to use :attr:`AcceptMixin.accept_mimetypes`
- instead.
- """
- warnings.warn(
- "'Request.is_xhr' is deprecated as of version 0.13 and will"
- " be removed in version 1.0. The 'X-Requested-With' header"
- " is not standard and is unreliable. You may be able to use"
- " 'accept_mimetypes' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.environ.get("HTTP_X_REQUESTED_WITH", "").lower() == "xmlhttprequest"
-
- is_secure = property(
- lambda self: self.environ["wsgi.url_scheme"] == "https",
- doc="`True` if the request is secure.",
- )
- is_multithread = environ_property(
- "wsgi.multithread",
- doc="""boolean that is `True` if the application is served by a
- multithreaded WSGI server.""",
- )
- is_multiprocess = environ_property(
- "wsgi.multiprocess",
- doc="""boolean that is `True` if the application is served by a
- WSGI server that spawns multiple processes.""",
- )
- is_run_once = environ_property(
- "wsgi.run_once",
- doc="""boolean that is `True` if the application will be
- executed only once in a process lifetime. This is the case for
- CGI for example, but it's not guaranteed that the execution only
- happens one time.""",
- )
-
-
-def _assert_not_shallow(request):
- if request.shallow:
- raise RuntimeError(
- "A shallow request tried to consume form data. If you really"
- " want to do that, set `shallow` to False."
- )
diff --git a/python/werkzeug/wrappers/base_response.py b/python/werkzeug/wrappers/base_response.py
deleted file mode 100644
index d944a7d..0000000
--- a/python/werkzeug/wrappers/base_response.py
+++ /dev/null
@@ -1,702 +0,0 @@
-import warnings
-
-from .._compat import integer_types
-from .._compat import string_types
-from .._compat import text_type
-from .._compat import to_bytes
-from .._compat import to_native
-from ..datastructures import Headers
-from ..http import dump_cookie
-from ..http import HTTP_STATUS_CODES
-from ..http import remove_entity_headers
-from ..urls import iri_to_uri
-from ..urls import url_join
-from ..utils import get_content_type
-from ..wsgi import ClosingIterator
-from ..wsgi import get_current_url
-
-
-def _run_wsgi_app(*args):
- """This function replaces itself to ensure that the test module is not
- imported unless required. DO NOT USE!
- """
- global _run_wsgi_app
- from ..test import run_wsgi_app as _run_wsgi_app
-
- return _run_wsgi_app(*args)
-
-
-def _warn_if_string(iterable):
- """Helper for the response objects to check if the iterable returned
- to the WSGI server is not a string.
- """
- if isinstance(iterable, string_types):
- warnings.warn(
- "Response iterable was set to a string. This will appear to"
- " work but means that the server will send the data to the"
- " client one character at a time. This is almost never"
- " intended behavior, use 'response.data' to assign strings"
- " to the response object.",
- stacklevel=2,
- )
-
-
-def _iter_encoded(iterable, charset):
- for item in iterable:
- if isinstance(item, text_type):
- yield item.encode(charset)
- else:
- yield item
-
-
-def _clean_accept_ranges(accept_ranges):
- if accept_ranges is True:
- return "bytes"
- elif accept_ranges is False:
- return "none"
- elif isinstance(accept_ranges, text_type):
- return to_native(accept_ranges)
- raise ValueError("Invalid accept_ranges value")
-
-
-class BaseResponse(object):
- """Base response class. The most important fact about a response object
- is that it's a regular WSGI application. It's initialized with a couple
- of response parameters (headers, body, status code etc.) and will start a
- valid WSGI response when called with the environ and start response
- callable.
-
- Because it's a WSGI application itself processing usually ends before the
- actual response is sent to the server. This helps debugging systems
- because they can catch all the exceptions before responses are started.
-
- Here a small example WSGI application that takes advantage of the
- response objects::
-
- from werkzeug.wrappers import BaseResponse as Response
-
- def index():
- return Response('Index page')
-
- def application(environ, start_response):
- path = environ.get('PATH_INFO') or '/'
- if path == '/':
- response = index()
- else:
- response = Response('Not Found', status=404)
- return response(environ, start_response)
-
- Like :class:`BaseRequest` which object is lacking a lot of functionality
- implemented in mixins. This gives you a better control about the actual
- API of your response objects, so you can create subclasses and add custom
- functionality. A full featured response object is available as
- :class:`Response` which implements a couple of useful mixins.
-
- To enforce a new type of already existing responses you can use the
- :meth:`force_type` method. This is useful if you're working with different
- subclasses of response objects and you want to post process them with a
- known interface.
-
- Per default the response object will assume all the text data is `utf-8`
- encoded. Please refer to :doc:`the unicode chapter </unicode>` for more
- details about customizing the behavior.
-
- Response can be any kind of iterable or string. If it's a string it's
- considered being an iterable with one item which is the string passed.
- Headers can be a list of tuples or a
- :class:`~werkzeug.datastructures.Headers` object.
-
- Special note for `mimetype` and `content_type`: For most mime types
- `mimetype` and `content_type` work the same, the difference affects
- only 'text' mimetypes. If the mimetype passed with `mimetype` is a
- mimetype starting with `text/`, the charset parameter of the response
- object is appended to it. In contrast the `content_type` parameter is
- always added as header unmodified.
-
- .. versionchanged:: 0.5
- the `direct_passthrough` parameter was added.
-
- :param response: a string or response iterable.
- :param status: a string with a status or an integer with the status code.
- :param headers: a list of headers or a
- :class:`~werkzeug.datastructures.Headers` object.
- :param mimetype: the mimetype for the response. See notice above.
- :param content_type: the content type for the response. See notice above.
- :param direct_passthrough: if set to `True` :meth:`iter_encoded` is not
- called before iteration which makes it
- possible to pass special iterators through
- unchanged (see :func:`wrap_file` for more
- details.)
- """
-
- #: the charset of the response.
- charset = "utf-8"
-
- #: the default status if none is provided.
- default_status = 200
-
- #: the default mimetype if none is provided.
- default_mimetype = "text/plain"
-
- #: if set to `False` accessing properties on the response object will
- #: not try to consume the response iterator and convert it into a list.
- #:
- #: .. versionadded:: 0.6.2
- #:
- #: That attribute was previously called `implicit_seqence_conversion`.
- #: (Notice the typo). If you did use this feature, you have to adapt
- #: your code to the name change.
- implicit_sequence_conversion = True
-
- #: Should this response object correct the location header to be RFC
- #: conformant? This is true by default.
- #:
- #: .. versionadded:: 0.8
- autocorrect_location_header = True
-
- #: Should this response object automatically set the content-length
- #: header if possible? This is true by default.
- #:
- #: .. versionadded:: 0.8
- automatically_set_content_length = True
-
- #: Warn if a cookie header exceeds this size. The default, 4093, should be
- #: safely `supported by most browsers <cookie_>`_. A cookie larger than
- #: this size will still be sent, but it may be ignored or handled
- #: incorrectly by some browsers. Set to 0 to disable this check.
- #:
- #: .. versionadded:: 0.13
- #:
- #: .. _`cookie`: http://browsercookielimits.squawky.net/
- max_cookie_size = 4093
-
- def __init__(
- self,
- response=None,
- status=None,
- headers=None,
- mimetype=None,
- content_type=None,
- direct_passthrough=False,
- ):
- if isinstance(headers, Headers):
- self.headers = headers
- elif not headers:
- self.headers = Headers()
- else:
- self.headers = Headers(headers)
-
- if content_type is None:
- if mimetype is None and "content-type" not in self.headers:
- mimetype = self.default_mimetype
- if mimetype is not None:
- mimetype = get_content_type(mimetype, self.charset)
- content_type = mimetype
- if content_type is not None:
- self.headers["Content-Type"] = content_type
- if status is None:
- status = self.default_status
- if isinstance(status, integer_types):
- self.status_code = status
- else:
- self.status = status
-
- self.direct_passthrough = direct_passthrough
- self._on_close = []
-
- # we set the response after the headers so that if a class changes
- # the charset attribute, the data is set in the correct charset.
- if response is None:
- self.response = []
- elif isinstance(response, (text_type, bytes, bytearray)):
- self.set_data(response)
- else:
- self.response = response
-
- def call_on_close(self, func):
- """Adds a function to the internal list of functions that should
- be called as part of closing down the response. Since 0.7 this
- function also returns the function that was passed so that this
- can be used as a decorator.
-
- .. versionadded:: 0.6
- """
- self._on_close.append(func)
- return func
-
- def __repr__(self):
- if self.is_sequence:
- body_info = "%d bytes" % sum(map(len, self.iter_encoded()))
- else:
- body_info = "streamed" if self.is_streamed else "likely-streamed"
- return "<%s %s [%s]>" % (self.__class__.__name__, body_info, self.status)
-
- @classmethod
- def force_type(cls, response, environ=None):
- """Enforce that the WSGI response is a response object of the current
- type. Werkzeug will use the :class:`BaseResponse` internally in many
- situations like the exceptions. If you call :meth:`get_response` on an
- exception you will get back a regular :class:`BaseResponse` object, even
- if you are using a custom subclass.
-
- This method can enforce a given response type, and it will also
- convert arbitrary WSGI callables into response objects if an environ
- is provided::
-
- # convert a Werkzeug response object into an instance of the
- # MyResponseClass subclass.
- response = MyResponseClass.force_type(response)
-
- # convert any WSGI application into a response object
- response = MyResponseClass.force_type(response, environ)
-
- This is especially useful if you want to post-process responses in
- the main dispatcher and use functionality provided by your subclass.
-
- Keep in mind that this will modify response objects in place if
- possible!
-
- :param response: a response object or wsgi application.
- :param environ: a WSGI environment object.
- :return: a response object.
- """
- if not isinstance(response, BaseResponse):
- if environ is None:
- raise TypeError(
- "cannot convert WSGI application into response"
- " objects without an environ"
- )
- response = BaseResponse(*_run_wsgi_app(response, environ))
- response.__class__ = cls
- return response
-
- @classmethod
- def from_app(cls, app, environ, buffered=False):
- """Create a new response object from an application output. This
- works best if you pass it an application that returns a generator all
- the time. Sometimes applications may use the `write()` callable
- returned by the `start_response` function. This tries to resolve such
- edge cases automatically. But if you don't get the expected output
- you should set `buffered` to `True` which enforces buffering.
-
- :param app: the WSGI application to execute.
- :param environ: the WSGI environment to execute against.
- :param buffered: set to `True` to enforce buffering.
- :return: a response object.
- """
- return cls(*_run_wsgi_app(app, environ, buffered))
-
- def _get_status_code(self):
- return self._status_code
-
- def _set_status_code(self, code):
- self._status_code = code
- try:
- self._status = "%d %s" % (code, HTTP_STATUS_CODES[code].upper())
- except KeyError:
- self._status = "%d UNKNOWN" % code
-
- status_code = property(
- _get_status_code, _set_status_code, doc="The HTTP Status code as number"
- )
- del _get_status_code, _set_status_code
-
- def _get_status(self):
- return self._status
-
- def _set_status(self, value):
- try:
- self._status = to_native(value)
- except AttributeError:
- raise TypeError("Invalid status argument")
-
- try:
- self._status_code = int(self._status.split(None, 1)[0])
- except ValueError:
- self._status_code = 0
- self._status = "0 %s" % self._status
- except IndexError:
- raise ValueError("Empty status argument")
-
- status = property(_get_status, _set_status, doc="The HTTP Status code")
- del _get_status, _set_status
-
- def get_data(self, as_text=False):
- """The string representation of the request body. Whenever you call
- this property the request iterable is encoded and flattened. This
- can lead to unwanted behavior if you stream big data.
-
- This behavior can be disabled by setting
- :attr:`implicit_sequence_conversion` to `False`.
-
- If `as_text` is set to `True` the return value will be a decoded
- unicode string.
-
- .. versionadded:: 0.9
- """
- self._ensure_sequence()
- rv = b"".join(self.iter_encoded())
- if as_text:
- rv = rv.decode(self.charset)
- return rv
-
- def set_data(self, value):
- """Sets a new string as response. The value set must either by a
- unicode or bytestring. If a unicode string is set it's encoded
- automatically to the charset of the response (utf-8 by default).
-
- .. versionadded:: 0.9
- """
- # if an unicode string is set, it's encoded directly so that we
- # can set the content length
- if isinstance(value, text_type):
- value = value.encode(self.charset)
- else:
- value = bytes(value)
- self.response = [value]
- if self.automatically_set_content_length:
- self.headers["Content-Length"] = str(len(value))
-
- data = property(
- get_data,
- set_data,
- doc="A descriptor that calls :meth:`get_data` and :meth:`set_data`.",
- )
-
- def calculate_content_length(self):
- """Returns the content length if available or `None` otherwise."""
- try:
- self._ensure_sequence()
- except RuntimeError:
- return None
- return sum(len(x) for x in self.iter_encoded())
-
- def _ensure_sequence(self, mutable=False):
- """This method can be called by methods that need a sequence. If
- `mutable` is true, it will also ensure that the response sequence
- is a standard Python list.
-
- .. versionadded:: 0.6
- """
- if self.is_sequence:
- # if we need a mutable object, we ensure it's a list.
- if mutable and not isinstance(self.response, list):
- self.response = list(self.response)
- return
- if self.direct_passthrough:
- raise RuntimeError(
- "Attempted implicit sequence conversion but the"
- " response object is in direct passthrough mode."
- )
- if not self.implicit_sequence_conversion:
- raise RuntimeError(
- "The response object required the iterable to be a"
- " sequence, but the implicit conversion was disabled."
- " Call make_sequence() yourself."
- )
- self.make_sequence()
-
- def make_sequence(self):
- """Converts the response iterator in a list. By default this happens
- automatically if required. If `implicit_sequence_conversion` is
- disabled, this method is not automatically called and some properties
- might raise exceptions. This also encodes all the items.
-
- .. versionadded:: 0.6
- """
- if not self.is_sequence:
- # if we consume an iterable we have to ensure that the close
- # method of the iterable is called if available when we tear
- # down the response
- close = getattr(self.response, "close", None)
- self.response = list(self.iter_encoded())
- if close is not None:
- self.call_on_close(close)
-
- def iter_encoded(self):
- """Iter the response encoded with the encoding of the response.
- If the response object is invoked as WSGI application the return
- value of this method is used as application iterator unless
- :attr:`direct_passthrough` was activated.
- """
- if __debug__:
- _warn_if_string(self.response)
- # Encode in a separate function so that self.response is fetched
- # early. This allows us to wrap the response with the return
- # value from get_app_iter or iter_encoded.
- return _iter_encoded(self.response, self.charset)
-
- def set_cookie(
- self,
- key,
- value="",
- max_age=None,
- expires=None,
- path="/",
- domain=None,
- secure=False,
- httponly=False,
- samesite=None,
- ):
- """Sets a cookie. The parameters are the same as in the cookie `Morsel`
- object in the Python standard library but it accepts unicode data, too.
-
- A warning is raised if the size of the cookie header exceeds
- :attr:`max_cookie_size`, but the header will still be set.
-
- :param key: the key (name) of the cookie to be set.
- :param value: the value of the cookie.
- :param max_age: should be a number of seconds, or `None` (default) if
- the cookie should last only as long as the client's
- browser session.
- :param expires: should be a `datetime` object or UNIX timestamp.
- :param path: limits the cookie to a given path, per default it will
- span the whole domain.
- :param domain: if you want to set a cross-domain cookie. For example,
- ``domain=".example.com"`` will set a cookie that is
- readable by the domain ``www.example.com``,
- ``foo.example.com`` etc. Otherwise, a cookie will only
- be readable by the domain that set it.
- :param secure: If `True`, the cookie will only be available via HTTPS
- :param httponly: disallow JavaScript to access the cookie. This is an
- extension to the cookie standard and probably not
- supported by all browsers.
- :param samesite: Limits the scope of the cookie such that it will only
- be attached to requests if those requests are
- "same-site".
- """
- self.headers.add(
- "Set-Cookie",
- dump_cookie(
- key,
- value=value,
- max_age=max_age,
- expires=expires,
- path=path,
- domain=domain,
- secure=secure,
- httponly=httponly,
- charset=self.charset,
- max_size=self.max_cookie_size,
- samesite=samesite,
- ),
- )
-
- def delete_cookie(self, key, path="/", domain=None):
- """Delete a cookie. Fails silently if key doesn't exist.
-
- :param key: the key (name) of the cookie to be deleted.
- :param path: if the cookie that should be deleted was limited to a
- path, the path has to be defined here.
- :param domain: if the cookie that should be deleted was limited to a
- domain, that domain has to be defined here.
- """
- self.set_cookie(key, expires=0, max_age=0, path=path, domain=domain)
-
- @property
- def is_streamed(self):
- """If the response is streamed (the response is not an iterable with
- a length information) this property is `True`. In this case streamed
- means that there is no information about the number of iterations.
- This is usually `True` if a generator is passed to the response object.
-
- This is useful for checking before applying some sort of post
- filtering that should not take place for streamed responses.
- """
- try:
- len(self.response)
- except (TypeError, AttributeError):
- return True
- return False
-
- @property
- def is_sequence(self):
- """If the iterator is buffered, this property will be `True`. A
- response object will consider an iterator to be buffered if the
- response attribute is a list or tuple.
-
- .. versionadded:: 0.6
- """
- return isinstance(self.response, (tuple, list))
-
- def close(self):
- """Close the wrapped response if possible. You can also use the object
- in a with statement which will automatically close it.
-
- .. versionadded:: 0.9
- Can now be used in a with statement.
- """
- if hasattr(self.response, "close"):
- self.response.close()
- for func in self._on_close:
- func()
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- self.close()
-
- def freeze(self):
- """Call this method if you want to make your response object ready for
- being pickled. This buffers the generator if there is one. It will
- also set the `Content-Length` header to the length of the body.
-
- .. versionchanged:: 0.6
- The `Content-Length` header is now set.
- """
- # we explicitly set the length to a list of the *encoded* response
- # iterator. Even if the implicit sequence conversion is disabled.
- self.response = list(self.iter_encoded())
- self.headers["Content-Length"] = str(sum(map(len, self.response)))
-
- def get_wsgi_headers(self, environ):
- """This is automatically called right before the response is started
- and returns headers modified for the given environment. It returns a
- copy of the headers from the response with some modifications applied
- if necessary.
-
- For example the location header (if present) is joined with the root
- URL of the environment. Also the content length is automatically set
- to zero here for certain status codes.
-
- .. versionchanged:: 0.6
- Previously that function was called `fix_headers` and modified
- the response object in place. Also since 0.6, IRIs in location
- and content-location headers are handled properly.
-
- Also starting with 0.6, Werkzeug will attempt to set the content
- length if it is able to figure it out on its own. This is the
- case if all the strings in the response iterable are already
- encoded and the iterable is buffered.
-
- :param environ: the WSGI environment of the request.
- :return: returns a new :class:`~werkzeug.datastructures.Headers`
- object.
- """
- headers = Headers(self.headers)
- location = None
- content_location = None
- content_length = None
- status = self.status_code
-
- # iterate over the headers to find all values in one go. Because
- # get_wsgi_headers is used each response that gives us a tiny
- # speedup.
- for key, value in headers:
- ikey = key.lower()
- if ikey == u"location":
- location = value
- elif ikey == u"content-location":
- content_location = value
- elif ikey == u"content-length":
- content_length = value
-
- # make sure the location header is an absolute URL
- if location is not None:
- old_location = location
- if isinstance(location, text_type):
- # Safe conversion is necessary here as we might redirect
- # to a broken URI scheme (for instance itms-services).
- location = iri_to_uri(location, safe_conversion=True)
-
- if self.autocorrect_location_header:
- current_url = get_current_url(environ, strip_querystring=True)
- if isinstance(current_url, text_type):
- current_url = iri_to_uri(current_url)
- location = url_join(current_url, location)
- if location != old_location:
- headers["Location"] = location
-
- # make sure the content location is a URL
- if content_location is not None and isinstance(content_location, text_type):
- headers["Content-Location"] = iri_to_uri(content_location)
-
- if 100 <= status < 200 or status == 204:
- # Per section 3.3.2 of RFC 7230, "a server MUST NOT send a
- # Content-Length header field in any response with a status
- # code of 1xx (Informational) or 204 (No Content)."
- headers.remove("Content-Length")
- elif status == 304:
- remove_entity_headers(headers)
-
- # if we can determine the content length automatically, we
- # should try to do that. But only if this does not involve
- # flattening the iterator or encoding of unicode strings in
- # the response. We however should not do that if we have a 304
- # response.
- if (
- self.automatically_set_content_length
- and self.is_sequence
- and content_length is None
- and status not in (204, 304)
- and not (100 <= status < 200)
- ):
- try:
- content_length = sum(len(to_bytes(x, "ascii")) for x in self.response)
- except UnicodeError:
- # aha, something non-bytestringy in there, too bad, we
- # can't safely figure out the length of the response.
- pass
- else:
- headers["Content-Length"] = str(content_length)
-
- return headers
-
- def get_app_iter(self, environ):
- """Returns the application iterator for the given environ. Depending
- on the request method and the current status code the return value
- might be an empty response rather than the one from the response.
-
- If the request method is `HEAD` or the status code is in a range
- where the HTTP specification requires an empty response, an empty
- iterable is returned.
-
- .. versionadded:: 0.6
-
- :param environ: the WSGI environment of the request.
- :return: a response iterable.
- """
- status = self.status_code
- if (
- environ["REQUEST_METHOD"] == "HEAD"
- or 100 <= status < 200
- or status in (204, 304)
- ):
- iterable = ()
- elif self.direct_passthrough:
- if __debug__:
- _warn_if_string(self.response)
- return self.response
- else:
- iterable = self.iter_encoded()
- return ClosingIterator(iterable, self.close)
-
- def get_wsgi_response(self, environ):
- """Returns the final WSGI response as tuple. The first item in
- the tuple is the application iterator, the second the status and
- the third the list of headers. The response returned is created
- specially for the given environment. For example if the request
- method in the WSGI environment is ``'HEAD'`` the response will
- be empty and only the headers and status code will be present.
-
- .. versionadded:: 0.6
-
- :param environ: the WSGI environment of the request.
- :return: an ``(app_iter, status, headers)`` tuple.
- """
- headers = self.get_wsgi_headers(environ)
- app_iter = self.get_app_iter(environ)
- return app_iter, self.status, headers.to_wsgi_list()
-
- def __call__(self, environ, start_response):
- """Process this response as WSGI application.
-
- :param environ: the WSGI environment.
- :param start_response: the response callable provided by the WSGI
- server.
- :return: an application iterator
- """
- app_iter, status, headers = self.get_wsgi_response(environ)
- start_response(status, headers)
- return app_iter
diff --git a/python/werkzeug/wrappers/common_descriptors.py b/python/werkzeug/wrappers/common_descriptors.py
deleted file mode 100644
index e4107ee..0000000
--- a/python/werkzeug/wrappers/common_descriptors.py
+++ /dev/null
@@ -1,322 +0,0 @@
-from datetime import datetime
-from datetime import timedelta
-
-from .._compat import string_types
-from ..datastructures import CallbackDict
-from ..http import dump_age
-from ..http import dump_header
-from ..http import dump_options_header
-from ..http import http_date
-from ..http import parse_age
-from ..http import parse_date
-from ..http import parse_options_header
-from ..http import parse_set_header
-from ..utils import cached_property
-from ..utils import environ_property
-from ..utils import get_content_type
-from ..utils import header_property
-from ..wsgi import get_content_length
-
-
-class CommonRequestDescriptorsMixin(object):
- """A mixin for :class:`BaseRequest` subclasses. Request objects that
- mix this class in will automatically get descriptors for a couple of
- HTTP headers with automatic type conversion.
-
- .. versionadded:: 0.5
- """
-
- content_type = environ_property(
- "CONTENT_TYPE",
- doc="""The Content-Type entity-header field indicates the media
- type of the entity-body sent to the recipient or, in the case of
- the HEAD method, the media type that would have been sent had
- the request been a GET.""",
- )
-
- @cached_property
- def content_length(self):
- """The Content-Length entity-header field indicates the size of the
- entity-body in bytes or, in the case of the HEAD method, the size of
- the entity-body that would have been sent had the request been a
- GET.
- """
- return get_content_length(self.environ)
-
- content_encoding = environ_property(
- "HTTP_CONTENT_ENCODING",
- doc="""The Content-Encoding entity-header field is used as a
- modifier to the media-type. When present, its value indicates
- what additional content codings have been applied to the
- entity-body, and thus what decoding mechanisms must be applied
- in order to obtain the media-type referenced by the Content-Type
- header field.
-
- .. versionadded:: 0.9""",
- )
- content_md5 = environ_property(
- "HTTP_CONTENT_MD5",
- doc="""The Content-MD5 entity-header field, as defined in
- RFC 1864, is an MD5 digest of the entity-body for the purpose of
- providing an end-to-end message integrity check (MIC) of the
- entity-body. (Note: a MIC is good for detecting accidental
- modification of the entity-body in transit, but is not proof
- against malicious attacks.)
-
- .. versionadded:: 0.9""",
- )
- referrer = environ_property(
- "HTTP_REFERER",
- doc="""The Referer[sic] request-header field allows the client
- to specify, for the server's benefit, the address (URI) of the
- resource from which the Request-URI was obtained (the
- "referrer", although the header field is misspelled).""",
- )
- date = environ_property(
- "HTTP_DATE",
- None,
- parse_date,
- doc="""The Date general-header field represents the date and
- time at which the message was originated, having the same
- semantics as orig-date in RFC 822.""",
- )
- max_forwards = environ_property(
- "HTTP_MAX_FORWARDS",
- None,
- int,
- doc="""The Max-Forwards request-header field provides a
- mechanism with the TRACE and OPTIONS methods to limit the number
- of proxies or gateways that can forward the request to the next
- inbound server.""",
- )
-
- def _parse_content_type(self):
- if not hasattr(self, "_parsed_content_type"):
- self._parsed_content_type = parse_options_header(
- self.environ.get("CONTENT_TYPE", "")
- )
-
- @property
- def mimetype(self):
- """Like :attr:`content_type`, but without parameters (eg, without
- charset, type etc.) and always lowercase. For example if the content
- type is ``text/HTML; charset=utf-8`` the mimetype would be
- ``'text/html'``.
- """
- self._parse_content_type()
- return self._parsed_content_type[0].lower()
-
- @property
- def mimetype_params(self):
- """The mimetype parameters as dict. For example if the content
- type is ``text/html; charset=utf-8`` the params would be
- ``{'charset': 'utf-8'}``.
- """
- self._parse_content_type()
- return self._parsed_content_type[1]
-
- @cached_property
- def pragma(self):
- """The Pragma general-header field is used to include
- implementation-specific directives that might apply to any recipient
- along the request/response chain. All pragma directives specify
- optional behavior from the viewpoint of the protocol; however, some
- systems MAY require that behavior be consistent with the directives.
- """
- return parse_set_header(self.environ.get("HTTP_PRAGMA", ""))
-
-
-class CommonResponseDescriptorsMixin(object):
- """A mixin for :class:`BaseResponse` subclasses. Response objects that
- mix this class in will automatically get descriptors for a couple of
- HTTP headers with automatic type conversion.
- """
-
- @property
- def mimetype(self):
- """The mimetype (content type without charset etc.)"""
- ct = self.headers.get("content-type")
- if ct:
- return ct.split(";")[0].strip()
-
- @mimetype.setter
- def mimetype(self, value):
- self.headers["Content-Type"] = get_content_type(value, self.charset)
-
- @property
- def mimetype_params(self):
- """The mimetype parameters as dict. For example if the
- content type is ``text/html; charset=utf-8`` the params would be
- ``{'charset': 'utf-8'}``.
-
- .. versionadded:: 0.5
- """
-
- def on_update(d):
- self.headers["Content-Type"] = dump_options_header(self.mimetype, d)
-
- d = parse_options_header(self.headers.get("content-type", ""))[1]
- return CallbackDict(d, on_update)
-
- location = header_property(
- "Location",
- doc="""The Location response-header field is used to redirect
- the recipient to a location other than the Request-URI for
- completion of the request or identification of a new
- resource.""",
- )
- age = header_property(
- "Age",
- None,
- parse_age,
- dump_age,
- doc="""The Age response-header field conveys the sender's
- estimate of the amount of time since the response (or its
- revalidation) was generated at the origin server.
-
- Age values are non-negative decimal integers, representing time
- in seconds.""",
- )
- content_type = header_property(
- "Content-Type",
- doc="""The Content-Type entity-header field indicates the media
- type of the entity-body sent to the recipient or, in the case of
- the HEAD method, the media type that would have been sent had
- the request been a GET.""",
- )
- content_length = header_property(
- "Content-Length",
- None,
- int,
- str,
- doc="""The Content-Length entity-header field indicates the size
- of the entity-body, in decimal number of OCTETs, sent to the
- recipient or, in the case of the HEAD method, the size of the
- entity-body that would have been sent had the request been a
- GET.""",
- )
- content_location = header_property(
- "Content-Location",
- doc="""The Content-Location entity-header field MAY be used to
- supply the resource location for the entity enclosed in the
- message when that entity is accessible from a location separate
- from the requested resource's URI.""",
- )
- content_encoding = header_property(
- "Content-Encoding",
- doc="""The Content-Encoding entity-header field is used as a
- modifier to the media-type. When present, its value indicates
- what additional content codings have been applied to the
- entity-body, and thus what decoding mechanisms must be applied
- in order to obtain the media-type referenced by the Content-Type
- header field.""",
- )
- content_md5 = header_property(
- "Content-MD5",
- doc="""The Content-MD5 entity-header field, as defined in
- RFC 1864, is an MD5 digest of the entity-body for the purpose of
- providing an end-to-end message integrity check (MIC) of the
- entity-body. (Note: a MIC is good for detecting accidental
- modification of the entity-body in transit, but is not proof
- against malicious attacks.)""",
- )
- date = header_property(
- "Date",
- None,
- parse_date,
- http_date,
- doc="""The Date general-header field represents the date and
- time at which the message was originated, having the same
- semantics as orig-date in RFC 822.""",
- )
- expires = header_property(
- "Expires",
- None,
- parse_date,
- http_date,
- doc="""The Expires entity-header field gives the date/time after
- which the response is considered stale. A stale cache entry may
- not normally be returned by a cache.""",
- )
- last_modified = header_property(
- "Last-Modified",
- None,
- parse_date,
- http_date,
- doc="""The Last-Modified entity-header field indicates the date
- and time at which the origin server believes the variant was
- last modified.""",
- )
-
- @property
- def retry_after(self):
- """The Retry-After response-header field can be used with a
- 503 (Service Unavailable) response to indicate how long the
- service is expected to be unavailable to the requesting client.
-
- Time in seconds until expiration or date.
- """
- value = self.headers.get("retry-after")
- if value is None:
- return
- elif value.isdigit():
- return datetime.utcnow() + timedelta(seconds=int(value))
- return parse_date(value)
-
- @retry_after.setter
- def retry_after(self, value):
- if value is None:
- if "retry-after" in self.headers:
- del self.headers["retry-after"]
- return
- elif isinstance(value, datetime):
- value = http_date(value)
- else:
- value = str(value)
- self.headers["Retry-After"] = value
-
- def _set_property(name, doc=None): # noqa: B902
- def fget(self):
- def on_update(header_set):
- if not header_set and name in self.headers:
- del self.headers[name]
- elif header_set:
- self.headers[name] = header_set.to_header()
-
- return parse_set_header(self.headers.get(name), on_update)
-
- def fset(self, value):
- if not value:
- del self.headers[name]
- elif isinstance(value, string_types):
- self.headers[name] = value
- else:
- self.headers[name] = dump_header(value)
-
- return property(fget, fset, doc=doc)
-
- vary = _set_property(
- "Vary",
- doc="""The Vary field value indicates the set of request-header
- fields that fully determines, while the response is fresh,
- whether a cache is permitted to use the response to reply to a
- subsequent request without revalidation.""",
- )
- content_language = _set_property(
- "Content-Language",
- doc="""The Content-Language entity-header field describes the
- natural language(s) of the intended audience for the enclosed
- entity. Note that this might not be equivalent to all the
- languages used within the entity-body.""",
- )
- allow = _set_property(
- "Allow",
- doc="""The Allow entity-header field lists the set of methods
- supported by the resource identified by the Request-URI. The
- purpose of this field is strictly to inform the recipient of
- valid methods associated with the resource. An Allow header
- field MUST be present in a 405 (Method Not Allowed)
- response.""",
- )
-
- del _set_property
diff --git a/python/werkzeug/wrappers/etag.py b/python/werkzeug/wrappers/etag.py
deleted file mode 100644
index 0733506..0000000
--- a/python/werkzeug/wrappers/etag.py
+++ /dev/null
@@ -1,304 +0,0 @@
-from .._compat import string_types
-from .._internal import _get_environ
-from ..datastructures import ContentRange
-from ..datastructures import RequestCacheControl
-from ..datastructures import ResponseCacheControl
-from ..http import generate_etag
-from ..http import http_date
-from ..http import is_resource_modified
-from ..http import parse_cache_control_header
-from ..http import parse_content_range_header
-from ..http import parse_date
-from ..http import parse_etags
-from ..http import parse_if_range_header
-from ..http import parse_range_header
-from ..http import quote_etag
-from ..http import unquote_etag
-from ..utils import cached_property
-from ..utils import header_property
-from ..wrappers.base_response import _clean_accept_ranges
-from ..wsgi import _RangeWrapper
-
-
-class ETagRequestMixin(object):
- """Add entity tag and cache descriptors to a request object or object with
- a WSGI environment available as :attr:`~BaseRequest.environ`. This not
- only provides access to etags but also to the cache control header.
- """
-
- @cached_property
- def cache_control(self):
- """A :class:`~werkzeug.datastructures.RequestCacheControl` object
- for the incoming cache control headers.
- """
- cache_control = self.environ.get("HTTP_CACHE_CONTROL")
- return parse_cache_control_header(cache_control, None, RequestCacheControl)
-
- @cached_property
- def if_match(self):
- """An object containing all the etags in the `If-Match` header.
-
- :rtype: :class:`~werkzeug.datastructures.ETags`
- """
- return parse_etags(self.environ.get("HTTP_IF_MATCH"))
-
- @cached_property
- def if_none_match(self):
- """An object containing all the etags in the `If-None-Match` header.
-
- :rtype: :class:`~werkzeug.datastructures.ETags`
- """
- return parse_etags(self.environ.get("HTTP_IF_NONE_MATCH"))
-
- @cached_property
- def if_modified_since(self):
- """The parsed `If-Modified-Since` header as datetime object."""
- return parse_date(self.environ.get("HTTP_IF_MODIFIED_SINCE"))
-
- @cached_property
- def if_unmodified_since(self):
- """The parsed `If-Unmodified-Since` header as datetime object."""
- return parse_date(self.environ.get("HTTP_IF_UNMODIFIED_SINCE"))
-
- @cached_property
- def if_range(self):
- """The parsed `If-Range` header.
-
- .. versionadded:: 0.7
-
- :rtype: :class:`~werkzeug.datastructures.IfRange`
- """
- return parse_if_range_header(self.environ.get("HTTP_IF_RANGE"))
-
- @cached_property
- def range(self):
- """The parsed `Range` header.
-
- .. versionadded:: 0.7
-
- :rtype: :class:`~werkzeug.datastructures.Range`
- """
- return parse_range_header(self.environ.get("HTTP_RANGE"))
-
-
-class ETagResponseMixin(object):
- """Adds extra functionality to a response object for etag and cache
- handling. This mixin requires an object with at least a `headers`
- object that implements a dict like interface similar to
- :class:`~werkzeug.datastructures.Headers`.
-
- If you want the :meth:`freeze` method to automatically add an etag, you
- have to mixin this method before the response base class. The default
- response class does not do that.
- """
-
- @property
- def cache_control(self):
- """The Cache-Control general-header field is used to specify
- directives that MUST be obeyed by all caching mechanisms along the
- request/response chain.
- """
-
- def on_update(cache_control):
- if not cache_control and "cache-control" in self.headers:
- del self.headers["cache-control"]
- elif cache_control:
- self.headers["Cache-Control"] = cache_control.to_header()
-
- return parse_cache_control_header(
- self.headers.get("cache-control"), on_update, ResponseCacheControl
- )
-
- def _wrap_response(self, start, length):
- """Wrap existing Response in case of Range Request context."""
- if self.status_code == 206:
- self.response = _RangeWrapper(self.response, start, length)
-
- def _is_range_request_processable(self, environ):
- """Return ``True`` if `Range` header is present and if underlying
- resource is considered unchanged when compared with `If-Range` header.
- """
- return (
- "HTTP_IF_RANGE" not in environ
- or not is_resource_modified(
- environ,
- self.headers.get("etag"),
- None,
- self.headers.get("last-modified"),
- ignore_if_range=False,
- )
- ) and "HTTP_RANGE" in environ
-
- def _process_range_request(self, environ, complete_length=None, accept_ranges=None):
- """Handle Range Request related headers (RFC7233). If `Accept-Ranges`
- header is valid, and Range Request is processable, we set the headers
- as described by the RFC, and wrap the underlying response in a
- RangeWrapper.
-
- Returns ``True`` if Range Request can be fulfilled, ``False`` otherwise.
-
- :raises: :class:`~werkzeug.exceptions.RequestedRangeNotSatisfiable`
- if `Range` header could not be parsed or satisfied.
- """
- from ..exceptions import RequestedRangeNotSatisfiable
-
- if accept_ranges is None:
- return False
- self.headers["Accept-Ranges"] = accept_ranges
- if not self._is_range_request_processable(environ) or complete_length is None:
- return False
- parsed_range = parse_range_header(environ.get("HTTP_RANGE"))
- if parsed_range is None:
- raise RequestedRangeNotSatisfiable(complete_length)
- range_tuple = parsed_range.range_for_length(complete_length)
- content_range_header = parsed_range.to_content_range_header(complete_length)
- if range_tuple is None or content_range_header is None:
- raise RequestedRangeNotSatisfiable(complete_length)
- content_length = range_tuple[1] - range_tuple[0]
- # Be sure not to send 206 response
- # if requested range is the full content.
- if content_length != complete_length:
- self.headers["Content-Length"] = content_length
- self.content_range = content_range_header
- self.status_code = 206
- self._wrap_response(range_tuple[0], content_length)
- return True
- return False
-
- def make_conditional(
- self, request_or_environ, accept_ranges=False, complete_length=None
- ):
- """Make the response conditional to the request. This method works
- best if an etag was defined for the response already. The `add_etag`
- method can be used to do that. If called without etag just the date
- header is set.
-
- This does nothing if the request method in the request or environ is
- anything but GET or HEAD.
-
- For optimal performance when handling range requests, it's recommended
- that your response data object implements `seekable`, `seek` and `tell`
- methods as described by :py:class:`io.IOBase`. Objects returned by
- :meth:`~werkzeug.wsgi.wrap_file` automatically implement those methods.
-
- It does not remove the body of the response because that's something
- the :meth:`__call__` function does for us automatically.
-
- Returns self so that you can do ``return resp.make_conditional(req)``
- but modifies the object in-place.
-
- :param request_or_environ: a request object or WSGI environment to be
- used to make the response conditional
- against.
- :param accept_ranges: This parameter dictates the value of
- `Accept-Ranges` header. If ``False`` (default),
- the header is not set. If ``True``, it will be set
- to ``"bytes"``. If ``None``, it will be set to
- ``"none"``. If it's a string, it will use this
- value.
- :param complete_length: Will be used only in valid Range Requests.
- It will set `Content-Range` complete length
- value and compute `Content-Length` real value.
- This parameter is mandatory for successful
- Range Requests completion.
- :raises: :class:`~werkzeug.exceptions.RequestedRangeNotSatisfiable`
- if `Range` header could not be parsed or satisfied.
- """
- environ = _get_environ(request_or_environ)
- if environ["REQUEST_METHOD"] in ("GET", "HEAD"):
- # if the date is not in the headers, add it now. We however
- # will not override an already existing header. Unfortunately
- # this header will be overriden by many WSGI servers including
- # wsgiref.
- if "date" not in self.headers:
- self.headers["Date"] = http_date()
- accept_ranges = _clean_accept_ranges(accept_ranges)
- is206 = self._process_range_request(environ, complete_length, accept_ranges)
- if not is206 and not is_resource_modified(
- environ,
- self.headers.get("etag"),
- None,
- self.headers.get("last-modified"),
- ):
- if parse_etags(environ.get("HTTP_IF_MATCH")):
- self.status_code = 412
- else:
- self.status_code = 304
- if (
- self.automatically_set_content_length
- and "content-length" not in self.headers
- ):
- length = self.calculate_content_length()
- if length is not None:
- self.headers["Content-Length"] = length
- return self
-
- def add_etag(self, overwrite=False, weak=False):
- """Add an etag for the current response if there is none yet."""
- if overwrite or "etag" not in self.headers:
- self.set_etag(generate_etag(self.get_data()), weak)
-
- def set_etag(self, etag, weak=False):
- """Set the etag, and override the old one if there was one."""
- self.headers["ETag"] = quote_etag(etag, weak)
-
- def get_etag(self):
- """Return a tuple in the form ``(etag, is_weak)``. If there is no
- ETag the return value is ``(None, None)``.
- """
- return unquote_etag(self.headers.get("ETag"))
-
- def freeze(self, no_etag=False):
- """Call this method if you want to make your response object ready for
- pickeling. This buffers the generator if there is one. This also
- sets the etag unless `no_etag` is set to `True`.
- """
- if not no_etag:
- self.add_etag()
- super(ETagResponseMixin, self).freeze()
-
- accept_ranges = header_property(
- "Accept-Ranges",
- doc="""The `Accept-Ranges` header. Even though the name would
- indicate that multiple values are supported, it must be one
- string token only.
-
- The values ``'bytes'`` and ``'none'`` are common.
-
- .. versionadded:: 0.7""",
- )
-
- def _get_content_range(self):
- def on_update(rng):
- if not rng:
- del self.headers["content-range"]
- else:
- self.headers["Content-Range"] = rng.to_header()
-
- rv = parse_content_range_header(self.headers.get("content-range"), on_update)
- # always provide a content range object to make the descriptor
- # more user friendly. It provides an unset() method that can be
- # used to remove the header quickly.
- if rv is None:
- rv = ContentRange(None, None, None, on_update=on_update)
- return rv
-
- def _set_content_range(self, value):
- if not value:
- del self.headers["content-range"]
- elif isinstance(value, string_types):
- self.headers["Content-Range"] = value
- else:
- self.headers["Content-Range"] = value.to_header()
-
- content_range = property(
- _get_content_range,
- _set_content_range,
- doc="""The ``Content-Range`` header as
- :class:`~werkzeug.datastructures.ContentRange` object. Even if
- the header is not set it wil provide such an object for easier
- manipulation.
-
- .. versionadded:: 0.7""",
- )
- del _get_content_range, _set_content_range
diff --git a/python/werkzeug/wrappers/json.py b/python/werkzeug/wrappers/json.py
deleted file mode 100644
index 6d5dc33..0000000
--- a/python/werkzeug/wrappers/json.py
+++ /dev/null
@@ -1,145 +0,0 @@
-from __future__ import absolute_import
-
-import datetime
-import uuid
-
-from .._compat import text_type
-from ..exceptions import BadRequest
-from ..utils import detect_utf_encoding
-
-try:
- import simplejson as _json
-except ImportError:
- import json as _json
-
-
-class _JSONModule(object):
- @staticmethod
- def _default(o):
- if isinstance(o, datetime.date):
- return o.isoformat()
-
- if isinstance(o, uuid.UUID):
- return str(o)
-
- if hasattr(o, "__html__"):
- return text_type(o.__html__())
-
- raise TypeError()
-
- @classmethod
- def dumps(cls, obj, **kw):
- kw.setdefault("separators", (",", ":"))
- kw.setdefault("default", cls._default)
- kw.setdefault("sort_keys", True)
- return _json.dumps(obj, **kw)
-
- @staticmethod
- def loads(s, **kw):
- if isinstance(s, bytes):
- # Needed for Python < 3.6
- encoding = detect_utf_encoding(s)
- s = s.decode(encoding)
-
- return _json.loads(s, **kw)
-
-
-class JSONMixin(object):
- """Mixin to parse :attr:`data` as JSON. Can be mixed in for both
- :class:`~werkzeug.wrappers.Request` and
- :class:`~werkzeug.wrappers.Response` classes.
-
- If `simplejson`_ is installed it is preferred over Python's built-in
- :mod:`json` module.
-
- .. _simplejson: https://simplejson.readthedocs.io/en/latest/
- """
-
- #: A module or other object that has ``dumps`` and ``loads``
- #: functions that match the API of the built-in :mod:`json` module.
- json_module = _JSONModule
-
- @property
- def json(self):
- """The parsed JSON data if :attr:`mimetype` indicates JSON
- (:mimetype:`application/json`, see :meth:`is_json`).
-
- Calls :meth:`get_json` with default arguments.
- """
- return self.get_json()
-
- @property
- def is_json(self):
- """Check if the mimetype indicates JSON data, either
- :mimetype:`application/json` or :mimetype:`application/*+json`.
- """
- mt = self.mimetype
- return (
- mt == "application/json"
- or mt.startswith("application/")
- and mt.endswith("+json")
- )
-
- def _get_data_for_json(self, cache):
- try:
- return self.get_data(cache=cache)
- except TypeError:
- # Response doesn't have cache param.
- return self.get_data()
-
- # Cached values for ``(silent=False, silent=True)``. Initialized
- # with sentinel values.
- _cached_json = (Ellipsis, Ellipsis)
-
- def get_json(self, force=False, silent=False, cache=True):
- """Parse :attr:`data` as JSON.
-
- If the mimetype does not indicate JSON
- (:mimetype:`application/json`, see :meth:`is_json`), this
- returns ``None``.
-
- If parsing fails, :meth:`on_json_loading_failed` is called and
- its return value is used as the return value.
-
- :param force: Ignore the mimetype and always try to parse JSON.
- :param silent: Silence parsing errors and return ``None``
- instead.
- :param cache: Store the parsed JSON to return for subsequent
- calls.
- """
- if cache and self._cached_json[silent] is not Ellipsis:
- return self._cached_json[silent]
-
- if not (force or self.is_json):
- return None
-
- data = self._get_data_for_json(cache=cache)
-
- try:
- rv = self.json_module.loads(data)
- except ValueError as e:
- if silent:
- rv = None
-
- if cache:
- normal_rv, _ = self._cached_json
- self._cached_json = (normal_rv, rv)
- else:
- rv = self.on_json_loading_failed(e)
-
- if cache:
- _, silent_rv = self._cached_json
- self._cached_json = (rv, silent_rv)
- else:
- if cache:
- self._cached_json = (rv, rv)
-
- return rv
-
- def on_json_loading_failed(self, e):
- """Called if :meth:`get_json` parsing fails and isn't silenced.
- If this method returns a value, it is used as the return value
- for :meth:`get_json`. The default implementation raises
- :exc:`~werkzeug.exceptions.BadRequest`.
- """
- raise BadRequest("Failed to decode JSON object: {0}".format(e))
diff --git a/python/werkzeug/wrappers/request.py b/python/werkzeug/wrappers/request.py
deleted file mode 100644
index d1c71b6..0000000
--- a/python/werkzeug/wrappers/request.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from .accept import AcceptMixin
-from .auth import AuthorizationMixin
-from .base_request import BaseRequest
-from .common_descriptors import CommonRequestDescriptorsMixin
-from .etag import ETagRequestMixin
-from .user_agent import UserAgentMixin
-
-
-class Request(
- BaseRequest,
- AcceptMixin,
- ETagRequestMixin,
- UserAgentMixin,
- AuthorizationMixin,
- CommonRequestDescriptorsMixin,
-):
- """Full featured request object implementing the following mixins:
-
- - :class:`AcceptMixin` for accept header parsing
- - :class:`ETagRequestMixin` for etag and cache control handling
- - :class:`UserAgentMixin` for user agent introspection
- - :class:`AuthorizationMixin` for http auth handling
- - :class:`CommonRequestDescriptorsMixin` for common headers
- """
-
-
-class StreamOnlyMixin(object):
- """If mixed in before the request object this will change the bahavior
- of it to disable handling of form parsing. This disables the
- :attr:`files`, :attr:`form` attributes and will just provide a
- :attr:`stream` attribute that however is always available.
-
- .. versionadded:: 0.9
- """
-
- disable_data_descriptor = True
- want_form_data_parsed = False
-
-
-class PlainRequest(StreamOnlyMixin, Request):
- """A request object without special form parsing capabilities.
-
- .. versionadded:: 0.9
- """
diff --git a/python/werkzeug/wrappers/response.py b/python/werkzeug/wrappers/response.py
deleted file mode 100644
index cd86cac..0000000
--- a/python/werkzeug/wrappers/response.py
+++ /dev/null
@@ -1,78 +0,0 @@
-from ..utils import cached_property
-from .auth import WWWAuthenticateMixin
-from .base_response import BaseResponse
-from .common_descriptors import CommonResponseDescriptorsMixin
-from .etag import ETagResponseMixin
-
-
-class ResponseStream(object):
- """A file descriptor like object used by the :class:`ResponseStreamMixin` to
- represent the body of the stream. It directly pushes into the response
- iterable of the response object.
- """
-
- mode = "wb+"
-
- def __init__(self, response):
- self.response = response
- self.closed = False
-
- def write(self, value):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- self.response._ensure_sequence(mutable=True)
- self.response.response.append(value)
- self.response.headers.pop("Content-Length", None)
- return len(value)
-
- def writelines(self, seq):
- for item in seq:
- self.write(item)
-
- def close(self):
- self.closed = True
-
- def flush(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
-
- def isatty(self):
- if self.closed:
- raise ValueError("I/O operation on closed file")
- return False
-
- def tell(self):
- self.response._ensure_sequence()
- return sum(map(len, self.response.response))
-
- @property
- def encoding(self):
- return self.response.charset
-
-
-class ResponseStreamMixin(object):
- """Mixin for :class:`BaseRequest` subclasses. Classes that inherit from
- this mixin will automatically get a :attr:`stream` property that provides
- a write-only interface to the response iterable.
- """
-
- @cached_property
- def stream(self):
- """The response iterable as write-only stream."""
- return ResponseStream(self)
-
-
-class Response(
- BaseResponse,
- ETagResponseMixin,
- ResponseStreamMixin,
- CommonResponseDescriptorsMixin,
- WWWAuthenticateMixin,
-):
- """Full featured response object implementing the following mixins:
-
- - :class:`ETagResponseMixin` for etag and cache control handling
- - :class:`ResponseStreamMixin` to add support for the `stream` property
- - :class:`CommonResponseDescriptorsMixin` for various HTTP descriptors
- - :class:`WWWAuthenticateMixin` for HTTP authentication support
- """
diff --git a/python/werkzeug/wrappers/user_agent.py b/python/werkzeug/wrappers/user_agent.py
deleted file mode 100644
index 72588dd..0000000
--- a/python/werkzeug/wrappers/user_agent.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from ..utils import cached_property
-
-
-class UserAgentMixin(object):
- """Adds a `user_agent` attribute to the request object which
- contains the parsed user agent of the browser that triggered the
- request as a :class:`~werkzeug.useragents.UserAgent` object.
- """
-
- @cached_property
- def user_agent(self):
- """The current user agent."""
- from ..useragents import UserAgent
-
- return UserAgent(self.environ)
diff --git a/python/werkzeug/wsgi.py b/python/werkzeug/wsgi.py
deleted file mode 100644
index f069f2d..0000000
--- a/python/werkzeug/wsgi.py
+++ /dev/null
@@ -1,1067 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- werkzeug.wsgi
- ~~~~~~~~~~~~~
-
- This module implements WSGI related helpers.
-
- :copyright: 2007 Pallets
- :license: BSD-3-Clause
-"""
-import io
-import re
-import warnings
-from functools import partial
-from functools import update_wrapper
-from itertools import chain
-
-from ._compat import BytesIO
-from ._compat import implements_iterator
-from ._compat import make_literal_wrapper
-from ._compat import string_types
-from ._compat import text_type
-from ._compat import to_bytes
-from ._compat import to_unicode
-from ._compat import try_coerce_native
-from ._compat import wsgi_get_bytes
-from ._internal import _encode_idna
-from .urls import uri_to_iri
-from .urls import url_join
-from .urls import url_parse
-from .urls import url_quote
-
-
-def responder(f):
- """Marks a function as responder. Decorate a function with it and it
- will automatically call the return value as WSGI application.
-
- Example::
-
- @responder
- def application(environ, start_response):
- return Response('Hello World!')
- """
- return update_wrapper(lambda *a: f(*a)(*a[-2:]), f)
-
-
-def get_current_url(
- environ,
- root_only=False,
- strip_querystring=False,
- host_only=False,
- trusted_hosts=None,
-):
- """A handy helper function that recreates the full URL as IRI for the
- current request or parts of it. Here's an example:
-
- >>> from werkzeug.test import create_environ
- >>> env = create_environ("/?param=foo", "http://localhost/script")
- >>> get_current_url(env)
- 'http://localhost/script/?param=foo'
- >>> get_current_url(env, root_only=True)
- 'http://localhost/script/'
- >>> get_current_url(env, host_only=True)
- 'http://localhost/'
- >>> get_current_url(env, strip_querystring=True)
- 'http://localhost/script/'
-
- This optionally it verifies that the host is in a list of trusted hosts.
- If the host is not in there it will raise a
- :exc:`~werkzeug.exceptions.SecurityError`.
-
- Note that the string returned might contain unicode characters as the
- representation is an IRI not an URI. If you need an ASCII only
- representation you can use the :func:`~werkzeug.urls.iri_to_uri`
- function:
-
- >>> from werkzeug.urls import iri_to_uri
- >>> iri_to_uri(get_current_url(env))
- 'http://localhost/script/?param=foo'
-
- :param environ: the WSGI environment to get the current URL from.
- :param root_only: set `True` if you only want the root URL.
- :param strip_querystring: set to `True` if you don't want the querystring.
- :param host_only: set to `True` if the host URL should be returned.
- :param trusted_hosts: a list of trusted hosts, see :func:`host_is_trusted`
- for more information.
- """
- tmp = [environ["wsgi.url_scheme"], "://", get_host(environ, trusted_hosts)]
- cat = tmp.append
- if host_only:
- return uri_to_iri("".join(tmp) + "/")
- cat(url_quote(wsgi_get_bytes(environ.get("SCRIPT_NAME", ""))).rstrip("/"))
- cat("/")
- if not root_only:
- cat(url_quote(wsgi_get_bytes(environ.get("PATH_INFO", "")).lstrip(b"/")))
- if not strip_querystring:
- qs = get_query_string(environ)
- if qs:
- cat("?" + qs)
- return uri_to_iri("".join(tmp))
-
-
-def host_is_trusted(hostname, trusted_list):
- """Checks if a host is trusted against a list. This also takes care
- of port normalization.
-
- .. versionadded:: 0.9
-
- :param hostname: the hostname to check
- :param trusted_list: a list of hostnames to check against. If a
- hostname starts with a dot it will match against
- all subdomains as well.
- """
- if not hostname:
- return False
-
- if isinstance(trusted_list, string_types):
- trusted_list = [trusted_list]
-
- def _normalize(hostname):
- if ":" in hostname:
- hostname = hostname.rsplit(":", 1)[0]
- return _encode_idna(hostname)
-
- try:
- hostname = _normalize(hostname)
- except UnicodeError:
- return False
- for ref in trusted_list:
- if ref.startswith("."):
- ref = ref[1:]
- suffix_match = True
- else:
- suffix_match = False
- try:
- ref = _normalize(ref)
- except UnicodeError:
- return False
- if ref == hostname:
- return True
- if suffix_match and hostname.endswith(b"." + ref):
- return True
- return False
-
-
-def get_host(environ, trusted_hosts=None):
- """Return the host for the given WSGI environment. This first checks
- the ``Host`` header. If it's not present, then ``SERVER_NAME`` and
- ``SERVER_PORT`` are used. The host will only contain the port if it
- is different than the standard port for the protocol.
-
- Optionally, verify that the host is trusted using
- :func:`host_is_trusted` and raise a
- :exc:`~werkzeug.exceptions.SecurityError` if it is not.
-
- :param environ: The WSGI environment to get the host from.
- :param trusted_hosts: A list of trusted hosts.
- :return: Host, with port if necessary.
- :raise ~werkzeug.exceptions.SecurityError: If the host is not
- trusted.
- """
- if "HTTP_HOST" in environ:
- rv = environ["HTTP_HOST"]
- if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
- rv = rv[:-3]
- elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
- rv = rv[:-4]
- else:
- rv = environ["SERVER_NAME"]
- if (environ["wsgi.url_scheme"], environ["SERVER_PORT"]) not in (
- ("https", "443"),
- ("http", "80"),
- ):
- rv += ":" + environ["SERVER_PORT"]
- if trusted_hosts is not None:
- if not host_is_trusted(rv, trusted_hosts):
- from .exceptions import SecurityError
-
- raise SecurityError('Host "%s" is not trusted' % rv)
- return rv
-
-
-def get_content_length(environ):
- """Returns the content length from the WSGI environment as
- integer. If it's not available or chunked transfer encoding is used,
- ``None`` is returned.
-
- .. versionadded:: 0.9
-
- :param environ: the WSGI environ to fetch the content length from.
- """
- if environ.get("HTTP_TRANSFER_ENCODING", "") == "chunked":
- return None
-
- content_length = environ.get("CONTENT_LENGTH")
- if content_length is not None:
- try:
- return max(0, int(content_length))
- except (ValueError, TypeError):
- pass
-
-
-def get_input_stream(environ, safe_fallback=True):
- """Returns the input stream from the WSGI environment and wraps it
- in the most sensible way possible. The stream returned is not the
- raw WSGI stream in most cases but one that is safe to read from
- without taking into account the content length.
-
- If content length is not set, the stream will be empty for safety reasons.
- If the WSGI server supports chunked or infinite streams, it should set
- the ``wsgi.input_terminated`` value in the WSGI environ to indicate that.
-
- .. versionadded:: 0.9
-
- :param environ: the WSGI environ to fetch the stream from.
- :param safe_fallback: use an empty stream as a safe fallback when the
- content length is not set. Disabling this allows infinite streams,
- which can be a denial-of-service risk.
- """
- stream = environ["wsgi.input"]
- content_length = get_content_length(environ)
-
- # A wsgi extension that tells us if the input is terminated. In
- # that case we return the stream unchanged as we know we can safely
- # read it until the end.
- if environ.get("wsgi.input_terminated"):
- return stream
-
- # If the request doesn't specify a content length, returning the stream is
- # potentially dangerous because it could be infinite, malicious or not. If
- # safe_fallback is true, return an empty stream instead for safety.
- if content_length is None:
- return BytesIO() if safe_fallback else stream
-
- # Otherwise limit the stream to the content length
- return LimitedStream(stream, content_length)
-
-
-def get_query_string(environ):
- """Returns the `QUERY_STRING` from the WSGI environment. This also takes
- care about the WSGI decoding dance on Python 3 environments as a
- native string. The string returned will be restricted to ASCII
- characters.
-
- .. versionadded:: 0.9
-
- :param environ: the WSGI environment object to get the query string from.
- """
- qs = wsgi_get_bytes(environ.get("QUERY_STRING", ""))
- # QUERY_STRING really should be ascii safe but some browsers
- # will send us some unicode stuff (I am looking at you IE).
- # In that case we want to urllib quote it badly.
- return try_coerce_native(url_quote(qs, safe=":&%=+$!*'(),"))
-
-
-def get_path_info(environ, charset="utf-8", errors="replace"):
- """Returns the `PATH_INFO` from the WSGI environment and properly
- decodes it. This also takes care about the WSGI decoding dance
- on Python 3 environments. if the `charset` is set to `None` a
- bytestring is returned.
-
- .. versionadded:: 0.9
-
- :param environ: the WSGI environment object to get the path from.
- :param charset: the charset for the path info, or `None` if no
- decoding should be performed.
- :param errors: the decoding error handling.
- """
- path = wsgi_get_bytes(environ.get("PATH_INFO", ""))
- return to_unicode(path, charset, errors, allow_none_charset=True)
-
-
-def get_script_name(environ, charset="utf-8", errors="replace"):
- """Returns the `SCRIPT_NAME` from the WSGI environment and properly
- decodes it. This also takes care about the WSGI decoding dance
- on Python 3 environments. if the `charset` is set to `None` a
- bytestring is returned.
-
- .. versionadded:: 0.9
-
- :param environ: the WSGI environment object to get the path from.
- :param charset: the charset for the path, or `None` if no
- decoding should be performed.
- :param errors: the decoding error handling.
- """
- path = wsgi_get_bytes(environ.get("SCRIPT_NAME", ""))
- return to_unicode(path, charset, errors, allow_none_charset=True)
-
-
-def pop_path_info(environ, charset="utf-8", errors="replace"):
- """Removes and returns the next segment of `PATH_INFO`, pushing it onto
- `SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
-
- If the `charset` is set to `None` a bytestring is returned.
-
- If there are empty segments (``'/foo//bar``) these are ignored but
- properly pushed to the `SCRIPT_NAME`:
-
- >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
- >>> pop_path_info(env)
- 'a'
- >>> env['SCRIPT_NAME']
- '/foo/a'
- >>> pop_path_info(env)
- 'b'
- >>> env['SCRIPT_NAME']
- '/foo/a/b'
-
- .. versionadded:: 0.5
-
- .. versionchanged:: 0.9
- The path is now decoded and a charset and encoding
- parameter can be provided.
-
- :param environ: the WSGI environment that is modified.
- """
- path = environ.get("PATH_INFO")
- if not path:
- return None
-
- script_name = environ.get("SCRIPT_NAME", "")
-
- # shift multiple leading slashes over
- old_path = path
- path = path.lstrip("/")
- if path != old_path:
- script_name += "/" * (len(old_path) - len(path))
-
- if "/" not in path:
- environ["PATH_INFO"] = ""
- environ["SCRIPT_NAME"] = script_name + path
- rv = wsgi_get_bytes(path)
- else:
- segment, path = path.split("/", 1)
- environ["PATH_INFO"] = "/" + path
- environ["SCRIPT_NAME"] = script_name + segment
- rv = wsgi_get_bytes(segment)
-
- return to_unicode(rv, charset, errors, allow_none_charset=True)
-
-
-def peek_path_info(environ, charset="utf-8", errors="replace"):
- """Returns the next segment on the `PATH_INFO` or `None` if there
- is none. Works like :func:`pop_path_info` without modifying the
- environment:
-
- >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
- >>> peek_path_info(env)
- 'a'
- >>> peek_path_info(env)
- 'a'
-
- If the `charset` is set to `None` a bytestring is returned.
-
- .. versionadded:: 0.5
-
- .. versionchanged:: 0.9
- The path is now decoded and a charset and encoding
- parameter can be provided.
-
- :param environ: the WSGI environment that is checked.
- """
- segments = environ.get("PATH_INFO", "").lstrip("/").split("/", 1)
- if segments:
- return to_unicode(
- wsgi_get_bytes(segments[0]), charset, errors, allow_none_charset=True
- )
-
-
-def extract_path_info(
- environ_or_baseurl,
- path_or_url,
- charset="utf-8",
- errors="werkzeug.url_quote",
- collapse_http_schemes=True,
-):
- """Extracts the path info from the given URL (or WSGI environment) and
- path. The path info returned is a unicode string, not a bytestring
- suitable for a WSGI environment. The URLs might also be IRIs.
-
- If the path info could not be determined, `None` is returned.
-
- Some examples:
-
- >>> extract_path_info('http://example.com/app', '/app/hello')
- u'/hello'
- >>> extract_path_info('http://example.com/app',
- ... 'https://example.com/app/hello')
- u'/hello'
- >>> extract_path_info('http://example.com/app',
- ... 'https://example.com/app/hello',
- ... collapse_http_schemes=False) is None
- True
-
- Instead of providing a base URL you can also pass a WSGI environment.
-
- :param environ_or_baseurl: a WSGI environment dict, a base URL or
- base IRI. This is the root of the
- application.
- :param path_or_url: an absolute path from the server root, a
- relative path (in which case it's the path info)
- or a full URL. Also accepts IRIs and unicode
- parameters.
- :param charset: the charset for byte data in URLs
- :param errors: the error handling on decode
- :param collapse_http_schemes: if set to `False` the algorithm does
- not assume that http and https on the
- same server point to the same
- resource.
-
- .. versionchanged:: 0.15
- The ``errors`` parameter defaults to leaving invalid bytes
- quoted instead of replacing them.
-
- .. versionadded:: 0.6
- """
-
- def _normalize_netloc(scheme, netloc):
- parts = netloc.split(u"@", 1)[-1].split(u":", 1)
- if len(parts) == 2:
- netloc, port = parts
- if (scheme == u"http" and port == u"80") or (
- scheme == u"https" and port == u"443"
- ):
- port = None
- else:
- netloc = parts[0]
- port = None
- if port is not None:
- netloc += u":" + port
- return netloc
-
- # make sure whatever we are working on is a IRI and parse it
- path = uri_to_iri(path_or_url, charset, errors)
- if isinstance(environ_or_baseurl, dict):
- environ_or_baseurl = get_current_url(environ_or_baseurl, root_only=True)
- base_iri = uri_to_iri(environ_or_baseurl, charset, errors)
- base_scheme, base_netloc, base_path = url_parse(base_iri)[:3]
- cur_scheme, cur_netloc, cur_path, = url_parse(url_join(base_iri, path))[:3]
-
- # normalize the network location
- base_netloc = _normalize_netloc(base_scheme, base_netloc)
- cur_netloc = _normalize_netloc(cur_scheme, cur_netloc)
-
- # is that IRI even on a known HTTP scheme?
- if collapse_http_schemes:
- for scheme in base_scheme, cur_scheme:
- if scheme not in (u"http", u"https"):
- return None
- else:
- if not (base_scheme in (u"http", u"https") and base_scheme == cur_scheme):
- return None
-
- # are the netlocs compatible?
- if base_netloc != cur_netloc:
- return None
-
- # are we below the application path?
- base_path = base_path.rstrip(u"/")
- if not cur_path.startswith(base_path):
- return None
-
- return u"/" + cur_path[len(base_path) :].lstrip(u"/")
-
-
-@implements_iterator
-class ClosingIterator(object):
- """The WSGI specification requires that all middlewares and gateways
- respect the `close` callback of the iterable returned by the application.
- Because it is useful to add another close action to a returned iterable
- and adding a custom iterable is a boring task this class can be used for
- that::
-
- return ClosingIterator(app(environ, start_response), [cleanup_session,
- cleanup_locals])
-
- If there is just one close function it can be passed instead of the list.
-
- A closing iterator is not needed if the application uses response objects
- and finishes the processing if the response is started::
-
- try:
- return response(environ, start_response)
- finally:
- cleanup_session()
- cleanup_locals()
- """
-
- def __init__(self, iterable, callbacks=None):
- iterator = iter(iterable)
- self._next = partial(next, iterator)
- if callbacks is None:
- callbacks = []
- elif callable(callbacks):
- callbacks = [callbacks]
- else:
- callbacks = list(callbacks)
- iterable_close = getattr(iterable, "close", None)
- if iterable_close:
- callbacks.insert(0, iterable_close)
- self._callbacks = callbacks
-
- def __iter__(self):
- return self
-
- def __next__(self):
- return self._next()
-
- def close(self):
- for callback in self._callbacks:
- callback()
-
-
-def wrap_file(environ, file, buffer_size=8192):
- """Wraps a file. This uses the WSGI server's file wrapper if available
- or otherwise the generic :class:`FileWrapper`.
-
- .. versionadded:: 0.5
-
- If the file wrapper from the WSGI server is used it's important to not
- iterate over it from inside the application but to pass it through
- unchanged. If you want to pass out a file wrapper inside a response
- object you have to set :attr:`~BaseResponse.direct_passthrough` to `True`.
-
- More information about file wrappers are available in :pep:`333`.
-
- :param file: a :class:`file`-like object with a :meth:`~file.read` method.
- :param buffer_size: number of bytes for one iteration.
- """
- return environ.get("wsgi.file_wrapper", FileWrapper)(file, buffer_size)
-
-
-@implements_iterator
-class FileWrapper(object):
- """This class can be used to convert a :class:`file`-like object into
- an iterable. It yields `buffer_size` blocks until the file is fully
- read.
-
- You should not use this class directly but rather use the
- :func:`wrap_file` function that uses the WSGI server's file wrapper
- support if it's available.
-
- .. versionadded:: 0.5
-
- If you're using this object together with a :class:`BaseResponse` you have
- to use the `direct_passthrough` mode.
-
- :param file: a :class:`file`-like object with a :meth:`~file.read` method.
- :param buffer_size: number of bytes for one iteration.
- """
-
- def __init__(self, file, buffer_size=8192):
- self.file = file
- self.buffer_size = buffer_size
-
- def close(self):
- if hasattr(self.file, "close"):
- self.file.close()
-
- def seekable(self):
- if hasattr(self.file, "seekable"):
- return self.file.seekable()
- if hasattr(self.file, "seek"):
- return True
- return False
-
- def seek(self, *args):
- if hasattr(self.file, "seek"):
- self.file.seek(*args)
-
- def tell(self):
- if hasattr(self.file, "tell"):
- return self.file.tell()
- return None
-
- def __iter__(self):
- return self
-
- def __next__(self):
- data = self.file.read(self.buffer_size)
- if data:
- return data
- raise StopIteration()
-
-
-@implements_iterator
-class _RangeWrapper(object):
- # private for now, but should we make it public in the future ?
-
- """This class can be used to convert an iterable object into
- an iterable that will only yield a piece of the underlying content.
- It yields blocks until the underlying stream range is fully read.
- The yielded blocks will have a size that can't exceed the original
- iterator defined block size, but that can be smaller.
-
- If you're using this object together with a :class:`BaseResponse` you have
- to use the `direct_passthrough` mode.
-
- :param iterable: an iterable object with a :meth:`__next__` method.
- :param start_byte: byte from which read will start.
- :param byte_range: how many bytes to read.
- """
-
- def __init__(self, iterable, start_byte=0, byte_range=None):
- self.iterable = iter(iterable)
- self.byte_range = byte_range
- self.start_byte = start_byte
- self.end_byte = None
- if byte_range is not None:
- self.end_byte = self.start_byte + self.byte_range
- self.read_length = 0
- self.seekable = hasattr(iterable, "seekable") and iterable.seekable()
- self.end_reached = False
-
- def __iter__(self):
- return self
-
- def _next_chunk(self):
- try:
- chunk = next(self.iterable)
- self.read_length += len(chunk)
- return chunk
- except StopIteration:
- self.end_reached = True
- raise
-
- def _first_iteration(self):
- chunk = None
- if self.seekable:
- self.iterable.seek(self.start_byte)
- self.read_length = self.iterable.tell()
- contextual_read_length = self.read_length
- else:
- while self.read_length <= self.start_byte:
- chunk = self._next_chunk()
- if chunk is not None:
- chunk = chunk[self.start_byte - self.read_length :]
- contextual_read_length = self.start_byte
- return chunk, contextual_read_length
-
- def _next(self):
- if self.end_reached:
- raise StopIteration()
- chunk = None
- contextual_read_length = self.read_length
- if self.read_length == 0:
- chunk, contextual_read_length = self._first_iteration()
- if chunk is None:
- chunk = self._next_chunk()
- if self.end_byte is not None and self.read_length >= self.end_byte:
- self.end_reached = True
- return chunk[: self.end_byte - contextual_read_length]
- return chunk
-
- def __next__(self):
- chunk = self._next()
- if chunk:
- return chunk
- self.end_reached = True
- raise StopIteration()
-
- def close(self):
- if hasattr(self.iterable, "close"):
- self.iterable.close()
-
-
-def _make_chunk_iter(stream, limit, buffer_size):
- """Helper for the line and chunk iter functions."""
- if isinstance(stream, (bytes, bytearray, text_type)):
- raise TypeError(
- "Passed a string or byte object instead of true iterator or stream."
- )
- if not hasattr(stream, "read"):
- for item in stream:
- if item:
- yield item
- return
- if not isinstance(stream, LimitedStream) and limit is not None:
- stream = LimitedStream(stream, limit)
- _read = stream.read
- while 1:
- item = _read(buffer_size)
- if not item:
- break
- yield item
-
-
-def make_line_iter(stream, limit=None, buffer_size=10 * 1024, cap_at_buffer=False):
- """Safely iterates line-based over an input stream. If the input stream
- is not a :class:`LimitedStream` the `limit` parameter is mandatory.
-
- This uses the stream's :meth:`~file.read` method internally as opposite
- to the :meth:`~file.readline` method that is unsafe and can only be used
- in violation of the WSGI specification. The same problem applies to the
- `__iter__` function of the input stream which calls :meth:`~file.readline`
- without arguments.
-
- If you need line-by-line processing it's strongly recommended to iterate
- over the input stream using this helper function.
-
- .. versionchanged:: 0.8
- This function now ensures that the limit was reached.
-
- .. versionadded:: 0.9
- added support for iterators as input stream.
-
- .. versionadded:: 0.11.10
- added support for the `cap_at_buffer` parameter.
-
- :param stream: the stream or iterate to iterate over.
- :param limit: the limit in bytes for the stream. (Usually
- content length. Not necessary if the `stream`
- is a :class:`LimitedStream`.
- :param buffer_size: The optional buffer size.
- :param cap_at_buffer: if this is set chunks are split if they are longer
- than the buffer size. Internally this is implemented
- that the buffer size might be exhausted by a factor
- of two however.
- """
- _iter = _make_chunk_iter(stream, limit, buffer_size)
-
- first_item = next(_iter, "")
- if not first_item:
- return
-
- s = make_literal_wrapper(first_item)
- empty = s("")
- cr = s("\r")
- lf = s("\n")
- crlf = s("\r\n")
-
- _iter = chain((first_item,), _iter)
-
- def _iter_basic_lines():
- _join = empty.join
- buffer = []
- while 1:
- new_data = next(_iter, "")
- if not new_data:
- break
- new_buf = []
- buf_size = 0
- for item in chain(buffer, new_data.splitlines(True)):
- new_buf.append(item)
- buf_size += len(item)
- if item and item[-1:] in crlf:
- yield _join(new_buf)
- new_buf = []
- elif cap_at_buffer and buf_size >= buffer_size:
- rv = _join(new_buf)
- while len(rv) >= buffer_size:
- yield rv[:buffer_size]
- rv = rv[buffer_size:]
- new_buf = [rv]
- buffer = new_buf
- if buffer:
- yield _join(buffer)
-
- # This hackery is necessary to merge 'foo\r' and '\n' into one item
- # of 'foo\r\n' if we were unlucky and we hit a chunk boundary.
- previous = empty
- for item in _iter_basic_lines():
- if item == lf and previous[-1:] == cr:
- previous += item
- item = empty
- if previous:
- yield previous
- previous = item
- if previous:
- yield previous
-
-
-def make_chunk_iter(
- stream, separator, limit=None, buffer_size=10 * 1024, cap_at_buffer=False
-):
- """Works like :func:`make_line_iter` but accepts a separator
- which divides chunks. If you want newline based processing
- you should use :func:`make_line_iter` instead as it
- supports arbitrary newline markers.
-
- .. versionadded:: 0.8
-
- .. versionadded:: 0.9
- added support for iterators as input stream.
-
- .. versionadded:: 0.11.10
- added support for the `cap_at_buffer` parameter.
-
- :param stream: the stream or iterate to iterate over.
- :param separator: the separator that divides chunks.
- :param limit: the limit in bytes for the stream. (Usually
- content length. Not necessary if the `stream`
- is otherwise already limited).
- :param buffer_size: The optional buffer size.
- :param cap_at_buffer: if this is set chunks are split if they are longer
- than the buffer size. Internally this is implemented
- that the buffer size might be exhausted by a factor
- of two however.
- """
- _iter = _make_chunk_iter(stream, limit, buffer_size)
-
- first_item = next(_iter, "")
- if not first_item:
- return
-
- _iter = chain((first_item,), _iter)
- if isinstance(first_item, text_type):
- separator = to_unicode(separator)
- _split = re.compile(r"(%s)" % re.escape(separator)).split
- _join = u"".join
- else:
- separator = to_bytes(separator)
- _split = re.compile(b"(" + re.escape(separator) + b")").split
- _join = b"".join
-
- buffer = []
- while 1:
- new_data = next(_iter, "")
- if not new_data:
- break
- chunks = _split(new_data)
- new_buf = []
- buf_size = 0
- for item in chain(buffer, chunks):
- if item == separator:
- yield _join(new_buf)
- new_buf = []
- buf_size = 0
- else:
- buf_size += len(item)
- new_buf.append(item)
-
- if cap_at_buffer and buf_size >= buffer_size:
- rv = _join(new_buf)
- while len(rv) >= buffer_size:
- yield rv[:buffer_size]
- rv = rv[buffer_size:]
- new_buf = [rv]
- buf_size = len(rv)
-
- buffer = new_buf
- if buffer:
- yield _join(buffer)
-
-
-@implements_iterator
-class LimitedStream(io.IOBase):
- """Wraps a stream so that it doesn't read more than n bytes. If the
- stream is exhausted and the caller tries to get more bytes from it
- :func:`on_exhausted` is called which by default returns an empty
- string. The return value of that function is forwarded
- to the reader function. So if it returns an empty string
- :meth:`read` will return an empty string as well.
-
- The limit however must never be higher than what the stream can
- output. Otherwise :meth:`readlines` will try to read past the
- limit.
-
- .. admonition:: Note on WSGI compliance
-
- calls to :meth:`readline` and :meth:`readlines` are not
- WSGI compliant because it passes a size argument to the
- readline methods. Unfortunately the WSGI PEP is not safely
- implementable without a size argument to :meth:`readline`
- because there is no EOF marker in the stream. As a result
- of that the use of :meth:`readline` is discouraged.
-
- For the same reason iterating over the :class:`LimitedStream`
- is not portable. It internally calls :meth:`readline`.
-
- We strongly suggest using :meth:`read` only or using the
- :func:`make_line_iter` which safely iterates line-based
- over a WSGI input stream.
-
- :param stream: the stream to wrap.
- :param limit: the limit for the stream, must not be longer than
- what the string can provide if the stream does not
- end with `EOF` (like `wsgi.input`)
- """
-
- def __init__(self, stream, limit):
- self._read = stream.read
- self._readline = stream.readline
- self._pos = 0
- self.limit = limit
-
- def __iter__(self):
- return self
-
- @property
- def is_exhausted(self):
- """If the stream is exhausted this attribute is `True`."""
- return self._pos >= self.limit
-
- def on_exhausted(self):
- """This is called when the stream tries to read past the limit.
- The return value of this function is returned from the reading
- function.
- """
- # Read null bytes from the stream so that we get the
- # correct end of stream marker.
- return self._read(0)
-
- def on_disconnect(self):
- """What should happen if a disconnect is detected? The return
- value of this function is returned from read functions in case
- the client went away. By default a
- :exc:`~werkzeug.exceptions.ClientDisconnected` exception is raised.
- """
- from .exceptions import ClientDisconnected
-
- raise ClientDisconnected()
-
- def exhaust(self, chunk_size=1024 * 64):
- """Exhaust the stream. This consumes all the data left until the
- limit is reached.
-
- :param chunk_size: the size for a chunk. It will read the chunk
- until the stream is exhausted and throw away
- the results.
- """
- to_read = self.limit - self._pos
- chunk = chunk_size
- while to_read > 0:
- chunk = min(to_read, chunk)
- self.read(chunk)
- to_read -= chunk
-
- def read(self, size=None):
- """Read `size` bytes or if size is not provided everything is read.
-
- :param size: the number of bytes read.
- """
- if self._pos >= self.limit:
- return self.on_exhausted()
- if size is None or size == -1: # -1 is for consistence with file
- size = self.limit
- to_read = min(self.limit - self._pos, size)
- try:
- read = self._read(to_read)
- except (IOError, ValueError):
- return self.on_disconnect()
- if to_read and len(read) != to_read:
- return self.on_disconnect()
- self._pos += len(read)
- return read
-
- def readline(self, size=None):
- """Reads one line from the stream."""
- if self._pos >= self.limit:
- return self.on_exhausted()
- if size is None:
- size = self.limit - self._pos
- else:
- size = min(size, self.limit - self._pos)
- try:
- line = self._readline(size)
- except (ValueError, IOError):
- return self.on_disconnect()
- if size and not line:
- return self.on_disconnect()
- self._pos += len(line)
- return line
-
- def readlines(self, size=None):
- """Reads a file into a list of strings. It calls :meth:`readline`
- until the file is read to the end. It does support the optional
- `size` argument if the underlaying stream supports it for
- `readline`.
- """
- last_pos = self._pos
- result = []
- if size is not None:
- end = min(self.limit, last_pos + size)
- else:
- end = self.limit
- while 1:
- if size is not None:
- size -= last_pos - self._pos
- if self._pos >= end:
- break
- result.append(self.readline(size))
- if size is not None:
- last_pos = self._pos
- return result
-
- def tell(self):
- """Returns the position of the stream.
-
- .. versionadded:: 0.9
- """
- return self._pos
-
- def __next__(self):
- line = self.readline()
- if not line:
- raise StopIteration()
- return line
-
- def readable(self):
- return True
-
-
-# DEPRECATED
-from .middleware.dispatcher import DispatcherMiddleware as _DispatcherMiddleware
-from .middleware.http_proxy import ProxyMiddleware as _ProxyMiddleware
-from .middleware.shared_data import SharedDataMiddleware as _SharedDataMiddleware
-
-
-class ProxyMiddleware(_ProxyMiddleware):
- """
- .. deprecated:: 0.15
- ``werkzeug.wsgi.ProxyMiddleware`` has moved to
- :mod:`werkzeug.middleware.http_proxy`. This import will be
- removed in 1.0.
- """
-
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.wsgi.ProxyMiddleware' has moved to 'werkzeug"
- ".middleware.http_proxy.ProxyMiddleware'. This import is"
- " deprecated as of version 0.15 and will be removed in"
- " version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(ProxyMiddleware, self).__init__(*args, **kwargs)
-
-
-class SharedDataMiddleware(_SharedDataMiddleware):
- """
- .. deprecated:: 0.15
- ``werkzeug.wsgi.SharedDataMiddleware`` has moved to
- :mod:`werkzeug.middleware.shared_data`. This import will be
- removed in 1.0.
- """
-
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.wsgi.SharedDataMiddleware' has moved to"
- " 'werkzeug.middleware.shared_data.SharedDataMiddleware'."
- " This import is deprecated as of version 0.15 and will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(SharedDataMiddleware, self).__init__(*args, **kwargs)
-
-
-class DispatcherMiddleware(_DispatcherMiddleware):
- """
- .. deprecated:: 0.15
- ``werkzeug.wsgi.DispatcherMiddleware`` has moved to
- :mod:`werkzeug.middleware.dispatcher`. This import will be
- removed in 1.0.
- """
-
- def __init__(self, *args, **kwargs):
- warnings.warn(
- "'werkzeug.wsgi.DispatcherMiddleware' has moved to"
- " 'werkzeug.middleware.dispatcher.DispatcherMiddleware'."
- " This import is deprecated as of version 0.15 and will be"
- " removed in version 1.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- super(DispatcherMiddleware, self).__init__(*args, **kwargs)
diff --git a/python/winsound.pyd b/python/winsound.pyd
deleted file mode 100644
index 651f097..0000000
--- a/python/winsound.pyd
+++ /dev/null
Binary files differ
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..3c03957
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,6 @@
+Flask>=1.0.3
+gevent>=1.2.2
+Brotli>=1.0.7
+PySocks>=1.6.8
+urllib3>=1.24.1
+defusedxml>=0.5.0